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
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
def test_construct(): expr = Compound(Basic, (1, 2, 3)) expected = Basic(1, 2, 3) assert construct(expr) == expected
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
def test_construct(): expr = Compound(Basic, (1, 2, 3)) expected = Basic(S(1), S(2), S(3)) assert construct(expr) == expected