Example #1
0
def test_non_frankenAdds():
    # the is_commutative property used to fail because of Basic.__new__
    # This caused is_commutative and str calls to fail
    expr = x+y*2
    rebuilt = construct(deconstruct(expr))
    # Ensure that we can run these commands without causing an error
    str(rebuilt)
    rebuilt.is_commutative
Example #2
0
def test_nested():
    expr = Basic(1, Basic(2), 3)
    cmpd = Compound(Basic, (1, Compound(Basic, (2,)), 3))
    assert deconstruct(expr) == cmpd
    assert construct(cmpd) == expr
Example #3
0
def test_construct():
    expr     = Compound(Basic, (1, 2, 3))
    expected = Basic(1, 2, 3)
    assert construct(expr) == expected
Example #4
0
def test_nested():
    expr = Basic(S(1), Basic(S(2)), S(3))
    cmpd = Compound(Basic, (1, Compound(Basic, (2, )), 3))
    assert deconstruct(expr) == cmpd
    assert construct(cmpd) == expr
Example #5
0
def test_construct():
    expr = Compound(Basic, (1, 2, 3))
    expected = Basic(S(1), S(2), S(3))
    assert construct(expr) == expected