@@ -9,7 +9,7 @@ import qualified UnliftIO.Exception as UE
9import Effectful.Interpreter
9import Effectful.Interpreter
10import Effectful.State.Dynamic
10import Effectful.State.Dynamic
11import Effectful.Monad
11import Effectful.Monad
12−import Utils
12+import qualified Utils as U
14stateTests :: TestTree
14stateTests :: TestTree
15stateTests = testGroup "State"
15stateTests = testGroup "State"
@@ -24,19 +24,19 @@ stateTests = testGroup "State"
24test_runState :: Assertion
24test_runState :: Assertion
25test_runState = runIOE $ do
25test_runState = runIOE $ do
26 (end, len) <- runState (0::Int) . execState collatzStart $ collatz
26 (end, len) <- runState (0::Int) . execState collatzStart $ collatz
27− assertEqual_ "correct end" 1 end
27+ U.assertEqual "correct end" 1 end
28− assertEqual_ "correct len" collatzLength len
28+ U.assertEqual "correct len" collatzLength len
30test_evalState :: Assertion
30test_evalState :: Assertion
31test_evalState = runIOE $ do
31test_evalState = runIOE $ do
32 len <- evalState (0::Int) . evalState collatzStart $ collatz *> get @Int
32 len <- evalState (0::Int) . evalState collatzStart $ collatz *> get @Int
33− assertEqual_ "correct len" collatzLength len
33+ U.assertEqual "correct len" collatzLength len
35test_stateM :: Assertion
35test_stateM :: Assertion
36test_stateM = runIOE $ do
36test_stateM = runIOE $ do
37 (a, b) <- runState "hi" . stateM $ \s -> pure (s, s ++ "!!!")
37 (a, b) <- runState "hi" . stateM $ \s -> pure (s, s ++ "!!!")
38− assertEqual_ "correct a" "hi" a
38+ U.assertEqual "correct a" "hi" a
39− assertEqual_ "correct b" "hi!!!" b
39+ U.assertEqual "correct b" "hi!!!" b
41test_deepStack :: Assertion
41test_deepStack :: Assertion
42test_deepStack = runIOE $ do
42test_deepStack = runIOE $ do
@@ -48,7 +48,7 @@ test_deepStack = runIOE $ do
48 modify @Int (+2)
48 modify @Int (+2)
49 modify @Int (+4)
49 modify @Int (+4)
50 modify @Int (+8)
50 modify @Int (+8)
51− assertEqual_ "n" 15 n
51+ U.assertEqual "n" 15 n
53test_exceptions :: Assertion
53test_exceptions :: Assertion
54test_exceptions = runIOE $ do
54test_exceptions = runIOE $ do
@@ -61,28 +61,28 @@ test_exceptions = runIOE $ do
64− -> (forall a es. IOE :> es => Eff es a -> Eff es (Either Ex a))
64+ -> (forall a es. IOE :> es => Eff es a -> Eff es (Either U.Ex a))
65 -> Eff '[IOE] ()
65 -> Eff '[IOE] ()
66 testTry lib tryImpl = do
66 testTry lib tryImpl = do
67 e <- tryImpl $ runState (0::Int) action
67 e <- tryImpl $ runState (0::Int) action
68− assertEqual_ (lib ++ " - exception caught") e (Left Ex)
68+ U.assertEqual (lib ++ " - exception caught") e (Left U.Ex)
69 s <- execState (0::Int) $ tryImpl action
69 s <- execState (0::Int) $ tryImpl action
70− assertEqual_ (lib ++ " - state partially updated") s 1
70+ U.assertEqual (lib ++ " - state partially updated") s 1
74− -> (forall a es. IOE :> es => Eff es a -> (Ex -> Eff es a) -> Eff es a)
74+ -> (forall a es. IOE :> es => Eff es a -> (U.Ex -> Eff es a) -> Eff es a)
75 -> Eff '[IOE] ()
75 -> Eff '[IOE] ()
76 testCatch lib catchImpl = do
76 testCatch lib catchImpl = do
77 s <- execState (0::Int) $ do
77 s <- execState (0::Int) $ do
78− _ <- (evalState () action) `catchImpl` \Ex -> modify @Int (+4)
78+ _ <- (evalState () action) `catchImpl` \U.Ex -> modify @Int (+4)
79 modify @Int (+8)
79 modify @Int (+8)
80− assertEqual_ (lib ++ " - state correctly updated") s 13
80+ U.assertEqual (lib ++ " - state correctly updated") s 13
82 action :: State Int :> es => Eff es ()
82 action :: State Int :> es => Eff es ()
83 action = do
83 action = do
84 modify @Int (+1)
84 modify @Int (+1)
85− _ <- E.throwM Ex
85+ _ <- E.throwM U.Ex
86 modify @Int (+2)
86 modify @Int (+2)
88test_localEffects :: Assertion
88test_localEffects :: Assertion
@@ -94,7 +94,7 @@ test_localEffects = runIOE $ do
94 execState () $ do
94 execState () $ do
95 putInt expected
95 putInt expected
97− assertEqual_ "correct x" expected x
97+ U.assertEqual "correct x" expected x
99 expected :: Int
99 expected :: Int
100 expected = 4
100 expected = 4