@@ -1,6 +1,7 @@
1module Main (main) where
1module Main (main) where
3import Control.Exception (SomeException(..), displayException)
3import Control.Exception (SomeException(..), displayException)
4+import Data.Foldable (for_)
4import Data.Word (Word8, Word32, Word64)
5import Data.Word (Word8, Word32, Word64)
5import Streamly.Test.Common (listEquals, checkListEqual, chooseInt)
6import Streamly.Test.Common (listEquals, checkListEqual, chooseInt)
6import Test.Hspec (Spec, hspec, describe)
7import Test.Hspec (Spec, hspec, describe)
@@ -467,6 +468,68 @@ wordBy =
467 let wrds = words lst
468 let wrds = words lst
468 in if wrds == [] && length lst > 0 then [""] else wrds
469 in if wrds == [] && length lst > 0 then [""] else wrds
471+parseManyWordQuotedBy :: H.SpecWith ()
472+parseManyWordQuotedBy =
473+ describe "parseMany wordQuotedBy"
475+ $ \c@(kQ, lQ, rQ, fromLQ, input, expected) -> do
476+ let inpStrm = S.fromList input
484+ parser = P.wordQuotedBy kQ esc lQ rQ fromLQ spc FL.toList
485+ result <- H.runIO $ S.toList $ S.parseMany parser inpStrm
486+ H.it (showCase c) $ result `H.shouldBe` expected
490+ showCase (kQ, _, _, _, input, expected) =
491+ show kQ ++ ", " ++ input ++ " -> " ++ show expected
498+ , "The quick brown fox"
499+ , ["The", "quick", "brown", "fox"])
504+ , "The' quick brown' fox"
505+ , ["The' quick brown'", "fox"])
510+ , "The' quick brown' fox"
511+ , ["The quick brown", "fox"])
515+ , \x -> if x == '[' then ']' else error "Not an opening quote."
516+ , "The[ quick brown] fox"
517+ , ["The[ quick brown]", "fox"])
521+ , \x -> if x == '[' then ']' else error "Not an opening quote."
522+ , "The[ qui[ck] brown] \\ f[ ox]"
523+ , ["The[ qui[ck] brown]", " f[ ox]"])
527+ , \x -> if x == '[' then ']' else error "Not an opening quote."
528+ , "The[ qui[ck] brown] fox"
529+ , ["The qui[ck] brown", "fox"])
470-- splitWithPass :: Property
533-- splitWithPass :: Property
471-- splitWithPass =
534-- splitWithPass =
472-- forAll (listOf (chooseInt (0, 1))) $ \ls ->
535-- forAll (listOf (chooseInt (0, 1))) $ \ls ->
@@ -1106,6 +1169,7 @@ main =
1106 prop ("P.takeP = Prelude.take") takeP
1169 prop ("P.takeP = Prelude.take") takeP
1107 prop "P.groupBy = Prelude.head . Prelude.groupBy" groupBy
1170 prop "P.groupBy = Prelude.head . Prelude.groupBy" groupBy
1108 prop "many (P.wordBy ' ') = words'" wordBy
1171 prop "many (P.wordBy ' ') = words'" wordBy
1172+ parseManyWordQuotedBy
1109 prop "choice" choice
1173 prop "choice" choice
1110 -- prop "" splitWithPass
1174 -- prop "" splitWithPass
1111 -- prop "" splitWithFailLeft
1175 -- prop "" splitWithFailLeft