Skip to content

Commit 89c8639

Browse files
committed
tests
1 parent 6cebde9 commit 89c8639

File tree

3 files changed

+12
-14
lines changed

3 files changed

+12
-14
lines changed

src/methods.jl

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ end
8888
@number_methods(Pow, term(f, a), term(f, a, b), skipbasics)
8989
@number_methods(Div, term(f, a), term(f, a, b), skipbasics)
9090

91-
for f in diadic
91+
for f in vcat(diadic, [+, -, *, \, /, ^])
9292
@eval promote_symtype(::$(typeof(f)),
9393
T::Type{<:Number},
9494
S::Type{<:Number}) = promote_type(T, S)
@@ -112,18 +112,6 @@ for f in diadic
112112
end
113113
end
114114

115-
for f in [+, -, *, \, /, ^]
116-
@eval promote_symtype(::$(typeof(f)),
117-
T::Type{<:Number},
118-
S::Type{<:Number}) = promote_type(T, S)
119-
@eval function promote_symtype(::$(typeof(f)),
120-
T::Type{<:SafeReal},
121-
S::Type{<:Number})
122-
X = promote_type(Real, S)
123-
X == Real ? SafeReal : X
124-
end
125-
end
126-
127115
promote_symtype(::typeof(rem2pi), T::Type{<:Number}, mode) = T
128116
Base.rem2pi(x::Symbolic{<:Number}, mode::Base.RoundingMode) = term(rem2pi, x, mode)
129117

src/types.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -698,6 +698,7 @@ function makeadd(sign, coeff, xs...)
698698
coeff, d
699699
end
700700

701+
add_t(a::Number,b::Number) = promote_symtype(+, symtype(a), symtype(b))
701702
add_t(a,b) = promote_symtype(+, symtype(a), symtype(b))
702703
sub_t(a,b) = promote_symtype(-, symtype(a), symtype(b))
703704
sub_t(a) = promote_symtype(-, symtype(a))

test/basics.jl

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ end
238238
end
239239

240240
@testset "div" begin
241-
@syms x y
241+
@syms x::SafeReal y::Real
242242
@test (2x/2y).num isa Sym
243243
@test (2x/3y).num.coeff == 2
244244
@test (2x/3y).den.coeff == 3
@@ -247,4 +247,13 @@ end
247247
@test (2.5x/3x).num.coeff == 2.5
248248
@test (2.5x/3x).den.coeff == 3
249249
@test (x/3x).den.coeff == 3
250+
251+
@syms x y
252+
@test (2x/2y).num isa Sym
253+
@test (2x/3y).num.coeff == 2
254+
@test (2x/3y).den.coeff == 3
255+
@test (2x/-3x) == -2//3
256+
@test (2.5x/3x).num == 2.5
257+
@test (2.5x/3x).den == 3
258+
@test (x/3x) == 1//3
250259
end

0 commit comments

Comments
 (0)