11module Test.Assert
2- ( ASSERT
3- , assert
2+ ( assert
43 , assert'
54 , assertEqual
65 , assertFalse
@@ -11,33 +10,29 @@ module Test.Assert
1110
1211import Prelude
1312
14- import Control.Monad.Eff (Eff , kind Effect )
15- import Control.Monad.Eff.Console (CONSOLE , error )
16-
17- -- | Assertion effect type.
18- foreign import data ASSERT :: Effect
13+ import Effect (Effect )
14+ import Effect.Console (error )
1915
2016-- | Throws a runtime exception with message "Assertion failed" when the boolean
2117-- | value is false.
22- assert :: forall e . Boolean -> Eff ( assert :: ASSERT | e ) Unit
18+ assert :: Boolean -> Effect Unit
2319assert = assert' " Assertion failed"
2420
2521-- | Throws a runtime exception with the specified message when the boolean
2622-- | value is false.
2723foreign import assert'
28- :: forall e
29- . String
24+ :: String
3025 -> Boolean
31- -> Eff ( assert :: ASSERT | e ) Unit
26+ -> Effect Unit
3227
3328-- | Throws a runtime exception with message "Assertion failed: An error should
3429-- | have been thrown", unless the argument throws an exception when evaluated.
3530-- |
3631-- | This function is specifically for testing unsafe pure code; for example,
3732-- | to make sure that an exception is thrown if a precondition is not
38- -- | satisfied. Functions which use `Eff (err :: EXCEPTION | eff) a` can be
33+ -- | satisfied. Functions which use `Effect a` can be
3934-- | tested with `catchException` instead.
40- assertThrows :: forall e a . (Unit -> a ) -> Eff ( assert :: ASSERT | e ) Unit
35+ assertThrows :: forall a . (Unit -> a ) -> Effect Unit
4136assertThrows =
4237 assertThrows' " Assertion failed: An error should have been thrown"
4338
@@ -46,30 +41,30 @@ assertThrows =
4641-- |
4742-- | This function is specifically for testing unsafe pure code; for example,
4843-- | to make sure that an exception is thrown if a precondition is not
49- -- | satisfied. Functions which use `Eff (err :: EXCEPTION | eff) a` can be
44+ -- | satisfied. Functions which use `Effect a` can be
5045-- | tested with `catchException` instead.
5146assertThrows'
52- :: forall e a
47+ :: forall a
5348 . String
5449 -> (Unit -> a )
55- -> Eff ( assert :: ASSERT | e ) Unit
50+ -> Effect Unit
5651assertThrows' msg fn = assert' msg =<< checkThrows fn
5752
5853foreign import checkThrows
59- :: forall e a
54+ :: forall a
6055 . (Unit -> a )
61- -> Eff ( assert :: ASSERT | e ) Boolean
56+ -> Effect Boolean
6257
6358-- | Compares the `expected` and `actual` values for equality and
6459-- | throws a runtime exception when the values are not equal.
6560-- |
6661-- | The message indicates the expected value and the actual value.
6762assertEqual
68- :: forall a e
63+ :: forall a
6964 . Eq a
7065 => Show a
7166 => { actual :: a , expected :: a }
72- -> Eff ( assert :: ASSERT , console :: CONSOLE | e ) Unit
67+ -> Effect Unit
7368assertEqual {actual, expected} = do
7469 unless result $ error message
7570 assert' message result
@@ -82,17 +77,15 @@ assertEqual {actual, expected} = do
8277-- | The message indicates the expected value (`true`)
8378-- | and the actual value (`false`).
8479assertTrue
85- :: forall e
86- . Boolean
87- -> Eff (assert :: ASSERT , console :: CONSOLE | e ) Unit
80+ :: Boolean
81+ -> Effect Unit
8882assertTrue actual = assertEqual { actual, expected: true }
8983
9084-- | Throws a runtime exception when the value is `true`.
9185-- |
9286-- | The message indicates the expected value (`false`)
9387-- | and the actual value (`true`).
9488assertFalse
95- :: forall e
96- . Boolean
97- -> Eff (assert :: ASSERT , console :: CONSOLE | e ) Unit
89+ :: Boolean
90+ -> Effect Unit
9891assertFalse actual = assertEqual { actual, expected: false }
0 commit comments