diff --git a/src/symbolic.jl b/src/symbolic.jl index caca5a6ca..e3748182f 100644 --- a/src/symbolic.jl +++ b/src/symbolic.jl @@ -1,5 +1,7 @@ export @vars, term, @fun +Base.:(==)(a::Symbolic, b::Symbolic) = a === b || isequal(a,b) + #### Variables """ diff --git a/test/rewrite.jl b/test/rewrite.jl index 5a6e7727c..80303f143 100644 --- a/test/rewrite.jl +++ b/test/rewrite.jl @@ -27,12 +27,12 @@ end @test rewriter(@rule (~x)^(~x) => ~x)(a^a) === a @test rewriter(@rule (~x)^(~x) => ~x)(b^a) === nothing @test rewriter(@rule (~x)^(~x) => ~x)(a+a) === nothing -@test rewriter(@rule (~x)^(~x) => ~x)(sin(a)^sin(a)) === sin(a) -@test rewriter(@rule (~x*~y + ~x*~z) => ~x * (~y+~z))(a*b + a*c) === a*(b+c) +@test rewriter(@rule (~x)^(~x) => ~x)(sin(a)^sin(a)) == sin(a) +@test rewriter(@rule (~x*~y + ~x*~z) => ~x * (~y+~z))(a*b + a*c) == a*(b+c) @test rewriter(@rule +(~~x) => ~~x)(a + b) == (a,b) -@test rewriter(@rule +(~~x) => ~~x)(a + b + c) == (a+b,c) -@test rewriter(@rule +(~~x) => ~~x)(+(a, b, c)) == (a+b,c) +@test rewriter(@rule +(~~x) => ~~x)(a + b + c) == (a,b,c) +@test rewriter(@rule +(~~x) => ~~x)(+(a, b, c)) == (a,b,c) @test rewriter(@rule +(~~x,~y, ~~x) => (~~x, ~y))(term(+,9,8,9,type=Any)) == ((9,),8) @test rewriter(@rule +(~~x,~y, ~~x) => (~~x, ~y, ~~x))(term(+,9,8,9,9,8,type=Any)) == ((9,8), 9, (9,8)) @test rewriter(@rule +(~~x,~y,~~x) => (~~x, ~y, ~~x))(term(+,6,type=Any)) == ((), 6, ())