mirror of
https://github.com/ruby/ruby.git
synced 2025-08-28 15:36:16 +02:00
* 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:
parent
9a28a29b87
commit
6d8bf54c44
3 changed files with 66 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue