summaryrefslogtreecommitdiffhomepage
path: root/mrbgems/mruby-string-ext/test
diff options
context:
space:
mode:
authorksss <[email protected]>2017-05-21 10:30:27 +0900
committerksss <[email protected]>2017-05-21 10:30:27 +0900
commit98f9c33fe07d098a1e06e0ea9a59324cf071a2d3 (patch)
tree607d7095cb1de58ba59717da80602de102797d88 /mrbgems/mruby-string-ext/test
parent78add728126cbe03b9048e57f897a7134508af5d (diff)
downloadmruby-98f9c33fe07d098a1e06e0ea9a59324cf071a2d3.tar.gz
mruby-98f9c33fe07d098a1e06e0ea9a59324cf071a2d3.zip
String#concat: Try to convert when not string
Diffstat (limited to 'mrbgems/mruby-string-ext/test')
-rw-r--r--mrbgems/mruby-string-ext/test/string.rb16
1 files changed, 10 insertions, 6 deletions
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