Exemple #1
0
def test_division_given_addition_to_string():
    """."""
    tree = Div(Add(Leaf(12), Leaf(6)), Leaf(6))
    assert tree.apply() == 3
    assert tree.__str__() == "(12 + 6) / 6"
Exemple #2
0
def test_addition_with_leaves_to_class_string():
    """."""
    assert eval(Add(Leaf(5), Leaf(6)).class_str()).apply() == 11
Exemple #3
0
def test_addition_with_leaves_to_string():
    """."""
    tree = Add(Leaf(5), Leaf(6))
    assert tree.apply() == 11
    assert tree.__str__() == "5 + 6"
Exemple #4
0
def test_addition_adds_when_given_leaves_with_numbers():
    """."""
    assert Add(Leaf(5), Leaf(6)).apply() == 11
Exemple #5
0
def test_addition_adds_when_given_leaves_with_numbers_deeper():
    """."""
    assert Add(Add(Add(Add(Leaf(6), Leaf(6)), Leaf(6)), Leaf(6)),
               Leaf(6)).apply() == 30
Exemple #6
0
def test_addition_doesnt_equal_addition_when_different_value():
    """."""
    assert Add(Leaf(2), Leaf(1)) != Add(Leaf(1), Leaf(2))
Exemple #7
0
def test_set_add_adds_when_given_leaves_with_sets():
    """."""
    assert Add(Leaf({5}), Leaf({6})).apply() == {5, 6}
def test_division_given_addition_to_string():
    """."""
    tree = Add(Sub(Leaf(5), Leaf(6)), Sub(Leaf(5), Leaf(6)))
    """assert tree.apply() == 3"""
    assert tree.__str__() == "(5 - 6) + (5 - 6)"
Exemple #9
0
def test_addition_equals_addition_when_same_value():
    """."""
    assert Add(Leaf(1), Leaf(2)) == Add(Leaf(1), Leaf(2))
def test_division_given_addition_to_string():
    """."""
    tree = Add(Leaf(3), Div(Add(Leaf(12), Leaf(6)), Leaf(6)))
    """assert tree.apply() == 3"""
    assert tree.__str__() == '3 + (12 + 6) / 6'
Exemple #11
0
def test_multiplication_given_addition_given_addition_to_string():
    """. Tree node class str."""
    tree = Add(Leaf(3), Div(Add(Leaf(12), Leaf(6)), Leaf(6)))
    assert tree.__str__() == "3 + (12 + 6) / 6"
Exemple #12
0
def test_addition_given_addition_to_class_string():
    """. Tree node class str."""
    assert eval(Add(Add(Leaf(5), Leaf(6)),
                    Add(Leaf(5), Leaf(6))).class_str()).apply() == 22
Exemple #13
0
def test_leaf_to_class_string1():
    """."""
    assert Add(Leaf(5), Leaf(6)).class_str() == "Add(Leaf(5), Leaf(6))"
Exemple #14
0
def test_no_apply():
    """."""
    assert Add(Add(Leaf(5), Leaf(6)), Add(Leaf(5), Leaf(6))).class_str() \
           == "Add(Add(Leaf(5), Leaf(6)), Add(Leaf(5), Leaf(6)))"