From 6f29716f9ffb710af7f344839ec67ef2b8a48ab2 Mon Sep 17 00:00:00 2001 From: Koichi Sasada Date: Thu, 24 Dec 2020 10:59:27 +0900 Subject: shareable_constant_value: experimental_copy "experimental_everything" makes the assigned value, it means the assignment change the state of assigned value. "experimental_copy" tries to make a deep copy and make copyied object sharable. --- test/ruby/test_parse.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'test') diff --git a/test/ruby/test_parse.rb b/test/ruby/test_parse.rb index 2e3fbc9945..5f638afa01 100644 --- a/test/ruby/test_parse.rb +++ b/test/ruby/test_parse.rb @@ -1205,6 +1205,7 @@ x = __ENCODING__ end def test_shareable_constant_value_simple + obj = [['unsharable_value']] a, b, c = eval_separately("#{<<~"begin;"}\n#{<<~'end;'}") begin; # shareable_constant_value: experimental_everything @@ -1222,6 +1223,18 @@ x = __ENCODING__ assert_ractor_shareable(c) assert_equal([1], a[0]) assert_ractor_shareable(a[0]) + + a, obj = eval_separately(<<~'end;') + # shareable_constant_value: experimental_copy + obj = [["unshareable"]] + A = obj + [A, obj] + end; + + assert_ractor_shareable(a) + assert_not_ractor_shareable(obj) + assert_equal obj, a + assert !obj.equal?(a) end def test_shareable_constant_value_nested -- cgit v1.2.3