diff options
author | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2021-11-11 17:31:58 +0900 |
---|---|---|
committer | nagachika <nagachika@ruby-lang.org> | 2021-11-22 10:51:35 +0900 |
commit | e6fced73e55dda487f026c929d97542cf1832252 (patch) | |
tree | 65456d13bb4616404d36eca4948cd323a93fbbb7 /test | |
parent | e735773fd4a0f9cbab82134e22d989bf540b744e (diff) |
Bump stringio version to 3.0.1
Diffstat (limited to 'test')
-rw-r--r-- | test/stringio/test_stringio.rb | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/test/stringio/test_stringio.rb b/test/stringio/test_stringio.rb index a49326119f..e0b4504b54 100644 --- a/test/stringio/test_stringio.rb +++ b/test/stringio/test_stringio.rb @@ -446,6 +446,15 @@ class TestStringIO < Test::Unit::TestCase f.close unless f.closed? end + def test_each_byte_closed + f = StringIO.new("1234") + assert_equal("1".ord, f.each_byte {|c| f.close; break c }) + f = StringIO.new("1234") + assert_raise(IOError) do + f.each_byte { f.close } + end + end + def test_getbyte f = StringIO.new("1234") assert_equal("1".ord, f.getbyte) @@ -520,11 +529,29 @@ class TestStringIO < Test::Unit::TestCase assert_equal(%w(1 2 3 4), f.each_char.to_a) end + def test_each_char_closed + f = StringIO.new("1234") + assert_equal("1", f.each_char {|c| f.close; break c }) + f = StringIO.new("1234") + assert_raise(IOError) do + f.each_char { f.close } + end + end + def test_each_codepoint f = StringIO.new("1234") assert_equal([49, 50, 51, 52], f.each_codepoint.to_a) end + def test_each_codepoint_closed + f = StringIO.new("1234") + assert_equal("1".ord, f.each_codepoint {|c| f.close; break c }) + f = StringIO.new("1234") + assert_raise(IOError) do + f.each_codepoint { f.close } + end + end + def test_each_codepoint_enumerator io = StringIO.new('你好построить') @@ -798,7 +825,7 @@ class TestStringIO < Test::Unit::TestCase end def test_overflow - skip if RbConfig::SIZEOF["void*"] > RbConfig::SIZEOF["long"] + omit if RbConfig::SIZEOF["void*"] > RbConfig::SIZEOF["long"] limit = RbConfig::LIMITS["INTPTR_MAX"] - 0x10 assert_separately(%w[-rstringio], "#{<<-"begin;"}\n#{<<-"end;"}") begin; @@ -808,7 +835,7 @@ class TestStringIO < Test::Unit::TestCase x = "a"*0x100000 break if [x].pack("p").unpack("i!")[0] < 0 ary << x - skip if ary.size > 100 + omit if ary.size > 100 end s = StringIO.new(x) s.gets("xxx", limit) |