[Modified isCongruence and eqIsCongruence. Nils Anders Danielsson **20050531204158 * Removed need for Arbitrary instance by requiring explicit generator instead. * Moved test of (/=)-style function to isCongruence. ] { hunk ./Test/ChasingBottoms/Nat/Tests.hs 75 -prop_Nat_Eq_congruence = eqIsCongruence arbitrary equalTo notEqualTo +prop_Nat_Eq_congruence = + eqIsCongruence arbitrary equalTo notEqualTo + (arbitrary :: Gen (Nat -> Integer)) hunk ./Test/ChasingBottoms/TestUtilities.hs 163 - --- | Tests for a congruence. 'Arbitrary' instance needed for --- 'coarbitrary'. +-- | Tests for a congruence. Also tests that the negated relation is +-- the negation of the relation. hunk ./Test/ChasingBottoms/TestUtilities.hs 167 - :: (Show a, Arbitrary a) + :: (Show a, Eq b) hunk ./Test/ChasingBottoms/TestUtilities.hs 176 + -> (a -> a -> Bool) + -- ^ The negated relation. + -> Gen (a -> b) + -- ^ Generator for functions. + -> (b -> b -> Bool) + -- ^ Equality for function result type. hunk ./Test/ChasingBottoms/TestUtilities.hs 183 -isCongruence element equalTo notEqualTo (===) = - isEquivalenceRelation element equalTo notEqualTo (===) ++ [cong] +isCongruence element equalTo notEqualTo (===) (/==) function (.===) = + isEquivalenceRelation element equalTo notEqualTo (===) + ++ [cong, eq_neq1, eq_neq2] hunk ./Test/ChasingBottoms/TestUtilities.hs 187 - cong = forAll arbitrary $ \f -> + cong = forAll function $ \f -> hunk ./Test/ChasingBottoms/TestUtilities.hs 189 - f x == (f y :: Integer) + f x .=== f y + eq_neq1 = forAll (pair element equalTo) $ \(x, y) -> + x === y && not (x /== y) + eq_neq2 = forAll (pair element notEqualTo) $ \(x, y) -> + not (x === y) && x /== y hunk ./Test/ChasingBottoms/TestUtilities.hs 195 --- | Test that an 'Eq' instance is a congruence, and that '/=' is --- the negation of '=='. +-- | Test that an 'Eq' instance is a congruence. hunk ./Test/ChasingBottoms/TestUtilities.hs 198 - :: (Show a, Arbitrary a, Eq a) + :: (Show a, Eq a, Eq b) hunk ./Test/ChasingBottoms/TestUtilities.hs 205 + -> Gen (a -> b) + -- ^ Generator for functions. hunk ./Test/ChasingBottoms/TestUtilities.hs 208 -eqIsCongruence element equalTo notEqualTo = - isCongruence element equalTo notEqualTo (==) ++ [eq_neq1, eq_neq2] - where - eq_neq1 = forAll (pair element equalTo) $ \(x, y) -> - x == y && not (x /= y) - eq_neq2 = forAll (pair element notEqualTo) $ \(x, y) -> - not (x == y) && x /= y +eqIsCongruence element equalTo notEqualTo function = + isCongruence element equalTo notEqualTo (==) (/=) function (==) }