on master help sign in
Improve test coverage up to 86%.
3cebbddBryan O'Sullivan
Data/Text/Array.hs−35
@@ -166,9 +166,6 @@ unsafeFreeze :: MArray s e -> ST s (Array e)
166
166
167#if defined(__GLASGOW_HASKELL__)
167#if defined(__GLASGOW_HASKELL__)
168
168
169−iNT_SCALE :: Int# -> Int#
170−iNT_SCALE n# = scale# *# n# where I# scale# = SIZEOF_INT
171−
172wORD16_SCALE :: Int# -> Int#
169wORD16_SCALE :: Int# -> Int#
173wORD16_SCALE n# = scale# *# n# where I# scale# = SIZEOF_WORD16
170wORD16_SCALE n# = scale# *# n# where I# scale# = SIZEOF_WORD16
174
171
@@ -228,38 +225,6 @@ new len initVal = do
228 sequence_ [unsafeWrite marr i initVal | i <- [0..len-1]]
225 sequence_ [unsafeWrite marr i initVal | i <- [0..len-1]]
229 return marr
226 return marr
230
227
231−instance Elt Int where
232−#if defined(__GLASGOW_HASKELL__)
233−
234− bytesInArray (I# i#) _ = I# (iNT_SCALE i#)
235− {-# INLINE bytesInArray #-}
236−
237− unsafeIndex (Array len ba#) i@(I# i#) =
238− CHECK_BOUNDS("unsafeIndex",len,i)
239− case indexIntArray# ba# i# of r# -> (I# r#)
240− {-# INLINE unsafeIndex #-}
241−
242− unsafeRead (MArray len mba#) i@(I# i#) = ST $ \s# ->
243− CHECK_BOUNDS("unsafeRead",len,i)
244− case readIntArray# mba# i# s# of
245− (# s2#, r# #) -> (# s2#, I# r# #)
246− {-# INLINE unsafeRead #-}
247−
248− unsafeWrite (MArray len marr#) i@(I# i#) (I# e#) = ST $ \s1# ->
249− CHECK_BOUNDS("unsafeWrite",len,i)
250− case writeIntArray# marr# i# e# s1# of
251− s2# -> (# s2#, () #)
252− {-# INLINE unsafeWrite #-}
253−
254−#elif defined(__HUGS__)
255−
256− bytesInArray n w = sizeOf w * n
257− unsafeIndex = unsafeIndexArray
258− unsafeRead = unsafeReadMArray
259− unsafeWrite = unsafeWriteMArray
260−
261−#endif
262−
263instance Elt Word16 where
228instance Elt Word16 where
264#if defined(__GLASGOW_HASKELL__)
229#if defined(__GLASGOW_HASKELL__)
265
230
Data/Text/Fusion/Internal.hs+2−4
@@ -30,31 +30,29 @@ import Data.Word (Word8)
30-- | Specialised, strict Maybe-like type.
30-- | Specialised, strict Maybe-like type.
31data M a = N
31data M a = N
32 | J {-# UNPACK #-} !a
32 | J {-# UNPACK #-} !a
33− deriving (Eq, Ord, Show)
34
33
35type M8 = M Word8
34type M8 = M Word8
36
35
37-- Restreaming state.
36-- Restreaming state.
38data S s = S {-# UNPACK #-} !s
37data S s = S {-# UNPACK #-} !s
39 {-# UNPACK #-} !M8 {-# UNPACK #-} !M8 {-# UNPACK #-} !M8
38 {-# UNPACK #-} !M8 {-# UNPACK #-} !M8 {-# UNPACK #-} !M8
40− deriving (Eq, Ord, Show)
41
39
42infixl 2 :!:
40infixl 2 :!:
43data PairS a b = !a :!: !b
41data PairS a b = !a :!: !b
44− deriving (Eq, Ord, Read, Show)
45
42
46-- | Allow a function over a stream to switch between two states.
43-- | Allow a function over a stream to switch between two states.
47data Switch = S1 | S2
44data Switch = S1 | S2
48− deriving (Eq, Ord, Show)
49
45
50data Step s a = Done
46data Step s a = Done
51 | Skip !s
47 | Skip !s
52 | Yield !a !s
48 | Yield !a !s
53
49
50+{-
54instance Show a => Show (Step s a)
51instance Show a => Show (Step s a)
55 where show Done = "Done"
52 where show Done = "Done"
56 show (Skip _) = "Skip"
53 show (Skip _) = "Skip"
57 show (Yield x _) = "Yield " ++ show x
54 show (Yield x _) = "Yield " ++ show x
55+-}
58
56
59instance (Eq a) => Eq (Stream a) where
57instance (Eq a) => Eq (Stream a) where
60 (==) = eq
58 (==) = eq
Data/Text/UnsafeChar.hs+3−1
@@ -19,7 +19,7 @@ module Data.Text.UnsafeChar
19 , unsafeChr8
19 , unsafeChr8
20 , unsafeChr32
20 , unsafeChr32
21 , unsafeWrite
21 , unsafeWrite
22− , unsafeWriteRev
22+ -- , unsafeWriteRev
23 ) where
23 ) where
24
24
25import Control.Exception (assert)
25import Control.Exception (assert)
@@ -60,6 +60,7 @@ unsafeWrite marr i c
60 hi = fromIntegral $ (m .&. 0x3FF) + 0xDC00
60 hi = fromIntegral $ (m .&. 0x3FF) + 0xDC00
61{-# INLINE unsafeWrite #-}
61{-# INLINE unsafeWrite #-}
62
62
63+{-
63unsafeWriteRev :: A.MArray s Word16 -> Int -> Char -> ST s Int
64unsafeWriteRev :: A.MArray s Word16 -> Int -> Char -> ST s Int
64unsafeWriteRev marr i c
65unsafeWriteRev marr i c
65 | n < 0x10000 = do
66 | n < 0x10000 = do
@@ -76,3 +77,4 @@ unsafeWriteRev marr i c
76 lo = fromIntegral $ (m `shiftR` 10) + 0xD800
77 lo = fromIntegral $ (m `shiftR` 10) + 0xD800
77 hi = fromIntegral $ (m .&. 0x3FF) + 0xDC00
78 hi = fromIntegral $ (m .&. 0x3FF) + 0xDC00
78{-# INLINE unsafeWriteRev #-}
79{-# INLINE unsafeWriteRev #-}
80+-}
Data/Text/UnsafeShift.hs+4
@@ -45,12 +45,14 @@ instance UnsafeShift Word32 where
45 {-# INLINE shiftR #-}
45 {-# INLINE shiftR #-}
46 shiftR (W32# x#) (I# i#) = W32# (x# `uncheckedShiftRL#` i#)
46 shiftR (W32# x#) (I# i#) = W32# (x# `uncheckedShiftRL#` i#)
47
47
48+{-
48instance UnsafeShift Word64 where
49instance UnsafeShift Word64 where
49 {-# INLINE shiftL #-}
50 {-# INLINE shiftL #-}
50 shiftL (W64# x#) (I# i#) = W64# (x# `uncheckedShiftL64#` i#)
51 shiftL (W64# x#) (I# i#) = W64# (x# `uncheckedShiftL64#` i#)
51
52
52 {-# INLINE shiftR #-}
53 {-# INLINE shiftR #-}
53 shiftR (W64# x#) (I# i#) = W64# (x# `uncheckedShiftRL64#` i#)
54 shiftR (W64# x#) (I# i#) = W64# (x# `uncheckedShiftRL64#` i#)
55+-}
54
56
55instance UnsafeShift Int where
57instance UnsafeShift Int where
56 {-# INLINE shiftL #-}
58 {-# INLINE shiftL #-}
@@ -59,9 +61,11 @@ instance UnsafeShift Int where
59 {-# INLINE shiftR #-}
61 {-# INLINE shiftR #-}
60 shiftR (I# x#) (I# i#) = I# (x# `iShiftRA#` i#)
62 shiftR (I# x#) (I# i#) = I# (x# `iShiftRA#` i#)
61
63
64+{-
62instance UnsafeShift Integer where
65instance UnsafeShift Integer where
63 {-# INLINE shiftL #-}
66 {-# INLINE shiftL #-}
64 shiftL = Bits.shiftL
67 shiftL = Bits.shiftL
65
68
66 {-# INLINE shiftR #-}
69 {-# INLINE shiftR #-}
67 shiftR = Bits.shiftR
70 shiftR = Bits.shiftR
71+-}
tests/Properties.hs+10−3
@@ -6,6 +6,7 @@ import Text.Show.Functions
6
6
7import Data.Char
7import Data.Char
8import Data.Monoid
8import Data.Monoid
9+import Data.String
9import Debug.Trace
10import Debug.Trace
10import Text.Printf
11import Text.Printf
11import System.Environment
12import System.Environment
@@ -15,7 +16,7 @@ import Control.Monad
15import Data.Word
16import Data.Word
16import qualified Data.ByteString as B
17import qualified Data.ByteString as B
17import qualified Data.Text as T
18import qualified Data.Text as T
18−import qualified Data.Text.Compat as T (breakSubstring)
19+import qualified Data.Text.Compat as C
19import qualified Data.Text.Lazy as TL
20import qualified Data.Text.Lazy as TL
20import qualified Data.Text.Encoding as E
21import qualified Data.Text.Encoding as E
21import Control.Exception
22import Control.Exception
@@ -142,6 +143,8 @@ prop_T_mappend s = mappend s`eqP` (unpackS . mappend (T.pack s))
142prop_TL_mappend s = mappend s`eqP` (unpackS . mappend (TL.pack s))
143prop_TL_mappend s = mappend s`eqP` (unpackS . mappend (TL.pack s))
143prop_T_mconcat = mconcat `eq` (unpackS . mconcat . L.map T.pack)
144prop_T_mconcat = mconcat `eq` (unpackS . mconcat . L.map T.pack)
144prop_TL_mconcat = mconcat `eq` (unpackS . mconcat . L.map TL.pack)
145prop_TL_mconcat = mconcat `eq` (unpackS . mconcat . L.map TL.pack)
146+prop_T_IsString = fromString `eqP` (T.unpack . fromString)
147+prop_TL_IsString = fromString `eqP` (TL.unpack . fromString)
145
148
146prop_S_cons x = (x:) `eqP` (unpackS . S.cons x)
149prop_S_cons x = (x:) `eqP` (unpackS . S.cons x)
147prop_T_cons x = (x:) `eqP` (unpackS . T.cons x)
150prop_T_cons x = (x:) `eqP` (unpackS . T.cons x)
@@ -332,6 +335,7 @@ prop_TL_split_i c = id `eq` (TL.intercalate (TL.singleton c) . TL.split c)
332prop_T_splitWith p = splitWith p `eqP` (map unpackS . T.splitWith p)
335prop_T_splitWith p = splitWith p `eqP` (map unpackS . T.splitWith p)
333prop_T_splitWith_count c = (L.length . T.splitWith (==c)) `eq` ((1+) . T.count c)
336prop_T_splitWith_count c = (L.length . T.splitWith (==c)) `eq` ((1+) . T.count c)
334prop_T_splitWith_split c = T.splitWith (==c) `eq` T.split (T.singleton c)
337prop_T_splitWith_split c = T.splitWith (==c) `eq` T.split (T.singleton c)
338+prop_T_splitWith_Csplit c = T.splitWith (==c) `eq` C.split c
335prop_TL_splitWith p = splitWith p `eqP` (map unpackS . TL.splitWith p)
339prop_TL_splitWith p = splitWith p `eqP` (map unpackS . TL.splitWith p)
336
340
337splitWith :: (a -> Bool) -> [a] -> [[a]]
341splitWith :: (a -> Bool) -> [a] -> [[a]]
@@ -350,10 +354,10 @@ prop_T_chunksOf_length k t = len == T.length t || (k <= 0 && len == 0)
350
354
351prop_T_breakSubstring_isInfixOf s l
355prop_T_breakSubstring_isInfixOf s l
352 = T.isInfixOf s l ==
356 = T.isInfixOf s l ==
353− T.null s || (not . T.null . snd $ T.breakSubstring s l)
357+ T.null s || (not . T.null . snd $ C.breakSubstring s l)
354prop_T_breakSubstringC c
358prop_T_breakSubstringC c
355 = L.break (==c) `eqP`
359 = L.break (==c) `eqP`
356− (unpack2 . T.breakSubstring (T.singleton c))
360+ (unpack2 . C.breakSubstring (T.singleton c))
357
361
358prop_T_lines = L.lines `eqP` (map unpackS . T.lines)
362prop_T_lines = L.lines `eqP` (map unpackS . T.lines)
359prop_TL_lines = L.lines `eqP` (map unpackS . TL.lines)
363prop_TL_lines = L.lines `eqP` (map unpackS . TL.lines)
@@ -472,6 +476,8 @@ tests = [
472 ("prop_TL_mappend", mytest prop_TL_mappend),
476 ("prop_TL_mappend", mytest prop_TL_mappend),
473 ("prop_T_mconcat", mytest prop_T_mconcat),
477 ("prop_T_mconcat", mytest prop_T_mconcat),
474 ("prop_TL_mconcat", mytest prop_TL_mconcat),
478 ("prop_TL_mconcat", mytest prop_TL_mconcat),
479+ ("prop_T_IsString", mytest prop_T_IsString),
480+ ("prop_TL_IsString", mytest prop_TL_IsString),
475
481
476 ("prop_S_cons", mytest prop_S_cons),
482 ("prop_S_cons", mytest prop_S_cons),
477 ("prop_T_cons", mytest prop_T_cons),
483 ("prop_T_cons", mytest prop_T_cons),
@@ -613,6 +619,7 @@ tests = [
613 ("prop_T_splitWith", mytest prop_T_splitWith),
619 ("prop_T_splitWith", mytest prop_T_splitWith),
614 ("prop_T_splitWith_count", mytest prop_T_splitWith_count),
620 ("prop_T_splitWith_count", mytest prop_T_splitWith_count),
615 ("prop_T_splitWith_split", mytest prop_T_splitWith_split),
621 ("prop_T_splitWith_split", mytest prop_T_splitWith_split),
622+ ("prop_T_splitWith_Csplit", mytest prop_T_splitWith_Csplit),
616 ("prop_TL_splitWith", mytest prop_TL_splitWith),
623 ("prop_TL_splitWith", mytest prop_TL_splitWith),
617 ("prop_T_chunksOf_same_lengths", mytest prop_T_chunksOf_same_lengths),
624 ("prop_T_chunksOf_same_lengths", mytest prop_T_chunksOf_same_lengths),
618 ("prop_T_chunksOf_length", mytest prop_T_chunksOf_length),
625 ("prop_T_chunksOf_length", mytest prop_T_chunksOf_length),