Exemple #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)
Exemple #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)
Exemple #3
0
def test_simple_max_expression():
    assert calculate(parse_expression("5 3 4 2 9 1 MAX")) == 9
Exemple #4
0
def test_triple_expression_with_square_root():
    assert calculate(parse_expression("20 9 SQRT 5 * +")) == 35
Exemple #5
0
def test_double_expression_with_square_root():
    assert calculate(parse_expression("9 SQRT 5 *")) == 15
Exemple #6
0
def test_simple_square_root():
    assert calculate(parse_expression("9 SQRT")) == 3
Exemple #7
0
def test_calculate_triple_expression():
    assert calculate(parse_expression("3 5 8 * 7 + *")) == 141
Exemple #8
0
def test_calculate_double_expression():
    assert calculate(parse_expression("4 2 + 3 -")) == 3
Exemple #9
0
def test_calculate_simple_expression():
    assert calculate(parse_expression("20 5 /")) == 4
Exemple #10
0
def test_simple_expression():
    exp = parse_expression("20 5 /")
    assert exp[0] == 20
    assert exp[1] == 5
    assert isinstance(exp[2], Divide)