{-# LANGUAGE TemplateHaskell #-} module TestSets where import Test.QuickCheck import SetsAsList -- The type of elements for testing: type Elem = Int -- ADT equations: prop_empty_elem :: Elem -> Bool prop_empty_elem x = not (isElem x empty) prop_insert_elem :: Elem -> Set Elem -> Bool prop_insert_elem x s = isElem x (insert x s) prop_insert2_elem :: Elem -> Elem -> Set Elem -> Bool prop_insert2_elem x y s = isElem x (insert y (insert x s)) prop_union :: Elem -> Set Elem -> Set Elem -> Bool prop_union x s1 s2 = isElem x (union s1 s2) == (isElem x s1 || isElem x s2) instance (Eq a, Arbitrary a) => Arbitrary (Set a) where arbitrary = do xs <- arbitrary return ((foldr :: (a -> b -> b) -> b -> [a] -> b) insert empty xs) -- Executing all tests: return [] testAll = $quickCheckAll