Skip to content

Commit

Permalink
Replace == and === in tests with isequal_interval
Browse files Browse the repository at this point in the history
  • Loading branch information
dpsanders committed Jul 14, 2024
1 parent 7a392cc commit fdbaa20
Show file tree
Hide file tree
Showing 11 changed files with 1,795 additions and 1,795 deletions.
76 changes: 38 additions & 38 deletions test/Non1788tests/exponential.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,61 +14,61 @@ import Base.isapprox
isapprox(x::Interval,y::Interval) = isapprox(inf(x),inf(y),atol=1E-4) && isapprox(sup(x),sup(y),atol=1E-4)

@testset "exp2_rev_test" begin
@test exp2_rev(∅, entireinterval(Float64))[2] ==
@test exp2_rev(interval(0.0, 1.0), ∅)[2] ==
@test exp2_rev(∅, interval(0.0, 1.0))[2] ==
@test exp2_rev(interval(-2.0, -1.0), entireinterval(Float64))[2] ==
@test exp2_rev(interval(1.0, 1.0), entireinterval(Float64))[2] == Interval(0.0, 0.0)
@test exp2_rev(entireinterval(Float64), entireinterval(Float64))[2] == interval(-∞, ∞)
@test exp2_rev(interval(-Inf, 0.0), entireinterval(Float64))[2] ==
@test isequal_interval(exp2_rev(∅, entireinterval(Float64))[2], ∅)
@test isequal_interval(exp2_rev(interval(0.0, 1.0), ∅)[2], ∅)
@test isequal_interval(exp2_rev(∅, interval(0.0, 1.0))[2], ∅)
@test isequal_interval(exp2_rev(interval(-2.0, -1.0), entireinterval(Float64))[2], ∅)
@test isequal_interval(exp2_rev(interval(1.0, 1.0), entireinterval(Float64))[2], Interval(0.0, 0.0))
@test isequal_interval(exp2_rev(entireinterval(Float64), entireinterval(Float64))[2], interval(-∞, ∞))
@test isequal_interval(exp2_rev(interval(-Inf, 0.0), entireinterval(Float64))[2], ∅)
end

@testset "exp10_rev_test" begin
@test exp10_rev(∅, entireinterval(Float64))[2] ==
@test exp10_rev(interval(0.0, 1.0), ∅)[2] ==
@test exp10_rev(∅, interval(0.0, 1.0))[2] ==
@test exp10_rev(interval(-2.0, -1.0), entireinterval(Float64))[2] ==
@test exp10_rev(interval(1.0, 1.0), entireinterval(Float64))[2] == Interval(0.0, 0.0)
@test exp10_rev(entireinterval(Float64), entireinterval(Float64))[2] == interval(-∞, ∞)
@test exp10_rev(interval(-Inf, 0.0), entireinterval(Float64))[2] ==
@test isequal_interval(exp10_rev(∅, entireinterval(Float64))[2], ∅)
@test isequal_interval(exp10_rev(interval(0.0, 1.0), ∅)[2], ∅)
@test isequal_interval(exp10_rev(∅, interval(0.0, 1.0))[2], ∅)
@test isequal_interval(exp10_rev(interval(-2.0, -1.0), entireinterval(Float64))[2], ∅)
@test isequal_interval(exp10_rev(interval(1.0, 1.0), entireinterval(Float64))[2], Interval(0.0, 0.0))
@test isequal_interval(exp10_rev(entireinterval(Float64), entireinterval(Float64))[2], interval(-∞, ∞))
@test isequal_interval(exp10_rev(interval(-Inf, 0.0), entireinterval(Float64))[2], ∅)
end

@testset "expm1_rev_test" begin
@test expm1_rev(∅, entireinterval(Float64))[2] ==
@test expm1_rev(interval(0.0, 1.0), ∅)[2] ==
@test expm1_rev(∅, interval(0.0, 1.0))[2] ==
@test expm1_rev(interval(-2.0, -1.0), entireinterval(Float64))[2] ==
@test isequal_interval(expm1_rev(∅, entireinterval(Float64))[2], ∅)
@test isequal_interval(expm1_rev(interval(0.0, 1.0), ∅)[2], ∅)
@test isequal_interval(expm1_rev(∅, interval(0.0, 1.0))[2], ∅)
@test isequal_interval(expm1_rev(interval(-2.0, -1.0), entireinterval(Float64))[2], ∅)
@test isapprox(expm1_rev(interval(1.0, 1.0), entireinterval(Float64))[2],Interval(0.693147, 0.693148))
@test expm1_rev(entireinterval(Float64), entireinterval(Float64))[2] == interval(-∞, ∞)
@test expm1_rev(interval(-Inf, -1.0), entireinterval(Float64))[2] ==
@test isequal_interval(expm1_rev(entireinterval(Float64), entireinterval(Float64))[2], interval(-∞, ∞))
@test isequal_interval(expm1_rev(interval(-Inf, -1.0), entireinterval(Float64))[2], ∅)
end

@testset "log2_rev_test" begin
@test log2_rev(∅, entireinterval(Float64))[2] ==
@test log2_rev(interval(0.0, 1.0), ∅)[2] ==
@test log2_rev(∅, interval(0.0, 1.0))[2] ==
@test log2_rev(interval(-2.0, -1.0), entireinterval(Float64))[2] == Interval(0.25, 0.5)
@test log2_rev(interval(1.0, 1.0), entireinterval(Float64))[2] == Interval(2.0, 2.0)
@test log2_rev(entireinterval(Float64), entireinterval(Float64))[2] == interval(0.0, Inf)
@test log2_rev(interval(-Inf, 0.0), entireinterval(Float64))[2] == Interval(0.0, 1.0)
@test isequal_interval(log2_rev(∅, entireinterval(Float64))[2], ∅)
@test isequal_interval(log2_rev(interval(0.0, 1.0), ∅)[2], ∅)
@test isequal_interval(log2_rev(∅, interval(0.0, 1.0))[2], ∅)
@test isequal_interval(log2_rev(interval(-2.0, -1.0), entireinterval(Float64))[2], Interval(0.25, 0.5))
@test isequal_interval(log2_rev(interval(1.0, 1.0), entireinterval(Float64))[2], Interval(2.0, 2.0))
@test isequal_interval(log2_rev(entireinterval(Float64), entireinterval(Float64))[2], interval(0.0, Inf))
@test isequal_interval(log2_rev(interval(-Inf, 0.0), entireinterval(Float64))[2], Interval(0.0, 1.0))
end

@testset "log10_rev_test" begin
@test log10_rev(∅, entireinterval(Float64))[2] ==
@test log10_rev(interval(0.0, 1.0), ∅)[2] ==
@test log10_rev(∅, interval(0.0, 1.0))[2] ==
@test isequal_interval(log10_rev(∅, entireinterval(Float64))[2], ∅)
@test isequal_interval(log10_rev(interval(0.0, 1.0), ∅)[2], ∅)
@test isequal_interval(log10_rev(∅, interval(0.0, 1.0))[2], ∅)
@test isapprox(log10_rev(interval(-2.0, -1.0), entireinterval(Float64))[2], Interval(0.00999999, 0.100001))
@test log10_rev(interval(1.0, 1.0), entireinterval(Float64))[2] == Interval(10.0, 10.0)
@test log10_rev(entireinterval(Float64), entireinterval(Float64))[2] == interval(0.0, Inf)
@test log10_rev(interval(-Inf, 0.0), entireinterval(Float64))[2] == Interval(0.0, 1.0)
@test isequal_interval(log10_rev(interval(1.0, 1.0), entireinterval(Float64))[2], Interval(10.0, 10.0))
@test isequal_interval(log10_rev(entireinterval(Float64), entireinterval(Float64))[2], interval(0.0, Inf))
@test isequal_interval(log10_rev(interval(-Inf, 0.0), entireinterval(Float64))[2], Interval(0.0, 1.0))
end

@testset "log1p_rev_test" begin
@test log1p_rev(∅, entireinterval(Float64))[2] ==
@test log1p_rev(interval(0.0, 1.0), ∅)[2] ==
@test log1p_rev(∅, interval(0.0, 1.0))[2] ==
@test isequal_interval(log1p_rev(∅, entireinterval(Float64))[2], ∅)
@test isequal_interval(log1p_rev(interval(0.0, 1.0), ∅)[2], ∅)
@test isequal_interval(log1p_rev(∅, interval(0.0, 1.0))[2], ∅)
@test isapprox(log1p_rev(interval(-2.0, -1.0), entireinterval(Float64))[2], Interval(-0.864665, -0.63212))
@test isapprox(log1p_rev(interval(1.0, 1.0), entireinterval(Float64))[2], Interval(1.71828, 1.71829))
@test log1p_rev(entireinterval(Float64), entireinterval(Float64))[2] == interval(-1.0, Inf)
@test log1p_rev(interval(-Inf, 0.0), entireinterval(Float64))[2] == Interval(-1.0, 0.0)
@test isequal_interval(log1p_rev(entireinterval(Float64), entireinterval(Float64))[2], interval(-1.0, Inf))
@test isequal_interval(log1p_rev(interval(-Inf, 0.0), entireinterval(Float64))[2], Interval(-1.0, 0.0))
end
24 changes: 12 additions & 12 deletions test/Non1788tests/extrema.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,21 @@ import Base.isapprox
isapprox(x::Interval,y::Interval) = isapprox(inf(x),inf(y),atol=1E-4) && isapprox(sup(x),sup(y),atol=1E-4)

@testset "max_rev_test" begin
@test max_rev(∅, entireinterval(Float64),entireinterval(Float64))[2] == interval(-∞, ∞)
@test max_rev(interval(0.0, 1.0), ∅,Interval(-2.0, -1.0))[2] ==
@test max_rev(∅, interval(0.0, 1.0),Interval(-2.0, -1.0))[2] ==
@test max_rev(interval(-2.0, -1.0), entireinterval(Float64),Interval(-3.0, -2.0))[2] == Interval(-∞, -1.0)
@test isequal_interval(max_rev(∅, entireinterval(Float64),entireinterval(Float64))[2], interval(-∞, ∞))
@test isequal_interval(max_rev(interval(0.0, 1.0), ∅,Interval(-2.0, -1.0))[2], ∅)
@test isequal_interval(max_rev(∅, interval(0.0, 1.0),Interval(-2.0, -1.0))[2], ∅)
@test isequal_interval(max_rev(interval(-2.0, -1.0), entireinterval(Float64),Interval(-3.0, -2.0))[2], Interval(-∞, -1.0))
@test isapprox(max_rev(interval(1.0, 1.0), entireinterval(Float64),Interval(-2.0, -1.0))[2], Interval(-∞, 1))
@test max_rev(entireinterval(Float64), interval(-2.0, -1.0), Interval(-3.0, -2.0))[2] == Interval(-2.0, -1.0)
@test max_rev(interval(-Inf, 0.0), entireinterval(Float64),Interval(-3.0, -2.0))[2] == Interval(-∞, 0.0)
@test isequal_interval(max_rev(entireinterval(Float64), interval(-2.0, -1.0), Interval(-3.0, -2.0))[2], Interval(-2.0, -1.0))
@test isequal_interval(max_rev(interval(-Inf, 0.0), entireinterval(Float64),Interval(-3.0, -2.0))[2], Interval(-∞, 0.0))
end

@testset "min_rev_test" begin
@test min_rev(∅, entireinterval(Float64),entireinterval(Float64))[2] == interval(-∞, ∞)
@test min_rev(interval(0.0, 1.0), ∅,Interval(-2.0, -1.0))[2] == # should return empty?
@test min_rev(∅, interval(0.0, 1.0),Interval(-2.0, -1.0))[2] ==
@test min_rev(interval(-2.0, -1.0), entireinterval(Float64),Interval(-3.0, -2.0))[2] == Interval(-∞, -2.0)
@test isequal_interval(min_rev(∅, entireinterval(Float64),entireinterval(Float64))[2], interval(-∞, ∞))
@test isequal_interval(min_rev(interval(0.0, 1.0), ∅,Interval(-2.0, -1.0))[2], # should return empty?)
@test isequal_interval(min_rev(∅, interval(0.0, 1.0),Interval(-2.0, -1.0))[2], ∅)
@test isequal_interval(min_rev(interval(-2.0, -1.0), entireinterval(Float64),Interval(-3.0, -2.0))[2], Interval(-∞, -2.0))
@test isapprox(min_rev(interval(1.0, 1.0), entireinterval(Float64),Interval(-2.0, -1.0))[2], Interval(-∞, -1.0))
@test min_rev(entireinterval(Float64), interval(-2.0, -1.0), Interval(-3.0, -2.0))[2] == Interval(-3.0, -2.0)
@test min_rev(interval(-Inf, 0.0), entireinterval(Float64),Interval(-3.0, -2.0))[2] == Interval(-∞, -2.0)
@test isequal_interval(min_rev(entireinterval(Float64), interval(-2.0, -1.0), Interval(-3.0, -2.0))[2], Interval(-3.0, -2.0))
@test isequal_interval(min_rev(interval(-Inf, 0.0), entireinterval(Float64),Interval(-3.0, -2.0))[2], Interval(-∞, -2.0))
end
4 changes: 2 additions & 2 deletions test/Non1788tests/hyperbolic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ isapprox(x::Interval,y::Interval) = isapprox(inf(x),inf(y),atol=1E-4) && isappro
end

@testset "tanh_rev_test" begin
@test tanh_rev(∅, -..∞)[2] ==
@test tanh_rev(interval(-10.0, -1.0), -..∞)[2] ==
@test isequal_interval(tanh_rev(∅, -..∞)[2], ∅)
@test isequal_interval(tanh_rev(interval(-10.0, -1.0), -..∞)[2], ∅)
@test isapprox(tanh_rev(interval(0.0, Inf), -..∞)[2], Interval(0.0, ∞))
@test isapprox(tanh_rev(interval(0.0, 1.0), -..∞)[2], Interval(0.0, ∞))
@test isapprox(tanh_rev(interval(-0.5, 1.0), -..∞)[2], Interval(-0.549307, ∞))
Expand Down
14 changes: 7 additions & 7 deletions test/Non1788tests/inv_hyperbolic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,28 @@ import Base.isapprox
isapprox(x::Interval,y::Interval) = isapprox(inf(x),inf(y),atol=1E-4) && isapprox(sup(x),sup(y),atol=1E-4)

@testset "asinh_rev_test" begin
@test asinh_rev(∅, -..∞)[2] ==
@test isequal_interval(asinh_rev(∅, -..∞)[2], ∅)
@test isapprox(asinh_rev(interval(0.0, Inf), -..∞)[2], Interval(0.0, ∞))
@test isapprox(asinh_rev(interval(0.0, 1.0), -..∞)[2], Interval(0, 1.17521))
@test isapprox(asinh_rev(interval(-0.5, 1.0), -..∞)[2], Interval(-0.521096, 1.17521))
@test isapprox(asinh_rev(interval(-1000.0, 1.0), -..∞)[2], Interval(-∞, 1.17521))
end

@testset "acosh_rev_test" begin
@test acosh_rev(∅, -..∞)[2] ==
@test acosh_rev(interval(0.0, Inf), -..∞)[2] == Interval(1.0, ∞)
@test isequal_interval(acosh_rev(∅, -..∞)[2], ∅)
@test isequal_interval(acosh_rev(interval(0.0, Inf), -..∞)[2], Interval(1.0, ∞))
@test isapprox(acosh_rev(interval(0.0, 1.0), -..∞)[2], Interval(1.0, 1.54309))
@test isapprox(acosh_rev(interval(-0.5, 1.0), -..∞)[2], Interval(1.0, 1.54309))
@test acosh_rev(interval(-1000.0, 1.0), -..∞)[2] == Interval(1.0, ∞)
@test isequal_interval(acosh_rev(interval(-1000.0, 1.0), -..∞)[2], Interval(1.0, ∞))
end

@testset "atanh_rev_test" begin
@test atanh_rev(∅, -..∞)[2] ==
@test isequal_interval(atanh_rev(∅, -..∞)[2], ∅)
@test isapprox(atanh_rev(interval(-10.0, -1.0), -..∞)[2], Interval(-1, -0.761594))
@test atanh_rev(interval(0.0, Inf), -..∞)[2] == Interval(0, 1)
@test isequal_interval(atanh_rev(interval(0.0, Inf), -..∞)[2], Interval(0, 1))
@test isapprox(atanh_rev(interval(0.0, 1.0), -..∞)[2], Interval(0, 0.761595))
@test isapprox(atanh_rev(interval(-0.5, 1.0), -..∞)[2], Interval(-0.462118, 0.761595))
@test isapprox(atanh_rev(interval(-1000.0, 1.0), -..∞)[2], Interval(-1, 0.761595))
@test atanh_rev(interval(0.0, 25.0), -..∞)[2] == Interval(0, 1)
@test isequal_interval(atanh_rev(interval(0.0, 25.0), -..∞)[2], Interval(0, 1))
@test isapprox(atanh_rev(interval(-1.0, 25.0), -..∞)[2], Interval(-0.761595, 1))
end
14 changes: 7 additions & 7 deletions test/Non1788tests/inv_rev.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ import Base.isapprox
isapprox(x::Interval,y::Interval) = isapprox(inf(x),inf(y),atol=1E-4) && isapprox(sup(x),sup(y),atol=1E-4)

@testset "inv_rev_test" begin
@test inv_rev(∅, entireinterval(Float64))[2] ==
@test inv_rev(interval(0.0, 1.0), ∅)[2] ==
@test inv_rev(∅, interval(0.0, 1.0))[2] ==
@test inv_rev(interval(-2.0, -1.0), entireinterval(Float64))[2] == Interval(-1.0, -0.5)
@test inv_rev(interval(1.0, 1.0), entireinterval(Float64))[2] == Interval(1.0, 1.0)
@test inv_rev(entireinterval(Float64), entireinterval(Float64))[2] == interval(-∞, ∞)
@test inv_rev(interval(-Inf, 0.0), entireinterval(Float64))[2] == Interval(-∞, 0.0)
@test isequal_interval(inv_rev(∅, entireinterval(Float64))[2], ∅)
@test isequal_interval(inv_rev(interval(0.0, 1.0), ∅)[2], ∅)
@test isequal_interval(inv_rev(∅, interval(0.0, 1.0))[2], ∅)
@test isequal_interval(inv_rev(interval(-2.0, -1.0), entireinterval(Float64))[2], Interval(-1.0, -0.5))
@test isequal_interval(inv_rev(interval(1.0, 1.0), entireinterval(Float64))[2], Interval(1.0, 1.0))
@test isequal_interval(inv_rev(entireinterval(Float64), entireinterval(Float64))[2], interval(-∞, ∞))
@test isequal_interval(inv_rev(interval(-Inf, 0.0), entireinterval(Float64))[2], Interval(-∞, 0.0))
end
22 changes: 11 additions & 11 deletions test/Non1788tests/inv_trig.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,20 @@ import Base.isapprox
isapprox(x::Interval,y::Interval) = isapprox(inf(x),inf(y),atol=1E-4) && isapprox(sup(x),sup(y),atol=1E-4)

@testset "acos_rev_test" begin
@test acos_rev(∅, entireinterval(Float64))[2] ==
@test acos_rev(interval(0.0, 1.0), ∅)[2] ==
@test acos_rev(∅, interval(0.0, 1.0))[2] ==
@test acos_rev(interval(-2.0, -1.0), entireinterval(Float64))[2] ==
@test isequal_interval(acos_rev(∅, entireinterval(Float64))[2], ∅)
@test isequal_interval(acos_rev(interval(0.0, 1.0), ∅)[2], ∅)
@test isequal_interval(acos_rev(∅, interval(0.0, 1.0))[2], ∅)
@test isequal_interval(acos_rev(interval(-2.0, -1.0), entireinterval(Float64))[2], ∅)
@test isapprox(acos_rev(interval(1.0, 1.0), entireinterval(Float64))[2], Interval(0.540302, 0.540303))
@test acos_rev(entireinterval(Float64), entireinterval(Float64))[2] == interval(-1.0, 1.0)
@test acos_rev(interval(-Inf, 0.0), entireinterval(Float64))[2] == Interval(1.0, 1.0)
@test isequal_interval(acos_rev(entireinterval(Float64), entireinterval(Float64))[2], interval(-1.0, 1.0))
@test isequal_interval(acos_rev(interval(-Inf, 0.0), entireinterval(Float64))[2], Interval(1.0, 1.0))
end

@testset "atan_rev_test" begin
@test atan_rev(∅, entireinterval(Float64))[2] ==
@test atan_rev(interval(0.0, 1.0), ∅)[2] ==
@test atan_rev(∅, interval(0.0, 1.0))[2] ==
@test isequal_interval(atan_rev(∅, entireinterval(Float64))[2], ∅)
@test isequal_interval(atan_rev(interval(0.0, 1.0), ∅)[2], ∅)
@test isequal_interval(atan_rev(∅, interval(0.0, 1.0))[2], ∅)
@test isapprox(atan_rev(interval(1.0, 1.0), entireinterval(Float64))[2], Interval(1.5574, 1.55741))
@test atan_rev(entireinterval(Float64), entireinterval(Float64))[2] == interval(-∞, ∞)
@test atan_rev(interval(-Inf, 0.0), entireinterval(Float64))[2] == Interval(-∞, ∞)
@test isequal_interval(atan_rev(entireinterval(Float64), entireinterval(Float64))[2], interval(-∞, ∞))
@test isequal_interval(atan_rev(interval(-Inf, 0.0), entireinterval(Float64))[2], Interval(-∞, ∞))
end
Loading

0 comments on commit fdbaa20

Please sign in to comment.