diff options
| -rw-r--r-- | bootstraptest/test_ractor.rb | 10 | ||||
| -rw-r--r-- | ractor.c | 2 |
2 files changed, 11 insertions, 1 deletions
diff --git a/bootstraptest/test_ractor.rb b/bootstraptest/test_ractor.rb index 7d09ac5283..bec742da4b 100644 --- a/bootstraptest/test_ractor.rb +++ b/bootstraptest/test_ractor.rb @@ -157,6 +157,16 @@ assert_equal '[:a, :b, :c, :d, :e]', %q{ Ractor.shareable_proc(&closure).call } +# Ractor.make_shareable makes a copy of given Proc +assert_equal '[true, true]', %q{ + pr1 = Proc.new do + self + end + pr2 = Ractor.shareable_proc(&pr1) + + [pr1.call == self, pr2.call == nil] +} + # Ractor::IsolationError cases assert_equal '3', %q{ ok = 0 @@ -2376,7 +2376,7 @@ ractor_shareable_proc(rb_execution_context_t *ec, VALUE replace_self, bool is_la } else { VALUE proc = is_lambda ? rb_block_lambda() : rb_block_proc(); - return rb_proc_ractor_make_shareable(proc, replace_self); + return rb_proc_ractor_make_shareable(rb_proc_dup(proc), replace_self); } } |
