Skip to content

Commit a026ab0

Browse files
committed
Merge pull request #18 from MichaelXavier/equality-helper
Add === and /== combinators
2 parents 8fc6fea + e91d4bf commit a026ab0

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

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)