Exemplo n.º 1
0
def test_parser_advanced_b():
    formula_str = 'SUM(CCR * src1."Traffic-Full") / SUM(src2."Traffic-full")'

    formula = arith_expr.parseString(formula_str, parseAll=True)[0]

    context = Context()

    r = formula(context)

    eq_(r, "SUM(t1.\"CCR\" * t2.\"Traffic-Full\") / SUM(t3.\"Traffic-full\")")
Exemplo n.º 2
0
def test_parser_advanced_a():
    formula_str = "SUM(CCR) / SUM(Traffic_full) + (2/-3)"

    formula = arith_expr.parseString(formula_str, parseAll=True)[0]

    context = Context()

    r = formula(context)

    eq_(r, "SUM(t1.\"CCR\") / SUM(t1.\"Traffic_full\") + (2 / -3)")
Exemplo n.º 3
0
def test_parser_subtraction():
    formula_str = "42-6 - 2  - 5"

    formula = arith_expr.parseString(formula_str, parseAll=True)[0]

    context = Context()

    r = formula(context)

    eq_(r, "42 - 6 - 2 - 5")
Exemplo n.º 4
0
def test_parser_brackets():
    formula_str = "4 / 7 + (2/-3)"

    formula = arith_expr.parseString(formula_str, parseAll=True)[0]

    context = Context()

    r = formula(context)

    eq_(r, "4 / 7 + (2 / -3)")
Exemplo n.º 5
0
def test_parser_addition():
    formula_str = "3 + 19+2  + 0"

    formula = arith_expr.parseString(formula_str, parseAll=True)[0]

    context = Context()

    r = formula(context)

    eq_(r, "3 + 19 + 2 + 0")