diff --git a/test/Project.toml b/test/Project.toml index 25e3ead7..165b883d 100644 --- a/test/Project.toml +++ b/test/Project.toml @@ -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" +Supposition = "5a0628fe-1738-4658-9b6d-0b7605a9755b" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" diff --git a/test/interval_tests/construction.jl b/test/interval_tests/construction.jl index df57db64..d40d5d5f 100644 --- a/test/interval_tests/construction.jl +++ b/test/interval_tests/construction.jl @@ -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 @@ -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))) diff --git a/test/interval_tests/supposition/numeric.jl b/test/interval_tests/supposition/numeric.jl new file mode 100644 index 00000000..42a60165 --- /dev/null +++ b/test/interval_tests/supposition/numeric.jl @@ -0,0 +1,30 @@ +using Test +using IntervalArithmetic +using Supposition, Supposition.Data + +# 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 diff --git a/test/runtests.jl b/test/runtests.jl index 62d506da..d5a0fd1d 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -9,7 +9,14 @@ 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 +for f ∈ filter(isfile, readdir("interval_tests/supposition"; join = true)) @testset "$f" begin include(f) end