Skip to content

Commit

Permalink
seeing as 'threadDelay' doesn't guarantee immediate pickup, we should…
Browse files Browse the repository at this point in the history
…n't test that. Did extend the test to verify a trigger does at least restart the timer
  • Loading branch information
Vlix committed Nov 3, 2024
1 parent 1e362d3 commit 599ce8d
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions auto-update/test/Control/DebounceSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ spec = describe "mkDebounce" $ do
threadDelay 500_000

readIORef ref `shouldReturn` 0
before2nd <- getMonotonicTime
debounced
readIORef ref `shouldReturn` 0
threadDelay 500_000
Expand All @@ -164,10 +165,10 @@ spec = describe "mkDebounce" $ do

waitUntil 1 $ readIORef ref `shouldReturn` 1
end <- getMonotonicTime
assertBool "Took less than 1.5 sec" $
assertBool "Took less than 1 sec after retrigger" $
end - before2nd > 1
assertBool "Took less than 1.5 sec total" $
end - start > 1.5
assertBool "Took more than 1.6 sec" $
end - start < 1.6

-- | Make a controllable delay function
getWaitAction :: IO (p -> IO (), IO ())
Expand Down

0 comments on commit 599ce8d

Please sign in to comment.