|
| 1 | +module ApproxFunBaseTests |
| 2 | + |
1 | 3 | using ApproxFunOrthogonalPolynomials
|
2 | 4 | using ApproxFunBase
|
3 | 5 | using Test
|
4 | 6 | using LinearAlgebra
|
5 | 7 | using StaticArrays
|
6 | 8 | using BandedMatrices
|
7 | 9 |
|
| 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 | + |
8 | 28 | @testset "ApproxFunBase" begin
|
9 | 29 | @testset "Constructor" begin
|
10 | 30 | @test (@inferred Fun()) == Fun(x->x, Chebyshev())
|
@@ -77,6 +97,26 @@ using BandedMatrices
|
77 | 97 | @test (@inferred h(Val(4)))(0.1) ≈ (0.1)^4
|
78 | 98 | @test h(Val(10))(0.1) ≈ (0.1)^10 rtol=1e-6
|
79 | 99 | 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 |
80 | 120 | end
|
81 | 121 |
|
82 | 122 | @testset "int coeffs" begin
|
@@ -298,3 +338,5 @@ using BandedMatrices
|
298 | 338 | end
|
299 | 339 | end
|
300 | 340 | end
|
| 341 | + |
| 342 | +end # module |
0 commit comments