Skip to content

Commit 48d73b9

Browse files
authored
Add UniqueInterval inference tests (#112)
1 parent 9782f79 commit 48d73b9

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

test/miscAFBase.jl

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,30 @@
1+
module ApproxFunBaseTests
2+
13
using ApproxFunOrthogonalPolynomials
24
using ApproxFunBase
35
using Test
46
using LinearAlgebra
57
using StaticArrays
68
using BandedMatrices
79

10+
using IntervalSets: AbstractInterval
11+
import IntervalSets: endpoints, closedendpoints
12+
13+
struct UniqueInterval{T, I<:AbstractInterval{T}} <: AbstractInterval{T}
14+
parentinterval :: I
15+
end
16+
17+
for f in [:endpoints, :closedendpoints]
18+
@eval $f(m::UniqueInterval) = $f(m.parentinterval)
19+
end
20+
21+
Base.in(x, m::UniqueInterval) = in(x, m.parentinterval)
22+
Base.isempty(m::UniqueInterval) = isempty(m.parentinterval)
23+
24+
ApproxFunBase.domainscompatible(a::UniqueInterval, b::UniqueInterval) = a == b
25+
26+
Base.:(==)(a::UniqueInterval, b::UniqueInterval) = (@assert a.parentinterval == b.parentinterval; true)
27+
828
@testset "ApproxFunBase" begin
929
@testset "Constructor" begin
1030
@test (@inferred Fun()) == Fun(x->x, Chebyshev())
@@ -77,6 +97,26 @@ using BandedMatrices
7797
@test (@inferred h(Val(4)))(0.1) (0.1)^4
7898
@test h(Val(10))(0.1) (0.1)^10 rtol=1e-6
7999
end
100+
101+
@testset "UniqueInterval" begin
102+
f = Fun(UniqueInterval(0..1))
103+
g = @inferred f^0
104+
@test coefficients(g) == coefficients(one(Fun(0..1)))
105+
g = @inferred f^1
106+
@test coefficients(g) == coefficients(Fun(0..1)^1)
107+
g = @inferred f^2
108+
@test coefficients(g) == coefficients(Fun(0..1)^2)
109+
g = @inferred f*f
110+
@test coefficients(g) == coefficients(Fun(0..1)^2)
111+
g = @inferred f^3
112+
@test coefficients(g) == coefficients(Fun(0..1)^3)
113+
g = @inferred f*f*f
114+
@test coefficients(g) == coefficients(Fun(0..1)^3)
115+
g = @inferred f^4
116+
@test coefficients(g) == coefficients(Fun(0..1)^4)
117+
g = @inferred f*f*f*f
118+
@test coefficients(g) == coefficients(Fun(0..1)^4)
119+
end
80120
end
81121

82122
@testset "int coeffs" begin
@@ -298,3 +338,5 @@ using BandedMatrices
298338
end
299339
end
300340
end
341+
342+
end # module

0 commit comments

Comments
 (0)