diff options
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | test/stringio/test_stringio.rb | 21 |
2 files changed, 26 insertions, 0 deletions
@@ -1,3 +1,8 @@ +Wed Dec 30 08:43:59 2015 Yuki Kurihara <co000ri@gmail.com> + + * test/stringio/test_stringio.rb (test_initialize): add test for + StringIO#initialize. [ruby-core:72585] [Feature #11920] + Wed Dec 30 05:19:24 2015 Eric Wong <e@80x24.org> * class.c (struct clone_const_arg): adjust for id_table diff --git a/test/stringio/test_stringio.rb b/test/stringio/test_stringio.rb index 9a041c2148..77a98726d8 100644 --- a/test/stringio/test_stringio.rb +++ b/test/stringio/test_stringio.rb @@ -13,6 +13,27 @@ class TestStringIO < Test::Unit::TestCase include TestEOF::Seek + def test_initialize + assert_kind_of StringIO, StringIO.new + assert_kind_of StringIO, StringIO.new('str') + assert_kind_of StringIO, StringIO.new('str', 'r+') + 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('str', nil) } + + o = Object.new + def o.to_str + nil + end + assert_raise(TypeError) { StringIO.new(o) } + def o.to_str + 'str' + end + assert_kind_of StringIO, StringIO.new(o) + end + def test_truncate io = StringIO.new("") io.puts "abc" |