[Fixed bug due to default behaviour of pred and succ (they go via Ints). Nils Anders Danielsson **20050530143214 Added specific instances. Added tests that catch bug. ] { hunk ./Test/ChasingBottoms/Nat.hs 91 + succ = (+ 1) + pred = subtract 1 hunk ./Test/ChasingBottoms/Nat/Tests.hs 21 +-- The default versions of succ and pred go via Ints, and hence +-- perform incorrectly in the presence of large natural numbers. Hence +-- this generator is needed. Other tests can possibly also fail in the +-- presence of large natural numbers, but QuickCheck does not handle +-- large numbers very well, especially not when coarbitrary is used, +-- so we do not use this generator for all tests. Furthermore +-- defaulting is turned off here and in Test.ChasingBottoms.Nat, and +-- that should minimise surprises. + +largeNat :: Gen Nat +largeNat = do + n <- choose (0, 2 * toInteger (maxBound :: Int)) + return (fromInteger n) + hunk ./Test/ChasingBottoms/Nat/Tests.hs 56 -prop_Nat_Enum_succ (n :: Nat) = succ n == n + 1 -prop_Nat_Enum_pred (n :: Nat) = n > 0 ==> pred n == n - 1 +prop_Nat_Enum_succ = + forAll largeNat $ \n -> + succ n == n + 1 +prop_Nat_Enum_pred = + forAll largeNat $ \n -> + n > 0 ==> pred n == n - 1 }