summaryrefslogtreecommitdiff
path: root/test/ruby/test_zjit.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/ruby/test_zjit.rb')
-rw-r--r--test/ruby/test_zjit.rb25
1 files changed, 25 insertions, 0 deletions
diff --git a/test/ruby/test_zjit.rb b/test/ruby/test_zjit.rb
index 33fcbe817f..98eae2a58f 100644
--- a/test/ruby/test_zjit.rb
+++ b/test/ruby/test_zjit.rb
@@ -348,6 +348,31 @@ class TestZJIT < Test::Unit::TestCase
}
end
+ def test_recursive_fact
+ assert_compiles '[1, 6, 720]', %q{
+ def fact(n)
+ if n == 0
+ return 1
+ end
+ return n * fact(n-1)
+ end
+ [fact(0), fact(3), fact(6)]
+ }
+ end
+
+ # FIXME: currently produces the wrong value
+ #def test_recursive_fib
+ # assert_compiles '[0, 2, 3]', %q{
+ # def fib(n)
+ # if n < 2
+ # return n
+ # end
+ # return fib(n-1) + fib(n-2)
+ # end
+ # [fib(0), fib(3), fib(4)]
+ # }
+ #end
+
private
# Assert that every method call in `test_script` can be compiled by ZJIT