summaryrefslogtreecommitdiff
path: root/test/ruby
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2021-06-27 09:42:01 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2021-06-27 11:18:41 +0900
commit13939d61b4b69bd109c5f41303c79868d639fa44 (patch)
tree5f96e396fb9667528767c04c590ef98096e1685f /test/ruby
parent35c7e83bb32869cd96112ffd850b02047b48fac1 (diff)
Check if closed after each yield [Bug #17661]
Diffstat (limited to 'test/ruby')
-rw-r--r--test/ruby/test_io.rb36
1 files changed, 36 insertions, 0 deletions
diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb
index 14592e4d58..7acedb60e2 100644
--- a/test/ruby/test_io.rb
+++ b/test/ruby/test_io.rb
@@ -394,6 +394,24 @@ class TestIO < Test::Unit::TestCase
}
end
+ def test_each_byte_closed
+ pipe(proc do |w|
+ w << "abc def"
+ w.close
+ end, proc do |r|
+ assert_raise(IOError) do
+ r.each_byte {|byte| r.close if byte == 32 }
+ end
+ end)
+ make_tempfile {|t|
+ File.open(t, 'rt') {|f|
+ assert_raise(IOError) do
+ f.each_byte {|c| f.close if c == 10}
+ end
+ }
+ }
+ end
+
def test_each_codepoint
make_tempfile {|t|
bug2959 = '[ruby-core:28650]'
@@ -405,6 +423,24 @@ class TestIO < Test::Unit::TestCase
}
end
+ def test_each_codepoint_closed
+ pipe(proc do |w|
+ w.print("abc def")
+ w.close
+ end, proc do |r|
+ assert_raise(IOError) do
+ r.each_codepoint {|c| r.close if c == 32}
+ end
+ end)
+ make_tempfile {|t|
+ File.open(t, 'rt') {|f|
+ assert_raise(IOError) do
+ f.each_codepoint {|c| f.close if c == 10}
+ end
+ }
+ }
+ end
+
def test_rubydev33072
t = make_tempfile
path = t.path