mirror of
https://github.com/ruby/ruby.git
synced 2025-08-28 07:26:00 +02:00
Make String#-@ not freeze receiver if called on unfrozen subclass instance
rb_fstring behavior in this case is to freeze the receiver. I'm not sure if that should be changed, so this takes the conservative approach of duping the receiver in String#-@ before passing to rb_fstring. Fixes [Bug #15926]
This commit is contained in:
parent
a4b5aaa9a7
commit
7582287eb2
2 changed files with 19 additions and 0 deletions
|
@ -3175,6 +3175,22 @@ CODE
|
|||
assert_same(str, -bar, "uminus deduplicates [Feature #13077]")
|
||||
end
|
||||
|
||||
def test_uminus_no_freeze_not_bare
|
||||
str = @cls.new("foo")
|
||||
-str
|
||||
assert_equal(false, str.frozen?)
|
||||
|
||||
str = @cls.new("foo")
|
||||
str.instance_variable_set(:@iv, 1)
|
||||
-str
|
||||
assert_equal(false, str.frozen?)
|
||||
|
||||
str = @cls.new("foo")
|
||||
str.taint
|
||||
-str
|
||||
assert_equal(false, str.frozen?)
|
||||
end
|
||||
|
||||
def test_ord
|
||||
assert_equal(97, "a".ord)
|
||||
assert_equal(97, "abc".ord)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue