diff options
| author | yui-knk <spiketeika@gmail.com> | 2024-01-05 19:45:19 +0900 |
|---|---|---|
| committer | Yuichiro Kaneko <spiketeika@gmail.com> | 2024-02-10 09:23:17 +0900 |
| commit | bf72cb84ca52bc062cc1711c03622ed6c928fed8 (patch) | |
| tree | a5e17e57e10fe9db150d04c7fd1946ab0a2529b0 /test/ruby | |
| parent | e7b0a01002323d9ed8eed9abca2a4979ebe9ae32 (diff) | |
Include the first constant name into `Ractor::IsolationError` message
If lhs of assignment is top-level constant reference, the first
constant name is omitted from error message.
This commit fixes it.
```
# shareable_constant_value: literal
::C = ["Not " + "shareable"]
# Before
# => cannot assign unshareable object to (Ractor::IsolationError)
# After
# => cannot assign unshareable object to ::C (Ractor::IsolationError)
```
Diffstat (limited to 'test/ruby')
| -rw-r--r-- | test/ruby/test_parse.rb | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/test/ruby/test_parse.rb b/test/ruby/test_parse.rb index 6b8c196a84..b6d306352c 100644 --- a/test/ruby/test_parse.rb +++ b/test/ruby/test_parse.rb @@ -1537,12 +1537,37 @@ x = __ENCODING__ end def test_shareable_constant_value_unshareable_literal - assert_raise_separately(Ractor::IsolationError, /unshareable/, + assert_raise_separately(Ractor::IsolationError, /unshareable object to C/, "#{<<~"begin;"}\n#{<<~'end;'}") begin; # shareable_constant_value: literal C = ["Not " + "shareable"] end; + + assert_raise_separately(Ractor::IsolationError, /unshareable object to B::C/, + "#{<<~"begin;"}\n#{<<~'end;'}") + begin; + # shareable_constant_value: literal + B = Class.new + B::C = ["Not " + "shareable"] + end; + + assert_separately([], "#{<<~"begin;"}\n#{<<~'end;'}") + begin; + assert_raise_with_message(Ractor::IsolationError, /unshareable object to ::C/) do + # shareable_constant_value: literal + ::C = ["Not " + "shareable"] + end + end; + + assert_separately([], "#{<<~"begin;"}\n#{<<~'end;'}") + begin; + assert_raise_with_message(Ractor::IsolationError, /unshareable object to ::B::C/) do + # shareable_constant_value: literal + ::B = Class.new + ::B::C = ["Not " + "shareable"] + end + end; end def test_shareable_constant_value_nonliteral |
