summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authoryui-knk <spiketeika@gmail.com>2024-01-06 17:33:20 +0900
committerYuichiro Kaneko <spiketeika@gmail.com>2024-02-10 09:23:17 +0900
commitea91ab696e6ee7225a2dde909e60dd9d0b241935 (patch)
tree47963367b2840fc1b425d47eee15cc7c59c1dbdd /test
parentbf72cb84ca52bc062cc1711c03622ed6c928fed8 (diff)
Fix constant name of `Ractor::IsolationError` message
`dest` of `const_decl_path` is `NODE_COLON2` or `NODE_COLON3` in some cases. For example, `B::C ||= [“Not ” + “shareable”]` passes `NODE_COLON2` and `::C ||= [“Not ” + “shareable”]` passes `NODE_COLON3`. This commit fixes `Ractor::IsolationError` message for such case. ``` # shareable_constant_value: literal ::C ||= ["Not " + "shareable"] # Before # => cannot assign unshareable object to C (Ractor::IsolationError) # After # => cannot assign unshareable object to ::C (Ractor::IsolationError) ```
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_parse.rb34
1 files changed, 34 insertions, 0 deletions
diff --git a/test/ruby/test_parse.rb b/test/ruby/test_parse.rb
index b6d306352c..edf61db325 100644
--- a/test/ruby/test_parse.rb
+++ b/test/ruby/test_parse.rb
@@ -1568,6 +1568,40 @@ x = __ENCODING__
::B::C = ["Not " + "shareable"]
end
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_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 ::B::C/) do
+ # shareable_constant_value: literal
+ ::B = Class.new
+ ::B::C ||= ["Not " + "shareable"]
+ end
+ end;
+
+ assert_raise_separately(Ractor::IsolationError, /unshareable object to ...::C/,
+ "#{<<~"begin;"}\n#{<<~'end;'}")
+ begin;
+ # shareable_constant_value: literal
+ B = Class.new
+ def self.expr; B; end
+ expr::C ||= ["Not " + "shareable"]
+ end;
end
def test_shareable_constant_value_nonliteral