git.iko.soy/typeable/attoparsec
on master help sign in
QuickCheck-2.13
commit566f1e4632bdd47cc6d22c8ff6aef8639c554edd authorOleg Grenrus <oleg.grenrus@iki.fi> dateTue 13 Aug 2019, 17:50 (7 years ago) parente952847
3 files changed+18−8
attoparsec.cabal+3−3 tests/QC/ByteString.hs+4−2 tests/QC/Text.hs+11−3
attoparsec.cabal+3−3
@@ -39,7 +39,7 @@ Flag developer
3939
4040library
4141 build-depends: array,
42− base >= 4.2 && < 5,
42+ base >= 4.3 && < 5,
4343 bytestring,
4444 containers,
4545 deepseq,
@@ -124,10 +124,10 @@ test-suite tests
124124
125125 build-depends:
126126 array,
127− base >= 4 && < 5,
127+ base,
128128 bytestring,
129129 deepseq >= 1.1,
130− QuickCheck >= 2.7 && < 2.10,
130+ QuickCheck >= 2.13.2 && < 2.14,
131131 quickcheck-unicode,
132132 scientific,
133133 tasty >= 0.11,
tests/QC/ByteString.hs+4−2
@@ -26,9 +26,11 @@ import qualified Data.ByteString.Lazy.Char8 as L8
2626satisfy :: Word8 -> L.ByteString -> Property
2727satisfy w s = parseBS (P.satisfy (<=w)) (L.cons w s) === Just w
2828
29−satisfyWith :: Char -> L.ByteString -> Property
30−satisfyWith c s = parseBS (P.satisfyWith (chr . fromIntegral) (<=c))
29+satisfyWith :: Word8 -> L.ByteString -> Property
30+satisfyWith w s = parseBS (P.satisfyWith (chr . fromIntegral) (<=c))
3131 (L.cons (fromIntegral (ord c)) s) === Just c
32+ where
33+ c = chr (fromIntegral w)
3234
3335word8 :: Word8 -> L.ByteString -> Property
3436word8 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
66import Control.Applicative ((<*>), (<$>))
77#endif
88import Data.Int (Int64)
9+import Data.Word (Word8)
910import Prelude hiding (take, takeWhile)
1011import QC.Common (liftOp, parseT)
1112import qualified QC.Text.FastSet as FastSet
@@ -16,8 +17,10 @@ import Test.QuickCheck
1617import qualified Data.Attoparsec.Text as P
1718import qualified Data.Attoparsec.Text.Lazy as PL
1819import qualified Data.Attoparsec.Text.FastSet as S
20+import qualified Data.ByteString as BS
1921import qualified Data.Char as Char
2022import qualified Data.Text as T
23+import qualified Data.Text.Encoding as TE
2124import qualified Data.Text.Lazy as L
2225
2326-- Basic byte-level combinators.
@@ -70,9 +73,12 @@ strings s t u =
7073 === Just t'
7174 where t' = toStrict t
7275
73−stringCI :: T.Text -> Property
74−stringCI s = P.parseOnly (P.stringCI fs) s === Right s
76+-- | Note: "simple, and efficient" works for well formed input...
77+-- i.e. e.g. Latin1 texts
78+stringCI :: [Word8] -> Property
79+stringCI ws = P.parseOnly (P.stringCI fs) s === Right s
7580 where fs = T.toCaseFold s
81+ s = TE.decodeLatin1 (BS.pack ws)
7682
7783asciiCI :: T.Text -> Gen Bool
7884asciiCI x =
@@ -150,7 +156,9 @@ endOfLine s =
150156 (c, fst <$> L.uncons s') === ('\r', Just '\n')
151157
152158scan :: L.Text -> Positive Int64 -> Property
153−scan s (Positive k) = parseT p s === Just (toStrict $ L.take k s)
159+-- for some reason, if counterexample is removed, this test fails?
160+scan s (Positive k) = counterexample (show s)
161+ $ parseT p s === Just (toStrict $ L.take k s)
154162 where p = P.scan k $ \ n _ ->
155163 if n > 0 then let !n' = n - 1 in Just n' else Nothing
156164