Just a heads-up that the following code in UnitTests.hs will not work correctly with the latest QuickCheck:
forAll' :: (TestShow a, Testable prop)
=> Gen a -> (a -> prop) -> Property
forAll' gen pf =
MkProperty $
gen >>= \x ->
unProperty (counterexample (testShow x) (pf x))
It will only run 1 test instead of 100.
To fix this, forAll' has to wrap the property in again to indicate that it introduces nondeterminism (see the source code for QuickCheck's forAll for an example). Alternatively, a less fragile approach would be not to use forAll' but to define a modifier which handles TestShow and MonoidEq (untested):
newtype TS a = TS a deriving Arbitrary
instance TestShow a => Show (TS a) where show = testShow
instance MonoidEq a => Eq (TS a) where TS x == TS y = x =::= y
propMonoidAssociativity :: (Arbitrary m, MonoidEq m, TestShow m) => TS m -> TS m -> TS m -> Property
propMonoidAssociativity (TS x) (TS y) (TS z) =
TS ((x <> y) <> z) === TS (x <> (y <> z))
Just a heads-up that the following code in
UnitTests.hs
will not work correctly with the latest QuickCheck:It will only run 1 test instead of 100.
To fix this,
forAll'
has to wrap the property inagain
to indicate that it introduces nondeterminism (see the source code for QuickCheck'sforAll
for an example). Alternatively, a less fragile approach would be not to useforAll'
but to define a modifier which handlesTestShow
andMonoidEq
(untested):