diff options
author | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-12-07 15:10:00 +0000 |
---|---|---|
committer | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-12-07 15:10:00 +0000 |
commit | 6e3f5ffa778a5d2c36ffcc422b1c9742fa5eb16b (patch) | |
tree | 025393fd97224c56104624276b716058c695cddd /test/ruby/test_string.rb | |
parent | 7f9827e4b3e76f215fa9fd36f24fd8e1fdef9866 (diff) | |
download | ruby-6e3f5ffa778a5d2c36ffcc422b1c9742fa5eb16b.tar.gz |
* string.c: introduce String#+@ and String#-@ to control
String mutability.
[Feature #11782]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52917 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_string.rb')
-rw-r--r-- | test/ruby/test_string.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/test/ruby/test_string.rb b/test/ruby/test_string.rb index 7627fe12dc..824c0e6b1c 100644 --- a/test/ruby/test_string.rb +++ b/test/ruby/test_string.rb @@ -2252,6 +2252,24 @@ class TestString < Test::Unit::TestCase end; end if [0].pack("l!").bytesize < [nil].pack("p").bytesize # enable only when string size range is smaller than memory space + + def test_uplus_minus + str = "foo" + assert_equal(false, str.frozen?) + assert_equal(false, (+str).frozen?) + assert_equal(true, (-str).frozen?) + + assert_equal(str.object_id, (+str).object_id) + assert_not_equal(str.object_id, (-str).object_id) + + str = "bar".freeze + assert_equal(true, str.frozen?) + assert_equal(false, (+str).frozen?) + assert_equal(true, (-str).frozen?) + + assert_not_equal(str.object_id, (+str).object_id) + assert_equal(str.object_id, (-str).object_id) + end end class TestString2 < TestString |