Skip to content

Commit c434832

Browse files
committed
Add tests for static integer and range functions
1 parent cf68133 commit c434832

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

test/runtests.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ using MeasureBase: test_interface, test_smf
1010
using Aqua
1111
Aqua.test_all(MeasureBase; ambiguities = false)
1212

13+
include("static.jl")
14+
1315
# Aqua._test_ambiguities(
1416
# Aqua.aspkgids(MeasureBase);
1517
# exclude = [LogarithmicNumbers.Logarithmic],

test/static.jl

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
using Test
2+
3+
import MeasureBase
4+
5+
import Static
6+
using Static: static
7+
import FillArrays
8+
9+
@testset "static" begin
10+
@test 2 isa MeasureBase.IntegerLike
11+
@test static(2) isa MeasureBase.IntegerLike
12+
@test true isa MeasureBase.IntegerLike
13+
@test static(true) isa MeasureBase.IntegerLike
14+
15+
@test @inferred(MeasureBase.one_to(7)) isa Base.OneTo
16+
@test @inferred(MeasureBase.one_to(7)) == 1:7
17+
@test @inferred(MeasureBase.one_to(static(7))) isa Static.SOneTo
18+
@test @inferred(MeasureBase.one_to(static(7))) == static(1):static(7)
19+
20+
@test @inferred(MeasureBase.fill_with(4.2, (7,))) == FillArrays.Fill(4.2, 7)
21+
@test @inferred(MeasureBase.fill_with(4.2, (static(7),))) == FillArrays.Fill(4.2, 7)
22+
@test @inferred(MeasureBase.fill_with(4.2, (3, static(7)))) == FillArrays.Fill(4.2, 3, 7)
23+
@test @inferred(MeasureBase.fill_with(4.2, (3:7,))) == FillArrays.Fill(4.2, (3:7,))
24+
@test @inferred(MeasureBase.fill_with(4.2, (static(3):static(7),))) == FillArrays.Fill(4.2, (3:7,))
25+
@test @inferred(MeasureBase.fill_with(4.2, (3:7, static(2):static(5)))) == FillArrays.Fill(4.2, (3:7, 2:5))
26+
27+
@test MeasureBase.maybestatic_length(MeasureBase.one_to(7)) isa Int
28+
@test MeasureBase.maybestatic_length(MeasureBase.one_to(7)) == 7
29+
@test MeasureBase.maybestatic_length(MeasureBase.one_to(static(7))) isa Static.StaticInt
30+
@test MeasureBase.maybestatic_length(MeasureBase.one_to(static(7))) == static(7)
31+
end

0 commit comments

Comments
 (0)