コード例 #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"
コード例 #2
0
def test_addition_with_leaves_to_class_string():
    """."""
    assert eval(Add(Leaf(5), Leaf(6)).class_str()).apply() == 11
コード例 #3
0
def test_addition_with_leaves_to_string():
    """."""
    tree = Add(Leaf(5), Leaf(6))
    assert tree.apply() == 11
    assert tree.__str__() == "5 + 6"
コード例 #4
0
ファイル: test_equations_ex12.py プロジェクト: Elgedr/Python
def test_addition_adds_when_given_leaves_with_numbers():
    """."""
    assert Add(Leaf(5), Leaf(6)).apply() == 11
コード例 #5
0
ファイル: test_equations_ex12.py プロジェクト: Elgedr/Python
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
コード例 #6
0
def test_addition_doesnt_equal_addition_when_different_value():
    """."""
    assert Add(Leaf(2), Leaf(1)) != Add(Leaf(1), Leaf(2))
コード例 #7
0
def test_set_add_adds_when_given_leaves_with_sets():
    """."""
    assert Add(Leaf({5}), Leaf({6})).apply() == {5, 6}
コード例 #8
0
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)"
コード例 #9
0
def test_addition_equals_addition_when_same_value():
    """."""
    assert Add(Leaf(1), Leaf(2)) == Add(Leaf(1), Leaf(2))
コード例 #10
0
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'
コード例 #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"
コード例 #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
コード例 #13
0
def test_leaf_to_class_string1():
    """."""
    assert Add(Leaf(5), Leaf(6)).class_str() == "Add(Leaf(5), Leaf(6))"
コード例 #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)))"