@@ -15,7 +15,7 @@ spec :: Spec
15spec = describe "mkDebounce" $ do
15spec = describe "mkDebounce" $ do
16 describe "Leading edge" $ do
16 describe "Leading edge" $ do
17 it "works for a single event" $ do
17 it "works for a single event" $ do
18− (ref, debounced, baton, returnFromWait) <- getDebounce Leading
18+ (ref, debounced, baton, returnFromWait) <- getDebounce leadingEdge
21 waitUntil 5 $ readIORef ref >>= (`shouldBe` 1)
21 waitUntil 5 $ readIORef ref >>= (`shouldBe` 1)
@@ -33,7 +33,7 @@ spec = describe "mkDebounce" $ do
33 readIORef ref >>= (`shouldBe` 2)
33 readIORef ref >>= (`shouldBe` 2)
35 it "works for multiple events" $ do
35 it "works for multiple events" $ do
36− (ref, debounced, baton, returnFromWait) <- getDebounce Leading
36+ (ref, debounced, baton, returnFromWait) <- getDebounce leadingEdge
39 waitForBatonToBeTaken baton
39 waitForBatonToBeTaken baton
@@ -47,7 +47,7 @@ spec = describe "mkDebounce" $ do
48 describe "Trailing edge" $ do
48 describe "Trailing edge" $ do
49 it "works for a single event" $ do
49 it "works for a single event" $ do
50− (ref, debounced, baton, returnFromWait) <- getDebounce Trailing
50+ (ref, debounced, baton, returnFromWait) <- getDebounce trailingEdge
@@ -65,7 +65,7 @@ spec = describe "mkDebounce" $ do
65 waitUntil 5 $ readIORef ref >>= (`shouldBe` 2)
65 waitUntil 5 $ readIORef ref >>= (`shouldBe` 2)
67 it "works for multiple events" $ do
67 it "works for multiple events" $ do
68− (ref, debounced, baton, returnFromWait) <- getDebounce Trailing
68+ (ref, debounced, baton, returnFromWait) <- getDebounce trailingEdge
71 waitForBatonToBeTaken baton
71 waitForBatonToBeTaken baton
@@ -76,37 +76,6 @@ spec = describe "mkDebounce" $ do
76 returnFromWait
76 returnFromWait
77 waitUntil 5 $ readIORef ref >>= (`shouldBe` 1)
77 waitUntil 5 $ readIORef ref >>= (`shouldBe` 1)
79− describe "Leading or trailing edge" $ do
80− it "works for a single event" $ do
81− (ref, debounced, baton, returnFromWait) <- getDebounce LeadingAndTrailing
84− waitUntil 5 $ readIORef ref >>= (`shouldBe` 1)
88− readIORef ref >>= (`shouldBe` 1)
92− waitUntil 5 $ readIORef ref >>= (`shouldBe` 2)
96− readIORef ref >>= (`shouldBe` 2)
98− it "works for multiple events" $ do
99− (ref, debounced, baton, returnFromWait) <- getDebounce LeadingAndTrailing
102− waitForBatonToBeTaken baton
105− waitUntil 5 $ readIORef ref >>= (`shouldBe` 1)
108− waitUntil 5 $ readIORef ref >>= (`shouldBe` 2)
111-- | Make a controllable delay function
80-- | Make a controllable delay function
112getWaitAction :: IO (p -> IO (), IO ())
81getWaitAction :: IO (p -> IO (), IO ())
@@ -117,7 +86,7 @@ getWaitAction = do
117 return (waitAction, returnFromWait)
86 return (waitAction, returnFromWait)
119-- | Get a debounce system with access to the internals for testing
88-- | 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 ())
121getDebounce edge = do
90getDebounce edge = do
122 ref :: IORef Int <- newIORef 0
91 ref :: IORef Int <- newIORef 0
123 let action = modifyIORef ref (+ 1)
92 let action = modifyIORef ref (+ 1)