git.iko.soy/typeable/attoparsec
on master help sign in
QuickCheck-2.13
566f1e4Oleg Grenrus
attoparsec.cabal+3−3
@@ -39,7 +39,7 @@ Flag developer
39
39
40library
40library
41 build-depends: array,
41 build-depends: array,
42− base >= 4.2 && < 5,
42+ base >= 4.3 && < 5,
43 bytestring,
43 bytestring,
44 containers,
44 containers,
45 deepseq,
45 deepseq,
@@ -124,10 +124,10 @@ test-suite tests
124
124
125 build-depends:
125 build-depends:
126 array,
126 array,
127− base >= 4 && < 5,
127+ base,
128 bytestring,
128 bytestring,
129 deepseq >= 1.1,
129 deepseq >= 1.1,
130− QuickCheck >= 2.7 && < 2.10,
130+ QuickCheck >= 2.13.2 && < 2.14,
131 quickcheck-unicode,
131 quickcheck-unicode,
132 scientific,
132 scientific,
133 tasty >= 0.11,
133 tasty >= 0.11,
tests/QC/ByteString.hs+4−2
@@ -26,9 +26,11 @@ import qualified Data.ByteString.Lazy.Char8 as L8
26satisfy :: Word8 -> L.ByteString -> Property
26satisfy :: Word8 -> L.ByteString -> Property
27satisfy w s = parseBS (P.satisfy (<=w)) (L.cons w s) === Just w
27satisfy w s = parseBS (P.satisfy (<=w)) (L.cons w s) === Just w
28
28
29−satisfyWith :: Char -> L.ByteString -> Property
29+satisfyWith :: Word8 -> L.ByteString -> Property
30−satisfyWith c s = parseBS (P.satisfyWith (chr . fromIntegral) (<=c))
30+satisfyWith w s = parseBS (P.satisfyWith (chr . fromIntegral) (<=c))
31 (L.cons (fromIntegral (ord c)) s) === Just c
31 (L.cons (fromIntegral (ord c)) s) === Just c
32+ where
33+ c = chr (fromIntegral w)
32
34
33word8 :: Word8 -> L.ByteString -> Property
35word8 :: Word8 -> L.ByteString -> Property
34word8 w s = parseBS (P.word8 w) (L.cons w s) === Just w
36word8 w s = parseBS (P.word8 w) (L.cons w s) === Just w
tests/QC/Text.hs+11−3
@@ -6,6 +6,7 @@ module QC.Text (tests) where
6import Control.Applicative ((<*>), (<$>))
6import Control.Applicative ((<*>), (<$>))
7#endif
7#endif
8import Data.Int (Int64)
8import Data.Int (Int64)
9+import Data.Word (Word8)
9import Prelude hiding (take, takeWhile)
10import Prelude hiding (take, takeWhile)
10import QC.Common (liftOp, parseT)
11import QC.Common (liftOp, parseT)
11import qualified QC.Text.FastSet as FastSet
12import qualified QC.Text.FastSet as FastSet
@@ -16,8 +17,10 @@ import Test.QuickCheck
16import qualified Data.Attoparsec.Text as P
17import qualified Data.Attoparsec.Text as P
17import qualified Data.Attoparsec.Text.Lazy as PL
18import qualified Data.Attoparsec.Text.Lazy as PL
18import qualified Data.Attoparsec.Text.FastSet as S
19import qualified Data.Attoparsec.Text.FastSet as S
20+import qualified Data.ByteString as BS
19import qualified Data.Char as Char
21import qualified Data.Char as Char
20import qualified Data.Text as T
22import qualified Data.Text as T
23+import qualified Data.Text.Encoding as TE
21import qualified Data.Text.Lazy as L
24import qualified Data.Text.Lazy as L
22
25
23-- Basic byte-level combinators.
26-- Basic byte-level combinators.
@@ -70,9 +73,12 @@ strings s t u =
70 === Just t'
73 === Just t'
71 where t' = toStrict t
74 where t' = toStrict t
72
75
76+-- | Note: "simple, and efficient" works for well formed input...
77+-- i.e. e.g. Latin1 texts
73−stringCI :: T.Text -> Property
78+stringCI :: [Word8] -> Property
74−stringCI s = P.parseOnly (P.stringCI fs) s === Right s
79+stringCI ws = P.parseOnly (P.stringCI fs) s === Right s
75 where fs = T.toCaseFold s
80 where fs = T.toCaseFold s
81+ s = TE.decodeLatin1 (BS.pack ws)
76
82
77asciiCI :: T.Text -> Gen Bool
83asciiCI :: T.Text -> Gen Bool
78asciiCI x =
84asciiCI x =
@@ -150,7 +156,9 @@ endOfLine s =
150 (c, fst <$> L.uncons s') === ('\r', Just '\n')
156 (c, fst <$> L.uncons s') === ('\r', Just '\n')
151
157
152scan :: L.Text -> Positive Int64 -> Property
158scan :: L.Text -> Positive Int64 -> Property
159+-- for some reason, if counterexample is removed, this test fails?
160+scan s (Positive k) = counterexample (show s)
153−scan s (Positive k) = parseT p s === Just (toStrict $ L.take k s)
161+ $ parseT p s === Just (toStrict $ L.take k s)
154 where p = P.scan k $ \ n _ ->
162 where p = P.scan k $ \ n _ ->
155 if n > 0 then let !n' = n - 1 in Just n' else Nothing
163 if n > 0 then let !n' = n - 1 in Just n' else Nothing
156
164