diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2014-06-07 22:28:42 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2014-06-07 22:28:42 +0900 |
| commit | 6459a984489e3674d4cb108c3b252525b8fd7068 (patch) | |
| tree | 4eb1ae910362cca02e48455538e00d2b2d6fa886 /mrbgems/mruby-string-ext/test/string.rb | |
| parent | 76012a885d40dd7a5451b747ca3f23ca39595faa (diff) | |
| download | mruby-6459a984489e3674d4cb108c3b252525b8fd7068.tar.gz mruby-6459a984489e3674d4cb108c3b252525b8fd7068.zip | |
move String#clear to mruby-string-ext; ref #2370
Diffstat (limited to 'mrbgems/mruby-string-ext/test/string.rb')
| -rw-r--r-- | mrbgems/mruby-string-ext/test/string.rb | 21 |
1 files changed, 21 insertions, 0 deletions
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 |
