Skip to content
1 change: 1 addition & 0 deletions test/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
IntervalArithmetic = "d1acc4aa-44c8-5952-acd4-ba5d80a2a253"
IntervalSets = "8197267c-284f-5f27-9208-e0e47529a953"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
6 changes: 6 additions & 0 deletions test/interval_tests/construction.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
@test sup(IntervalArithmetic._unsafe_bareinterval(Float64, Inf, Inf)) == Inf
@test isempty_interval(bareinterval(Inf, Inf))
@test isnai(interval(Inf, Inf))
@test isnai(interval(1//0, 1//0))
@test isnai(interval(-1//0, -1//0))
@test isnai(interval(1//0, -1//0))
end

@testset "Basics" begin
Expand Down Expand Up @@ -70,6 +73,9 @@ end
@test isnai(interval(1, NaN))
@test isnai(interval(NaN))

@test isnai(interval(1//0))
@test isnai(interval(-1//0))

# check no issue with `Integer` modular arithmetic
@test bounds(interval(typemin(Int64), typemax(Int64))) == (float(typemin(Int64)), float(typemax(Int64)))

Expand Down
29 changes: 29 additions & 0 deletions test/interval_tests/supposition/numeric.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using Test
using IntervalArithmetic

# Define properties to be checked
function degenerate_interval(a)
x = interval(a)
y = interval(a, a)
x === y
end

@testset "Float tests" begin
# Define number generators
floatgen = Data.Floats()

# Check properties
@check max_examples=1000 degenerate_interval(floatgen)
end

@testset "Rational tests" begin
# Define number generators
intgen = Data.Integers(typemin(Int)+1,typemax(Int)) # Don't allow typemin(Int) to avoid overflow
rationalgen = @composed function generate_rational(num=intgen, den=intgen)
assume!(!(iszero(num) && iszero(den)))
return num // den
end

# Check properties
@check max_examples = 1000 degenerate_interval(rationalgen)
end
15 changes: 14 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,25 @@ import IntervalSets as IS
include("generate_ITF1788.jl")

# interval tests
for f ∈ readdir("interval_tests"; join = true)
for f ∈ filter(isfile, readdir("interval_tests"; join = true))
@testset "$f" begin
include(f)
end
end

# interval tests using Supposition
# We use Pkg.add to add a specific version of Supposition
using Pkg
Pkg.add(url = "https://github.com/Seelengrab/Supposition.jl.git", rev = "feat/support_x86")
using Supposition, Supposition.Data

for f ∈ filter(isfile, readdir("interval_tests/supposition"; join = true))
@testset "$f" begin
include(f)
end
end
Pkg.rm("Supposition")

# ITF1788 tests
# these tests were generated using:
# for f ∈ readdir("itl")
Expand Down
Loading