Skip to content

Commit 6091e55

Browse files
committed
produce and verify output in performEvent test
1 parent 94f1d3b commit 6091e55

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

test/RequesterT.hs

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{-# LANGUAGE AllowAmbiguousTypes #-}
12
{-# LANGUAGE CPP #-}
23
{-# LANGUAGE BangPatterns #-}
34
{-# LANGUAGE FlexibleContexts #-}
@@ -80,6 +81,7 @@ main = do
8081
let ![[Nothing, Nothing]] = os6 -- TODO re-enable this test after issue #233 has been resolved
8182
let !(Just [(-9223372036854775808,"2")]) = M.toList <$> head (head os7)
8283
let !(Just [(-9223372036854775808,"dcba")]) = M.toList <$> head (head os8)
84+
let ![[Nothing,Just "0:1"],[Nothing,Just "1:2"],[Nothing,Just "2:3"]] = os9
8385
return ()
8486

8587
unwrapApp :: forall t m a.
@@ -241,17 +243,26 @@ testMatchRequestsWithResponses pulse = mdo
241243
, \x -> has @Read r $ readMaybe x
242244
)
243245

244-
-- If a widget is destroyed, and simultaneously it tries to use performEvent, the event shouldn't be performed.
246+
-- If a widget is destroyed, and simultaneously it tries to use performEvent, the event does not get performed.
247+
-- TODO Determine whether this is actually the behavior we want.
245248
testMoribundPerformEvent
246-
:: ( Adjustable t m
249+
:: forall t m
250+
. ( Adjustable t m
247251
, PerformEvent t m
248252
, MonadIO (Performable m)
253+
, MonadHold t m
254+
, Reflex t
249255
)
250-
=> Event t Int -> m (Event t ())
256+
=> Event t Int -> m (Event t String)
251257
testMoribundPerformEvent pulse = do
252-
runWithReplace (performEvent $ liftIO . print <$> pulse) $ ffor pulse $ \i -> do
253-
performEvent $ liftIO . print <$> pulse
254-
pure ()
255-
pure never
258+
(outputInitial, outputReplaced) <- runWithReplace (performPrint 0 pulse) $ ffor pulse $ \i -> performPrint i pulse
259+
switchHold outputInitial outputReplaced
260+
where
261+
performPrint i evt =
262+
let outputEvt = ((show i <> ":") <>) . show <$> evt
263+
in performEvent $ ffor outputEvt $ \output ->
264+
let msg = show i <> ":" <> show output
265+
in return output
266+
256267

257268
deriveArgDict ''TestRequest

0 commit comments

Comments
 (0)