diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-12-29 23:44:01 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-12-29 23:44:01 +0000 |
commit | 3586aef4b8a18fca685f883c80367a80182b943e (patch) | |
tree | eb632c25c42e6736212612f74fca8e766c65c58c /test | |
parent | 7e85d487fe237874477983447e1c590d4d9527aa (diff) | |
download | ruby-3586aef4b8a18fca685f883c80367a80182b943e.tar.gz |
test_stringio.rb: test_initialize
* test/stringio/test_stringio.rb (test_initialize): add test for
StringIO#initialize. [ruby-core:72585] [Feature #11920]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53378 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/stringio/test_stringio.rb | 21 |
1 files changed, 21 insertions, 0 deletions
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" |