From 3586aef4b8a18fca685f883c80367a80182b943e Mon Sep 17 00:00:00 2001 From: nobu Date: Tue, 29 Dec 2015 23:44:01 +0000 Subject: 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 --- ChangeLog | 5 +++++ test/stringio/test_stringio.rb | 21 +++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/ChangeLog b/ChangeLog index dcbfbf59c5..c41a9689f8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Wed Dec 30 08:43:59 2015 Yuki Kurihara + + * 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 * 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" -- cgit v1.2.3