def execute(string): log(string) try: log(antlang.evaluate(string)) except Exception as e: log(e) log('')
def test_discount(): ant.evaluate('discount: {x × 1\y÷100}') res = ' '.join([str(x) for x in (1.8, 7 * (80 / 100), 9.0)]) assert str(ant.evaluate('(2,7,18) discount 10,20,50')) == res
def test_fun(decl, fun_call, res): ant.evaluate(decl) ant.evaluate(fun_call) == res
def test_names(): ant.evaluate('one: 1') ant.evaluate('two: 2') ant.evaluate('plus: +') ant.evaluate('three: 3') assert str(ant.evaluate('one plus two')) == str(ant.evaluate('three'))
def test_eval(a, res): assert str(ant.evaluate(a)) == res