ruby-changes:41306
From: nobu <ko1@a...>
Date: Wed, 30 Dec 2015 08:44:18 +0900 (JST)
Subject: [ruby-changes:41306] nobu:r53378 (trunk): test_stringio.rb: test_initialize
nobu 2015-12-30 08:44:01 +0900 (Wed, 30 Dec 2015) New Revision: 53378 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=53378 Log: test_stringio.rb: test_initialize * test/stringio/test_stringio.rb (test_initialize): add test for StringIO#initialize. [ruby-core:72585] [Feature #11920] Modified files: trunk/ChangeLog trunk/test/stringio/test_stringio.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 53377) +++ ChangeLog (revision 53378) @@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Wed Dec 30 08:43:59 2015 Yuki Kurihara <co000ri@g...> + + * 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@8...> * class.c (struct clone_const_arg): adjust for id_table Index: test/stringio/test_stringio.rb =================================================================== --- test/stringio/test_stringio.rb (revision 53377) +++ test/stringio/test_stringio.rb (revision 53378) @@ -13,6 +13,27 @@ class TestStringIO < Test::Unit::TestCas https://github.com/ruby/ruby/blob/trunk/test/stringio/test_stringio.rb#L13 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" -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/