예제 #1
0
def execute(string):
    log(string)
    try:
        log(antlang.evaluate(string))
    except Exception as e:
        log(e)
    log('')
예제 #2
0
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
예제 #3
0
def test_fun(decl, fun_call, res):
    ant.evaluate(decl)
    ant.evaluate(fun_call) == res
예제 #4
0
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'))
예제 #5
0
def test_eval(a, res):
    assert str(ant.evaluate(a)) == res