From 6459a984489e3674d4cb108c3b252525b8fd7068 Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Sat, 7 Jun 2014 22:28:42 +0900 Subject: move String#clear to mruby-string-ext; ref #2370 --- mrbgems/mruby-string-ext/test/string.rb | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (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 0ef92b35a..72c919b35 100644 --- a/mrbgems/mruby-string-ext/test/string.rb +++ b/mrbgems/mruby-string-ext/test/string.rb @@ -172,3 +172,24 @@ assert('String#lines') do assert_equal ["\n", "\n", "\n"], "\n\n\n".lines assert_equal [], "".lines end + +assert('String#clear') do + # embed string + s = "foo" + assert_equal("", s.clear) + assert_equal("", s) + + # not embed string and not shared string + s = "foo" * 100 + a = s + assert_equal("", s.clear) + assert_equal("", s) + assert_equal("", a) + + # shared string + s = "foo" * 100 + a = s[10, 90] # create shared string + assert_equal("", s.clear) # clear + assert_equal("", s) # s is cleared + assert_not_equal("", a) # a should not be affected +end -- cgit v1.2.3