Skip to content

Commit f978827

Browse files
bvrbKolaru
andauthored
First attempt at a Supposition.jl-based test (#736)
* Add Supposition.jl to test dependencies * Add Supposition-based test for construction of degenerate intervals using Rationals * Add test to runtests.jl * Update Supposition test for degenerate interval construction - decrease number of random samples - add test for floats - switch from Int8 to Int - change equality check * Add Rational tests for 1//0 and -1//0 edge cases * Limit supposition test to 64 bit * Realize that supposition is failing at precompile time and change CI instead * Use the feat/support_x86 branch of Supposition * Use workaround to get the Supposition branch fixing x86 * Add Pkg to test deps --------- Co-authored-by: Benoît Richard <[email protected]>
1 parent 4b7e7ef commit f978827

File tree

4 files changed

+50
-1
lines changed

4 files changed

+50
-1
lines changed

test/Project.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
66
IntervalArithmetic = "d1acc4aa-44c8-5952-acd4-ba5d80a2a253"
77
IntervalSets = "8197267c-284f-5f27-9208-e0e47529a953"
88
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
9+
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
910
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

test/interval_tests/construction.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
@test sup(IntervalArithmetic._unsafe_bareinterval(Float64, Inf, Inf)) == Inf
1010
@test isempty_interval(bareinterval(Inf, Inf))
1111
@test isnai(interval(Inf, Inf))
12+
@test isnai(interval(1//0, 1//0))
13+
@test isnai(interval(-1//0, -1//0))
14+
@test isnai(interval(1//0, -1//0))
1215
end
1316

1417
@testset "Basics" begin
@@ -70,6 +73,9 @@ end
7073
@test isnai(interval(1, NaN))
7174
@test isnai(interval(NaN))
7275

76+
@test isnai(interval(1//0))
77+
@test isnai(interval(-1//0))
78+
7379
# check no issue with `Integer` modular arithmetic
7480
@test bounds(interval(typemin(Int64), typemax(Int64))) == (float(typemin(Int64)), float(typemax(Int64)))
7581

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
using Test
2+
using IntervalArithmetic
3+
4+
# Define properties to be checked
5+
function degenerate_interval(a)
6+
x = interval(a)
7+
y = interval(a, a)
8+
x === y
9+
end
10+
11+
@testset "Float tests" begin
12+
# Define number generators
13+
floatgen = Data.Floats()
14+
15+
# Check properties
16+
@check max_examples=1000 degenerate_interval(floatgen)
17+
end
18+
19+
@testset "Rational tests" begin
20+
# Define number generators
21+
intgen = Data.Integers(typemin(Int)+1,typemax(Int)) # Don't allow typemin(Int) to avoid overflow
22+
rationalgen = @composed function generate_rational(num=intgen, den=intgen)
23+
assume!(!(iszero(num) && iszero(den)))
24+
return num // den
25+
end
26+
27+
# Check properties
28+
@check max_examples = 1000 degenerate_interval(rationalgen)
29+
end

test/runtests.jl

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,25 @@ import IntervalSets as IS
99
include("generate_ITF1788.jl")
1010

1111
# interval tests
12-
for f readdir("interval_tests"; join = true)
12+
for f filter(isfile, readdir("interval_tests"; join = true))
1313
@testset "$f" begin
1414
include(f)
1515
end
1616
end
1717

18+
# interval tests using Supposition
19+
# We use Pkg.add to add a specific version of Supposition
20+
using Pkg
21+
Pkg.add(url = "https://github.com/Seelengrab/Supposition.jl.git", rev = "feat/support_x86")
22+
using Supposition, Supposition.Data
23+
24+
for f filter(isfile, readdir("interval_tests/supposition"; join = true))
25+
@testset "$f" begin
26+
include(f)
27+
end
28+
end
29+
Pkg.rm("Supposition")
30+
1831
# ITF1788 tests
1932
# these tests were generated using:
2033
# for f ∈ readdir("itl")

0 commit comments

Comments
 (0)