diff options
author | Jeremy Evans <code@jeremyevans.net> | 2019-06-18 18:59:49 -0700 |
---|---|---|
committer | Jeremy Evans <code@jeremyevans.net> | 2019-07-02 08:26:50 -0700 |
commit | 7582287eb27e6b649789ce31ffdcbbb9ffcaf726 (patch) | |
tree | 43faa29b74a1fba0426967becba6ed0564e98a64 /test/ruby/test_string.rb | |
parent | a4b5aaa9a7225693168e43455de2e10c3721b789 (diff) |
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]
Diffstat (limited to 'test/ruby/test_string.rb')
-rw-r--r-- | test/ruby/test_string.rb | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/test/ruby/test_string.rb b/test/ruby/test_string.rb index 507e067a0d..26de52dedb 100644 --- a/test/ruby/test_string.rb +++ b/test/ruby/test_string.rb @@ -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) |