From 98f9c33fe07d098a1e06e0ea9a59324cf071a2d3 Mon Sep 17 00:00:00 2001 From: ksss Date: Sun, 21 May 2017 10:30:27 +0900 Subject: String#concat: Try to convert when not string --- mrbgems/mruby-string-ext/test/string.rb | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'mrbgems/mruby-string-ext/test/string.rb') diff --git a/mrbgems/mruby-string-ext/test/string.rb b/mrbgems/mruby-string-ext/test/string.rb index 24bc859d8..da39bd8e9 100644 --- a/mrbgems/mruby-string-ext/test/string.rb +++ b/mrbgems/mruby-string-ext/test/string.rb @@ -122,12 +122,16 @@ assert('String#swapcase!') do end assert('String#concat') do - s = "Hello " - s.concat "World!" - t = "Hello " - t << "World!" - assert_equal "Hello World!", t - assert_equal "Hello World!", s + assert_equal "Hello World!", "Hello " << "World" << 33 + assert_equal "Hello World!", "Hello ".concat("World").concat(33) + + o = Object.new + def o.to_str + "to_str" + end + assert_equal "hi to_str", "hi " << o + + assert_raise(TypeError) { "".concat(Object.new) } end assert('String#casecmp') do -- cgit v1.2.3