summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorKoichi Sasada <ko1@atdot.net>2020-12-24 10:59:27 +0900
committerKoichi Sasada <ko1@atdot.net>2020-12-24 14:28:47 +0900
commit6f29716f9ffb710af7f344839ec67ef2b8a48ab2 (patch)
tree296e34994f4670acfe02bca27e5a4864629a5248 /test
parent1e215a66d26d56befab4fbb72e1d953879411955 (diff)
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.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/3989
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_parse.rb13
1 files changed, 13 insertions, 0 deletions
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