def test_set_multiply_multiplies_when_given_leaves_with_sets__second_multiple_elements( ): """.""" assert Mul(Leaf({5, 6}), Leaf({3, 4})).apply() == { frozenset({5, 3}), frozenset({6, 3}), frozenset({5, 4}), frozenset({6, 4}) }
def test_set_div_divides_when_given_leaves_with_sets(): """.""" assert Div(Leaf({5, 6}), Leaf({6})).apply() == {5}
def test_subtraction_with_leaves_to_string(): """.""" tree = Sub(Leaf(5), Leaf(6)) assert tree.apply() == -1 assert tree.__str__() == "5 - 6"
def test_leaf_to_string(): """.""" assert Leaf(6).__str__() == "6"
def test_addition_with_leaves_to_class_string(): """.""" assert eval(Add(Leaf(5), Leaf(6)).class_str()).apply() == 11
def test2123(): """.""" tree = Xor(And(Leaf({5}), Leaf({5, 6})), And(Leaf({5}), Leaf({3}))) assert tree.__str__() == "({5} & {5, 6}) ^ ({5} & {3})"
def test_subtract_subtracts_when_given_leaves_with_numbers(): """.""" assert Sub(Leaf(5), Leaf(6)).apply() == -1
def test_leaf_apply_yields_number_when_given_a_number(): """.""" assert Leaf(6).apply() == 6
def test_bitwise_or_given_bitwise_and_given_div_given_mul_given_bitwise_pow_to_string( ): """.""" tree = Or(And(Leaf(3), Div()), ) assert tree.__str__() == "3 & 1 | 5 ** 2 * 1 / 5 & 2"
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)"
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'
def test_subtraction_with_leaves_to_string(): """Done.""" tree = Sub(Leaf(6), Leaf(6)) assert tree.apply() == 0 assert tree.__str__() == "6 - 6"
def test_leaf_to_string(): """Done.""" assert Leaf(7).__str__() == "7"
def test_set_multiply_multiplies_when_given_leaves_with_sets__second_number(): """.""" assert Mul(Leaf({5, 6}), Leaf(4)).apply() == {frozenset({5, 4}), frozenset({6, 4})}
def test_set_subtract_subtracts_when_given_subtraction_with_int(): """.""" assert Sub(Sub(Leaf({5}), Leaf({7})), Sub(Leaf(5), Leaf(6))).apply() == {5}
def test_set_add_adds_when_given_leaves_with_sets(): """.""" assert Add(Leaf({5}), Leaf({6})).apply() == {5, 6}
def test_divide_divides_when_given_leaves_with_numbers(): """.""" assert Div(Div(Div(Div(Leaf(6), Leaf(6)), Leaf(6)), Leaf(6)), Leaf(6)).apply() == 0
def test_leaf_doesnt_equal_leaf_when_different_value(): """.""" assert Leaf(1) != Leaf(2)
def test_addition_adds_when_given_leaves_with_numbers(): """.""" assert Add(Leaf(5), Leaf(6)).apply() == 11
def test_addition_equals_addition_when_same_value(): """.""" assert Add(Leaf(1), Leaf(2)) == Add(Leaf(1), Leaf(2))
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
def test_addition_doesnt_equal_addition_when_different_value(): """.""" assert Add(Leaf(2), Leaf(1)) != Add(Leaf(1), Leaf(2))
def test_leaf_to_class_string(): """.""" assert eval(Leaf(6).class_str()).apply() == 6
def test_leaf_equals_leaf_when_same_value(): """.""" assert Leaf(1) == Leaf(1)
def test_subtraction_with_leaves_to_class_string(): """.""" assert eval(Sub(Leaf(5), Leaf(6)).class_str()).apply() == -1
def test_set_leaf_apply_yields_set_when_given_a_set(): """.""" assert Leaf({6}).apply() == {6}
def test_addition_with_leaves_to_string(): """.""" tree = Add(Leaf(5), Leaf(6)) assert tree.apply() == 11 assert tree.__str__() == "5 + 6"
def test231(): """.""" assert Mul(Leaf(2), Leaf({1, 3})).apply() == {frozenset({2, 1}), frozenset({2, 3})}
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"
def test_pow_raises_to_power_when_given_exponents(): """.""" assert Pow(Pow(Leaf(3), Leaf(2)), Pow(Leaf(2), Leaf(4))).apply() == 1853020188851841