1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Add test for recursion

This commit is contained in:
John Hawthorn 2021-06-25 14:47:23 -07:00 committed by Alan Wu
parent 7ed1e3ff0b
commit 073e3b2eab

View file

@ -112,6 +112,17 @@ class TestYJIT < Test::Unit::TestCase
RUBY
end
def test_recursion
assert_compiles(<<~'RUBY', insns: %i[opt_le opt_minus opt_plus], stdout: '34')
def fib(n)
return n if n <= 1
fib(n-1) + fib(n-2)
end
fib(9)
RUBY
end
def assert_compiles(test_script, insns: [], min_calls: 1, stdout: nil, exits: {})
reset_stats = <<~RUBY
YJIT.runtime_stats