Skip to content

Commit

Permalink
add test_deep_expression
Browse files Browse the repository at this point in the history
  • Loading branch information
krinart committed Feb 6, 2019
1 parent 24770bb commit 21fb6bd
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions tests/interpreters/test_python.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,3 +220,21 @@ def score(input):
var0 = 1
return var0"""
utils.assert_code_equal(interpreter.interpret(expr), expected_code)


def test_deep_expression():
expr = ast.NumVal(1)
for i in range(120):
expr = ast.BinNumExpr(expr, ast.NumVal(1), ast.BinNumOpType.ADD)

interpreter = interpreters.PythonInterpreter()

result_code = interpreter.interpret(expr)
result_code += """
result = score(None)
"""

scope = {}
exec(result_code, scope)

assert scope["result"] == 121

0 comments on commit 21fb6bd

Please sign in to comment.