From 9f541770f64665daa84d9f83fec6f9df101c5314 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20B=C3=A4renz?= Date: Mon, 5 Feb 2024 15:15:18 +0100 Subject: [PATCH] Add exception tests --- rhine/test/Except.hs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/rhine/test/Except.hs b/rhine/test/Except.hs index 7bb18aa1..114f7240 100644 --- a/rhine/test/Except.hs +++ b/rhine/test/Except.hs @@ -25,4 +25,18 @@ tests = go $ n - 1 inputs = [0] runScheduleRhinePure (clsf @@ FixedStep @1) inputs @?= [Just 0] + , testCase "Can raise, catch, and keep very many exceptions without steps in between" $ do + let clsf = safely $ go 1000 [] + go n ns = do + _ <- try $ throwOnCond (< n) () >>> arr (const ns) + go (n - 1) (n : ns) + inputs = [0] + runScheduleRhinePure (clsf @@ FixedStep @1) inputs @?= [Just [1 .. 1000]] + , testCase "Can raise, catch, and keep very many exceptions without steps in between, using Monad" $ do + let clsf = safely $ go 1000 [] + go n ns = do + n' <- try $ throwOnCond (< n) n >>> arr (const ns) + go (n' - 1) (n' : ns) + inputs = [0] + runScheduleRhinePure (clsf @@ FixedStep @1) inputs @?= [Just [1 .. 1000]] ]