diff options
| author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2022-07-01 00:57:15 +0900 |
|---|---|---|
| committer | git <svn-admin@ruby-lang.org> | 2024-03-15 04:34:14 +0000 |
| commit | a1ced60692022184d40bdbb980131705e6be4fda (patch) | |
| tree | 8e1197b17a02e0fbedd9e72632f49811b06fe837 /test | |
| parent | 1e7c0fcc9ad9f6212752b0fce54d502a5eb6459c (diff) | |
[ruby/stringio] NULL StringIO by `StringIO.new(nil)`
https://github.com/ruby/stringio/commit/779f71359d
Diffstat (limited to 'test')
| -rw-r--r-- | test/stringio/test_stringio.rb | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/test/stringio/test_stringio.rb b/test/stringio/test_stringio.rb index b0eff57c77..2af6923574 100644 --- a/test/stringio/test_stringio.rb +++ b/test/stringio/test_stringio.rb @@ -22,10 +22,11 @@ class TestStringIO < Test::Unit::TestCase assert_kind_of StringIO, StringIO.new assert_kind_of StringIO, StringIO.new('str') assert_kind_of StringIO, StringIO.new('str', 'r+') + assert_kind_of StringIO, StringIO.new(nil) assert_raise(ArgumentError) { StringIO.new('', 'x') } assert_raise(ArgumentError) { StringIO.new('', 'rx') } assert_raise(ArgumentError) { StringIO.new('', 'rbt') } - assert_raise(TypeError) { StringIO.new(nil) } + assert_raise(TypeError) { StringIO.new(Object) } o = Object.new def o.to_str @@ -40,6 +41,13 @@ class TestStringIO < Test::Unit::TestCase assert_kind_of StringIO, StringIO.new(o) end + def test_null + io = StringIO.new(nil) + assert_nil io.gets + io.puts "abc" + assert_nil io.string + end + def test_truncate io = StringIO.new("") io.puts "abc" |
