diff --git a/src/types.jl b/src/types.jl index 86c6fb2..6e7a0a2 100644 --- a/src/types.jl +++ b/src/types.jl @@ -82,6 +82,7 @@ Basic(x::Basic) = x Base.promote_rule(::Type{Basic}, ::Type{S}) where {S<:Number} = Basic Base.promote_rule(::Type{S}, ::Type{Basic}) where {S<:Number} = Basic Base.promote_rule(::Type{S}, ::Type{Basic}) where {S<:AbstractIrrational} = Basic +Base.promote_rule(::Type{Bool}, ::Type{Basic}) = Basic ## Class ID get_type(s::Basic) = ccall((:basic_get_type, libsymengine), UInt, (Ref{Basic},), s) diff --git a/test/runtests.jl b/test/runtests.jl index 2336e45..7a84211 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -49,6 +49,13 @@ c = prod(convert(SymEngine.CVecBasic, [x, x, 2])) @test 2 * x * 3 == 6 * x @test 3 * 2 * x == 6 * x + +# Issue #146 +@test x + true == x + 1 +@test x + false == x +@test x * true == x +@test x * false == 0 + # https://github.com/symengine/SymEngine.jl/issues/259 @testset "Issue #259" begin let (a, b, c) = symbols("a b c") @@ -59,6 +66,7 @@ c = prod(convert(SymEngine.CVecBasic, [x, x, 2])) end end + c = x ^ 5 @test diff(c, x) == 5 * x ^ 4