Ejemplo n.º 1
0
def test__can_multiply_numbers_and_sums(x):
    assert 2 * (x + 1) == Product(Number(2), Sum(Variable("x"), Number(1)))
    assert (x + 1) * 2 == Product(Number(2), Sum(Variable("x"), Number(1)))
Ejemplo n.º 2
0
def test__can_multiply_products_and_sums(x):
    assert (x + 1) * (2 + x) == Product(
        Sum(Number(1), Variable("x")), Sum(Number(2), Variable("x"))
    )
Ejemplo n.º 3
0
def test__can_do_implicit_numeric_cast_in_sum_expressions(x):
    assert 1 + x == Sum(Number(1), Variable("x"))
    assert x + 1 == Sum(Variable("x"), Number(1))
Ejemplo n.º 4
0
def test__can_sum_numbers_and_variables(x):
    assert Number(1) + x == Sum(Number(1), Variable("x"))
    assert x + Number(1) == Sum(Variable("x"), Number(1))
Ejemplo n.º 5
0
def test_can_fold_numbers_in_sum_regardless_of_position(x):
    assert 2 + x + 3 == Sum(Number(5), Variable("x"))
Ejemplo n.º 6
0
def test__can_sum_two_variables_with_implicit_cast():
    assert Variable("x") + "x" == Sum(Variable("x"), Variable("x"))
    assert "x" + Variable("x") == Sum(Variable("x"), Variable("x"))
Ejemplo n.º 7
0
def test__can_sum_two_distinct_variables():
    assert Variable("x") + Variable("y") == Sum(Variable("x"), Variable("y"))