Skip to content

Commit f01c386

Browse files
committed
Add tests
1 parent ff3d518 commit f01c386

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

test/clock.jl

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
using Test
2+
using SciMLBase
3+
using SciMLBase: Clock, PeriodicClock, Continuous, SolverStepClock, first_clock_tick_time,
4+
IndexedClock, canonicalize_indexed_clock
5+
6+
@testset "Clock" begin
7+
@test PeriodicClock(nothing, 0.2) isa TimeDomain
8+
@test Continuous() isa TimeDomain
9+
@test SolverStepClock() isa TimeDomain
10+
11+
@test Clock(1) isa TimeDomain
12+
@test Clock(24.0; phase=0.1) == PeriodicClock(24.0, 0.1)
13+
@test Clock(1//24) == PeriodicClock(1//24, 0.0)
14+
@test Clock(;phase=0.2) == PeriodicClock(nothing, 0.2)
15+
16+
@test isclock(PeriodicClock(; dt=1.0))
17+
@test !isclock(Continuous())
18+
@test !isclock(SolverStepClock())
19+
20+
@test !issolverstepclock(PeriodicClock(; dt=1.0))
21+
@test !issolverstepclock(Continuous())
22+
@test issolverstepclock(SolverStepClock())
23+
24+
@test !iscontinuous(PeriodicClock(; dt=1.0))
25+
@test iscontinuous(Continuous())
26+
@test !iscontinuous(SolverStepClock())
27+
28+
@test is_discrete_time_domain(PeriodicClock(; dt=1.0))
29+
@test !is_discrete_time_domain(Continuous())
30+
@test is_discrete_time_domain(SolverStepClock())
31+
32+
@test first_clock_tick_time(PeriodicClock(; dt=2.0), 5.0) === 6.0
33+
@test_throws ErrorException first_clock_tick_time(Continuous(), 5.0)
34+
@test first_clock_tick_time(SolverStepClock(), 5.0) === 5.0
35+
36+
ic = Clock(1)[5]
37+
@test ic === IndexedClock(Clock(1), 5)
38+
end

test/runtests.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ end
6666
@time @safetestset "Initialization" begin
6767
include("initialization.jl")
6868
end
69+
@time @safetestset "Clocks" begin
70+
include("clock.jl")
71+
end
6972
end
7073

7174
if !is_APPVEYOR &&

0 commit comments

Comments
 (0)