aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-12-07 15:10:00 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-12-07 15:10:00 +0000
commit6d8bf54c440fd38eb12b3780556d6f7b88beb1ba (patch)
tree025393fd97224c56104624276b716058c695cddd /test
parent9a28a29b870b5f45d370bc8f16c431b435f0bbb3 (diff)
downloadruby-6d8bf54c440fd38eb12b3780556d6f7b88beb1ba.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')
-rw-r--r--test/ruby/test_string.rb18
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