-- -- Must have rules off, otherwise the fusion rules will replace the rhs -- with the lhs, and we only end up testing lhs == lhs -- import Test.QuickCheck import Data.List import Data.Char import Data.Word import Data.Maybe import Data.Int (Int64) import Text.Printf import Debug.Trace import System.Environment import System.IO import System.IO.Unsafe import System.Random import Foreign.Ptr import Data.ByteString.Lazy (ByteString(..), pack , unpack) import qualified Data.ByteString.Lazy as L import qualified Data.ByteString as P import qualified Data.ByteString.Base as P import qualified Data.ByteString.Char8 as C import qualified Data.ByteString.Lazy.Char8 as D import Prelude hiding (abs) import Data.ByteString.FusionStream import QuickCheckUtils import Debug.Trace ------------------------------------------------------------------------ -- -- arbitrary instances for stream functions -- instance Arbitrary Stream where arbitrary = arbitrary >>= return . readStrUp coarbitrary = undefined -- -- TODO, test Producers properly -- newtype StreamCU = StreamCU (Stream -> P) newtype StreamCD = StreamCD (Stream -> P) newtype StreamCB = StreamCB (Stream -> X) -- monomorphic newtype StreamTU = StreamTU (Stream -> Stream) newtype StreamTD = StreamTD (Stream -> Stream) newtype StreamTB = StreamTB (Stream -> Stream) instance Arbitrary StreamTB where arbitrary = do f <- arbitrary g <- arbitrary elements [StreamTB (mapS f) ,StreamTB (filterS g)] coarbitrary = undefined instance Arbitrary StreamTU where arbitrary = do f <- arbitrary g <- arbitrary h <- arbitrary c <- arbitrary elements [StreamTU (mapIndexedS f) ,StreamTU (scanS g h) ,StreamTU (consS c) ,StreamTU (flip snocS c) ] coarbitrary = undefined instance Arbitrary StreamTD where arbitrary = do f <- arbitrary g <- arbitrary elements [StreamTD (scanS f g)] coarbitrary = undefined instance Arbitrary StreamCD where arbitrary = do f <- arbitrary g <- arbitrary h <- arbitrary i <- arbitrary elements [StreamCD (foldrS f g) ,StreamCD (foldlS h i) ,StreamCD writeStrDn] coarbitrary = undefined instance Arbitrary StreamCU where arbitrary = do f <- arbitrary g <- arbitrary h <- arbitrary i <- arbitrary elements [StreamCU (foldlS h i) ,StreamCU (foldrS f g) ,StreamCU (foldrS f g) ,StreamCU writeStrUp] coarbitrary = undefined -- bidirectional consumers: length, maximumand minimum instance Arbitrary StreamCB where arbitrary = elements [StreamCB lengthS -- ,StreamCB maximumS -- if not null -- ,StreamCB minimumS -- if not null ] coarbitrary = undefined {- instance Arbitrary StreamPU where arbitrary = elements [StreamPU readStrUp] coarbitrary = undefined instance Arbitrary StreamPD where arbitrary = elements [StreamPD readStrDn] coarbitrary = undefined -- instance Show StreamPU where show _ = "Producer Up Stream>" -- instance Show StreamPD where show _ = "Producer Down Stream>" -} instance Show StreamCU where show _ = "Consumer Up ByteString>" instance Show StreamCD where show _ = "Consumer Down ByteString>" instance Show StreamCB where show _ = "Consumer Bi ByteString>" instance Show StreamTU where show _ = "Trans Up Stream>" instance Show StreamTD where show _ = "Trans Down Stream>" instance Show StreamTB where show _ = "Trans Bi Stream>" instance Show Stream where show _ = "" ------------------------------------------------------------------------ -- -- properties relating to RULES -- -- -- Consumer . Producer -- prop_strConsumerUp_strProducerUp (StreamCU f) stream = strConsumerUp f (strProducerUp stream) == f stream prop_strConsumerDn_strProducerDn (StreamCD f) stream = strConsumerDn f (strProducerDn stream) == f stream prop_strConsumerUp_strProducerBi (StreamCU f) stream = strConsumerUp f (strProducerBi stream) == f stream -- side condition... prop_strConsumerDn_strProducerBi (StreamCD f) w1 w2 = strConsumerDn f (strProducerUp stream) == f stream where stream = replicateS (fromIntegral (w1 :: Word8)) w2 prop_strConsumerBi_strProducerUp (StreamCB f) stream = strConsumerBi f (strProducerUp stream) == f stream prop_strConsumerBi_strProducerDn (StreamCB f) stream = strConsumerBi f (strProducerDn stream) == f stream prop_strConsumerBi_strProducerBi (StreamCB f) stream = strConsumerBi f (strProducerBi stream) == f stream -- -- Consumer . Transformer -- prop_strConsumerUp_strTransformerUp (StreamCU f) (StreamTU g) s = strConsumerUp f (strTransformerUp g s) == strConsumerUp (\x -> f (g x)) s prop_strConsumerDn_strTransformerDn (StreamCD f) (StreamTD g) s = strConsumerDn f (strTransformerDn g s) == strConsumerDn (\x -> f (g x)) s prop_strConsumerUp_strTransformerBi (StreamCU f) (StreamTB g) s = strConsumerUp f (strTransformerBi g s) == strConsumerUp (\x -> f (g x)) s prop_strConsumerDn_strTransformerBi (StreamCD f) (StreamTB g) s = strConsumerDn f (strTransformerBi g s) == strConsumerDn (\x -> f (g x)) s prop_strConsumerBi_strTransformerUp (StreamCB f) (StreamTU g) s = strConsumerBi f (strTransformerUp g s) == strConsumerUp (\x -> f (g x)) s prop_strConsumerBi_strTransformerDn (StreamCB f) (StreamTD g) s = strConsumerBi f (strTransformerDn g s) == strConsumerDn (\x -> f (g x)) s prop_strConsumerBi_strTransformerBi (StreamCB f) (StreamTB g) s = strConsumerBi f (strTransformerBi g s) == strConsumerBi (\x -> f (g x)) s -- -- Transformer . Producer -- prop_strTransformerUp_strProducerUp (StreamTU f) stream = strTransformerUp f (strProducerUp stream) == strProducerUp (f stream) prop_strTransformerDn_strProducerDn (StreamTD f) stream = strTransformerDn f (strProducerDn stream) == strProducerDn (f stream) prop_strTransformerUp_strProducerBi (StreamTU f) stream = strTransformerUp f (strProducerBi stream) == strProducerUp (f stream) -- side condition... prop_strTransformerDn_strProducerBi (StreamTU f) w1 w2 = strTransformerDn f (strProducerBi stream) == strProducerDn (f stream) where stream = replicateS (fromIntegral (w1 :: Word8)) w2 prop_strTransformerBi_strProducerUp (StreamTB f) stream = strTransformerBi f (strProducerUp stream) == strProducerUp (f stream) prop_strTransformerBi_strProducerDn (StreamTB f) stream = strTransformerBi f (strProducerDn stream) == strProducerDn (f stream) prop_strTransformerBi_strProducerBi (StreamTB f) stream = strTransformerBi f (strProducerBi stream) == strProducerBi (f stream) -- -- Transformer . Transformer -- prop_strTransformerUp_strTransformerUp (StreamTU f) (StreamTU g) s = strTransformerUp f (strTransformerUp g s) == strTransformerUp (\x -> f (g x)) s prop_strTransformerDn_strTransformerDn (StreamTD f) (StreamTD g) s = strTransformerDn f (strTransformerDn g s) == strTransformerDn (\x -> f (g x)) s prop_strTransformerUp_strTransformerBi (StreamTU f) (StreamTB g) s = strTransformerUp f (strTransformerBi g s) == strTransformerUp (\x -> f (g x)) s prop_strTransformerDn_strTransformerBi (StreamTD f) (StreamTB g) s = strTransformerDn f (strTransformerBi g s) == strTransformerDn (\x -> f (g x)) s prop_strTransformerBi_strTransformerUp (StreamTB f) (StreamTU g) s = strTransformerBi f (strTransformerUp g s) == strTransformerUp (\x -> f (g x)) s prop_strTransformerBi_strTransformerDn (StreamTB f) (StreamTD g) s = strTransformerBi f (strTransformerDn g s) == strTransformerDn (\x -> f (g x)) s prop_strTransformerBi_strTransformerBi (StreamTB f) (StreamTB g) s = strTransformerBi f (strTransformerBi g s) == strTransformerBi (\x -> f (g x)) s ------------------------------------------------------------------------ -- Lazy rules {- newtype LStreamCU = LStreamCU (Stream -> [P]) newtype LStreamPU = LStreamPU ([P] -> Stream) newtype LStreamTU = LStreamTU (Stream -> Stream) newtype LStreamTB = LStreamTB (Stream -> Stream) instance Show LStreamCU where show _ = "Lazy Consumer Up [ByteString]>" instance Show LStreamPU where show _ = "Lazy Producer Up <[ByteString] -> Stream>" instance Show LStreamTU where show _ = "Lazy Transformer Up Stream>" instance Show LStreamTB where show _ = "Lazy Transformer Bi Stream>" -- -- XXX have to manuall filter the results to get this to work. -- instance Arbitrary LStreamCU where arbitrary = do f <- arbitrary z <- arbitrary f' <- arbitrary z' <- arbitrary elements [LStreamCU (foldlS (flip f) z) ,LStreamCU (foldrS f' z')] -- elements [LStreamCU (filter (not.P.null) . foldlS (flip f) z) -- ,LStreamCU (filter (not.P.null) . foldrS f' z')] coarbitrary = undefined instance Arbitrary LStreamPU where arbitrary = elements [LStreamPU readLStrUp] coarbitrary = undefined instance Arbitrary LStreamTU where arbitrary = do z <- arbitrary y <- arbitrary x <- arbitrary f <- arbitrary g <- arbitrary elements [LStreamTU (consS z) ,LStreamTU ((flip snocS y)) ,LStreamTU (scanS f x) ,LStreamTU (mapIndexedS g) ] coarbitrary = undefined instance Arbitrary LStreamTB where arbitrary = do f <- arbitrary g <- arbitrary elements [LStreamTB (mapS f) ,LStreamTB (filterS g) ] coarbitrary = undefined -- and check the invariant still holds prop_lstrTransformerUp_lstrProducerUp (LStreamTU f) (LStreamPU g) (L.LPS s) = checkbranches (lstrTransformerUp f (lstrProducerUp g s)) (lstrProducerUp (f . g) s) prop_lstrTransformerUp_lstrTransformerUp (LStreamTU f) (LStreamTU g) (L.LPS s) = checkbranches (lstrTransformerUp f (lstrTransformerUp g s)) (lstrTransformerUp (f . g) s) prop_lstrTransformerUp_lstrTransformerBi (LStreamTU f) (LStreamTU g) (L.LPS s) = checkbranches (lstrTransformerUp f (lstrTransformerBi g s)) (lstrTransformerUp (f . g) s) prop_lstrTransformerBi_lstrProducerUp (LStreamTB f) (LStreamPU g) (L.LPS s) = checkbranches (lstrTransformerBi f (lstrProducerUp g s)) (lstrProducerUp (f . g) s) prop_lstrTransformerBi_lstrTransformerUp (LStreamTB f) (LStreamTU g) (L.LPS s) = checkbranches (lstrTransformerBi f (lstrTransformerUp g s)) (lstrTransformerUp (f . g) s) prop_lstrTransformerBi_lstrTransformerBi (LStreamTB f) (LStreamTB g) (L.LPS s) = checkbranches (lstrTransformerBi f (lstrTransformerBi g s)) (lstrTransformerBi (f . g) s) prop_lstrConsumerUp_lstrProducerUp (LStreamCU f) (LStreamPU g) (L.LPS s) = checkbranches (lstrConsumerUp f (lstrProducerUp g s)) (f (g s)) prop_lstrConsumerUp_lstrTransformerUp (LStreamCU f) (LStreamTU g) (L.LPS s) = checkbranches (lstrConsumerUp f (lstrTransformerUp g s)) (lstrConsumerUp (f . g) s) prop_lstrConsumerUp_lstrTransformerBi (LStreamCU f) (LStreamTB g) (L.LPS s) = checkbranches (lstrConsumerUp f (lstrTransformerBi g s)) (lstrConsumerUp (f . g) s) -} ------------------------------------------------------------------------ -- pair rewrites prop_null_to_fusible_nullS s = P.null s == strConsumerBi nullS s prop_unfused_nullS_to_null s = strConsumerBi nullS s == P.null s prop_length_to_fusible_lengthS s = P.length s == strConsumerBi lengthS s prop_unfused_lengthS_to_length s = strConsumerBi lengthS s == P.length s prop_cons_to_fusible_consS w s = P.cons w s == strTransformerUp (consS w) s prop_unfused_consS_to_cons w s = strTransformerUp (consS w) s == P.cons w s prop_snoc_to_fusible_snocS s w = P.snoc s w == strTransformerDn (consS w) s prop_unfused_snocS_to_snoc s w = strTransformerDn (consS w) s == P.snoc s w prop_head_to_fusible_headS s = not(P.null s) ==> P.head s == strConsumerUp headS s prop_unfused_headS_to_head s = not(P.null s) ==> strConsumerUp headS s == P.head s prop_last_to_fusible_lastS s = not(P.null s) ==> P.last s == strConsumerDn headS s prop_unfused_lastS_to_last s = not(P.null s) ==> strConsumerDn headS s == P.last s prop_map_to_fusible_mapS f s = P.map f s == strTransformerBi (mapS f) s prop_unfused_mapS_to_map f s = strTransformerBi (mapS f) s == P.map f s prop_foldl_to_fusible_foldlS f z s = P.foldl f z s == strConsumerDn (foldrS (flip f) z) s where _ = z :: Int prop_unfused_foldlS_to_foldl f z s = strConsumerDn (foldrS f z) s == P.foldl (flip f) z s where _ = z :: Int prop_foldl'_to_fusible_foldlS' f z s = P.foldl f z s == strConsumerUp (foldlS (flip f) z) s where _ = z :: Int prop_unfused_foldlS'_to_foldl' f z s = strConsumerUp (foldlS f z) s == P.foldl' (flip f) z s where _ = z :: Int prop_foldr_to_fusible_foldrS f z s = P.foldr f z s == strConsumerUp (foldrS f z) s where _ = z :: Int prop_unfused_foldrS_to_foldr f z s = strConsumerUp (foldrS f z) s == P.foldr f z s where _ = z :: Int prop_foldr'_to_fusible_foldrS' f z s = P.foldr' f z s == strConsumerDn (foldlS f z) s where _ = z :: Int prop_unfused_foldrS'_to_foldr' f z s = strConsumerDn (foldlS f z) s == P.foldr' f z s where _ = z :: Int prop_foldl1_to_fusible_foldl1S f s = not (P.null s) ==> P.foldl1 f s == strConsumerDn (foldr1S (flip f)) s prop_unfused_foldl1S_to_foldl1 f s = not (P.null s) ==> strConsumerDn (foldr1S f) s == P.foldl1 (flip f) s prop_foldr1_to_fusible_foldr1S f s = not (P.null s) ==> P.foldr1 f s == strConsumerUp (foldr1S f) s prop_unfused_foldr1S_to_foldr1 f s = not (P.null s) ==> strConsumerUp (foldr1S f) s == P.foldr1 f s prop_foldl1'_to_fusible_foldl1S' f s = not(P.null s) ==> P.foldl1' f s == strConsumerUp (foldl1S (flip f)) s prop_unfused_foldl1S'_to_foldl1' f s = not(P.null s) ==> strConsumerUp (foldl1S f) s == P.foldl1' (flip f) s prop_foldr1'_to_fusible_foldr1S' f s = not(P.null s) ==> P.foldr1' f s == strConsumerDn (foldl1S f) s prop_unfused_foldr1S'_to_foldr1' f s = not(P.null s) ==> strConsumerDn (foldl1S f) s == P.foldr1' f s prop_any_to_fusible_anyS z s = P.any z s == strConsumerBi (anyS z) s prop_unfused_anyS_to_any z s = strConsumerBi (anyS z) s == P.any z s prop_all_to_fusible_allS z s = P.all z s == strConsumerBi (allS z) s prop_unfused_allS_to_all z s = strConsumerBi (allS z) s == P.all z s prop_maximum_to_fusible_maximumS s = not(P.null s) ==> P.maximum s == strConsumerBi maximumS s prop_unfused_maximumS_to_maximum s = not(P.null s) ==> strConsumerBi maximumS s == P.maximum s prop_minimum_to_fusible_minimumS s = not(P.null s) ==> P.minimum s == strConsumerBi minimumS s prop_unfused_minimumS_to_minimum s = not(P.null s) ==> strConsumerBi minimumS s == P.minimum s prop_takeWhile_to_fusible_takeWhileS p s = P.takeWhile p s == strTransformerUp (takeWhileS p) s prop_unfused_takeWhileS_to_takeWhile p s = strTransformerUp (takeWhileS p) s == P.takeWhile p s prop_dropWhile_to_fusible_dropWhileS p s = P.dropWhile p s == strTransformerUp (dropWhileS p) s prop_unfused_dropWhileS_to_dropWhile p s = strTransformerUp (dropWhileS p) s == P.dropWhile p s prop_count_to_fusible_countS w s = P.count w s == strConsumerBi (countS w) s prop_unfused_countS_to_count w s = strConsumerBi (countS w) s == P.count w s prop_elem_to_fusible_elemS z s = P.elem z s == strConsumerBi (elemS z) s prop_unfused_elemS_to_elem z s = strConsumerBi (elemS z) s == P.elem z s prop_find_to_fusible_findS p s = P.find p s == strConsumerBi (findS p) s prop_unfused_findS_to_find p s = strConsumerBi (findS p) s == P.find p s prop_filter_to_fusible_filterS f s = P.filter f s == strTransformerBi (filterS f) s prop_unfused_filterS_to_filter f s = strTransformerBi (filterS f) s == P.filter f s {- prop_specialise_filter_eq x s = P.filter ((==) x) s == P.filterByte x s prop_specialise_filter_ne x s = P.filter ((/=) x) s == P.filterNotByte x s -} prop_mapIndexed_to_fusible_mapIndexedS f s = P.mapIndexed f s == strTransformerUp (mapIndexedS f) s prop_unfused_mapIndexedS_to_mapIndexed f s = strTransformerUp (mapIndexedS f) s == P.mapIndexed f s prop_tail_to_fusible_tailS s = not (P.null s) ==> P.tail s == strTransformerUp tailS s prop_unfused_tailS_to_tail s = not (P.null s) ==> strTransformerUp tailS s == P.tail s prop_init_to_fusible_initS s = not (P.null s) ==> P.init s == strTransformerDn tailS s prop_unfused_initS_to_init s = not (P.null s) ==> strTransformerDn tailS s == P.init s prop_take_to_fusible_takeS n s = P.take n s == strTransformerUp (takeS n) s prop_unfused_takeS_to_take n s = strTransformerUp (takeS n) s == P.take n s prop_elemIndex_to_fusible_elemIndexS z s = P.elemIndex z s == strConsumerUp (elemIndexS z) s prop_unfused_elemIndexS_to_elemIndex z s = strConsumerUp (elemIndexS z) s == P.elemIndex z s prop_findIndex_to_fusible_findIndexS z s = P.findIndex z s == strConsumerUp (findIndexS z) s prop_unfused_findIndexS_to_findIndex z s = strConsumerUp (findIndexS z) s == P.findIndex z s -- prop_findIndexOrEnd_to_fusible_findIndexOrEndS z s = -- P.findIndexOrEnd z s == strConsumerUp (findIndexOrEndS z) s -- prop_unfused_findIndexOrEndS_to_findIndexOrEnd z s = -- strConsumerUp (findIndexOrEndS z) s == P.findIndexOrEnd z s {- prop_unfoldr_to_fusible_unfoldrS f s t = P.unfoldr f s t == strProducerUp (unfoldrS f s) prop_unfused_unfoldrS_to_unfoldr f s t = strProducerUp (unfoldrS f s) t == P.unfoldr f s prop_replicate_to_fusible_replicateS n w s = P.replicate n w s == strProducerBi (replicateS n w) s prop_unfused_replicateS_to_replicate n w s = strProducerBi (replicateS n w) s == P.replicate n w s -} ------------------------------------------------------------------------ -- Rules to test stream_tests = [("null -> fusible null ", mytest prop_null_to_fusible_nullS) ,("unfused null -> null ", mytest prop_unfused_nullS_to_null) ,("length -> fusible length ", mytest prop_length_to_fusible_lengthS) ,("unfused length -> length ", mytest prop_unfused_lengthS_to_length) ,("cons -> fusible cons ", mytest prop_cons_to_fusible_consS) ,("unfused cons -> cons ", mytest prop_unfused_consS_to_cons) ,("snoc -> fusible snoc ", mytest prop_snoc_to_fusible_snocS) ,("unfused snoc -> snoc ", mytest prop_unfused_snocS_to_snoc) ,("head -> fusible head ", mytest prop_head_to_fusible_headS) ,("unfused head -> head ", mytest prop_unfused_headS_to_head) ,("last -> fusible last ", mytest prop_last_to_fusible_lastS) ,("unfused last -> last ", mytest prop_unfused_lastS_to_last) ,("map -> fusible map ", mytest prop_map_to_fusible_mapS) ,("unfused map -> map ", mytest prop_unfused_mapS_to_map) ,("foldl -> fusible foldl ", mytest prop_foldl_to_fusible_foldlS) ,("unfused foldl -> foldl ", mytest prop_unfused_foldlS_to_foldl) ,("foldl' -> fusible foldl' ", mytest prop_foldl'_to_fusible_foldlS') ,("unfused foldl' -> foldl' ", mytest prop_unfused_foldlS'_to_foldl') ,("foldr -> fusible foldr ", mytest prop_foldr_to_fusible_foldrS) ,("unfused foldr -> foldr ", mytest prop_unfused_foldrS_to_foldr) ,("foldr' -> fusible foldr' ", mytest prop_foldr'_to_fusible_foldrS') ,("unfused foldr' -> foldr' ", mytest prop_unfused_foldrS'_to_foldr') ,("foldl1' -> fusible foldl1'", mytest prop_foldl1'_to_fusible_foldl1S') ,("unfused foldl1'-> foldl1' ", mytest prop_unfused_foldl1S'_to_foldl1') ,("foldr1' -> fusible foldr1'", mytest prop_foldr1'_to_fusible_foldr1S') ,("unfused foldr1'-> foldr1' ", mytest prop_unfused_foldr1S'_to_foldr1') -- ,("foldl1 -> fusible foldl1 ", mytest prop_foldl1_to_fusible_foldl1S) -- ,("unfused foldl1 -> foldl1 ", mytest prop_unfused_foldl1S_to_foldl1) -- ,("foldr1 -> fusible foldr1 ", mytest prop_foldr1_to_fusible_foldr1S) -- ,("unfused foldr1 -> foldr1 ", mytest prop_unfused_foldr1S_to_foldr1) ,("any -> fusible any ", mytest prop_any_to_fusible_anyS) ,("unfused any -> any ", mytest prop_unfused_anyS_to_any) ,("all -> fusible all ", mytest prop_all_to_fusible_allS) ,("unfused all -> all ", mytest prop_unfused_allS_to_all) ,("maximum -> fusible maximum", mytest prop_maximum_to_fusible_maximumS) ,("unfused maximum-> maximum ", mytest prop_unfused_maximumS_to_maximum) ,("minimum -> fusible minimum", mytest prop_minimum_to_fusible_minimumS) ,("unfused minimum-> minimum ", mytest prop_unfused_minimumS_to_minimum) ,("takeWhile -> fusible takeWhile", mytest prop_takeWhile_to_fusible_takeWhileS) ,("unfused takeWhile-> takeWhile ", mytest prop_unfused_takeWhileS_to_takeWhile) ,("dropWhile -> fusible dropWhile", mytest prop_dropWhile_to_fusible_dropWhileS) ,("unfused dropWhile-> dropWhile ", mytest prop_unfused_dropWhileS_to_dropWhile) ,("count -> fusible count ", mytest prop_count_to_fusible_countS) ,("unfused count -> count ", mytest prop_unfused_countS_to_count) ,("elem -> fusible elem ", mytest prop_elem_to_fusible_elemS) ,("unfused elem -> elem ", mytest prop_unfused_elemS_to_elem) ,("find -> fusible find ", mytest prop_find_to_fusible_findS) ,("unfused find -> find ", mytest prop_unfused_findS_to_find) ,("filter -> fusible filter ", mytest prop_filter_to_fusible_filterS) ,("unfused filter -> filter ", mytest prop_unfused_filterS_to_filter) -- ,("filter (==) -> filterByte ", mytest prop_specialise_filter_eq) -- ,("filter (/=) -> filterNoteByte ", mytest prop_specialise_filter_ne) ,("mapIndexed -> fusible mapIndexedS", mytest prop_mapIndexed_to_fusible_mapIndexedS) ,("unfused mapIndexedS -> mapIndexed", mytest prop_unfused_mapIndexedS_to_mapIndexed) ,("tail -> fusible tail ", mytest prop_tail_to_fusible_tailS) ,("unfused tail -> tail ", mytest prop_unfused_tailS_to_tail) ,("init -> fusible init ", mytest prop_init_to_fusible_initS) ,("unfused init -> init ", mytest prop_unfused_initS_to_init) ,("take -> fusible take ", mytest prop_take_to_fusible_takeS) ,("unfused take -> take ", mytest prop_unfused_takeS_to_take) ,("elemIndex -> fusible elemIndex ", mytest prop_elemIndex_to_fusible_elemIndexS) ,("unfused elemIndex-> elemIndex ", mytest prop_unfused_elemIndexS_to_elemIndex) ,("findIndex -> fusible findIndex ", mytest prop_findIndex_to_fusible_findIndexS) ,("unfused findIndex-> findIndex ", mytest prop_unfused_findIndexS_to_findIndex) {- ,("unfoldr -> fusible unfoldr ", mytest prop_unfoldr_to_fusible_unfoldrS) ,("unfused unfoldr-> unfoldr ", mytest prop_unfused_unfoldrS_to_unfoldr) ,("replicate -> fusible replicate ", mytest prop_replicate_to_fusible_replicateS) ,("unfused replicate-> replicate ", mytest prop_unfused_replicateS_to_replicate) -} -- ,("findIndexOrEnd->fusible findIndexOrEnd", -- mytest prop_findIndexOrEnd_to_fusible_findIndexOrEndS) -- ,("unfused findIndexOrEnd->findIndexOrEnd", -- mytest prop_unfused_findIndexOrEndS_to_findIndexOrEnd) -- rules ,("consumer up/producer up", mytest prop_strConsumerUp_strProducerUp) ,("consumer dn/producer dn", mytest prop_strConsumerDn_strProducerDn) ,("consumer up/producer bi", mytest prop_strConsumerUp_strProducerBi) ,("consumer dn/producer bi", mytest prop_strConsumerDn_strProducerBi) ,("consumer bi/producer up", mytest prop_strConsumerBi_strProducerUp) ,("consumer bi/producer dn", mytest prop_strConsumerBi_strProducerDn) ,("consumer bi/producer bi", mytest prop_strConsumerBi_strProducerBi) ,("consumer up/trans up", mytest prop_strConsumerUp_strTransformerUp) ,("consumer dn/trans dn", mytest prop_strConsumerDn_strTransformerDn) ,("consumer up/trans bi", mytest prop_strConsumerUp_strTransformerBi) ,("consumer dn/trans bi", mytest prop_strConsumerDn_strTransformerBi) ,("consumer bi/trans up", mytest prop_strConsumerBi_strTransformerUp) ,("consumer bi/trans dn", mytest prop_strConsumerBi_strTransformerDn) ,("consumer bi/trans bi", mytest prop_strConsumerBi_strTransformerBi) ,("trans up/producer up", mytest prop_strTransformerUp_strProducerUp) ,("trans dn/producer dn", mytest prop_strTransformerDn_strProducerDn) ,("trans up/producer bi", mytest prop_strTransformerUp_strProducerBi) ,("trans dn/producer bi", mytest prop_strTransformerDn_strProducerBi) ,("trans bi/producer up", mytest prop_strTransformerBi_strProducerUp) ,("trans bi/producer dn", mytest prop_strTransformerBi_strProducerDn) ,("trans bi/producer bi", mytest prop_strTransformerBi_strProducerBi) ,("trans up/trans up", mytest prop_strTransformerUp_strTransformerUp) ,("trans dn/trans dn", mytest prop_strTransformerDn_strTransformerDn) ,("trans up/trans bi", mytest prop_strTransformerUp_strTransformerBi) ,("trans dn/trans bi", mytest prop_strTransformerDn_strTransformerBi) ,("trans bi/trans up", mytest prop_strTransformerBi_strTransformerUp) ,("trans bi/trans dn", mytest prop_strTransformerBi_strTransformerDn) ,("trans bi/trans bi", mytest prop_strTransformerBi_strTransformerBi) {- ,("lazy trans up/producer up", mytest prop_lstrTransformerUp_lstrProducerUp) ,("lazy trans up/trans up", mytest prop_lstrTransformerUp_lstrTransformerUp) ,("lazy trans up/trans bi", mytest prop_lstrTransformerUp_lstrTransformerBi) ,("lazy trans bi/producer up", mytest prop_lstrTransformerBi_lstrProducerUp) ,("lazy trans bi/trans up", mytest prop_lstrTransformerBi_lstrTransformerUp) ,("lazy trans bi/trans bi", mytest prop_lstrTransformerBi_lstrTransformerBi) ,("lazy consumer up/producer up", mytest prop_lstrConsumerUp_lstrProducerUp) ,("lazy consumer up/trans up", mytest prop_lstrConsumerUp_lstrTransformerUp) ,("lazy consumer up/trans bi", mytest prop_lstrConsumerUp_lstrTransformerBi) -} ] ------------------------------------------------------------------------ -- The entry point -- main = run tests run :: [(String, Int -> IO ())] -> IO () run tests = do x <- getArgs let n = if null x then 100 else read . head $ x mapM_ (\(s,a) -> printf "%-25s: " s >> a n) tests ------------------------------------------------------------------------ -- -- And now a list of all the properties to test. -- tests = stream_tests