diff --git a/src/ordering.jl b/src/ordering.jl index 4c633828d..930552678 100644 --- a/src/ordering.jl +++ b/src/ordering.jl @@ -10,7 +10,11 @@ arglength(a) = length(arguments(a)) function <ₑ(a, b) - if !istree(a) && !istree(b) + if a isa Term && (b isa Symbolic && !(b isa Term)) + return false + elseif b isa Term && (a isa Symbolic && !(a isa Term)) + return true + elseif !istree(a) && !istree(b) T = typeof(a) S = typeof(b) return T===S ? (T <: Number ? isless(a, b) : hash(a) < hash(b)) : nameof(T) < nameof(S) diff --git a/test/order.jl b/test/order.jl index a776f1073..af8c3bc72 100644 --- a/test/order.jl +++ b/test/order.jl @@ -5,7 +5,7 @@ SymbolicUtils.show_simplified[] = false @syms a b c -function istotal(x,y) +function istotal(x, y) #either if x <ₑ y return !(y <ₑ x) @@ -13,7 +13,7 @@ function istotal(x,y) return !(x <ₑ y) # already tested else # neither, equal - return true + return isequal(x, y) end end @@ -78,8 +78,7 @@ end @testset "small terms" begin # this failing was a cause of a nasty stackoverflow #82 @syms a - @test Term(^, [a, -1]) <ₑ (a + 2) - @test !((a + 2) <ₑ Term(^, [a, -1])) + istotal(Term(^, [a, -1]), (a + 2)) end @testset "transitivity" begin