Skip to content

Commit bdf5351

Browse files
committed
Add tests
1 parent 6875015 commit bdf5351

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

src/operators.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ for (op, fun) in [(:+, :plusconstant), (:-, :minusconstant), (:*, :multconstant)
2323
@eval $op(p::APL, α) = $fun(p, α)
2424
@eval $op(α, p::APL) = $fun(α, p)
2525
end
26-
isapprox(p::APL, α; kwargs...) = isapproxconstant(promote(p, α)...; kwargs...)
27-
isapprox(α, p::APL; kwargs...) = isapproxconstant(promote(p, α)...; kwargs...)
26+
isapprox(p::APL, α; kwargs...) = isapprox(promote(p, α)...; kwargs...)
27+
isapprox(α, p::APL; kwargs...) = isapprox(promote(p, α)...; kwargs...)
2828

2929
(-)(m::AbstractMonomialLike) = (-1) * m
3030
(-)(t::AbstractTermLike) = (-coefficient(t)) * monomial(t)

test/alg.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
Mod.@polyvar x y
33
@test 2 .- ((1 .+ (-x)) .* 4) ./ 2 == x.^2 .* (1 ./ x) .* 2
44
@test dot(0, x^2 - 2*x^2) == dot((x^2 - x)', x^2 - x^2)
5+
@test dot(x + 1, 2) == 2x + 2
56
@test 2 .* x .+ 2 == (x + 3) .+ (x .- 1)
67
@test ((x + y) .- y) ./ y == x / y
78
@test (-2)*x == -(2*x)

test/comp.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ MultivariatePolynomials.terms(p::CustomPoly) = terms(p.p)
5151
@test polynomial(CustomTerms(x + 1 - x)) isa AbstractPolynomial
5252
@test MultivariatePolynomials.eqconstant(polynomial(CustomTerms(x + 1 - x)), 1)
5353
@test MultivariatePolynomials.eqconstant(CustomTerms(x + 1 - x), 1)
54-
@test CustomPoly(x + 1 - x) == 1
54+
@test 2 * CustomPoly(x + 1 - x) == 2
5555
@test 2 != CustomTerms(x + 1 - x)
56-
@test x^2 == CustomTerms(x - x + x^2)
56+
@test 3x^2 == CustomTerms(x - x + x^2) * 3
5757
@test CustomPoly(-x + x^2) != x^2
5858
@test 2*x*y + 3*y^2 == 3*y^2 + 2*y*x
5959
@test 3*x*y + 2*y^2 != 3*y^2 + 2*y*x
@@ -67,6 +67,8 @@ MultivariatePolynomials.terms(p::CustomPoly) = terms(p.p)
6767
@test isapprox(3*y^2 + x^2, x^2 + 1e-3*x*y + 3*y^2, rtol=1e-2, ztol=1e-2)
6868
@test !isapprox(3*y^2 + x^2, x^2 + 1e-1*x*y + 3*y^2, rtol=1e-2, ztol=1e-2)
6969
@test !isapprox(3.0*y^2 + x + x^2, x + 3*y^2, rtol=1e-2, ztol=1e-2)
70+
@test isapprox(x+1-x, 1+1e-8, rtol=1e-7)
71+
@test !isapprox(1+1e-8, x+1-x, rtol=1e-9)
7072
end
7173
@testset "RationalPoly equality" begin
7274
Mod.@polyvar x y

0 commit comments

Comments
 (0)