Commits

Bryan O'Sullivan committed 309a0a8

Improve test coverage up to 86%.

  • Participants
  • Parent commits 569197b

Comments (0)

Files changed (5)

Data/Text/Array.hs

 
 #if defined(__GLASGOW_HASKELL__)
 
-iNT_SCALE :: Int# -> Int#
-iNT_SCALE n# = scale# *# n# where I# scale# = SIZEOF_INT
-
 wORD16_SCALE :: Int# -> Int#
 wORD16_SCALE n# = scale# *# n# where I# scale# = SIZEOF_WORD16
 
   sequence_ [unsafeWrite marr i initVal | i <- [0..len-1]]
   return marr
 
-instance Elt Int where
-#if defined(__GLASGOW_HASKELL__)
-
-    bytesInArray (I# i#) _ = I# (iNT_SCALE i#)
-    {-# INLINE bytesInArray #-}
-
-    unsafeIndex (Array len ba#) i@(I# i#) =
-      CHECK_BOUNDS("unsafeIndex",len,i)
-        case indexIntArray# ba# i# of r# -> (I# r#)
-    {-# INLINE unsafeIndex #-}
-
-    unsafeRead (MArray len mba#) i@(I# i#) = ST $ \s# ->
-      CHECK_BOUNDS("unsafeRead",len,i)
-      case readIntArray# mba# i# s# of
-        (# s2#, r# #) -> (# s2#, I# r# #)
-    {-# INLINE unsafeRead #-}
-
-    unsafeWrite (MArray len marr#) i@(I# i#) (I# e#) = ST $ \s1# ->
-      CHECK_BOUNDS("unsafeWrite",len,i)
-      case writeIntArray# marr# i# e# s1# of
-        s2# -> (# s2#, () #)
-    {-# INLINE unsafeWrite #-}
-
-#elif defined(__HUGS__)
-
-    bytesInArray n w = sizeOf w * n
-    unsafeIndex = unsafeIndexArray
-    unsafeRead = unsafeReadMArray
-    unsafeWrite = unsafeWriteMArray
-
-#endif
-
 instance Elt Word16 where
 #if defined(__GLASGOW_HASKELL__)
 

Data/Text/Fusion/Internal.hs

 -- | Specialised, strict Maybe-like type.
 data M a = N
          | J {-# UNPACK #-} !a
-           deriving (Eq, Ord, Show)
 
 type M8 = M Word8
 
 -- Restreaming state.
 data S s = S {-# UNPACK #-} !s
     {-# UNPACK #-} !M8 {-# UNPACK #-} !M8 {-# UNPACK #-} !M8
-           deriving (Eq, Ord, Show)
 
 infixl 2 :!:
 data PairS a b = !a :!: !b
-               deriving (Eq, Ord, Read, Show)
 
 -- | Allow a function over a stream to switch between two states.
 data Switch = S1 | S2
-            deriving (Eq, Ord, Show)
 
 data Step s a = Done
               | Skip !s
               | Yield !a !s
 
+{-
 instance Show a => Show (Step s a)
     where show Done        = "Done"
           show (Skip _)    = "Skip"
           show (Yield x _) = "Yield " ++ show x
+-}
 
 instance (Eq a) => Eq (Stream a) where
     (==) = eq

Data/Text/UnsafeChar.hs

     , unsafeChr8
     , unsafeChr32
     , unsafeWrite
-    , unsafeWriteRev
+    -- , unsafeWriteRev
     ) where
 
 import Control.Exception (assert)
           hi = fromIntegral $ (m .&. 0x3FF) + 0xDC00
 {-# INLINE unsafeWrite #-}
 
+{-
 unsafeWriteRev :: A.MArray s Word16 -> Int -> Char -> ST s Int
 unsafeWriteRev marr i c
     | n < 0x10000 = do
           lo = fromIntegral $ (m `shiftR` 10) + 0xD800
           hi = fromIntegral $ (m .&. 0x3FF) + 0xDC00
 {-# INLINE unsafeWriteRev #-}
+-}

Data/Text/UnsafeShift.hs

     {-# INLINE shiftR #-}
     shiftR (W32# x#) (I# i#) = W32# (x# `uncheckedShiftRL#` i#)
 
+{-
 instance UnsafeShift Word64 where
     {-# INLINE shiftL #-}
     shiftL (W64# x#) (I# i#) = W64# (x# `uncheckedShiftL64#` i#)
 
     {-# INLINE shiftR #-}
     shiftR (W64# x#) (I# i#) = W64# (x# `uncheckedShiftRL64#` i#)
+-}
 
 instance UnsafeShift Int where
     {-# INLINE shiftL #-}
     {-# INLINE shiftR #-}
     shiftR (I# x#) (I# i#) = I# (x# `iShiftRA#` i#)
 
+{-
 instance UnsafeShift Integer where
     {-# INLINE shiftL #-}
     shiftL = Bits.shiftL
 
     {-# INLINE shiftR #-}
     shiftR = Bits.shiftR
+-}

tests/Properties.hs

 
 import Data.Char
 import Data.Monoid
+import Data.String
 import Debug.Trace
 import Text.Printf
 import System.Environment
 import Data.Word
 import qualified Data.ByteString as B
 import qualified Data.Text as T
-import qualified Data.Text.Compat as T (breakSubstring)
+import qualified Data.Text.Compat as C
 import qualified Data.Text.Lazy as TL
 import qualified Data.Text.Encoding as E
 import Control.Exception
 prop_TL_mappend s      = mappend s`eqP` (unpackS . mappend (TL.pack s))
 prop_T_mconcat         = mconcat  `eq` (unpackS . mconcat . L.map T.pack)
 prop_TL_mconcat        = mconcat  `eq` (unpackS . mconcat . L.map TL.pack)
+prop_T_IsString        = fromString  `eqP` (T.unpack . fromString)
+prop_TL_IsString       = fromString  `eqP` (TL.unpack . fromString)
 
 prop_S_cons x          = (x:)     `eqP` (unpackS . S.cons x)
 prop_T_cons x          = (x:)     `eqP` (unpackS . T.cons x)
 prop_T_splitWith p     = splitWith p `eqP` (map unpackS . T.splitWith p)
 prop_T_splitWith_count c = (L.length . T.splitWith (==c)) `eq` ((1+) . T.count c)
 prop_T_splitWith_split c = T.splitWith (==c) `eq` T.split (T.singleton c)
+prop_T_splitWith_Csplit c = T.splitWith (==c) `eq` C.split c
 prop_TL_splitWith p    = splitWith p `eqP` (map unpackS . TL.splitWith p)
 
 splitWith :: (a -> Bool) -> [a] -> [[a]]
 
 prop_T_breakSubstring_isInfixOf s l
                      = T.isInfixOf s l ==
-                       T.null s || (not . T.null . snd $ T.breakSubstring s l)
+                       T.null s || (not . T.null . snd $ C.breakSubstring s l)
 prop_T_breakSubstringC c
                      = L.break (==c) `eqP`
-                       (unpack2 . T.breakSubstring (T.singleton c))
+                       (unpack2 . C.breakSubstring (T.singleton c))
 
 prop_T_lines           = L.lines       `eqP` (map unpackS . T.lines)
 prop_TL_lines          = L.lines       `eqP` (map unpackS . TL.lines)
   ("prop_TL_mappend", mytest prop_TL_mappend),
   ("prop_T_mconcat", mytest prop_T_mconcat),
   ("prop_TL_mconcat", mytest prop_TL_mconcat),
+  ("prop_T_IsString", mytest prop_T_IsString),
+  ("prop_TL_IsString", mytest prop_TL_IsString),
 
   ("prop_S_cons", mytest prop_S_cons),
   ("prop_T_cons", mytest prop_T_cons),
   ("prop_T_splitWith", mytest prop_T_splitWith),
   ("prop_T_splitWith_count", mytest prop_T_splitWith_count),
   ("prop_T_splitWith_split", mytest prop_T_splitWith_split),
+  ("prop_T_splitWith_Csplit", mytest prop_T_splitWith_Csplit),
   ("prop_TL_splitWith", mytest prop_TL_splitWith),
   ("prop_T_chunksOf_same_lengths", mytest prop_T_chunksOf_same_lengths),
   ("prop_T_chunksOf_length", mytest prop_T_chunksOf_length),