diff options
Diffstat (limited to 'test/ruby/test_proc.rb')
| -rw-r--r-- | test/ruby/test_proc.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/test/ruby/test_proc.rb b/test/ruby/test_proc.rb index f74342322f..eefd5b189b 100644 --- a/test/ruby/test_proc.rb +++ b/test/ruby/test_proc.rb @@ -342,6 +342,25 @@ class TestProc < Test::Unit::TestCase assert_equal(9, b) end + # Not named test_curry_* so that test_curry_with_trace does not re-run it + # under set_trace_func (which would be needlessly slow with GC.stress). + def test_proc_curry_keeps_args_alive + # The argument array passed down by `curry` must stay alive across the + # inner call; otherwise GC may reclaim it while it is still read as argv + # and crash with "try to mark T_NONE object". See the RB_GC_GUARD in `curry`. + assert_separately([], "#{<<~"begin;"}\n#{<<~'end;'}", timeout: 60) + begin; + GC.stress = true + l = ->(a, b, c) { a + b + c } + 30.times do + l1 = l.curry.call(1) + l2 = l1.curry.call(2) + assert_equal(6, l2.curry.call(3)) + assert_equal(6, l1.curry.call(2, 3)) + end + end; + end + def test_lambda? l = proc {} assert_equal(false, l.lambda?) |
