ruby-changes:56244
From: Kazuhiro <ko1@a...>
Date: Fri, 28 Jun 2019 12:38:51 +0900 (JST)
Subject: [ruby-changes:56244] Kazuhiro NISHIYAMA: 7eaedda557 (trunk): Use block instead of explicit close
https://git.ruby-lang.org/ruby.git/commit/?id=7eaedda557 From 7eaedda557f689087861e6c0e7c9abca8cd92fc1 Mon Sep 17 00:00:00 2001 From: Kazuhiro NISHIYAMA <zn@m...> Date: Fri, 28 Jun 2019 12:37:36 +0900 Subject: Use block instead of explicit close diff --git a/test/scanf/test_scanfio.rb b/test/scanf/test_scanfio.rb index 857ac7e..fdd5928 100644 --- a/test/scanf/test_scanfio.rb +++ b/test/scanf/test_scanfio.rb @@ -10,21 +10,19 @@ require 'scanf' https://github.com/ruby/ruby/blob/trunk/test/scanf/test_scanfio.rb#L10 class TestScanfIO < Test::Unit::TestCase def test_io - fh = File.new(File.join(File.dirname(__FILE__), "data.txt"), "r") - assert_equal(0, fh.pos) - assert_equal(["this", "is"], fh.scanf("%s%s")) - assert_equal([33, "little"], fh.scanf("%da fun%s")) - ensure - fh.close + File.open(File.join(File.dirname(__FILE__), "data.txt"), "r") do |fh| + assert_equal(0, fh.pos) + assert_equal(["this", "is"], fh.scanf("%s%s")) + assert_equal([33, "little"], fh.scanf("%da fun%s")) + end end def test_pipe_scanf - r, w = IO.pipe - w.write('a') - w.close - assert_equal([], r.scanf('a')) - ensure - r.close + IO.pipe do |r, w| + w.write('a') + w.close + assert_equal([], r.scanf('a')) + end end end -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/