1 {-# LANGUAGE CPP #-}
    2 
    3 module Rules where
    4 --
    5 -- Tests to ensure rules are firing.
    6 --
    7 
    8 import qualified Data.ByteString.Char8       as C
    9 import qualified Data.ByteString             as P
   10 import qualified Data.ByteString.Lazy        as L
   11 import qualified Data.ByteString.Lazy.Char8  as D
   12 import Data.List
   13 import Data.Char
   14 
   15 import QuickCheckUtils
   16 
   17 #if defined(HAVE_TEST_FRAMEWORK)
   18 import Test.Framework.Providers.QuickCheck2
   19 #else
   20 import TestFramework
   21 #endif
   22 
   23 
   24 prop_break_C x = C.break ((==) x) `eq1` break ((==) x)
   25 prop_break_P x = P.break ((==) x) `eq1` break ((==) x)
   26 prop_intercalate_P c = (\s1 s2 -> P.intercalate (P.singleton c) (s1 : s2 : []))
   27                         `eq2`
   28                        (\s1 s2 -> intercalate [c] (s1 : s2 : []))
   29 
   30 prop_break_isSpace_C = C.break isSpace `eq1` break isSpace
   31 prop_dropWhile_isSpace_C = C.dropWhile isSpace `eq1` dropWhile isSpace
   32 
   33 rules =
   34     [ testProperty "break (==)"        prop_break_C
   35     , testProperty "break (==)"        prop_break_P
   36     , testProperty "break isSpace"     prop_break_isSpace_C
   37     , testProperty "dropWhile isSpace" prop_dropWhile_isSpace_C
   38     , testProperty "intercalate"       prop_intercalate_P
   39     ]