|
| 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 |
0 commit comments