@@ -15,7 +15,7 @@ spec :: Spec
1515spec = describe "mkDebounce" $ do
1616 describe "Leading edge" $ do
1717 it "works for a single event" $ do
18− (ref, debounced, baton, returnFromWait) <- getDebounce Leading
18+ (ref, debounced, baton, returnFromWait) <- getDebounce leadingEdge
1919
2020 debounced
2121 waitUntil 5 $ readIORef ref >>= (`shouldBe` 1)
@@ -33,7 +33,7 @@ spec = describe "mkDebounce" $ do
3333 readIORef ref >>= (`shouldBe` 2)
3434
3535 it "works for multiple events" $ do
36− (ref, debounced, baton, returnFromWait) <- getDebounce Leading
36+ (ref, debounced, baton, returnFromWait) <- getDebounce leadingEdge
3737
3838 debounced
3939 waitForBatonToBeTaken baton
@@ -47,7 +47,7 @@ spec = describe "mkDebounce" $ do
4747
4848 describe "Trailing edge" $ do
4949 it "works for a single event" $ do
50− (ref, debounced, baton, returnFromWait) <- getDebounce Trailing
50+ (ref, debounced, baton, returnFromWait) <- getDebounce trailingEdge
5151
5252 debounced
5353 pause
@@ -65,7 +65,7 @@ spec = describe "mkDebounce" $ do
6565 waitUntil 5 $ readIORef ref >>= (`shouldBe` 2)
6666
6767 it "works for multiple events" $ do
68− (ref, debounced, baton, returnFromWait) <- getDebounce Trailing
68+ (ref, debounced, baton, returnFromWait) <- getDebounce trailingEdge
6969
7070 debounced
7171 waitForBatonToBeTaken baton
@@ -76,37 +76,6 @@ spec = describe "mkDebounce" $ do
7676 returnFromWait
7777 waitUntil 5 $ readIORef ref >>= (`shouldBe` 1)
7878
79− describe "Leading or trailing edge" $ do
80− it "works for a single event" $ do
81− (ref, debounced, baton, returnFromWait) <- getDebounce LeadingAndTrailing
82−
83− debounced
84− waitUntil 5 $ readIORef ref >>= (`shouldBe` 1)
85−
86− returnFromWait
87− pause
88− readIORef ref >>= (`shouldBe` 1)
89−
90− -- Try another round
91− debounced
92− waitUntil 5 $ readIORef ref >>= (`shouldBe` 2)
93−
94− returnFromWait
95− pause
96− readIORef ref >>= (`shouldBe` 2)
97−
98− it "works for multiple events" $ do
99− (ref, debounced, baton, returnFromWait) <- getDebounce LeadingAndTrailing
100−
101− debounced
102− waitForBatonToBeTaken baton
103− debounced
104−
105− waitUntil 5 $ readIORef ref >>= (`shouldBe` 1)
106−
107− returnFromWait
108− waitUntil 5 $ readIORef ref >>= (`shouldBe` 2)
109−
11079
11180-- | Make a controllable delay function
11281getWaitAction :: IO (p -> IO (), IO ())
@@ -117,7 +86,7 @@ getWaitAction = do
11786 return (waitAction, returnFromWait)
11887
11988-- | Get a debounce system with access to the internals for testing
120−getDebounce :: DebounceEdge -> IO (IORef Int, IO (), MVar (), IO ())
89+getDebounce :: DI.DebounceEdge -> IO (IORef Int, IO (), MVar (), IO ())
12190getDebounce edge = do
12291 ref :: IORef Int <- newIORef 0
12392 let action = modifyIORef ref (+ 1)