def test_mul_a(): assert str(a * a) == "a * a" assert str(a * Zero()) == "0" assert str(Zero() * a) == "0" assert str(a * One()) == "a" assert str(One() * a) == "a"
def test_add_zero_object(): assert str(Zero() + a) == "a" assert str(a + Zero()) == "a" assert str(Zero() + Zero()) == "0" assert str(Zero() + One()) == "1" assert str(One() + Zero()) == "1"
def test_add_a(): assert str(a + a) == "2 * a" assert str(a + Zero()) == "a" assert str(Zero() + a) == "a" assert str(a + One()) == "a + 1" assert str(One() + a) == "1 + a"
def test_mul_zero_object(): assert str(Zero() * a) == "0" assert str(a * Zero()) == "0" assert str(Zero() * Zero()) == "0" assert str(Zero() * Zero()) == "0" assert str(Zero() * One()) == "0" assert str(One() * Zero()) == "0"
def test_mul_one(): assert str(1 * a) == "a" assert str(a * 1) == "a" assert str(1 * Zero()) == "0" assert str(Zero() * 1) == "0" assert str(1 * One()) == "1" assert str(One() * 1) == "1"
def test_mul_zero(): assert str(0 * a) == "0" assert str(a * 0) == "0" assert str(0 * Zero()) == "0" assert str(Zero() * 0) == "0" assert str(0 * One()) == "0" assert str(One() * 0) == "0"
def test_add_b(): assert str(b + a) == "b + a" assert str(a + b) == "a + b" assert str(b + Zero()) == "b" assert str(Zero() + b) == "b" assert str(b + One()) == "b + 1" assert str(One() + b) == "1 + b"
def test_add_zero(): assert str(0 + a) == "a" assert str(a + 0) == "a" assert str(0 + Zero()) == "0" assert str(Zero() + 0) == "0" assert str(0 + One()) == "1" assert str(One() + 0) == "1"
def test_mul_b(): assert str(b * a) == "b * a" assert str(a * b) == "a * b" assert str(b * Zero()) == "0" assert str(Zero() * b) == "0" assert str(b * One()) == "b" assert str(One() * b) == "b"
def test_add_two(): assert str(2 + a) == "2 * 1 + a" assert str(a + 2) == "a + 2 * 1" assert str(2 + Zero()) == "2 * 1" assert str(Zero() + 2) == "2 * 1" assert str(2 + One()) == "3 * 1" assert str(One() + 2) == "3 * 1"
def test_add_one(): assert str(1 + a) == "1 + a" assert str(a + 1) == "a + 1" assert str(1 + Zero()) == "1" assert str(Zero() + 1) == "1" assert str(1 + One()) == "2 * 1" assert str(One() + 1) == "2 * 1"
def test_mul_two(): assert str(2 * a) == "2 * a" assert str(a * 2) == "2 * a" assert str(2 * Zero()) == "0" assert str(Zero() * 2) == "0" assert str(2 * One()) == "2 * 1" assert str(One() * 2) == "2 * 1"
def test_add_one_object(): assert str(One() + a) == "1 + a" assert str(a + One()) == "a + 1" assert str(One() + Zero()) == "1" assert str(Zero() + One()) == "1" assert str(One() + One()) == "2 * 1" assert str(One() + One()) == "2 * 1"
def test_mul_one_object(): assert str(One() * a) == "a" assert str(a * One()) == "a" assert str(One() * Zero()) == "0" assert str(Zero() * One()) == "0" assert str(One() * One()) == "1" assert str(One() * One()) == "1"
def test_equality_one_zero(): assert One() == One() assert One() != Zero() assert Zero() == Zero()
def test_equality_scaled(): assert Scaled(One(), 1) == Scaled(One(), 1) assert Scaled(One(), 2) != Scaled(One(), 1) assert Scaled(Zero(), 1) != Scaled(One(), 1)
def test_equality_product(): assert Product(One(), Zero()) == Product(One(), Zero()) assert Product(One(), Zero()) == Product(Zero(), One()) assert Product(One(), Zero()) != Product(One(), One())
def test_equality_sum(): assert Sum(One(), Zero()) == Sum(One(), Zero()) assert Sum(One(), Zero()) == Sum(Zero(), One()) assert Sum(One(), Zero()) != Sum(One(), One())
def test_get_algebra(): for x in [Element(), One(), Zero()]: assert get_algebra(x) == Element with pytest.raises(RuntimeError): get_algebra(1)