Skip to content

Commit

Permalink
Fix timing test
Browse files Browse the repository at this point in the history
  • Loading branch information
wouterwln committed Sep 10, 2024
1 parent 377ed92 commit e1eaf15
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions test/entity_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -74,18 +74,19 @@
# Test functionality for different real time factors
for real_time_factor in [0.25, 0.5, 1, 2, 5]
let e = create_entity(MockEntity(); real_time_factor=real_time_factor)
t = 0.2
obs = keep(Any)
subscribe_to_observations!(e, obs)

# Test timekeeping functionality
@test clock(e).real_time_factor == real_time_factor
prev_time = time(clock(e))
sleep(0.1)
sleep(t)
elapsed_time = time(clock(e)) - prev_time
@test isapprox(
elapsed_time,
0.1 / real_time_factor,
atol=0.1 * real_time_factor,
t / real_time_factor,
rtol=0.1,
)

# Sanity check that no observations are obtained (timer and clock are decoupled)
Expand Down

0 comments on commit e1eaf15

Please sign in to comment.