From cce331272b07636d536c8227288ab3fbcf24e2aa Mon Sep 17 00:00:00 2001 From: Koichi Sasada Date: Thu, 9 Dec 2021 03:58:44 +0900 Subject: `Ractor.make_shareable` checks proc's sefl `Ractor.make_shareable(proc_obj)` raises an `IsolationError` if the self of `proc_obj` is not a shareable object. [Bug #18243] --- test/ruby/test_iseq.rb | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'test/ruby') diff --git a/test/ruby/test_iseq.rb b/test/ruby/test_iseq.rb index ac191531de..aa0bf35b80 100644 --- a/test/ruby/test_iseq.rb +++ b/test/ruby/test_iseq.rb @@ -129,7 +129,7 @@ class TestISeq < Test::Unit::TestCase def test_lambda_with_ractor_roundtrip iseq = compile(<<~EOF, __LINE__+1) x = 42 - y = lambda { x } + y = nil.instance_eval{ lambda { x } } Ractor.make_shareable(y) y.call EOF @@ -148,16 +148,20 @@ class TestISeq < Test::Unit::TestCase def test_ractor_unshareable_outer_variable name = "\u{2603 26a1}" - y = eval("proc {#{name} = nil; proc {|x| #{name} = x}}").call + y = nil.instance_eval do + eval("proc {#{name} = nil; proc {|x| #{name} = x}}").call + end assert_raise_with_message(ArgumentError, /\(#{name}\)/) do Ractor.make_shareable(y) end - y = eval("proc {#{name} = []; proc {|x| #{name}}}").call + y = nil.instance_eval do + eval("proc {#{name} = []; proc {|x| #{name}}}").call + end assert_raise_with_message(Ractor::IsolationError, /`#{name}'/) do Ractor.make_shareable(y) end obj = Object.new - def obj.foo(*) ->{super} end + def obj.foo(*) nil.instance_eval{ ->{super} } end assert_raise_with_message(Ractor::IsolationError, /hidden variable/) do Ractor.make_shareable(obj.foo) end -- cgit v1.2.3