Skip to content

Commit 35f98a5

Browse files
committed
Replace Interval with interval in tests
1 parent 5cbf7a8 commit 35f98a5

29 files changed

+6848
-6856
lines changed

test/decoration_tests/decoration_tests.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ let b
1313

1414
a = DecoratedInterval(@interval(-1, 1), com)
1515
b = sqrt(a)
16-
@test interval(b) sqrt(Interval(0, 1))
16+
@test interval(b) sqrt(interval(0, 1))
1717
@test decoration(b) == trv
1818

1919
d = DecoratedInterval(a, dac)
@@ -41,13 +41,13 @@ let b
4141
@test @decorated(-3,-2) ^ -3 DecoratedInterval(-1/8.,-1/27)
4242
@test @decorated(0,3) ^ 2 DecoratedInterval(0, 9)
4343
@test @decorated(0,3) ^ -2 DecoratedInterval(1/9, Inf, trv)
44-
@test @decorated(2,3)^Interval(0.0, 1.0) DecoratedInterval(1.0,3.0)
44+
@test @decorated(2,3)^interval(0.0, 1.0) DecoratedInterval(1.0,3.0)
4545
@test @decorated(2,3)^@decorated(0.0, 1.0) DecoratedInterval(1.0,3.0)
46-
@test @decorated(0, 2)^Interval(0.0, 1.0) DecoratedInterval(0.0,2.0, trv)
46+
@test @decorated(0, 2)^interval(0.0, 1.0) DecoratedInterval(0.0,2.0, trv)
4747
@test @decorated(0, 2)^@decorated(0.0, 1.0) DecoratedInterval(0.0,2.0, trv)
48-
@test @decorated(-3, 2)^Interval(0.0, 1.0) DecoratedInterval(0.0,2.0, trv)
48+
@test @decorated(-3, 2)^interval(0.0, 1.0) DecoratedInterval(0.0,2.0, trv)
4949
@test @decorated(-3, 2)^@decorated(0.0, 1.0) DecoratedInterval(0.0,2.0, trv)
50-
@test @decorated(-3, 2)^Interval(-1.0, 1.0) DecoratedInterval(0.0,Inf, trv)
50+
@test @decorated(-3, 2)^interval(-1.0, 1.0) DecoratedInterval(0.0,Inf, trv)
5151
@test @decorated(-3, 2)^@decorated(-1.0, 1.0) DecoratedInterval(0.0, Inf, trv)
5252

5353
a = @decorated 1 2

test/display_tests/display.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ let x, b
77
@testset "Interval" begin
88
a = 1..2
99
b = -1.1..1.3
10-
c = Interval(pi)
10+
c = interval(pi)
1111
# large_expo = IntervalArithmetic.atomic(Interval{BigFloat}, -Inf)
1212
# Use smaller exponent, cf. JuliaLang/julia#48678
13-
large_expo = Interval(0, big"1e123456789")
13+
large_expo = interval(0, big"1e123456789")
1414

1515
@testset "6 significant digits" begin
1616
setformat(:standard; sigdigits = 6)
@@ -66,7 +66,7 @@ let x, b
6666
end
6767

6868
@testset "Interval{Rational{T}}" begin
69-
a = Interval(1//3, 5//4)
69+
a = interval(1//3, 5//4)
7070
@test_broken typeof(a) == Interval{Rational{Int}}
7171

7272
setformat(:standard)
@@ -96,7 +96,7 @@ let x, b
9696
end
9797

9898
@testset "Complex{Interval}" begin
99-
a = Complex(Interval(0, 2), Interval(1))
99+
a = Complex(interval(0, 2), interval(1))
100100
@test typeof(a) == Complex{Interval{Float64}}
101101

102102
setformat(:standard)
@@ -143,7 +143,7 @@ let x, b
143143
setprecision(BigFloat, 128)
144144

145145
@testset "BigFloat intervals" begin
146-
a = Interval(big(1))
146+
a = interval(big(1))
147147
@test typeof(a) == Interval{BigFloat}
148148

149149
setformat(:standard; decorations = false)

test/interval_tests/bisect.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ using Test
66
@test bisect(X, 0.5) (0..0.5, 0.5..1)
77
@test bisect(X, 0.25) (0..0.25, 0.25..1)
88

9-
@test bisect(X) (Interval(0.0, 0.49609375), Interval(0.49609375, 1.0))
9+
@test bisect(X) (interval(0.0, 0.49609375), interval(0.49609375, 1.0))
1010

1111
X = -..
1212
@test bisect(X, 0.5) (-..0, 0..∞)
@@ -23,8 +23,8 @@ using Test
2323
@test bisect(X, 1, 0.5) ( (0..0.5) × (0..2), (0.5..1) × (0..2) )
2424
@test bisect(X, 1, 0.25) ( (0..0.25) × (0..2), (0.25..1) × (0..2) )
2525

26-
@test bisect(X) (IntervalBox(0..1, Interval(0.0, 0.9921875)),
27-
IntervalBox(0..1, Interval(0.9921875, 2.0)))
26+
@test bisect(X) (IntervalBox(0..1, interval(0.0, 0.9921875)),
27+
IntervalBox(0..1, interval(0.9921875, 2.0)))
2828

2929
X = (-..∞) × (-..∞)
3030
@test bisect(X, 0.5) ( (-..0) × (-..∞), (0..∞) × (-..∞))

test/interval_tests/consistency.jl

Lines changed: 111 additions & 111 deletions
Large diffs are not rendered by default.

test/interval_tests/construction.jl

Lines changed: 57 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -5,47 +5,46 @@ using Test
55

66
@testset "Constructing intervals" begin
77
# Naive constructors, with no conversion involved
8-
@test Interval(1.0) Interval(Interval(1.0)) Interval{Float64}(Interval(1.0))
9-
@test Interval(1) Interval(1.0, 1.0)
10-
@test size(Interval(1)) == () # Match the `size` behaviour of `Number`
11-
@test Interval(big(1)) Interval(1.0, 1.0)
12-
@test_broken Interval(1//10) Interval{Rational{Int}}(1//10, 1//10)
13-
@test_broken Interval(BigInt(1)//10) Interval{Rational{BigInt}}(1//10, 1//10)
14-
@test Interval( (1.0, 2.0) ) Interval(1.0, 2.0)
15-
@test_broken Interval{Rational{Int}}(1) Interval(1//1)
16-
@test Interval{BigFloat}(1) Interval{BigFloat}(big(1.0), big(1.0))
8+
@test Interval{Float64}(1.0, 1.0) interval(1) interval(interval(1.0))
9+
interval(Float64, interval(1.0))
10+
@test size(interval(1)) == () # Match the `size` behaviour of `Number`
11+
@test interval(big(1)) Interval{Float64}(1.0, 1.0)
12+
@test_broken interval(1//10) Interval{Rational{Int}}(1//10, 1//10)
13+
@test_broken interval(BigInt(1)//10) Interval{Rational{BigInt}}(1//10, 1//10)
14+
@test interval( (1.0, 2.0) ) Interval{Float64}(1.0, 2.0)
15+
@test_broken interval(Rational{Int}, 1) interval(1//1)
16+
@test interval(BigFloat, 1) Interval{BigFloat}(big(1.0), big(1.0))
1717

1818
# Irrational
1919
for irr in (π, ℯ)
2020
@test @interval(-irr, irr).hi == (-irr..irr).hi
21-
@test 0..irr hull(interval(0), Interval{Float64}(irr))
21+
@test 0..irr hull(interval(0), interval(Float64, irr))
2222
@test (1.2..irr).hi == @interval(1.2, irr).hi
23-
@test irr..irr Interval{Float64}(irr)
24-
@test Interval(irr) @interval(irr)
25-
@test Interval(irr, irr) Interval(irr)
26-
@test Interval{Float32}(irr, irr) Interval{Float32}(irr)
23+
@test irr..irr interval(Float64, irr)
24+
@test interval(irr) @interval(irr) interval(irr, irr)
25+
@test Interval{Float32}(irr, irr) interval(Float32, irr)
2726
end
2827

29-
@test_broken..big(4) hull(Interval{BigFloat}(π), interval(4))
30-
@test π..big(4) hull(Interval{BigFloat}(π), interval(4))
28+
@test_broken..big(4) hull(interval(BigFloat, π), interval(4))
29+
@test π..big(4) hull(interval(BigFloat, π), interval(4))
3130

32-
@test..pi hull(@interval(ℯ), Interval{Float64}(π))
33-
@test big(ℯ) in Interval(ℯ, π)
34-
@test big(π) in Interval(ℯ, π)
35-
@test big(ℯ) in Interval(0, ℯ)
36-
@test big(π) in Interval(π, 4)
31+
@test..pi hull(@interval(ℯ), interval(Float64, π))
32+
@test big(ℯ) in interval(ℯ, π)
33+
@test big(π) in interval(ℯ, π)
34+
@test big(ℯ) in interval(0, ℯ)
35+
@test big(π) in interval(π, 4)
3736

3837
@test big(ℯ) in Interval{Float32}(ℯ, π)
3938
@test big(π) in Interval{Float32}(ℯ, π)
4039
@test big(ℯ) in Interval{Float32}(0, ℯ)
4140
@test big(π) in Interval{Float32}(π, 4)
4241

43-
@test interval(Interval(pi)) Interval(pi)
44-
@test interval(Interval(NaN, -Inf)) emptyinterval()
42+
@test interval(interval)) interval)
43+
@test interval(Interval{Float64}(NaN, -Inf)) emptyinterval()
4544

4645
# a < Inf and b > -Inf
47-
@test @interval("1e300") Interval(9.999999999999999e299, 1.0e300)
48-
@test @interval("-1e307") Interval(-1.0000000000000001e307, -1.0e307)
46+
@test @interval("1e300") Interval{Float64}(9.999999999999999e299, 1.0e300)
47+
@test @interval("-1e307") Interval{Float64}(-1.0000000000000001e307, -1.0e307)
4948

5049
# Disallowed construction with a > b
5150
@test_logs (:warn,) @test isempty(@interval(2, 1))
@@ -58,15 +57,15 @@ using Test
5857
@test_logs (:warn,) @test isempty(interval(Inf, Inf))
5958

6059
# Conversion to Interval without type
61-
@test convert(Interval, 1) Interval(1.0)
62-
@test convert(Interval, pi) @interval(pi)
63-
@test convert(Interval, ℯ) @interval(ℯ)
64-
@test convert(Interval, BigInt(1)) Interval(BigInt(1))
65-
@test convert(Interval, 1//10) @interval(1//10)
66-
@test convert(Interval, Interval(0.1, 0.2)) === Interval(0.1, 0.2)
60+
@test_throws MethodError convert(Interval, 1)
61+
@test_throws MethodError convert(Interval, π)
62+
@test_throws MethodError convert(Interval, ℯ)
63+
@test_throws MethodError convert(Interval, BigInt(1))
64+
@test_throws MethodError convert(Interval, 1//10)
65+
@test convert(Interval, Interval{Float64}(0.1, 0.2)) === Interval{Float64}(0.1, 0.2)
6766

6867
a = @interval(0.1)
69-
b = @interval(pi)
68+
b = @interval(π)
7069

7170
@test @floatinterval("0.1") a
7271
@test typeof(a) == Interval{Float64}
@@ -89,17 +88,17 @@ using Test
8988
# TODO Actually use the rounding mode here
9089
for rounding in (:wide, :narrow)
9190
a = @interval(0.1, 0.2)
92-
@test a Interval(0.09999999999999999, 0.20000000000000004)
91+
@test a interval(0.09999999999999999, 0.20000000000000004)
9392

9493
b = @interval(0.1)
95-
@test b Interval(0.09999999999999999, 0.10000000000000002)
96-
@test b Interval(0.09999999999999999, 0.20000000000000004)
94+
@test b interval(0.09999999999999999, 0.10000000000000002)
95+
@test b interval(0.09999999999999999, 0.20000000000000004)
9796
@test float(b) a
9897

9998
c = @interval("0.1", "0.2")
10099
@test c a # c is narrower than a
101-
@test Interval(1//2) Interval(0.5)
102-
@test_broken Interval(1//10).lo == rationalize(0.1)
100+
@test interval(1//2) interval(0.5)
101+
@test_broken interval(1//10).lo == rationalize(0.1)
103102
end
104103

105104
@test string(emptyinterval()) == ""
@@ -116,13 +115,13 @@ end
116115
@test typeof(a)== Interval{Float64}
117116
@test typeof(big(a)) == Interval{BigFloat}
118117

119-
@test @floatinterval(123412341234123412341241234) Interval(1.234123412341234e26, 1.2341234123412342e26)
118+
@test @floatinterval(123412341234123412341241234) interval(1.234123412341234e26, 1.2341234123412342e26)
120119
@test @interval(big"3") @floatinterval(3)
121120

122-
@test @floatinterval(big"1e10000") Interval(prevfloat(∞), ∞)
121+
@test @floatinterval(big"1e10000") interval(prevfloat(∞), ∞)
123122

124123
a = big(10)^10000
125-
@test @floatinterval(a) Interval(prevfloat(∞), ∞)
124+
@test @floatinterval(a) interval(prevfloat(∞), ∞)
126125
end
127126

128127
#=
@@ -147,11 +146,11 @@ end
147146
@test_logs (:warn, ) @test isempty(4..π)
148147
@test_logs (:warn, ) @test isempty(NaN..3)
149148
@test_logs (:warn, ) @test isempty(3..NaN)
150-
@test 1..π Interval(1, π)
149+
@test 1..π Interval{Float64}(1, π)
151150
end
152151

153152
@testset "± tests" begin
154-
@test 3 ± 1 Interval(2.0, 4.0)
153+
@test 3 ± 1 Interval{Float64}(2.0, 4.0)
155154
@test 3 ± 0.5 2.5..3.5
156155
@test 3 ± 0.1 2.9..3.1
157156
@test 0.5 ± 1 -0.5..1.5
@@ -169,8 +168,8 @@ end
169168
end
170169

171170
@testset "Promotion between intervals" begin
172-
x = Interval{Float64}(π)
173-
y = Interval{BigFloat}(π)
171+
x = interval(Float64, π)
172+
y = interval(BigFloat, π)
174173
x_, y_ = promote(x, y)
175174

176175
@test promote_type(typeof(x), typeof(y)) == Interval{BigFloat}
@@ -185,9 +184,9 @@ end
185184
@test typeof(@interval Float16 1 2) == Interval{Float16}
186185

187186
# PR 496
188-
@test eltype(Interval(1, 2)) == Interval{Float64}
189-
@test IntervalArithmetic.numtype(Interval(1, 2)) == Float64
190-
@test all([1 2; 3 4] * Interval(-1, 1) .≛ [-1..1 -2..2;-3..3 -4..4])
187+
@test eltype(interval(1, 2)) == Interval{Float64}
188+
@test IntervalArithmetic.numtype(interval(1, 2)) == Float64
189+
@test all([1 2; 3 4] * interval(-1, 1) .≛ [-1..1 -2..2;-3..3 -4..4])
191190

192191
@test eltype(IntervalBox(1..2, 2..3)) == Interval{Float64}
193192
@test IntervalArithmetic.numtype(IntervalBox(1..2, 2..3)) == Float64
@@ -200,19 +199,19 @@ end
200199
a = convert(Interval{Float64}, @biginterval(3, 4))
201200
@test typeof(a) == Interval{Float64}
202201

203-
pi64, pi32 = Interval{Float64}(pi), Interval{Float32}(pi)
202+
pi64, pi32 = interval(Float64, pi), interval(Float32, pi)
204203
x, y = promote(pi64, pi32)
205204
@test x pi64
206205
@test y Interval{Float64}(pi32)
207206
end
208207

209208
@testset "Interval{T} constructor" begin
210-
@test Interval{Float64}(1) 1..1
209+
@test Interval{Float64}(1, 1) 1..1
211210
# no rounding
212-
@test Interval{Float64}(1.1) Interval(1.1, 1.1)
211+
@test bounds(Interval{Float64}(1.1, 1.1)) == (1.1, 1.1)
213212

214-
@test Interval{BigFloat}(1) @biginterval(1, 1)
215-
@test Interval{BigFloat}(big"1.1") Interval(big"1.1", big"1.1")
213+
@test Interval{BigFloat}(1, 1) @biginterval(1, 1)
214+
@test bounds(Interval{BigFloat}(big"1.1", big"1.1")) == (big"1.1", big"1.1")
216215
end
217216

218217
# issue 206:
@@ -221,19 +220,19 @@ end
221220

222221
a = I"[2/3, 1.1]"
223222
b = @interval("[2/3, 1.1]")
224-
c = Interval(0.6666666666666666, 1.1)
223+
c = interval(0.6666666666666666, 1.1)
225224
@test a b
226225
@test b c
227226

228227
a = I"[1]"
229228
b = @interval("[1]")
230-
c = Interval(1.0, 1.0)
229+
c = interval(1.0, 1.0)
231230
@test a b
232231
@test b c
233232

234233
a = I"[-0x1.3p-1, 2/3]"
235234
b = @interval("[-0x1.3p-1, 2/3]")
236-
c = Interval(-0.59375, 0.6666666666666667)
235+
c = interval(-0.59375, 0.6666666666666667)
237236
@test a b
238237
@test b c
239238
end
@@ -254,21 +253,21 @@ end
254253
end
255254

256255
@testset "Interval{T}(x::Interval)" begin
257-
@test Interval{Float64}(3..4) Interval(3.0, 4.0)
256+
@test Interval{Float64}(3..4) Interval{Float64}(3.0, 4.0)
258257
@test Interval{BigFloat}(3..4) Interval{BigFloat}(3, 4)
259258
end
260259

261260
@testset "@interval with fields" begin
262261
a = 3..4
263262
x = @interval(a.lo, 2*a.hi)
264-
@test Interval(3, 8) x
263+
@test interval(3, 8) x
265264
end
266265

267266
@testset "@interval with user-defined function" begin
268267
f(x) = x.lo == Inf ? one(x) : x/(1+x) # monotonic
269268

270269
x = 3..4
271-
@test Interval(0.75, 0.8) @interval(f(x.lo), f(x.hi))
270+
@test interval(0.75, 0.8) @interval(f(x.lo), f(x.hi))
272271
end
273272

274273
# issue 192:

0 commit comments

Comments
 (0)