From 1d2eaf95282dec2dd34a9f7f69fb2eae8defac10 Mon Sep 17 00:00:00 2001 From: Florian Hahn Date: Sat, 13 Jul 2013 18:33:51 +0200 Subject: [PATCH] Add some tests for CALLM and CALLMT --- luna/tests/test_call.py | 46 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/luna/tests/test_call.py b/luna/tests/test_call.py index 55635c0..c38e490 100644 --- a/luna/tests/test_call.py +++ b/luna/tests/test_call.py @@ -57,3 +57,49 @@ def test_call_recursive(self): return x """) assert ret.getval() == 3628800 + + def test_nested_function_tailcall(self): + """ + Tests CALLMT with user defined function + """ + ret = codetest(""" + function f(x) + y = x+1 + return y + end + return f(f(5)) + """) + assert ret.getval() == 7 + + def test_nested_function_tailcall_builtin(self): + """ + Tests CALLMT with builtin function + """ + ret = codetest(""" + return math.sin(math.sin(1)) + """) + assert ret.getval() == 0.7456241416655579 + + def test_nested_function_call(self): + """ + Tests CALLM with user function + """ + ret = codetest(""" + function f(x) + y = x+1 + return y + end + x = f(f(5)) + return x + """) + assert ret.getval() == 7 + + def test_nested_function_call_builtin(self): + """ + Tests CALLM with builtin function + """ + ret = codetest(""" + x = math.sin(math.sin(1)) + return x + """) + assert ret.getval() == 0.7456241416655579