Skip to content

Commit

Permalink
Add more assertions in test_uplus_minus
Browse files Browse the repository at this point in the history
Not along after 1b83074 CI
started to rarely fail this test:

```
TestString#test_uplus_minus: Test::Unit::AssertionFailedError: uminus deduplicates [Feature #13077].
  1) Failure:
TestString#test_uplus_minus [/tmp/ruby/src/trunk/test/ruby/test_string.rb:3368]:
```

It's unclear what is going on, but one possibility is that
`"bar".freeze` might no longer compile correctly.

Another possibility is that another test redefine `String#freeze`,
causing `opt_str_freeze` to no longer return an `fstring`.
  • Loading branch information
byroot committed Apr 15, 2024
1 parent 9a57b04 commit bb1c341
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions test/ruby/test_string.rb
Expand Up @@ -3356,16 +3356,20 @@ def test_uplus_minus
assert_same(str, +str)
assert_not_same(str, -str)

require 'objspace'

str = "bar".freeze
assert_includes ObjectSpace.dump(str), '"fstring":true'

assert_predicate(str, :frozen?)
assert_not_predicate(+str, :frozen?)
assert_predicate(-str, :frozen?)

assert_not_same(str, +str)
assert_same(str, -str)

bar = %w(b a r).join('')
assert_same(str, -bar, "uminus deduplicates [Feature #13077]")
bar = -%w(b a r).join('')
assert_same(str, bar, "uminus deduplicates [Feature #13077] #{ObjectSpace.dump(bar)}")
end

def test_uminus_frozen
Expand Down

0 comments on commit bb1c341

Please sign in to comment.