Skip to content

Commit

Permalink
Add some tests for CALLM and CALLMT
Browse files Browse the repository at this point in the history
  • Loading branch information
fhahn committed Jul 13, 2013
1 parent 8a3a3ce commit 1d2eaf9
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions luna/tests/test_call.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 1d2eaf9

Please sign in to comment.