Add a null-correcntess test for strict takeWhileEnd (gh-184)
[packages/text.git] / tests / Tests / Properties.hs
1 -- | QuickCheck properties for the text library.
2
3 {-# LANGUAGE BangPatterns, FlexibleInstances, OverloadedStrings,
4 ScopedTypeVariables, TypeSynonymInstances #-}
5 {-# OPTIONS_GHC -fno-enable-rewrite-rules -fno-warn-missing-signatures #-}
6 module Tests.Properties
7 (
8 tests
9 ) where
10
11 import Control.Applicative ((<$>), (<*>))
12 import Control.Arrow ((***), second)
13 import Data.Bits ((.&.))
14 import Data.Char (chr, isDigit, isHexDigit, isLower, isSpace, isLetter, isUpper, ord)
15 import Data.Int (Int8, Int16, Int32, Int64)
16 import Data.Monoid (Monoid(..))
17 import Data.String (IsString(fromString))
18 import Data.Text.Encoding.Error
19 import Data.Text.Foreign
20 import Data.Text.Internal.Encoding.Utf8
21 import Data.Text.Internal.Fusion.Size
22 import Data.Text.Internal.Search (indices)
23 import Data.Text.Lazy.Read as TL
24 import Data.Text.Read as T
25 import Data.Word (Word, Word8, Word16, Word32, Word64)
26 import Data.Maybe (mapMaybe)
27 import Numeric (showEFloat, showFFloat, showGFloat, showHex)
28 import Prelude hiding (replicate)
29 import Test.Framework (Test, testGroup)
30 import Test.Framework.Providers.QuickCheck2 (testProperty)
31 import Test.QuickCheck hiding ((.&.))
32 import Test.QuickCheck.Monadic
33 import Test.QuickCheck.Property (Property(..))
34 import Test.QuickCheck.Unicode (char)
35 import Tests.QuickCheckUtils
36 import Tests.Utils
37 import Text.Show.Functions ()
38 import qualified Control.Exception as Exception
39 import qualified Data.Bits as Bits (shiftL, shiftR)
40 import qualified Data.ByteString as B
41 import qualified Data.ByteString.Lazy as BL
42 import qualified Data.Char as C
43 import qualified Data.List as L
44 import qualified Data.Text as T
45 import qualified Data.Text.Encoding as E
46 import qualified Data.Text.IO as T
47 import qualified Data.Text.Internal.Fusion as S
48 import qualified Data.Text.Internal.Fusion.Common as S
49 import qualified Data.Text.Internal.Lazy.Fusion as SL
50 import qualified Data.Text.Internal.Lazy.Search as S (indices)
51 import qualified Data.Text.Internal.Unsafe.Shift as U
52 import qualified Data.Text.Lazy as TL
53 import qualified Data.Text.Lazy.Builder as TB
54 import qualified Data.Text.Lazy.Builder.Int as TB
55 import qualified Data.Text.Lazy.Builder.RealFloat as TB
56 import qualified Data.Text.Lazy.Encoding as EL
57 import qualified Data.Text.Lazy.IO as TL
58 import qualified System.IO as IO
59 import qualified Tests.Properties.Mul as Mul
60 import qualified Tests.SlowFunctions as Slow
61
62 t_pack_unpack = (T.unpack . T.pack) `eq` id
63 tl_pack_unpack = (TL.unpack . TL.pack) `eq` id
64 t_stream_unstream = (S.unstream . S.stream) `eq` id
65 tl_stream_unstream = (SL.unstream . SL.stream) `eq` id
66 t_reverse_stream t = (S.reverse . S.reverseStream) t === t
67 t_singleton c = [c] === (T.unpack . T.singleton) c
68 tl_singleton c = [c] === (TL.unpack . TL.singleton) c
69 tl_unstreamChunks x = f 11 x === f 1000 x
70 where f n = SL.unstreamChunks n . S.streamList
71 tl_chunk_unchunk = (TL.fromChunks . TL.toChunks) `eq` id
72 tl_from_to_strict = (TL.fromStrict . TL.toStrict) `eq` id
73
74 -- Note: this silently truncates code-points > 255 to 8-bit due to 'B.pack'
75 encodeL1 :: T.Text -> B.ByteString
76 encodeL1 = B.pack . map (fromIntegral . fromEnum) . T.unpack
77 encodeLazyL1 :: TL.Text -> BL.ByteString
78 encodeLazyL1 = BL.fromChunks . map encodeL1 . TL.toChunks
79
80 t_ascii t = E.decodeASCII (E.encodeUtf8 a) === a
81 where a = T.map (\c -> chr (ord c `mod` 128)) t
82 tl_ascii t = EL.decodeASCII (EL.encodeUtf8 a) === a
83 where a = TL.map (\c -> chr (ord c `mod` 128)) t
84 t_latin1 t = E.decodeLatin1 (encodeL1 a) === a
85 where a = T.map (\c -> chr (ord c `mod` 256)) t
86 tl_latin1 t = EL.decodeLatin1 (encodeLazyL1 a) === a
87 where a = TL.map (\c -> chr (ord c `mod` 256)) t
88 t_utf8 = forAll genUnicode $ (E.decodeUtf8 . E.encodeUtf8) `eq` id
89 t_utf8' = forAll genUnicode $ (E.decodeUtf8' . E.encodeUtf8) `eq` (id . Right)
90 tl_utf8 = forAll genUnicode $ (EL.decodeUtf8 . EL.encodeUtf8) `eq` id
91 tl_utf8' = forAll genUnicode $ (EL.decodeUtf8' . EL.encodeUtf8) `eq` (id . Right)
92 t_utf16LE = forAll genUnicode $ (E.decodeUtf16LE . E.encodeUtf16LE) `eq` id
93 tl_utf16LE = forAll genUnicode $ (EL.decodeUtf16LE . EL.encodeUtf16LE) `eq` id
94 t_utf16BE = forAll genUnicode $ (E.decodeUtf16BE . E.encodeUtf16BE) `eq` id
95 tl_utf16BE = forAll genUnicode $ (EL.decodeUtf16BE . EL.encodeUtf16BE) `eq` id
96 t_utf32LE = forAll genUnicode $ (E.decodeUtf32LE . E.encodeUtf32LE) `eq` id
97 tl_utf32LE = forAll genUnicode $ (EL.decodeUtf32LE . EL.encodeUtf32LE) `eq` id
98 t_utf32BE = forAll genUnicode $ (E.decodeUtf32BE . E.encodeUtf32BE) `eq` id
99 tl_utf32BE = forAll genUnicode $ (EL.decodeUtf32BE . EL.encodeUtf32BE) `eq` id
100
101 t_utf8_incr = forAll genUnicode $ \s (Positive n) -> (recode n `eq` id) s
102 where recode n = T.concat . map fst . feedChunksOf n E.streamDecodeUtf8 .
103 E.encodeUtf8
104
105 feedChunksOf :: Int -> (B.ByteString -> E.Decoding) -> B.ByteString
106 -> [(T.Text, B.ByteString)]
107 feedChunksOf n f bs
108 | B.null bs = []
109 | otherwise = let (x,y) = B.splitAt n bs
110 E.Some t b f' = f x
111 in (t,b) : feedChunksOf n f' y
112
113 t_utf8_undecoded = forAll genUnicode $ \t ->
114 let b = E.encodeUtf8 t
115 ls = concatMap (leftover . E.encodeUtf8 . T.singleton) . T.unpack $ t
116 leftover = (++ [B.empty]) . init . tail . B.inits
117 in (map snd . feedChunksOf 1 E.streamDecodeUtf8) b === ls
118
119 data Badness = Solo | Leading | Trailing
120 deriving (Eq, Show)
121
122 instance Arbitrary Badness where
123 arbitrary = elements [Solo, Leading, Trailing]
124
125 t_utf8_err :: Badness -> DecodeErr -> Property
126 t_utf8_err bad de = do
127 let gen = case bad of
128 Solo -> genInvalidUTF8
129 Leading -> B.append <$> genInvalidUTF8 <*> genUTF8
130 Trailing -> B.append <$> genUTF8 <*> genInvalidUTF8
131 genUTF8 = E.encodeUtf8 <$> genUnicode
132 forAll gen $ \bs -> MkProperty $ do
133 onErr <- genDecodeErr de
134 unProperty . monadicIO $ do
135 l <- run $ let len = T.length (E.decodeUtf8With onErr bs)
136 in (len `seq` return (Right len)) `Exception.catch`
137 (\(e::UnicodeException) -> return (Left e))
138 assert $ case l of
139 Left err -> length (show err) >= 0
140 Right _ -> de /= Strict
141
142 t_utf8_err' :: B.ByteString -> Property
143 t_utf8_err' bs = monadicIO . assert $ case E.decodeUtf8' bs of
144 Left err -> length (show err) >= 0
145 Right t -> T.length t >= 0
146
147 genInvalidUTF8 :: Gen B.ByteString
148 genInvalidUTF8 = B.pack <$> oneof [
149 -- invalid leading byte of a 2-byte sequence
150 (:) <$> choose (0xC0, 0xC1) <*> upTo 1 contByte
151 -- invalid leading byte of a 4-byte sequence
152 , (:) <$> choose (0xF5, 0xFF) <*> upTo 3 contByte
153 -- 4-byte sequence greater than U+10FFFF
154 , do k <- choose (0x11, 0x13)
155 let w0 = 0xF0 + (k `Bits.shiftR` 2)
156 w1 = 0x80 + ((k .&. 3) `Bits.shiftL` 4)
157 ([w0,w1]++) <$> vectorOf 2 contByte
158 -- continuation bytes without a start byte
159 , listOf1 contByte
160 -- short 2-byte sequence
161 , (:[]) <$> choose (0xC2, 0xDF)
162 -- short 3-byte sequence
163 , (:) <$> choose (0xE0, 0xEF) <*> upTo 1 contByte
164 -- short 4-byte sequence
165 , (:) <$> choose (0xF0, 0xF4) <*> upTo 2 contByte
166 -- overlong encoding
167 , do k <- choose (0,0xFFFF)
168 let c = chr k
169 case k of
170 _ | k < 0x80 -> oneof [ let (w,x) = ord2 c in return [w,x]
171 , let (w,x,y) = ord3 c in return [w,x,y]
172 , let (w,x,y,z) = ord4 c in return [w,x,y,z] ]
173 | k < 0x7FF -> oneof [ let (w,x,y) = ord3 c in return [w,x,y]
174 , let (w,x,y,z) = ord4 c in return [w,x,y,z] ]
175 | otherwise -> let (w,x,y,z) = ord4 c in return [w,x,y,z]
176 ]
177 where
178 contByte = (0x80 +) <$> choose (0, 0x3f)
179 upTo n gen = do
180 k <- choose (0,n)
181 vectorOf k gen
182
183 s_Eq s = (s==) `eq` ((S.streamList s==) . S.streamList)
184 where _types = s :: String
185 sf_Eq p s =
186 ((L.filter p s==) . L.filter p) `eq`
187 (((S.filter p $ S.streamList s)==) . S.filter p . S.streamList)
188 t_Eq s = (s==) `eq` ((T.pack s==) . T.pack)
189 tl_Eq s = (s==) `eq` ((TL.pack s==) . TL.pack)
190 s_Ord s = (compare s) `eq` (compare (S.streamList s) . S.streamList)
191 where _types = s :: String
192 sf_Ord p s =
193 ((compare $ L.filter p s) . L.filter p) `eq`
194 (compare (S.filter p $ S.streamList s) . S.filter p . S.streamList)
195 t_Ord s = (compare s) `eq` (compare (T.pack s) . T.pack)
196 tl_Ord s = (compare s) `eq` (compare (TL.pack s) . TL.pack)
197 t_Read = id `eq` (T.unpack . read . show)
198 tl_Read = id `eq` (TL.unpack . read . show)
199 t_Show = show `eq` (show . T.pack)
200 tl_Show = show `eq` (show . TL.pack)
201 t_mappend s = mappend s`eqP` (unpackS . mappend (T.pack s))
202 tl_mappend s = mappend s`eqP` (unpackS . mappend (TL.pack s))
203 t_mconcat = unsquare $
204 mconcat `eq` (unpackS . mconcat . L.map T.pack)
205 tl_mconcat = unsquare $
206 mconcat `eq` (unpackS . mconcat . L.map TL.pack)
207 t_mempty = mempty === (unpackS (mempty :: T.Text))
208 tl_mempty = mempty === (unpackS (mempty :: TL.Text))
209 t_IsString = fromString `eqP` (T.unpack . fromString)
210 tl_IsString = fromString `eqP` (TL.unpack . fromString)
211
212 s_cons x = (x:) `eqP` (unpackS . S.cons x)
213 s_cons_s x = (x:) `eqP` (unpackS . S.unstream . S.cons x)
214 sf_cons p x = ((x:) . L.filter p) `eqP` (unpackS . S.cons x . S.filter p)
215 t_cons x = (x:) `eqP` (unpackS . T.cons x)
216 tl_cons x = (x:) `eqP` (unpackS . TL.cons x)
217 s_snoc x = (++ [x]) `eqP` (unpackS . (flip S.snoc) x)
218 t_snoc x = (++ [x]) `eqP` (unpackS . (flip T.snoc) x)
219 tl_snoc x = (++ [x]) `eqP` (unpackS . (flip TL.snoc) x)
220 s_append s = (s++) `eqP` (unpackS . S.append (S.streamList s))
221 s_append_s s = (s++) `eqP`
222 (unpackS . S.unstream . S.append (S.streamList s))
223 sf_append p s = (L.filter p s++) `eqP`
224 (unpackS . S.append (S.filter p $ S.streamList s))
225 t_append s = (s++) `eqP` (unpackS . T.append (packS s))
226
227 uncons (x:xs) = Just (x,xs)
228 uncons _ = Nothing
229
230 s_uncons = uncons `eqP` (fmap (second unpackS) . S.uncons)
231 sf_uncons p = (uncons . L.filter p) `eqP`
232 (fmap (second unpackS) . S.uncons . S.filter p)
233 t_uncons = uncons `eqP` (fmap (second unpackS) . T.uncons)
234 tl_uncons = uncons `eqP` (fmap (second unpackS) . TL.uncons)
235 s_head = head `eqP` S.head
236 sf_head p = (head . L.filter p) `eqP` (S.head . S.filter p)
237 t_head = head `eqP` T.head
238 tl_head = head `eqP` TL.head
239 s_last = last `eqP` S.last
240 sf_last p = (last . L.filter p) `eqP` (S.last . S.filter p)
241 t_last = last `eqP` T.last
242 tl_last = last `eqP` TL.last
243 s_tail = tail `eqP` (unpackS . S.tail)
244 s_tail_s = tail `eqP` (unpackS . S.unstream . S.tail)
245 sf_tail p = (tail . L.filter p) `eqP` (unpackS . S.tail . S.filter p)
246 t_tail = tail `eqP` (unpackS . T.tail)
247 tl_tail = tail `eqP` (unpackS . TL.tail)
248 s_init = init `eqP` (unpackS . S.init)
249 s_init_s = init `eqP` (unpackS . S.unstream . S.init)
250 sf_init p = (init . L.filter p) `eqP` (unpackS . S.init . S.filter p)
251 t_init = init `eqP` (unpackS . T.init)
252 tl_init = init `eqP` (unpackS . TL.init)
253 s_null = null `eqP` S.null
254 sf_null p = (null . L.filter p) `eqP` (S.null . S.filter p)
255 t_null = null `eqP` T.null
256 tl_null = null `eqP` TL.null
257 s_length = length `eqP` S.length
258 sf_length p = (length . L.filter p) `eqP` (S.length . S.filter p)
259 sl_length = (fromIntegral . length) `eqP` SL.length
260 t_length = length `eqP` T.length
261 tl_length = L.genericLength `eqP` TL.length
262 t_compareLength t = (compare (T.length t)) `eq` T.compareLength t
263 tl_compareLength t= (compare (TL.length t)) `eq` TL.compareLength t
264
265 s_map f = map f `eqP` (unpackS . S.map f)
266 s_map_s f = map f `eqP` (unpackS . S.unstream . S.map f)
267 sf_map p f = (map f . L.filter p) `eqP` (unpackS . S.map f . S.filter p)
268 t_map f = map f `eqP` (unpackS . T.map f)
269 tl_map f = map f `eqP` (unpackS . TL.map f)
270 s_intercalate c = unsquare $
271 L.intercalate c `eq`
272 (unpackS . S.intercalate (packS c) . map packS)
273 t_intercalate c = unsquare $
274 L.intercalate c `eq`
275 (unpackS . T.intercalate (packS c) . map packS)
276 tl_intercalate c = unsquare $
277 L.intercalate c `eq`
278 (unpackS . TL.intercalate (TL.pack c) . map TL.pack)
279 s_intersperse c = L.intersperse c `eqP`
280 (unpackS . S.intersperse c)
281 s_intersperse_s c = L.intersperse c `eqP`
282 (unpackS . S.unstream . S.intersperse c)
283 sf_intersperse p c= (L.intersperse c . L.filter p) `eqP`
284 (unpackS . S.intersperse c . S.filter p)
285 t_intersperse c = unsquare $
286 L.intersperse c `eqP` (unpackS . T.intersperse c)
287 tl_intersperse c = unsquare $
288 L.intersperse c `eqP` (unpackS . TL.intersperse c)
289 t_transpose = unsquare $
290 L.transpose `eq` (map unpackS . T.transpose . map packS)
291 tl_transpose = unsquare $
292 L.transpose `eq` (map unpackS . TL.transpose . map TL.pack)
293 t_reverse = L.reverse `eqP` (unpackS . T.reverse)
294 tl_reverse = L.reverse `eqP` (unpackS . TL.reverse)
295 t_reverse_short n = L.reverse `eqP` (unpackS . S.reverse . shorten n . S.stream)
296
297 t_replace s d = (L.intercalate d . splitOn s) `eqP`
298 (unpackS . T.replace (T.pack s) (T.pack d))
299 tl_replace s d = (L.intercalate d . splitOn s) `eqP`
300 (unpackS . TL.replace (TL.pack s) (TL.pack d))
301
302 splitOn :: (Eq a) => [a] -> [a] -> [[a]]
303 splitOn pat src0
304 | l == 0 = error "splitOn: empty"
305 | otherwise = go src0
306 where
307 l = length pat
308 go src = search 0 src
309 where
310 search _ [] = [src]
311 search !n s@(_:s')
312 | pat `L.isPrefixOf` s = take n src : go (drop l s)
313 | otherwise = search (n+1) s'
314
315 s_toCaseFold_length xs = S.length (S.toCaseFold s) >= length xs
316 where s = S.streamList xs
317 sf_toCaseFold_length p xs =
318 (S.length . S.toCaseFold . S.filter p $ s) >= (length . L.filter p $ xs)
319 where s = S.streamList xs
320 t_toCaseFold_length t = T.length (T.toCaseFold t) >= T.length t
321 tl_toCaseFold_length t = TL.length (TL.toCaseFold t) >= TL.length t
322 t_toLower_length t = T.length (T.toLower t) >= T.length t
323 t_toLower_lower t = p (T.toLower t) >= p t
324 where p = T.length . T.filter isLower
325 tl_toLower_lower t = p (TL.toLower t) >= p t
326 where p = TL.length . TL.filter isLower
327 t_toUpper_length t = T.length (T.toUpper t) >= T.length t
328 t_toUpper_upper t = p (T.toUpper t) >= p t
329 where p = T.length . T.filter isUpper
330 tl_toUpper_upper t = p (TL.toUpper t) >= p t
331 where p = TL.length . TL.filter isUpper
332 t_toTitle_title t = all (<= 1) (caps w)
333 where caps = fmap (T.length . T.filter isUpper) . T.words . T.toTitle
334 -- TIL: there exist uppercase-only letters
335 w = T.filter (\c -> if C.isUpper c then C.toLower c /= c else True) t
336 t_toTitle_1stNotLower = and . notLow . T.toTitle . T.filter stable
337 where notLow = mapMaybe (fmap (not . isLower) . (T.find isLetter)) . T.words
338 -- Surprise! The Spanish/Portuguese ordinal indicators changed
339 -- from category Ll (letter, lowercase) to Lo (letter, other)
340 -- in Unicode 7.0
341 -- Oh, and there exist lowercase-only letters (see previous test)
342 stable c = if isLower c
343 then C.toUpper c /= c
344 else c /= '\170' && c /= '\186'
345
346 justifyLeft k c xs = xs ++ L.replicate (k - length xs) c
347 justifyRight m n xs = L.replicate (m - length xs) n ++ xs
348 center k c xs
349 | len >= k = xs
350 | otherwise = L.replicate l c ++ xs ++ L.replicate r c
351 where len = length xs
352 d = k - len
353 r = d `div` 2
354 l = d - r
355
356 s_justifyLeft k c = justifyLeft j c `eqP` (unpackS . S.justifyLeftI j c)
357 where j = fromIntegral (k :: Word8)
358 s_justifyLeft_s k c = justifyLeft j c `eqP`
359 (unpackS . S.unstream . S.justifyLeftI j c)
360 where j = fromIntegral (k :: Word8)
361 sf_justifyLeft p k c = (justifyLeft j c . L.filter p) `eqP`
362 (unpackS . S.justifyLeftI j c . S.filter p)
363 where j = fromIntegral (k :: Word8)
364 t_justifyLeft k c = justifyLeft j c `eqP` (unpackS . T.justifyLeft j c)
365 where j = fromIntegral (k :: Word8)
366 tl_justifyLeft k c = justifyLeft j c `eqP`
367 (unpackS . TL.justifyLeft (fromIntegral j) c)
368 where j = fromIntegral (k :: Word8)
369 t_justifyRight k c = justifyRight j c `eqP` (unpackS . T.justifyRight j c)
370 where j = fromIntegral (k :: Word8)
371 tl_justifyRight k c = justifyRight j c `eqP`
372 (unpackS . TL.justifyRight (fromIntegral j) c)
373 where j = fromIntegral (k :: Word8)
374 t_center k c = center j c `eqP` (unpackS . T.center j c)
375 where j = fromIntegral (k :: Word8)
376 tl_center k c = center j c `eqP` (unpackS . TL.center (fromIntegral j) c)
377 where j = fromIntegral (k :: Word8)
378
379 sf_foldl p f z = (L.foldl f z . L.filter p) `eqP` (S.foldl f z . S.filter p)
380 where _types = f :: Char -> Char -> Char
381 t_foldl f z = L.foldl f z `eqP` (T.foldl f z)
382 where _types = f :: Char -> Char -> Char
383 tl_foldl f z = L.foldl f z `eqP` (TL.foldl f z)
384 where _types = f :: Char -> Char -> Char
385 sf_foldl' p f z = (L.foldl' f z . L.filter p) `eqP`
386 (S.foldl' f z . S.filter p)
387 where _types = f :: Char -> Char -> Char
388 t_foldl' f z = L.foldl' f z `eqP` T.foldl' f z
389 where _types = f :: Char -> Char -> Char
390 tl_foldl' f z = L.foldl' f z `eqP` TL.foldl' f z
391 where _types = f :: Char -> Char -> Char
392 sf_foldl1 p f = (L.foldl1 f . L.filter p) `eqP` (S.foldl1 f . S.filter p)
393 t_foldl1 f = L.foldl1 f `eqP` T.foldl1 f
394 tl_foldl1 f = L.foldl1 f `eqP` TL.foldl1 f
395 sf_foldl1' p f = (L.foldl1' f . L.filter p) `eqP` (S.foldl1' f . S.filter p)
396 t_foldl1' f = L.foldl1' f `eqP` T.foldl1' f
397 tl_foldl1' f = L.foldl1' f `eqP` TL.foldl1' f
398 sf_foldr p f z = (L.foldr f z . L.filter p) `eqP` (S.foldr f z . S.filter p)
399 where _types = f :: Char -> Char -> Char
400 t_foldr f z = L.foldr f z `eqP` T.foldr f z
401 where _types = f :: Char -> Char -> Char
402 tl_foldr f z = unsquare $
403 L.foldr f z `eqP` TL.foldr f z
404 where _types = f :: Char -> Char -> Char
405 sf_foldr1 p f = unsquare $
406 (L.foldr1 f . L.filter p) `eqP` (S.foldr1 f . S.filter p)
407 t_foldr1 f = L.foldr1 f `eqP` T.foldr1 f
408 tl_foldr1 f = unsquare $
409 L.foldr1 f `eqP` TL.foldr1 f
410
411 s_concat_s = unsquare $
412 L.concat `eq` (unpackS . S.unstream . S.concat . map packS)
413 sf_concat p = unsquare $
414 (L.concat . map (L.filter p)) `eq`
415 (unpackS . S.concat . map (S.filter p . packS))
416 t_concat = unsquare $
417 L.concat `eq` (unpackS . T.concat . map packS)
418 tl_concat = unsquare $
419 L.concat `eq` (unpackS . TL.concat . map TL.pack)
420 sf_concatMap p f = unsquare $ (L.concatMap f . L.filter p) `eqP`
421 (unpackS . S.concatMap (packS . f) . S.filter p)
422 t_concatMap f = unsquare $
423 L.concatMap f `eqP` (unpackS . T.concatMap (packS . f))
424 tl_concatMap f = unsquare $
425 L.concatMap f `eqP` (unpackS . TL.concatMap (TL.pack . f))
426 sf_any q p = (L.any p . L.filter q) `eqP` (S.any p . S.filter q)
427 t_any p = L.any p `eqP` T.any p
428 tl_any p = L.any p `eqP` TL.any p
429 sf_all q p = (L.all p . L.filter q) `eqP` (S.all p . S.filter q)
430 t_all p = L.all p `eqP` T.all p
431 tl_all p = L.all p `eqP` TL.all p
432 sf_maximum p = (L.maximum . L.filter p) `eqP` (S.maximum . S.filter p)
433 t_maximum = L.maximum `eqP` T.maximum
434 tl_maximum = L.maximum `eqP` TL.maximum
435 sf_minimum p = (L.minimum . L.filter p) `eqP` (S.minimum . S.filter p)
436 t_minimum = L.minimum `eqP` T.minimum
437 tl_minimum = L.minimum `eqP` TL.minimum
438
439 sf_scanl p f z = (L.scanl f z . L.filter p) `eqP`
440 (unpackS . S.scanl f z . S.filter p)
441 t_scanl f z = L.scanl f z `eqP` (unpackS . T.scanl f z)
442 tl_scanl f z = L.scanl f z `eqP` (unpackS . TL.scanl f z)
443 t_scanl1 f = L.scanl1 f `eqP` (unpackS . T.scanl1 f)
444 tl_scanl1 f = L.scanl1 f `eqP` (unpackS . TL.scanl1 f)
445 t_scanr f z = L.scanr f z `eqP` (unpackS . T.scanr f z)
446 tl_scanr f z = L.scanr f z `eqP` (unpackS . TL.scanr f z)
447 t_scanr1 f = L.scanr1 f `eqP` (unpackS . T.scanr1 f)
448 tl_scanr1 f = L.scanr1 f `eqP` (unpackS . TL.scanr1 f)
449
450 t_mapAccumL f z = L.mapAccumL f z `eqP` (second unpackS . T.mapAccumL f z)
451 where _types = f :: Int -> Char -> (Int,Char)
452 tl_mapAccumL f z = L.mapAccumL f z `eqP` (second unpackS . TL.mapAccumL f z)
453 where _types = f :: Int -> Char -> (Int,Char)
454 t_mapAccumR f z = L.mapAccumR f z `eqP` (second unpackS . T.mapAccumR f z)
455 where _types = f :: Int -> Char -> (Int,Char)
456 tl_mapAccumR f z = L.mapAccumR f z `eqP` (second unpackS . TL.mapAccumR f z)
457 where _types = f :: Int -> Char -> (Int,Char)
458
459 tl_repeat n = (L.take m . L.repeat) `eq`
460 (unpackS . TL.take (fromIntegral m) . TL.repeat)
461 where m = fromIntegral (n :: Word8)
462
463 replicate n l = concat (L.replicate n l)
464
465 s_replicate n = replicate m `eq`
466 (unpackS . S.replicateI (fromIntegral m) . packS)
467 where m = fromIntegral (n :: Word8)
468 t_replicate n = replicate m `eq` (unpackS . T.replicate m . packS)
469 where m = fromIntegral (n :: Word8)
470 tl_replicate n = replicate m `eq`
471 (unpackS . TL.replicate (fromIntegral m) . packS)
472 where m = fromIntegral (n :: Word8)
473
474 tl_cycle n = (L.take m . L.cycle) `eq`
475 (unpackS . TL.take (fromIntegral m) . TL.cycle . packS)
476 where m = fromIntegral (n :: Word8)
477
478 tl_iterate f n = (L.take m . L.iterate f) `eq`
479 (unpackS . TL.take (fromIntegral m) . TL.iterate f)
480 where m = fromIntegral (n :: Word8)
481
482 unf :: Int -> Char -> Maybe (Char, Char)
483 unf n c | fromEnum c * 100 > n = Nothing
484 | otherwise = Just (c, succ c)
485
486 t_unfoldr n = L.unfoldr (unf m) `eq` (unpackS . T.unfoldr (unf m))
487 where m = fromIntegral (n :: Word16)
488 tl_unfoldr n = L.unfoldr (unf m) `eq` (unpackS . TL.unfoldr (unf m))
489 where m = fromIntegral (n :: Word16)
490 t_unfoldrN n m = (L.take i . L.unfoldr (unf j)) `eq`
491 (unpackS . T.unfoldrN i (unf j))
492 where i = fromIntegral (n :: Word16)
493 j = fromIntegral (m :: Word16)
494 tl_unfoldrN n m = (L.take i . L.unfoldr (unf j)) `eq`
495 (unpackS . TL.unfoldrN (fromIntegral i) (unf j))
496 where i = fromIntegral (n :: Word16)
497 j = fromIntegral (m :: Word16)
498
499 unpack2 :: (Stringy s) => (s,s) -> (String,String)
500 unpack2 = unpackS *** unpackS
501
502 s_take n = L.take n `eqP` (unpackS . S.take n)
503 s_take_s m = L.take n `eqP` (unpackS . S.unstream . S.take n)
504 where n = small m
505 sf_take p n = (L.take n . L.filter p) `eqP`
506 (unpackS . S.take n . S.filter p)
507 t_take n = L.take n `eqP` (unpackS . T.take n)
508 t_takeEnd n = (L.reverse . L.take n . L.reverse) `eqP`
509 (unpackS . T.takeEnd n)
510 tl_take n = L.take n `eqP` (unpackS . TL.take (fromIntegral n))
511 tl_takeEnd n = (L.reverse . L.take (fromIntegral n) . L.reverse) `eqP`
512 (unpackS . TL.takeEnd n)
513 s_drop n = L.drop n `eqP` (unpackS . S.drop n)
514 s_drop_s m = L.drop n `eqP` (unpackS . S.unstream . S.drop n)
515 where n = small m
516 sf_drop p n = (L.drop n . L.filter p) `eqP`
517 (unpackS . S.drop n . S.filter p)
518 t_drop n = L.drop n `eqP` (unpackS . T.drop n)
519 t_dropEnd n = (L.reverse . L.drop n . L.reverse) `eqP`
520 (unpackS . T.dropEnd n)
521 tl_drop n = L.drop n `eqP` (unpackS . TL.drop (fromIntegral n))
522 tl_dropEnd n = (L.reverse . L.drop n . L.reverse) `eqP`
523 (unpackS . TL.dropEnd (fromIntegral n))
524 s_take_drop m = (L.take n . L.drop n) `eqP` (unpackS . S.take n . S.drop n)
525 where n = small m
526 s_take_drop_s m = (L.take n . L.drop n) `eqP`
527 (unpackS . S.unstream . S.take n . S.drop n)
528 where n = small m
529 s_takeWhile p = L.takeWhile p `eqP` (unpackS . S.takeWhile p)
530 s_takeWhile_s p = L.takeWhile p `eqP` (unpackS . S.unstream . S.takeWhile p)
531 sf_takeWhile q p = (L.takeWhile p . L.filter q) `eqP`
532 (unpackS . S.takeWhile p . S.filter q)
533 noMatch = do
534 c <- char
535 d <- suchThat char (/= c)
536 return (c,d)
537 t_takeWhile p = L.takeWhile p `eqP` (unpackS . T.takeWhile p)
538 tl_takeWhile p = L.takeWhile p `eqP` (unpackS . TL.takeWhile p)
539 t_takeWhileEnd p = (L.reverse . L.takeWhile p . L.reverse) `eqP`
540 (unpackS . T.takeWhileEnd p)
541 t_takeWhileEnd_null n = forAll noMatch $ \(c,d) -> T.null $
542 T.takeWhileEnd (==d) (T.replicate n (T.singleton c))
543 tl_takeWhileEnd p = (L.reverse . L.takeWhile p . L.reverse) `eqP`
544 (unpackS . TL.takeWhileEnd p)
545 TL.takeWhileEnd (==d) (TL.replicate n (TL.singleton c))
546 s_dropWhile p = L.dropWhile p `eqP` (unpackS . S.dropWhile p)
547 s_dropWhile_s p = L.dropWhile p `eqP` (unpackS . S.unstream . S.dropWhile p)
548 sf_dropWhile q p = (L.dropWhile p . L.filter q) `eqP`
549 (unpackS . S.dropWhile p . S.filter q)
550 t_dropWhile p = L.dropWhile p `eqP` (unpackS . T.dropWhile p)
551 tl_dropWhile p = L.dropWhile p `eqP` (unpackS . S.dropWhile p)
552 t_dropWhileEnd p = (L.reverse . L.dropWhile p . L.reverse) `eqP`
553 (unpackS . T.dropWhileEnd p)
554 tl_dropWhileEnd p = (L.reverse . L.dropWhile p . L.reverse) `eqP`
555 (unpackS . TL.dropWhileEnd p)
556 t_dropAround p = (L.dropWhile p . L.reverse . L.dropWhile p . L.reverse)
557 `eqP` (unpackS . T.dropAround p)
558 tl_dropAround p = (L.dropWhile p . L.reverse . L.dropWhile p . L.reverse)
559 `eqP` (unpackS . TL.dropAround p)
560 t_stripStart = T.dropWhile isSpace `eq` T.stripStart
561 tl_stripStart = TL.dropWhile isSpace `eq` TL.stripStart
562 t_stripEnd = T.dropWhileEnd isSpace `eq` T.stripEnd
563 tl_stripEnd = TL.dropWhileEnd isSpace `eq` TL.stripEnd
564 t_strip = T.dropAround isSpace `eq` T.strip
565 tl_strip = TL.dropAround isSpace `eq` TL.strip
566 t_splitAt n = L.splitAt n `eqP` (unpack2 . T.splitAt n)
567 tl_splitAt n = L.splitAt n `eqP` (unpack2 . TL.splitAt (fromIntegral n))
568 t_span p = L.span p `eqP` (unpack2 . T.span p)
569 tl_span p = L.span p `eqP` (unpack2 . TL.span p)
570
571 t_breakOn_id s = squid `eq` (uncurry T.append . T.breakOn s)
572 where squid t | T.null s = error "empty"
573 | otherwise = t
574 tl_breakOn_id s = squid `eq` (uncurry TL.append . TL.breakOn s)
575 where squid t | TL.null s = error "empty"
576 | otherwise = t
577 t_breakOn_start (NotEmpty s) t =
578 let (k,m) = T.breakOn s t
579 in k `T.isPrefixOf` t && (T.null m || s `T.isPrefixOf` m)
580 tl_breakOn_start (NotEmpty s) t =
581 let (k,m) = TL.breakOn s t
582 in k `TL.isPrefixOf` t && TL.null m || s `TL.isPrefixOf` m
583 t_breakOnEnd_end (NotEmpty s) t =
584 let (m,k) = T.breakOnEnd s t
585 in k `T.isSuffixOf` t && (T.null m || s `T.isSuffixOf` m)
586 tl_breakOnEnd_end (NotEmpty s) t =
587 let (m,k) = TL.breakOnEnd s t
588 in k `TL.isSuffixOf` t && (TL.null m || s `TL.isSuffixOf` m)
589 t_break p = L.break p `eqP` (unpack2 . T.break p)
590 tl_break p = L.break p `eqP` (unpack2 . TL.break p)
591 t_group = L.group `eqP` (map unpackS . T.group)
592 tl_group = L.group `eqP` (map unpackS . TL.group)
593 t_groupBy p = L.groupBy p `eqP` (map unpackS . T.groupBy p)
594 tl_groupBy p = L.groupBy p `eqP` (map unpackS . TL.groupBy p)
595 t_inits = L.inits `eqP` (map unpackS . T.inits)
596 tl_inits = L.inits `eqP` (map unpackS . TL.inits)
597 t_tails = L.tails `eqP` (map unpackS . T.tails)
598 tl_tails = unsquare $
599 L.tails `eqP` (map unpackS . TL.tails)
600 t_findAppendId = unsquare $ \(NotEmpty s) ts ->
601 let t = T.intercalate s ts
602 in all (==t) $ map (uncurry T.append) (T.breakOnAll s t)
603 tl_findAppendId = unsquare $ \(NotEmpty s) ts ->
604 let t = TL.intercalate s ts
605 in all (==t) $ map (uncurry TL.append) (TL.breakOnAll s t)
606 t_findContains = unsquare $ \(NotEmpty s) ->
607 all (T.isPrefixOf s . snd) . T.breakOnAll s . T.intercalate s
608 tl_findContains = unsquare $ \(NotEmpty s) -> all (TL.isPrefixOf s . snd) .
609 TL.breakOnAll s . TL.intercalate s
610 sl_filterCount c = (L.genericLength . L.filter (==c)) `eqP` SL.countChar c
611 t_findCount s = (L.length . T.breakOnAll s) `eq` T.count s
612 tl_findCount s = (L.genericLength . TL.breakOnAll s) `eq` TL.count s
613
614 t_splitOn_split s = unsquare $
615 (T.splitOn s `eq` Slow.splitOn s) . T.intercalate s
616 tl_splitOn_split s = unsquare $
617 ((TL.splitOn (TL.fromStrict s) . TL.fromStrict) `eq`
618 (map TL.fromStrict . T.splitOn s)) . T.intercalate s
619 t_splitOn_i (NotEmpty t) = id `eq` (T.intercalate t . T.splitOn t)
620 tl_splitOn_i (NotEmpty t) = id `eq` (TL.intercalate t . TL.splitOn t)
621
622 t_split p = split p `eqP` (map unpackS . T.split p)
623 t_split_count c = (L.length . T.split (==c)) `eq`
624 ((1+) . T.count (T.singleton c))
625 t_split_splitOn c = T.split (==c) `eq` T.splitOn (T.singleton c)
626 tl_split p = split p `eqP` (map unpackS . TL.split p)
627
628 split :: (a -> Bool) -> [a] -> [[a]]
629 split _ [] = [[]]
630 split p xs = loop xs
631 where loop s | null s' = [l]
632 | otherwise = l : loop (tail s')
633 where (l, s') = break p s
634
635 t_chunksOf_same_lengths k = all ((==k) . T.length) . ini . T.chunksOf k
636 where ini [] = []
637 ini xs = init xs
638
639 t_chunksOf_length k t = len == T.length t || (k <= 0 && len == 0)
640 where len = L.sum . L.map T.length $ T.chunksOf k t
641
642 tl_chunksOf k = T.chunksOf k `eq` (map (T.concat . TL.toChunks) .
643 TL.chunksOf (fromIntegral k) . TL.fromStrict)
644
645 t_lines = L.lines `eqP` (map unpackS . T.lines)
646 tl_lines = L.lines `eqP` (map unpackS . TL.lines)
647 {-
648 t_lines' = lines' `eqP` (map unpackS . T.lines')
649 where lines' "" = []
650 lines' s = let (l, s') = break eol s
651 in l : case s' of
652 [] -> []
653 ('\r':'\n':s'') -> lines' s''
654 (_:s'') -> lines' s''
655 eol c = c == '\r' || c == '\n'
656 -}
657 t_words = L.words `eqP` (map unpackS . T.words)
658
659 tl_words = L.words `eqP` (map unpackS . TL.words)
660 t_unlines = unsquare $
661 L.unlines `eq` (unpackS . T.unlines . map packS)
662 tl_unlines = unsquare $
663 L.unlines `eq` (unpackS . TL.unlines . map packS)
664 t_unwords = unsquare $
665 L.unwords `eq` (unpackS . T.unwords . map packS)
666 tl_unwords = unsquare $
667 L.unwords `eq` (unpackS . TL.unwords . map packS)
668
669 s_isPrefixOf s = L.isPrefixOf s `eqP`
670 (S.isPrefixOf (S.stream $ packS s) . S.stream)
671 sf_isPrefixOf p s = (L.isPrefixOf s . L.filter p) `eqP`
672 (S.isPrefixOf (S.stream $ packS s) . S.filter p . S.stream)
673 t_isPrefixOf s = L.isPrefixOf s`eqP` T.isPrefixOf (packS s)
674 tl_isPrefixOf s = L.isPrefixOf s`eqP` TL.isPrefixOf (packS s)
675 t_isSuffixOf s = L.isSuffixOf s`eqP` T.isSuffixOf (packS s)
676 tl_isSuffixOf s = L.isSuffixOf s`eqP` TL.isSuffixOf (packS s)
677 t_isInfixOf s = L.isInfixOf s `eqP` T.isInfixOf (packS s)
678 tl_isInfixOf s = L.isInfixOf s `eqP` TL.isInfixOf (packS s)
679
680 t_stripPrefix s = (fmap packS . L.stripPrefix s) `eqP` T.stripPrefix (packS s)
681 tl_stripPrefix s = (fmap packS . L.stripPrefix s) `eqP` TL.stripPrefix (packS s)
682
683 stripSuffix p t = reverse `fmap` L.stripPrefix (reverse p) (reverse t)
684
685 t_stripSuffix s = (fmap packS . stripSuffix s) `eqP` T.stripSuffix (packS s)
686 tl_stripSuffix s = (fmap packS . stripSuffix s) `eqP` TL.stripSuffix (packS s)
687
688 commonPrefixes a0@(_:_) b0@(_:_) = Just (go a0 b0 [])
689 where go (a:as) (b:bs) ps
690 | a == b = go as bs (a:ps)
691 go as bs ps = (reverse ps,as,bs)
692 commonPrefixes _ _ = Nothing
693
694 t_commonPrefixes a b (NonEmpty p)
695 = commonPrefixes pa pb ==
696 repack `fmap` T.commonPrefixes (packS pa) (packS pb)
697 where repack (x,y,z) = (unpackS x,unpackS y,unpackS z)
698 pa = p ++ a
699 pb = p ++ b
700
701 tl_commonPrefixes a b (NonEmpty p)
702 = commonPrefixes pa pb ==
703 repack `fmap` TL.commonPrefixes (packS pa) (packS pb)
704 where repack (x,y,z) = (unpackS x,unpackS y,unpackS z)
705 pa = p ++ a
706 pb = p ++ b
707
708 sf_elem p c = (L.elem c . L.filter p) `eqP` (S.elem c . S.filter p)
709 sf_filter q p = (L.filter p . L.filter q) `eqP`
710 (unpackS . S.filter p . S.filter q)
711 t_filter p = L.filter p `eqP` (unpackS . T.filter p)
712 tl_filter p = L.filter p `eqP` (unpackS . TL.filter p)
713 sf_findBy q p = (L.find p . L.filter q) `eqP` (S.findBy p . S.filter q)
714 t_find p = L.find p `eqP` T.find p
715 tl_find p = L.find p `eqP` TL.find p
716 t_partition p = L.partition p `eqP` (unpack2 . T.partition p)
717 tl_partition p = L.partition p `eqP` (unpack2 . TL.partition p)
718
719 sf_index p s = forAll (choose (-l,l*2))
720 ((L.filter p s L.!!) `eq` S.index (S.filter p $ packS s))
721 where l = L.length s
722 t_index s = forAll (choose (-l,l*2)) ((s L.!!) `eq` T.index (packS s))
723 where l = L.length s
724
725 tl_index s = forAll (choose (-l,l*2))
726 ((s L.!!) `eq` (TL.index (packS s) . fromIntegral))
727 where l = L.length s
728
729 t_findIndex p = L.findIndex p `eqP` T.findIndex p
730 t_count (NotEmpty t) = (subtract 1 . L.length . T.splitOn t) `eq` T.count t
731 tl_count (NotEmpty t) = (subtract 1 . L.genericLength . TL.splitOn t) `eq`
732 TL.count t
733 t_zip s = L.zip s `eqP` T.zip (packS s)
734 tl_zip s = L.zip s `eqP` TL.zip (packS s)
735 sf_zipWith p c s = (L.zipWith c (L.filter p s) . L.filter p) `eqP`
736 (unpackS . S.zipWith c (S.filter p $ packS s) . S.filter p)
737 t_zipWith c s = L.zipWith c s `eqP` (unpackS . T.zipWith c (packS s))
738 tl_zipWith c s = L.zipWith c s `eqP` (unpackS . TL.zipWith c (packS s))
739
740 t_indices (NotEmpty s) = Slow.indices s `eq` indices s
741 tl_indices (NotEmpty s) = lazyIndices s `eq` S.indices s
742 where lazyIndices ss t = map fromIntegral $ Slow.indices (conc ss) (conc t)
743 conc = T.concat . TL.toChunks
744 t_indices_occurs = unsquare $ \(NotEmpty t) ts ->
745 let s = T.intercalate t ts
746 in Slow.indices t s === indices t s
747
748 -- Bit shifts.
749 shiftL w = forAll (choose (0,width-1)) $ \k -> Bits.shiftL w k == U.shiftL w k
750 where width = round (log (fromIntegral m) / log 2 :: Double)
751 (m,_) = (maxBound, m == w)
752 shiftR w = forAll (choose (0,width-1)) $ \k -> Bits.shiftR w k == U.shiftR w k
753 where width = round (log (fromIntegral m) / log 2 :: Double)
754 (m,_) = (maxBound, m == w)
755
756 shiftL_Int = shiftL :: Int -> Property
757 shiftL_Word16 = shiftL :: Word16 -> Property
758 shiftL_Word32 = shiftL :: Word32 -> Property
759 shiftR_Int = shiftR :: Int -> Property
760 shiftR_Word16 = shiftR :: Word16 -> Property
761 shiftR_Word32 = shiftR :: Word32 -> Property
762
763 -- Builder.
764
765 tb_singleton = id `eqP`
766 (unpackS . TB.toLazyText . mconcat . map TB.singleton)
767 tb_fromText = L.concat `eq` (unpackS . TB.toLazyText . mconcat .
768 map (TB.fromText . packS))
769 tb_associative s1 s2 s3 =
770 TB.toLazyText (b1 `mappend` (b2 `mappend` b3)) ==
771 TB.toLazyText ((b1 `mappend` b2) `mappend` b3)
772 where b1 = TB.fromText (packS s1)
773 b2 = TB.fromText (packS s2)
774 b3 = TB.fromText (packS s3)
775
776 -- Numeric builder stuff.
777
778 tb_decimal :: (Integral a, Show a) => a -> Bool
779 tb_decimal = (TB.toLazyText . TB.decimal) `eq` (TL.pack . show)
780
781 tb_decimal_integer (a::Integer) = tb_decimal a
782 tb_decimal_integer_big (Big a) = tb_decimal a
783 tb_decimal_int (a::Int) = tb_decimal a
784 tb_decimal_int8 (a::Int8) = tb_decimal a
785 tb_decimal_int16 (a::Int16) = tb_decimal a
786 tb_decimal_int32 (a::Int32) = tb_decimal a
787 tb_decimal_int64 (a::Int64) = tb_decimal a
788 tb_decimal_word (a::Word) = tb_decimal a
789 tb_decimal_word8 (a::Word8) = tb_decimal a
790 tb_decimal_word16 (a::Word16) = tb_decimal a
791 tb_decimal_word32 (a::Word32) = tb_decimal a
792 tb_decimal_word64 (a::Word64) = tb_decimal a
793
794 tb_decimal_big_int (BigBounded (a::Int)) = tb_decimal a
795 tb_decimal_big_int64 (BigBounded (a::Int64)) = tb_decimal a
796 tb_decimal_big_word (BigBounded (a::Word)) = tb_decimal a
797 tb_decimal_big_word64 (BigBounded (a::Word64)) = tb_decimal a
798
799 tb_hex :: (Integral a, Show a) => a -> Bool
800 tb_hex = (TB.toLazyText . TB.hexadecimal) `eq` (TL.pack . flip showHex "")
801
802 tb_hexadecimal_integer (a::Integer) = tb_hex a
803 tb_hexadecimal_int (a::Int) = tb_hex a
804 tb_hexadecimal_int8 (a::Int8) = tb_hex a
805 tb_hexadecimal_int16 (a::Int16) = tb_hex a
806 tb_hexadecimal_int32 (a::Int32) = tb_hex a
807 tb_hexadecimal_int64 (a::Int64) = tb_hex a
808 tb_hexadecimal_word (a::Word) = tb_hex a
809 tb_hexadecimal_word8 (a::Word8) = tb_hex a
810 tb_hexadecimal_word16 (a::Word16) = tb_hex a
811 tb_hexadecimal_word32 (a::Word32) = tb_hex a
812 tb_hexadecimal_word64 (a::Word64) = tb_hex a
813
814 tb_realfloat :: (RealFloat a, Show a) => a -> Bool
815 tb_realfloat = (TB.toLazyText . TB.realFloat) `eq` (TL.pack . show)
816
817 tb_realfloat_float (a::Float) = tb_realfloat a
818 tb_realfloat_double (a::Double) = tb_realfloat a
819
820 showFloat :: (RealFloat a) => TB.FPFormat -> Maybe Int -> a -> ShowS
821 showFloat TB.Exponent = showEFloat
822 showFloat TB.Fixed = showFFloat
823 showFloat TB.Generic = showGFloat
824
825 tb_formatRealFloat :: (RealFloat a, Show a) =>
826 a -> TB.FPFormat -> Precision a -> Property
827 tb_formatRealFloat a fmt prec =
828 TB.formatRealFloat fmt p a ===
829 TB.fromString (showFloat fmt p a "")
830 where p = precision a prec
831
832 tb_formatRealFloat_float (a::Float) = tb_formatRealFloat a
833 tb_formatRealFloat_double (a::Double) = tb_formatRealFloat a
834
835 -- Reading.
836
837 t_decimal (n::Int) s =
838 T.signed T.decimal (T.pack (show n) `T.append` t) === Right (n,t)
839 where t = T.dropWhile isDigit s
840 tl_decimal (n::Int) s =
841 TL.signed TL.decimal (TL.pack (show n) `TL.append` t) === Right (n,t)
842 where t = TL.dropWhile isDigit s
843 t_hexadecimal m s ox =
844 T.hexadecimal (T.concat [p, T.pack (showHex n ""), t]) === Right (n,t)
845 where t = T.dropWhile isHexDigit s
846 p = if ox then "0x" else ""
847 n = getPositive m :: Int
848 tl_hexadecimal m s ox =
849 TL.hexadecimal (TL.concat [p, TL.pack (showHex n ""), t]) === Right (n,t)
850 where t = TL.dropWhile isHexDigit s
851 p = if ox then "0x" else ""
852 n = getPositive m :: Int
853
854 isFloaty c = c `elem` ("+-.0123456789eE" :: String)
855
856 t_read_rational p tol (n::Double) s =
857 case p (T.pack (show n) `T.append` t) of
858 Left _err -> False
859 Right (n',t') -> t == t' && abs (n-n') <= tol
860 where t = T.dropWhile isFloaty s
861
862 tl_read_rational p tol (n::Double) s =
863 case p (TL.pack (show n) `TL.append` t) of
864 Left _err -> False
865 Right (n',t') -> t == t' && abs (n-n') <= tol
866 where t = TL.dropWhile isFloaty s
867
868 t_double = t_read_rational T.double 1e-13
869 tl_double = tl_read_rational TL.double 1e-13
870 t_rational = t_read_rational T.rational 1e-16
871 tl_rational = tl_read_rational TL.rational 1e-16
872
873 -- Input and output.
874
875 t_put_get = write_read T.unlines T.filter put get
876 where put h = withRedirect h IO.stdout . T.putStr
877 get h = withRedirect h IO.stdin T.getContents
878 tl_put_get = write_read TL.unlines TL.filter put get
879 where put h = withRedirect h IO.stdout . TL.putStr
880 get h = withRedirect h IO.stdin TL.getContents
881 t_write_read = write_read T.unlines T.filter T.hPutStr T.hGetContents
882 tl_write_read = write_read TL.unlines TL.filter TL.hPutStr TL.hGetContents
883
884 t_write_read_line e m b t = write_read head T.filter T.hPutStrLn
885 T.hGetLine e m b [t]
886 tl_write_read_line e m b t = write_read head TL.filter TL.hPutStrLn
887 TL.hGetLine e m b [t]
888
889 -- Low-level.
890
891 t_dropWord16 m t = dropWord16 m t `T.isSuffixOf` t
892 t_takeWord16 m t = takeWord16 m t `T.isPrefixOf` t
893 t_take_drop_16 m t = T.append (takeWord16 n t) (dropWord16 n t) === t
894 where n = small m
895 t_use_from t = monadicIO $ assert . (==t) =<< run (useAsPtr t fromPtr)
896
897 t_copy t = T.copy t === t
898
899 -- Regression tests.
900 s_filter_eq s = S.filter p t == S.streamList (filter p s)
901 where p = (/= S.last t)
902 t = S.streamList s
903
904 -- Make a stream appear shorter than it really is, to ensure that
905 -- functions that consume inaccurately sized streams behave
906 -- themselves.
907 shorten :: Int -> S.Stream a -> S.Stream a
908 shorten n t@(S.Stream arr off len)
909 | n > 0 = S.Stream arr off (smaller (exactSize n) len)
910 | otherwise = t
911
912 tests :: Test
913 tests =
914 testGroup "Properties" [
915 testGroup "creation/elimination" [
916 testProperty "t_pack_unpack" t_pack_unpack,
917 testProperty "tl_pack_unpack" tl_pack_unpack,
918 testProperty "t_stream_unstream" t_stream_unstream,
919 testProperty "tl_stream_unstream" tl_stream_unstream,
920 testProperty "t_reverse_stream" t_reverse_stream,
921 testProperty "t_singleton" t_singleton,
922 testProperty "tl_singleton" tl_singleton,
923 testProperty "tl_unstreamChunks" tl_unstreamChunks,
924 testProperty "tl_chunk_unchunk" tl_chunk_unchunk,
925 testProperty "tl_from_to_strict" tl_from_to_strict
926 ],
927
928 testGroup "transcoding" [
929 testProperty "t_ascii" t_ascii,
930 testProperty "tl_ascii" tl_ascii,
931 testProperty "t_latin1" t_latin1,
932 testProperty "tl_latin1" tl_latin1,
933 testProperty "t_utf8" t_utf8,
934 testProperty "t_utf8'" t_utf8',
935 testProperty "t_utf8_incr" t_utf8_incr,
936 testProperty "t_utf8_undecoded" t_utf8_undecoded,
937 testProperty "tl_utf8" tl_utf8,
938 testProperty "tl_utf8'" tl_utf8',
939 testProperty "t_utf16LE" t_utf16LE,
940 testProperty "tl_utf16LE" tl_utf16LE,
941 testProperty "t_utf16BE" t_utf16BE,
942 testProperty "tl_utf16BE" tl_utf16BE,
943 testProperty "t_utf32LE" t_utf32LE,
944 testProperty "tl_utf32LE" tl_utf32LE,
945 testProperty "t_utf32BE" t_utf32BE,
946 testProperty "tl_utf32BE" tl_utf32BE,
947 testGroup "errors" [
948 testProperty "t_utf8_err" t_utf8_err,
949 testProperty "t_utf8_err'" t_utf8_err'
950 ]
951 ],
952
953 testGroup "instances" [
954 testProperty "s_Eq" s_Eq,
955 testProperty "sf_Eq" sf_Eq,
956 testProperty "t_Eq" t_Eq,
957 testProperty "tl_Eq" tl_Eq,
958 testProperty "s_Ord" s_Ord,
959 testProperty "sf_Ord" sf_Ord,
960 testProperty "t_Ord" t_Ord,
961 testProperty "tl_Ord" tl_Ord,
962 testProperty "t_Read" t_Read,
963 testProperty "tl_Read" tl_Read,
964 testProperty "t_Show" t_Show,
965 testProperty "tl_Show" tl_Show,
966 testProperty "t_mappend" t_mappend,
967 testProperty "tl_mappend" tl_mappend,
968 testProperty "t_mconcat" t_mconcat,
969 testProperty "tl_mconcat" tl_mconcat,
970 testProperty "t_mempty" t_mempty,
971 testProperty "tl_mempty" tl_mempty,
972 testProperty "t_IsString" t_IsString,
973 testProperty "tl_IsString" tl_IsString
974 ],
975
976 testGroup "basics" [
977 testProperty "s_cons" s_cons,
978 testProperty "s_cons_s" s_cons_s,
979 testProperty "sf_cons" sf_cons,
980 testProperty "t_cons" t_cons,
981 testProperty "tl_cons" tl_cons,
982 testProperty "s_snoc" s_snoc,
983 testProperty "t_snoc" t_snoc,
984 testProperty "tl_snoc" tl_snoc,
985 testProperty "s_append" s_append,
986 testProperty "s_append_s" s_append_s,
987 testProperty "sf_append" sf_append,
988 testProperty "t_append" t_append,
989 testProperty "s_uncons" s_uncons,
990 testProperty "sf_uncons" sf_uncons,
991 testProperty "t_uncons" t_uncons,
992 testProperty "tl_uncons" tl_uncons,
993 testProperty "s_head" s_head,
994 testProperty "sf_head" sf_head,
995 testProperty "t_head" t_head,
996 testProperty "tl_head" tl_head,
997 testProperty "s_last" s_last,
998 testProperty "sf_last" sf_last,
999 testProperty "t_last" t_last,
1000 testProperty "tl_last" tl_last,
1001 testProperty "s_tail" s_tail,
1002 testProperty "s_tail_s" s_tail_s,
1003 testProperty "sf_tail" sf_tail,
1004 testProperty "t_tail" t_tail,
1005 testProperty "tl_tail" tl_tail,
1006 testProperty "s_init" s_init,
1007 testProperty "s_init_s" s_init_s,
1008 testProperty "sf_init" sf_init,
1009 testProperty "t_init" t_init,
1010 testProperty "tl_init" tl_init,
1011 testProperty "s_null" s_null,
1012 testProperty "sf_null" sf_null,
1013 testProperty "t_null" t_null,
1014 testProperty "tl_null" tl_null,
1015 testProperty "s_length" s_length,
1016 testProperty "sf_length" sf_length,
1017 testProperty "sl_length" sl_length,
1018 testProperty "t_length" t_length,
1019 testProperty "tl_length" tl_length,
1020 testProperty "t_compareLength" t_compareLength,
1021 testProperty "tl_compareLength" tl_compareLength
1022 ],
1023
1024 testGroup "transformations" [
1025 testProperty "s_map" s_map,
1026 testProperty "s_map_s" s_map_s,
1027 testProperty "sf_map" sf_map,
1028 testProperty "t_map" t_map,
1029 testProperty "tl_map" tl_map,
1030 testProperty "s_intercalate" s_intercalate,
1031 testProperty "t_intercalate" t_intercalate,
1032 testProperty "tl_intercalate" tl_intercalate,
1033 testProperty "s_intersperse" s_intersperse,
1034 testProperty "s_intersperse_s" s_intersperse_s,
1035 testProperty "sf_intersperse" sf_intersperse,
1036 testProperty "t_intersperse" t_intersperse,
1037 testProperty "tl_intersperse" tl_intersperse,
1038 testProperty "t_transpose" t_transpose,
1039 testProperty "tl_transpose" tl_transpose,
1040 testProperty "t_reverse" t_reverse,
1041 testProperty "tl_reverse" tl_reverse,
1042 testProperty "t_reverse_short" t_reverse_short,
1043 testProperty "t_replace" t_replace,
1044 testProperty "tl_replace" tl_replace,
1045
1046 testGroup "case conversion" [
1047 testProperty "s_toCaseFold_length" s_toCaseFold_length,
1048 testProperty "sf_toCaseFold_length" sf_toCaseFold_length,
1049 testProperty "t_toCaseFold_length" t_toCaseFold_length,
1050 testProperty "tl_toCaseFold_length" tl_toCaseFold_length,
1051 testProperty "t_toLower_length" t_toLower_length,
1052 testProperty "t_toLower_lower" t_toLower_lower,
1053 testProperty "tl_toLower_lower" tl_toLower_lower,
1054 testProperty "t_toUpper_length" t_toUpper_length,
1055 testProperty "t_toUpper_upper" t_toUpper_upper,
1056 testProperty "tl_toUpper_upper" tl_toUpper_upper,
1057 testProperty "t_toTitle_title" t_toTitle_title,
1058 testProperty "t_toTitle_1stNotLower" t_toTitle_1stNotLower
1059 ],
1060
1061 testGroup "justification" [
1062 testProperty "s_justifyLeft" s_justifyLeft,
1063 testProperty "s_justifyLeft_s" s_justifyLeft_s,
1064 testProperty "sf_justifyLeft" sf_justifyLeft,
1065 testProperty "t_justifyLeft" t_justifyLeft,
1066 testProperty "tl_justifyLeft" tl_justifyLeft,
1067 testProperty "t_justifyRight" t_justifyRight,
1068 testProperty "tl_justifyRight" tl_justifyRight,
1069 testProperty "t_center" t_center,
1070 testProperty "tl_center" tl_center
1071 ]
1072 ],
1073
1074 testGroup "folds" [
1075 testProperty "sf_foldl" sf_foldl,
1076 testProperty "t_foldl" t_foldl,
1077 testProperty "tl_foldl" tl_foldl,
1078 testProperty "sf_foldl'" sf_foldl',
1079 testProperty "t_foldl'" t_foldl',
1080 testProperty "tl_foldl'" tl_foldl',
1081 testProperty "sf_foldl1" sf_foldl1,
1082 testProperty "t_foldl1" t_foldl1,
1083 testProperty "tl_foldl1" tl_foldl1,
1084 testProperty "t_foldl1'" t_foldl1',
1085 testProperty "sf_foldl1'" sf_foldl1',
1086 testProperty "tl_foldl1'" tl_foldl1',
1087 testProperty "sf_foldr" sf_foldr,
1088 testProperty "t_foldr" t_foldr,
1089 testProperty "tl_foldr" tl_foldr,
1090 testProperty "sf_foldr1" sf_foldr1,
1091 testProperty "t_foldr1" t_foldr1,
1092 testProperty "tl_foldr1" tl_foldr1,
1093
1094 testGroup "special" [
1095 testProperty "s_concat_s" s_concat_s,
1096 testProperty "sf_concat" sf_concat,
1097 testProperty "t_concat" t_concat,
1098 testProperty "tl_concat" tl_concat,
1099 testProperty "sf_concatMap" sf_concatMap,
1100 testProperty "t_concatMap" t_concatMap,
1101 testProperty "tl_concatMap" tl_concatMap,
1102 testProperty "sf_any" sf_any,
1103 testProperty "t_any" t_any,
1104 testProperty "tl_any" tl_any,
1105 testProperty "sf_all" sf_all,
1106 testProperty "t_all" t_all,
1107 testProperty "tl_all" tl_all,
1108 testProperty "sf_maximum" sf_maximum,
1109 testProperty "t_maximum" t_maximum,
1110 testProperty "tl_maximum" tl_maximum,
1111 testProperty "sf_minimum" sf_minimum,
1112 testProperty "t_minimum" t_minimum,
1113 testProperty "tl_minimum" tl_minimum
1114 ]
1115 ],
1116
1117 testGroup "construction" [
1118 testGroup "scans" [
1119 testProperty "sf_scanl" sf_scanl,
1120 testProperty "t_scanl" t_scanl,
1121 testProperty "tl_scanl" tl_scanl,
1122 testProperty "t_scanl1" t_scanl1,
1123 testProperty "tl_scanl1" tl_scanl1,
1124 testProperty "t_scanr" t_scanr,
1125 testProperty "tl_scanr" tl_scanr,
1126 testProperty "t_scanr1" t_scanr1,
1127 testProperty "tl_scanr1" tl_scanr1
1128 ],
1129
1130 testGroup "mapAccum" [
1131 testProperty "t_mapAccumL" t_mapAccumL,
1132 testProperty "tl_mapAccumL" tl_mapAccumL,
1133 testProperty "t_mapAccumR" t_mapAccumR,
1134 testProperty "tl_mapAccumR" tl_mapAccumR
1135 ],
1136
1137 testGroup "unfolds" [
1138 testProperty "tl_repeat" tl_repeat,
1139 testProperty "s_replicate" s_replicate,
1140 testProperty "t_replicate" t_replicate,
1141 testProperty "tl_replicate" tl_replicate,
1142 testProperty "tl_cycle" tl_cycle,
1143 testProperty "tl_iterate" tl_iterate,
1144 testProperty "t_unfoldr" t_unfoldr,
1145 testProperty "tl_unfoldr" tl_unfoldr,
1146 testProperty "t_unfoldrN" t_unfoldrN,
1147 testProperty "tl_unfoldrN" tl_unfoldrN
1148 ]
1149 ],
1150
1151 testGroup "substrings" [
1152 testGroup "breaking" [
1153 testProperty "s_take" s_take,
1154 testProperty "s_take_s" s_take_s,
1155 testProperty "sf_take" sf_take,
1156 testProperty "t_take" t_take,
1157 testProperty "t_takeEnd" t_takeEnd,
1158 testProperty "tl_take" tl_take,
1159 testProperty "tl_takeEnd" tl_takeEnd,
1160 testProperty "s_drop" s_drop,
1161 testProperty "s_drop_s" s_drop_s,
1162 testProperty "sf_drop" sf_drop,
1163 testProperty "t_drop" t_drop,
1164 testProperty "t_dropEnd" t_dropEnd,
1165 testProperty "tl_drop" tl_drop,
1166 testProperty "tl_dropEnd" tl_dropEnd,
1167 testProperty "s_take_drop" s_take_drop,
1168 testProperty "s_take_drop_s" s_take_drop_s,
1169 testProperty "s_takeWhile" s_takeWhile,
1170 testProperty "s_takeWhile_s" s_takeWhile_s,
1171 testProperty "sf_takeWhile" sf_takeWhile,
1172 testProperty "t_takeWhile" t_takeWhile,
1173 testProperty "tl_takeWhile" tl_takeWhile,
1174 testProperty "t_takeWhileEnd" t_takeWhileEnd,
1175 testProperty "t_takeWhileEnd_null" t_takeWhileEnd_null,
1176 testProperty "tl_takeWhileEnd" tl_takeWhileEnd,
1177 testProperty "sf_dropWhile" sf_dropWhile,
1178 testProperty "s_dropWhile" s_dropWhile,
1179 testProperty "s_dropWhile_s" s_dropWhile_s,
1180 testProperty "t_dropWhile" t_dropWhile,
1181 testProperty "tl_dropWhile" tl_dropWhile,
1182 testProperty "t_dropWhileEnd" t_dropWhileEnd,
1183 testProperty "tl_dropWhileEnd" tl_dropWhileEnd,
1184 testProperty "t_dropAround" t_dropAround,
1185 testProperty "tl_dropAround" tl_dropAround,
1186 testProperty "t_stripStart" t_stripStart,
1187 testProperty "tl_stripStart" tl_stripStart,
1188 testProperty "t_stripEnd" t_stripEnd,
1189 testProperty "tl_stripEnd" tl_stripEnd,
1190 testProperty "t_strip" t_strip,
1191 testProperty "tl_strip" tl_strip,
1192 testProperty "t_splitAt" t_splitAt,
1193 testProperty "tl_splitAt" tl_splitAt,
1194 testProperty "t_span" t_span,
1195 testProperty "tl_span" tl_span,
1196 testProperty "t_breakOn_id" t_breakOn_id,
1197 testProperty "tl_breakOn_id" tl_breakOn_id,
1198 testProperty "t_breakOn_start" t_breakOn_start,
1199 testProperty "tl_breakOn_start" tl_breakOn_start,
1200 testProperty "t_breakOnEnd_end" t_breakOnEnd_end,
1201 testProperty "tl_breakOnEnd_end" tl_breakOnEnd_end,
1202 testProperty "t_break" t_break,
1203 testProperty "tl_break" tl_break,
1204 testProperty "t_group" t_group,
1205 testProperty "tl_group" tl_group,
1206 testProperty "t_groupBy" t_groupBy,
1207 testProperty "tl_groupBy" tl_groupBy,
1208 testProperty "t_inits" t_inits,
1209 testProperty "tl_inits" tl_inits,
1210 testProperty "t_tails" t_tails,
1211 testProperty "tl_tails" tl_tails
1212 ],
1213
1214 testGroup "breaking many" [
1215 testProperty "t_findAppendId" t_findAppendId,
1216 testProperty "tl_findAppendId" tl_findAppendId,
1217 testProperty "t_findContains" t_findContains,
1218 testProperty "tl_findContains" tl_findContains,
1219 testProperty "sl_filterCount" sl_filterCount,
1220 testProperty "t_findCount" t_findCount,
1221 testProperty "tl_findCount" tl_findCount,
1222 testProperty "t_splitOn_split" t_splitOn_split,
1223 testProperty "tl_splitOn_split" tl_splitOn_split,
1224 testProperty "t_splitOn_i" t_splitOn_i,
1225 testProperty "tl_splitOn_i" tl_splitOn_i,
1226 testProperty "t_split" t_split,
1227 testProperty "t_split_count" t_split_count,
1228 testProperty "t_split_splitOn" t_split_splitOn,
1229 testProperty "tl_split" tl_split,
1230 testProperty "t_chunksOf_same_lengths" t_chunksOf_same_lengths,
1231 testProperty "t_chunksOf_length" t_chunksOf_length,
1232 testProperty "tl_chunksOf" tl_chunksOf
1233 ],
1234
1235 testGroup "lines and words" [
1236 testProperty "t_lines" t_lines,
1237 testProperty "tl_lines" tl_lines,
1238 --testProperty "t_lines'" t_lines',
1239 testProperty "t_words" t_words,
1240 testProperty "tl_words" tl_words,
1241 testProperty "t_unlines" t_unlines,
1242 testProperty "tl_unlines" tl_unlines,
1243 testProperty "t_unwords" t_unwords,
1244 testProperty "tl_unwords" tl_unwords
1245 ]
1246 ],
1247
1248 testGroup "predicates" [
1249 testProperty "s_isPrefixOf" s_isPrefixOf,
1250 testProperty "sf_isPrefixOf" sf_isPrefixOf,
1251 testProperty "t_isPrefixOf" t_isPrefixOf,
1252 testProperty "tl_isPrefixOf" tl_isPrefixOf,
1253 testProperty "t_isSuffixOf" t_isSuffixOf,
1254 testProperty "tl_isSuffixOf" tl_isSuffixOf,
1255 testProperty "t_isInfixOf" t_isInfixOf,
1256 testProperty "tl_isInfixOf" tl_isInfixOf,
1257
1258 testGroup "view" [
1259 testProperty "t_stripPrefix" t_stripPrefix,
1260 testProperty "tl_stripPrefix" tl_stripPrefix,
1261 testProperty "t_stripSuffix" t_stripSuffix,
1262 testProperty "tl_stripSuffix" tl_stripSuffix,
1263 testProperty "t_commonPrefixes" t_commonPrefixes,
1264 testProperty "tl_commonPrefixes" tl_commonPrefixes
1265 ]
1266 ],
1267
1268 testGroup "searching" [
1269 testProperty "sf_elem" sf_elem,
1270 testProperty "sf_filter" sf_filter,
1271 testProperty "t_filter" t_filter,
1272 testProperty "tl_filter" tl_filter,
1273 testProperty "sf_findBy" sf_findBy,
1274 testProperty "t_find" t_find,
1275 testProperty "tl_find" tl_find,
1276 testProperty "t_partition" t_partition,
1277 testProperty "tl_partition" tl_partition
1278 ],
1279
1280 testGroup "indexing" [
1281 testProperty "sf_index" sf_index,
1282 testProperty "t_index" t_index,
1283 testProperty "tl_index" tl_index,
1284 testProperty "t_findIndex" t_findIndex,
1285 testProperty "t_count" t_count,
1286 testProperty "tl_count" tl_count,
1287 testProperty "t_indices" t_indices,
1288 testProperty "tl_indices" tl_indices,
1289 testProperty "t_indices_occurs" t_indices_occurs
1290 ],
1291
1292 testGroup "zips" [
1293 testProperty "t_zip" t_zip,
1294 testProperty "tl_zip" tl_zip,
1295 testProperty "sf_zipWith" sf_zipWith,
1296 testProperty "t_zipWith" t_zipWith,
1297 testProperty "tl_zipWith" tl_zipWith
1298 ],
1299
1300 testGroup "regressions" [
1301 testProperty "s_filter_eq" s_filter_eq
1302 ],
1303
1304 testGroup "shifts" [
1305 testProperty "shiftL_Int" shiftL_Int,
1306 testProperty "shiftL_Word16" shiftL_Word16,
1307 testProperty "shiftL_Word32" shiftL_Word32,
1308 testProperty "shiftR_Int" shiftR_Int,
1309 testProperty "shiftR_Word16" shiftR_Word16,
1310 testProperty "shiftR_Word32" shiftR_Word32
1311 ],
1312
1313 testGroup "builder" [
1314 testProperty "tb_associative" tb_associative,
1315 testGroup "decimal" [
1316 testProperty "tb_decimal_int" tb_decimal_int,
1317 testProperty "tb_decimal_int8" tb_decimal_int8,
1318 testProperty "tb_decimal_int16" tb_decimal_int16,
1319 testProperty "tb_decimal_int32" tb_decimal_int32,
1320 testProperty "tb_decimal_int64" tb_decimal_int64,
1321 testProperty "tb_decimal_integer" tb_decimal_integer,
1322 testProperty "tb_decimal_integer_big" tb_decimal_integer_big,
1323 testProperty "tb_decimal_word" tb_decimal_word,
1324 testProperty "tb_decimal_word8" tb_decimal_word8,
1325 testProperty "tb_decimal_word16" tb_decimal_word16,
1326 testProperty "tb_decimal_word32" tb_decimal_word32,
1327 testProperty "tb_decimal_word64" tb_decimal_word64,
1328 testProperty "tb_decimal_big_int" tb_decimal_big_int,
1329 testProperty "tb_decimal_big_word" tb_decimal_big_word,
1330 testProperty "tb_decimal_big_int64" tb_decimal_big_int64,
1331 testProperty "tb_decimal_big_word64" tb_decimal_big_word64
1332 ],
1333 testGroup "hexadecimal" [
1334 testProperty "tb_hexadecimal_int" tb_hexadecimal_int,
1335 testProperty "tb_hexadecimal_int8" tb_hexadecimal_int8,
1336 testProperty "tb_hexadecimal_int16" tb_hexadecimal_int16,
1337 testProperty "tb_hexadecimal_int32" tb_hexadecimal_int32,
1338 testProperty "tb_hexadecimal_int64" tb_hexadecimal_int64,
1339 testProperty "tb_hexadecimal_integer" tb_hexadecimal_integer,
1340 testProperty "tb_hexadecimal_word" tb_hexadecimal_word,
1341 testProperty "tb_hexadecimal_word8" tb_hexadecimal_word8,
1342 testProperty "tb_hexadecimal_word16" tb_hexadecimal_word16,
1343 testProperty "tb_hexadecimal_word32" tb_hexadecimal_word32,
1344 testProperty "tb_hexadecimal_word64" tb_hexadecimal_word64
1345 ],
1346 testGroup "realfloat" [
1347 testProperty "tb_realfloat_double" tb_realfloat_double,
1348 testProperty "tb_realfloat_float" tb_realfloat_float,
1349 testProperty "tb_formatRealFloat_float" tb_formatRealFloat_float,
1350 testProperty "tb_formatRealFloat_double" tb_formatRealFloat_double
1351 ],
1352 testProperty "tb_fromText" tb_fromText,
1353 testProperty "tb_singleton" tb_singleton
1354 ],
1355
1356 testGroup "read" [
1357 testProperty "t_decimal" t_decimal,
1358 testProperty "tl_decimal" tl_decimal,
1359 testProperty "t_hexadecimal" t_hexadecimal,
1360 testProperty "tl_hexadecimal" tl_hexadecimal,
1361 testProperty "t_double" t_double,
1362 testProperty "tl_double" tl_double,
1363 testProperty "t_rational" t_rational,
1364 testProperty "tl_rational" tl_rational
1365 ],
1366
1367 {-
1368 testGroup "input-output" [
1369 testProperty "t_write_read" t_write_read,
1370 testProperty "tl_write_read" tl_write_read,
1371 testProperty "t_write_read_line" t_write_read_line,
1372 testProperty "tl_write_read_line" tl_write_read_line
1373 -- These tests are subject to I/O race conditions when run under
1374 -- test-framework-quickcheck2.
1375 -- testProperty "t_put_get" t_put_get
1376 -- testProperty "tl_put_get" tl_put_get
1377 ],
1378 -}
1379
1380 testGroup "lowlevel" [
1381 testProperty "t_dropWord16" t_dropWord16,
1382 testProperty "t_takeWord16" t_takeWord16,
1383 testProperty "t_take_drop_16" t_take_drop_16,
1384 testProperty "t_use_from" t_use_from,
1385 testProperty "t_copy" t_copy
1386 ],
1387
1388 testGroup "mul" Mul.tests
1389 ]