@@ -21,6 +21,7 @@ import Control.Monad.State.Strict hiding (mapM, mapM_, forM, forM_, sequence, se
2121import Control.Monad.Writer hiding (mapM, mapM_, forM, forM_, sequence, sequence_)
2222import Data.Dependent.Map (DSum (..))
2323import System.Mem
24+import System.Exit
2425
2526import System.IO.Unsafe
2627
@@ -85,16 +86,20 @@ testSpider builder (bMap, eMap) = unsafePerformIO $ S.runSpiderHost $ do
8586tracePerf :: Show a => a -> b -> b
8687tracePerf = flip const
8788
88−testAgreement :: (Eq c, Eq d, Show c, Show d) => (forall m t. TestCaseConstraint t m => (Behavior t a, Event t b) -> m (Behavior t c, Event t d)) -> (Map Int a, Map Int b) -> IO ()
89+testAgreement :: (Eq c, Eq d, Show c, Show d) => (forall m t. TestCaseConstraint t m => (Behavior t a, Event t b) -> m (Behavior t c, Event t d)) -> (Map Int a, Map Int b) -> IO Bool
8990testAgreement builder inputs = do
9091 let identityResult = testPure builder inputs
9192 tracePerf "---------" $ return ()
9293 let spiderResult = testSpider builder inputs
9394 tracePerf "---------" $ return ()
94− if identityResult == spiderResult then putStrLn "Success:" >> print identityResult else do
95− putStrLn "Failure:"
96− putStrLn $ "Pure result: " <> show identityResult
97− putStrLn $ "Spider result: " <> show spiderResult
95+ let resultsAgree = identityResult == spiderResult
96+ if resultsAgree
97+ then do putStrLn "Success:"
98+ print identityResult
99+ else do putStrLn "Failure:"
100+ putStrLn $ "Pure result: " <> show identityResult
101+ putStrLn $ "Spider result: " <> show spiderResult
102+ return resultsAgree
98103
99104type TestCaseConstraint t m = (Reflex t, MonadSample t m, MonadHold t m, MonadFix m, MonadFix (PushM t))
100105
@@ -215,7 +220,9 @@ testCases =
215220
216221test :: IO ()
217222test = do
218− forM_ testCases $ \(name, TestCase inputs builder) -> do
223+ results <- forM testCases $ \(name, TestCase inputs builder) -> do
219224 putStrLn $ "Test: " <> name
220225 testAgreement builder inputs
221− return ()
226+ exitWith $ if and results
227+ then ExitSuccess
228+ else ExitFailure 1