Exemplo n.º 1
0
def x():
    return Variable("x")
Exemplo n.º 2
0
def test__can_fold_numbers_in_product_regardless_of_position(x):
    assert 2 * x * 3 == Product(Number(6), Variable("x"))
Exemplo 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))
Exemplo n.º 4
0
def y():
    return Variable("y")
Exemplo n.º 5
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"))
    )
Exemplo n.º 6
0
def test__can_do_implicit_cast_in_inequality_comparison():
    assert "x" != Variable("y")
    assert Variable("y") != "x"
Exemplo n.º 7
0
def test__can_compare_for_inequality():
    assert Variable("x") != Variable("y")
Exemplo n.º 8
0
def test__can_multiply_numbers_and_variables(x):
    assert Number(2) * x == Product(Number(2), Variable("x"))
    assert x * Number(2) == Product(Variable("x"), Number(2))
Exemplo n.º 9
0
def test__can_multiply_two_distinct_variables():
    assert Variable("x") * Variable("y") == Product(Variable("x"),
                                                    Variable("y"))
Exemplo n.º 10
0
def test__can_multiply_two_variables_with_implicit_cast():
    assert "x" * Variable("x") == Product(Variable("x"), Variable("x"))
    assert Variable("x") * "x" == Product(Variable("x"), Variable("x"))
Exemplo n.º 11
0
def test__can_compare_for_equality():
    assert Variable("x") == Variable("x")
Exemplo n.º 12
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"))
Exemplo n.º 13
0
def test__can_sum_two_distinct_variables():
    assert Variable("x") + Variable("y") == Sum(Variable("x"), Variable("y"))
Exemplo n.º 14
0
def test__multiplying_by_one_is_no_op(x):
    assert 1 * x == Variable("x")
    assert x * 1 == Variable("x")
Exemplo n.º 15
0
def test_can_fold_numbers_in_sum_regardless_of_position(x):
    assert 2 + x + 3 == Sum(Number(5), Variable("x"))
Exemplo n.º 16
0
def test__can_multiply_numbers_and_products(x):
    assert 2 * (x * 1) == Product(Variable("x"), Number(2))
    assert (x * 1) * 2 == Product(Variable("x"), Number(2))
Exemplo n.º 17
0
def test__adding_zero_is_no_op(x):
    assert 0 + x == Variable("x")
    assert x + 0 == Variable("x")
Exemplo n.º 18
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)))
Exemplo n.º 19
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))
Exemplo n.º 20
0
def test__can_do_implicit_numeric_cast_in_product_expressions(x):
    assert 2 * x == Product(Number(2), Variable("x"))
    assert x * 2 == Product(Variable("x"), Number(2))
Exemplo n.º 21
0
def test__can_do_implicit_cast_in_equality_comparison():
    assert "x" == Variable("x")
    assert Variable("x") == "x"