module Data.Homeomorphic.Test where

import Data.Homeomorphic.Internal
import Data.Homeomorphic.Check

import Test.QuickCheck
import Control.Monad
import Data.List(sort)


data AB = A | B
          deriving (Eq, Ord, Show)

instance Arbitrary AB where
    arbitrary = elements [A,B]
    coarbitrary = error "Data.Homoemorphic.Test.coarbitrary (ABC): Not implemented"


data Command = Insert (Shell AB)
             | Find (Shell AB)
             deriving (Eq, Ord, Show)

instance Arbitrary Command where
    arbitrary = oneof [liftM Insert arbitrary, liftM Find arbitrary]
    coarbitrary = error "Data.Homoemorphic.Test.coarbitrary (Command): Not implemented"



tester :: [Command] -> Bool
tester xs = foldl f empty (zip [0..] xs) `seq` True
    where
        f x (v,Insert k) = insert k v x
        f x (v,Find   k) = find k x `seq` x