Esempio n. 1
0
def test_double_expression():
    exp = parse_expression("4 2 + 3 -")
    assert exp[0] == 4
    assert exp[1] == 2
    assert isinstance(exp[2], Sum)
    assert exp[3] == 3
    assert isinstance(exp[4], Subtract)
Esempio n. 2
0
def test_triple_expression():
    exp = parse_expression("3 5 8 * 7 + *")
    assert exp[0] == 3
    assert exp[1] == 5
    assert exp[2] == 8
    assert isinstance(exp[3], Multiply)
    assert exp[4] == 7
    assert isinstance(exp[5], Sum)
    assert isinstance(exp[6], Multiply)
Esempio n. 3
0
def test_simple_max_expression():
    assert calculate(parse_expression("5 3 4 2 9 1 MAX")) == 9
Esempio n. 4
0
def test_triple_expression_with_square_root():
    assert calculate(parse_expression("20 9 SQRT 5 * +")) == 35
Esempio n. 5
0
def test_double_expression_with_square_root():
    assert calculate(parse_expression("9 SQRT 5 *")) == 15
Esempio n. 6
0
def test_simple_square_root():
    assert calculate(parse_expression("9 SQRT")) == 3
Esempio n. 7
0
def test_calculate_triple_expression():
    assert calculate(parse_expression("3 5 8 * 7 + *")) == 141
Esempio n. 8
0
def test_calculate_double_expression():
    assert calculate(parse_expression("4 2 + 3 -")) == 3
Esempio n. 9
0
def test_calculate_simple_expression():
    assert calculate(parse_expression("20 5 /")) == 4
Esempio n. 10
0
def test_simple_expression():
    exp = parse_expression("20 5 /")
    assert exp[0] == 20
    assert exp[1] == 5
    assert isinstance(exp[2], Divide)