@@ -119,6 +119,12 @@ eqP a b s w = eq "orig" (a s) (b t) &&
119 eq s a b | a =^= b = True
119 eq s a b | a =^= b = True
120 | otherwise = trace (s ++ ": " ++ show a ++ " /= " ++ show b) False
120 | otherwise = trace (s ++ ": " ++ show a ++ " /= " ++ show b) False
122+-- For tests that have O(n^2) running times or input sizes, resize
123+-- their inputs to the square root of the originals.
124+unsquare :: (Arbitrary a, Show a, Testable b) => (a -> b) -> Property
125+unsquare = forAll . sized $ \n -> resize (smaller n) arbitrary
126+ where smaller = round . sqrt . fromIntegral
122prop_S_Eq s = (s==) `eq` ((S.stream s==) . S.stream)
128prop_S_Eq s = (s==) `eq` ((S.stream s==) . S.stream)
123prop_T_Eq s = (s==) `eq` ((T.pack s==) . T.pack)
129prop_T_Eq s = (s==) `eq` ((T.pack s==) . T.pack)
124prop_TL_Eq s = (s==) `eq` ((TL.pack s==) . TL.pack)
130prop_TL_Eq s = (s==) `eq` ((TL.pack s==) . TL.pack)
@@ -131,8 +137,8 @@ prop_T_Show = show `eq` (show . T.pack)
131prop_TL_Show = show `eq` (show . TL.pack)
137prop_TL_Show = show `eq` (show . TL.pack)
132prop_T_mappend s = mappend s`eqP` (unpackS . mappend (T.pack s))
138prop_T_mappend s = mappend s`eqP` (unpackS . mappend (T.pack s))
133prop_TL_mappend s = mappend s`eqP` (unpackS . mappend (TL.pack s))
139prop_TL_mappend s = mappend s`eqP` (unpackS . mappend (TL.pack s))
134−prop_T_mconcat = mconcat `eq` (unpackS . mconcat . L.map T.pack)
140+prop_T_mconcat = unsquare (mconcat `eq` (unpackS . mconcat . L.map T.pack))
135−prop_TL_mconcat = mconcat `eq` (unpackS . mconcat . L.map TL.pack)
141+prop_TL_mconcat = unsquare (mconcat `eq` (unpackS . mconcat . L.map TL.pack))
136prop_T_IsString = fromString `eqP` (T.unpack . fromString)
142prop_T_IsString = fromString `eqP` (T.unpack . fromString)
137prop_TL_IsString = fromString `eqP` (TL.unpack . fromString)
143prop_TL_IsString = fromString `eqP` (TL.unpack . fromString)
@@ -172,12 +178,12 @@ prop_T_length = length `eqP` T.length
172prop_TL_length = length `eqP` (fromIntegral . TL.length)
178prop_TL_length = length `eqP` (fromIntegral . TL.length)
173prop_T_map f = map f `eqP` (unpackS . T.map f)
179prop_T_map f = map f `eqP` (unpackS . T.map f)
174prop_TL_map f = map f `eqP` (unpackS . TL.map f)
180prop_TL_map f = map f `eqP` (unpackS . TL.map f)
175−prop_T_intercalate c = L.intercalate c `eq` (unpackS . T.intercalate (packS c) . map packS)
181+prop_T_intercalate c = unsquare (L.intercalate c `eq` (unpackS . T.intercalate (packS c) . map packS))
176−prop_TL_intercalate c = L.intercalate c `eq` (unpackS . TL.intercalate (TL.pack c) . map TL.pack)
182+prop_TL_intercalate c = unsquare (L.intercalate c `eq` (unpackS . TL.intercalate (TL.pack c) . map TL.pack))
177prop_T_intersperse c = L.intersperse c `eqP` (unpackS . T.intersperse c)
183prop_T_intersperse c = L.intersperse c `eqP` (unpackS . T.intersperse c)
178prop_TL_intersperse c = L.intersperse c `eqP` (unpackS . TL.intersperse c)
184prop_TL_intersperse c = L.intersperse c `eqP` (unpackS . TL.intersperse c)
179−prop_T_transpose = L.transpose `eq` (map unpackS . T.transpose . map packS)
185+prop_T_transpose = unsquare (L.transpose `eq` (map unpackS . T.transpose . map packS))
180−prop_TL_transpose = L.transpose `eq` (map unpackS . TL.transpose . map TL.pack)
186+prop_TL_transpose = unsquare (L.transpose `eq` (map unpackS . TL.transpose . map TL.pack))
181prop_T_reverse = L.reverse `eqP` (unpackS . T.reverse)
187prop_T_reverse = L.reverse `eqP` (unpackS . T.reverse)
182prop_TL_reverse = L.reverse `eqP` (unpackS . TL.reverse)
188prop_TL_reverse = L.reverse `eqP` (unpackS . TL.reverse)
183prop_T_reverse_short n = L.reverse `eqP` (unpackS . S.reverse . shorten n . S.stream)
189prop_T_reverse_short n = L.reverse `eqP` (unpackS . S.reverse . shorten n . S.stream)
@@ -231,10 +237,10 @@ prop_TL_foldr f z = L.foldr f z `eqP` TL.foldr f z
231prop_T_foldr1 f = L.foldr1 f `eqP` T.foldr1 f
237prop_T_foldr1 f = L.foldr1 f `eqP` T.foldr1 f
232prop_TL_foldr1 f = L.foldr1 f `eqP` TL.foldr1 f
238prop_TL_foldr1 f = L.foldr1 f `eqP` TL.foldr1 f
234−prop_T_concat = L.concat `eq` (unpackS . T.concat . map packS)
240+prop_T_concat = unsquare (L.concat `eq` (unpackS . T.concat . map packS))
235−prop_TL_concat = L.concat `eq` (unpackS . TL.concat . map TL.pack)
241+prop_TL_concat = unsquare (L.concat `eq` (unpackS . TL.concat . map TL.pack))
236−prop_T_concatMap f = L.concatMap f `eqP` (unpackS . T.concatMap (packS . f))
242+prop_T_concatMap f = unsquare (L.concatMap f `eqP` (unpackS . T.concatMap (packS . f)))
237−prop_TL_concatMap f = L.concatMap f `eqP` (unpackS . TL.concatMap (TL.pack . f))
243+prop_TL_concatMap f = unsquare (L.concatMap f `eqP` (unpackS . TL.concatMap (TL.pack . f)))
238prop_T_any p = L.any p `eqP` T.any p
244prop_T_any p = L.any p `eqP` T.any p
239prop_TL_any p = L.any p `eqP` TL.any p
245prop_TL_any p = L.any p `eqP` TL.any p
240prop_T_all p = L.all p `eqP` T.all p
246prop_T_all p = L.all p `eqP` T.all p
@@ -362,11 +368,12 @@ prop_T_lines' = lines' `eqP` (map unpackS . T.lines')
362 eol c = c == '\r' || c == '\n'
368 eol c = c == '\r' || c == '\n'
364prop_T_words = L.words `eqP` (map unpackS . T.words)
370prop_T_words = L.words `eqP` (map unpackS . T.words)
365prop_TL_words = L.words `eqP` (map unpackS . TL.words)
372prop_TL_words = L.words `eqP` (map unpackS . TL.words)
366−prop_T_unlines = L.unlines `eq` (unpackS . T.unlines . map packS)
373+prop_T_unlines = unsquare (L.unlines `eq` (unpackS . T.unlines . map packS))
367−prop_TL_unlines = L.unlines `eq` (unpackS . TL.unlines . map packS)
374+prop_TL_unlines = unsquare (L.unlines `eq` (unpackS . TL.unlines . map packS))
368−prop_T_unwords = L.unwords `eq` (unpackS . T.unwords . map packS)
375+prop_T_unwords = unsquare (L.unwords `eq` (unpackS . T.unwords . map packS))
369−prop_TL_unwords = L.unwords `eq` (unpackS . TL.unwords . map packS)
376+prop_TL_unwords = unsquare (L.unwords `eq` (unpackS . TL.unwords . map packS))
371prop_S_isPrefixOf s = L.isPrefixOf s`eqP` (S.isPrefixOf (S.stream $ packS s) . S.stream)
378prop_S_isPrefixOf s = L.isPrefixOf s`eqP` (S.isPrefixOf (S.stream $ packS s) . S.stream)
372prop_T_isPrefixOf s = L.isPrefixOf s`eqP` T.isPrefixOf (packS s)
379prop_T_isPrefixOf s = L.isPrefixOf s`eqP` T.isPrefixOf (packS s)
@@ -385,10 +392,12 @@ prop_TL_find p = L.find p `eqP` TL.find p
385prop_T_partition p = L.partition p `eqP` (unpack2 . T.partition p)
392prop_T_partition p = L.partition p `eqP` (unpack2 . T.partition p)
386prop_TL_partition p = L.partition p `eqP` (unpack2 . TL.partition p)
393prop_TL_partition p = L.partition p `eqP` (unpack2 . TL.partition p)
388−prop_T_index x s = x < L.length s && x >= 0 ==>
389− (L.!!) s x == T.index (packS s) x
395+prop_T_index s = forAll (choose (-l,l*2)) ((s L.!!) `eq` T.index (packS s))
390−prop_TL_index x s = x < L.length s && x >= 0 ==>
396+ where l = L.length s
391− (L.!!) s x == TL.index (packS s) (fromIntegral x)
398+prop_TL_index s = forAll (choose (-l,l*2)) ((s L.!!) `eq` (TL.index (packS s) . fromIntegral))
399+ where l = L.length s
392prop_T_findIndex p = L.findIndex p `eqP` T.findIndex p
401prop_T_findIndex p = L.findIndex p `eqP` T.findIndex p
393prop_TL_findIndex p = (fmap fromIntegral . L.findIndex p) `eqP` TL.findIndex p
402prop_TL_findIndex p = (fmap fromIntegral . L.findIndex p) `eqP` TL.findIndex p
394prop_T_findIndices p = L.findIndices p `eqP` T.findIndices p
403prop_T_findIndices p = L.findIndices p `eqP` T.findIndices p
@@ -644,6 +653,7 @@ tests = [
644 ("prop_TL_partition", mytest prop_TL_partition),
653 ("prop_TL_partition", mytest prop_TL_partition),
646 ("prop_T_index", mytest prop_T_index),
655 ("prop_T_index", mytest prop_T_index),
656+ ("prop_TL_index", mytest prop_TL_index),
647 ("prop_T_findIndex", mytest prop_T_findIndex),
657 ("prop_T_findIndex", mytest prop_T_findIndex),
648 ("prop_TL_findIndex", mytest prop_TL_findIndex),
658 ("prop_TL_findIndex", mytest prop_TL_findIndex),
649 ("prop_T_findIndices", mytest prop_T_findIndices),
659 ("prop_T_findIndices", mytest prop_T_findIndices),