Skip to content

Commit

Permalink
Update runtests.jl
Browse files Browse the repository at this point in the history
  • Loading branch information
testercwt committed Jul 25, 2023
1 parent 69e8a8c commit d480760
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -121,17 +121,24 @@ end
GameZero.scheduler[] = GameZero.Scheduler()
flag=false
f()= (flag=true;nothing)
function _sleep(t)
t1=Base.time_ns()
while true
sleep(0.01)
Base.time_ns()-t1 > t * 1.0e9 && break
end
end

@testset "once" begin
flag=false
schedule_once(f,1)
schedule_once(f,0.5)
@test flag==false
sleep(0.5)
_sleep(0.5)
GameZero.tick!(GameZero.scheduler[])
@test flag==true
flag=false
sleep(0.5)
_sleep(0.5)
GameZero.tick!(GameZero.scheduler[])
@test flag==true
end
Expand All @@ -141,11 +148,11 @@ end
schedule_once(f,1)
schedule_unique(f,0.5)
@test flag==false
sleep(0.5)
_sleep(0.5)
GameZero.tick!(GameZero.scheduler[])
@test flag==true
flag=false
sleep(0.5)
_sleep(0.5)
GameZero.tick!(GameZero.scheduler[])
@test flag==false
end
Expand All @@ -154,11 +161,11 @@ end
flag=false
schedule_interval(f,1)
@test flag==false
sleep(1)
_sleep(1)
GameZero.tick!(GameZero.scheduler[])
@test flag==true
flag=false
sleep(1)
_sleep(1)
GameZero.tick!(GameZero.scheduler[])
@test flag==true
GameZero.clear!(GameZero.scheduler[])
Expand All @@ -172,18 +179,18 @@ end
flag=false
schedule_conti(f,1)
@test flag==false
sleep(1)
_sleep(1)
GameZero.tick!(GameZero.scheduler[])
@test flag==true

flag=false
schedule_conti(f2,1)
@test flag==false
sleep(1)
_sleep(1)
GameZero.tick!(GameZero.scheduler[])
@test flag==true
flag=false
sleep(0.5)
_sleep(0.5)
GameZero.tick!(GameZero.scheduler[])
@test flag==true
end
Expand Down

0 comments on commit d480760

Please sign in to comment.