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
This commit is contained in:
parent
7e85d487fe
commit
3586aef4b8
@ -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>
|
Wed Dec 30 05:19:24 2015 Eric Wong <e@80x24.org>
|
||||||
|
|
||||||
* class.c (struct clone_const_arg): adjust for id_table
|
* class.c (struct clone_const_arg): adjust for id_table
|
||||||
|
@ -13,6 +13,27 @@ class TestStringIO < Test::Unit::TestCase
|
|||||||
|
|
||||||
include TestEOF::Seek
|
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
|
def test_truncate
|
||||||
io = StringIO.new("")
|
io = StringIO.new("")
|
||||||
io.puts "abc"
|
io.puts "abc"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user