summaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorJun Hiroe <[email protected]>2014-06-05 01:10:02 +0900
committerJun Hiroe <[email protected]>2014-06-07 16:15:32 +0900
commit9709fe79a3a75eefc92329cc0b74e159ff31525f (patch)
treed0608206e9bcb74d5848ffd29c07747c26c9071c /test
parent04edab4c2117acd71031f62c753ed09f6d0da5bb (diff)
downloadmruby-9709fe79a3a75eefc92329cc0b74e159ff31525f.tar.gz
mruby-9709fe79a3a75eefc92329cc0b74e159ff31525f.zip
Implement String#clear
Diffstat (limited to 'test')
-rw-r--r--test/t/string.rb21
1 files changed, 21 insertions, 0 deletions
diff --git a/test/t/string.rb b/test/t/string.rb
index 5ecb51530..779a74791 100644
--- a/test/t/string.rb
+++ b/test/t/string.rb
@@ -515,3 +515,24 @@ assert('String#each_byte') do
assert_equal bytes1, bytes2
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