* 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
This commit is contained in:
ko1 2015-12-07 15:10:00 +00:00
parent 9a28a29b87
commit 6d8bf54c44
3 changed files with 66 additions and 0 deletions

View file

@ -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