11using ApproxFunBase
2- using Test
32using ApproxFunBase: PointSpace, HeavisideSpace, PiecewiseSegment, dimension, SVector, checkpoints, AnyDomain
4- using StaticArrays
53using BandedMatrices: rowrange, colrange, BandedMatrix
4+ using DomainSets: Point
65using LinearAlgebra
6+ using StaticArrays
7+ using Test
78
89@testset " Spaces" begin
910 @testset " PointSpace" begin
1011 @test eltype (domain (PointSpace ([0 ,0.1 ,1 ])) ) == Float64
1112
1213 f = @inferred Fun (x-> (x- 0.1 ),PointSpace ([0 ,0.1 ,1 ]))
1314 @test roots (f) == [0.1 ]
15+ @test first (f) == - 0.1
16+ @test last (f) == 0.9
17+ @test f (Point (0 )) == - 0.1
1418
1519 a = @inferred Fun (exp, space (f))
1620 @test f/ a == @inferred Fun (x-> (x- 0.1 )* exp (- x),space (f))
@@ -204,6 +208,11 @@ using LinearAlgebra
204208 F = Fun{typeof (PointSpace (1 : 3 )), Float32}
205209 @test ApproxFunBase. cfstype (F) == Float32
206210 end
211+
212+ @testset " isconstantfun" begin
213+ f = Fun (PointSpace (1 : 4 ), ones (4 ))
214+ @test ApproxFunBase. isconstantfun (f)
215+ end
207216 end
208217
209218 @testset " DiracSpace" begin
@@ -212,6 +221,8 @@ using LinearAlgebra
212221 @test f (0.5 ) == 0
213222 @test f (5 ) == 0
214223 @test isinf (f (0 ))
224+ @test isinf (f (Point (0 )))
225+ @test sum (f) == 6
215226 end
216227
217228 @testset " Derivative operator for HeavisideSpace" begin
@@ -317,6 +328,12 @@ using LinearAlgebra
317328 @test g >= f
318329 @test 1 < f < 3
319330 @test differentiate (f) == Fun (0 , ConstantSpace (0 .. 1 ))
331+ @test f (- 1 ) == 0
332+ @test first (f) == last (f) == 2
333+ @test ApproxFunBase. isconstantfun (f)
334+
335+ f = Fun (2 , ConstantSpace ())
336+ @test first (f) == last (f) == 2
320337
321338 @test maxspace (ConstantSpace (Point (1 )), ConstantSpace (Point (2 ))) == ConstantSpace (Point (1 ) ∪ Point (2 ))
322339 @test maxspace (ConstantSpace (Point (1 )), ConstantSpace (AnyDomain ())) == ConstantSpace (Point (1 ))
0 commit comments