Skip to content

Commit e91d4bf

Browse files
committed
Add === and /== combinators
Got the idea from haskell's purecheck. Use these quite frequently.
1 parent 8fc6fea commit e91d4bf

2 files changed

Lines changed: 16 additions & 0 deletions

File tree

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,12 @@
7979

8080
### Values
8181

82+
(/==) :: forall a b. (Eq a, Show a) => a -> a -> Result
83+
8284
(<?>) :: Boolean -> String -> Result
8385

86+
(===) :: forall a b. (Eq a, Show a) => a -> a -> Result
87+
8488
quickCheck :: forall prop. (Testable prop) => prop -> QC Unit
8589

8690
quickCheck' :: forall prop. (Testable prop) => Number -> prop -> QC Unit

src/Test/QuickCheck.purs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,3 +167,15 @@ quickCheck' n prop = do
167167

168168
quickCheck :: forall prop. (Testable prop) => prop -> QC Unit
169169
quickCheck prop = quickCheck' 100 prop
170+
171+
-- | Self-documenting equality assertion
172+
(===) :: forall a b. (Eq a, Show a) => a -> a -> Result
173+
(===) a b = a == b <?> msg
174+
where
175+
msg = show a ++ " /= " ++ show b
176+
177+
-- | Self-documenting inequality assertion
178+
(/==) :: forall a b. (Eq a, Show a) => a -> a -> Result
179+
(/==) a b = a /= b <?> msg
180+
where
181+
msg = show a ++ " == " ++ show b

0 commit comments

Comments
 (0)