git.iko.soy/typeable/attoparsec
on master help sign in
Fix up an errant test.
66ab088Bryan O'Sullivan
tests/Makefile+4−1
@@ -1,9 +1,12 @@
1−all: TestFastSet.out QC.out
1+all: TestFastSet.out qc.out
2
2
3%.out: %.exe
3%.out: %.exe
4 ./$< | tee $<.tmp
4 ./$< | tee $<.tmp
5 mv $<.tmp $@
5 mv $<.tmp $@
6
6
7+qc.exe: QC.hs
8+ ghc -O -fno-warn-orphans --make -o $@ $<
9+
7%.exe: %.hs
10%.exe: %.hs
8 ghc -O -fno-warn-orphans --make -o $@ $<
11 ghc -O -fno-warn-orphans --make -o $@ $<
9
12
tests/QC.hs+6−3
@@ -1,3 +1,4 @@
1+{-# LANGUAGE OverloadedStrings #-}
1module Main (main) where
2module Main (main) where
2
3
3import Control.Monad (forM_)
4import Control.Monad (forM_)
@@ -10,6 +11,7 @@ import Test.Framework.Providers.QuickCheck2 (testProperty)
10import Test.QuickCheck hiding (NonEmpty)
11import Test.QuickCheck hiding (NonEmpty)
11import qualified Data.Attoparsec as P
12import qualified Data.Attoparsec as P
12import qualified Data.ByteString as B
13import qualified Data.ByteString as B
14+import qualified Data.ByteString.Char8 as C
13
15
14-- Make sure that structures whose types claim they are non-empty
16-- Make sure that structures whose types claim they are non-empty
15-- really are.
17-- really are.
@@ -63,9 +65,10 @@ takeWhile (w,s) =
63 P.Done t' h' -> t == t' && h == h'
65 P.Done t' h' -> t == t' && h == h'
64 _ -> False
66 _ -> False
65
67
66−takeWhile1 (w, NonEmpty s) =
68+takeWhile1 (w, s) =
69+ let s' = B.cons w s
67− let (h,t) = B.span (==w) s
70+ (h,t) = B.span (<=w) s'
68− in case defP (P.takeWhile1 (==w)) s of
71+ in case defP (P.takeWhile1 (<=w)) s' of
69 P.Done t' h' -> t == t' && h == h'
72 P.Done t' h' -> t == t' && h == h'
70 _ -> False
73 _ -> False
71
74