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