diff options
Diffstat (limited to 'test/ruby')
-rw-r--r-- | test/ruby/test_array.rb | 12 | ||||
-rw-r--r-- | test/ruby/test_rubyoptions.rb | 4 | ||||
-rw-r--r-- | test/ruby/test_string.rb | 12 |
3 files changed, 26 insertions, 2 deletions
diff --git a/test/ruby/test_array.rb b/test/ruby/test_array.rb index fd3b98432d..25bf5955ec 100644 --- a/test/ruby/test_array.rb +++ b/test/ruby/test_array.rb @@ -1224,6 +1224,18 @@ class TestArray < Test::Unit::TestCase if (@cls == Array) assert_equal(a_id, a.to_ary.__id__) end + + o = Object.new + def o.to_ary + [4, 5] + end + assert_equal([1, 2, 3, 4, 5], a.concat(o)) + + o = Object.new + def o.to_ary + foo_bar() + end + assert_match(/foo_bar/, assert_raise(NoMethodError) {a.concat(o)}.message) end def test_to_s diff --git a/test/ruby/test_rubyoptions.rb b/test/ruby/test_rubyoptions.rb index 7e4ac8cfb4..d4143cffb8 100644 --- a/test/ruby/test_rubyoptions.rb +++ b/test/ruby/test_rubyoptions.rb @@ -53,9 +53,9 @@ class TestRubyOptions < Test::Unit::TestCase end def test_debug - assert_in_out_err(%w(-de) + ["p $DEBUG"], "", %w(true), //) + assert_in_out_err(%w(-de) + ["p $DEBUG"], "", %w(true), []) - assert_in_out_err(%w(--debug -e) + ["p $DEBUG"], "", %w(true), //) + assert_in_out_err(%w(--debug -e) + ["p $DEBUG"], "", %w(true), []) end def test_verbose diff --git a/test/ruby/test_string.rb b/test/ruby/test_string.rb index f0688a342c..290f53634d 100644 --- a/test/ruby/test_string.rb +++ b/test/ruby/test_string.rb @@ -1408,6 +1408,18 @@ class TestString < Test::Unit::TestCase a = S("me") assert_equal("me", a.to_s) assert_equal(a.__id__, a.to_s.__id__) if @cls == String + + o = Object.new + def o.to_str + "at" + end + assert_equal("meat", a.concat(o)) + + o = Object.new + def o.to_str + foo_bar() + end + assert_match(/foo_bar/, assert_raise(NoMethodError) {a.concat(o)}.message) end def test_tr |