From 5914fa3ac4be061d5046b204bc856d5e506f9b35 Mon Sep 17 00:00:00 2001 From: Alice Rixte Date: Sun, 13 Oct 2024 21:56:05 +0200 Subject: [PATCH] Fix #2844 --- .../FileSystem/Event/{Darwin.m => Darwin.c} | 0 streamly.cabal | 2 +- test/Streamly/Test/Data/Parser.hs | 23 +++++++++++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) rename src/Streamly/Internal/FileSystem/Event/{Darwin.m => Darwin.c} (100%) diff --git a/src/Streamly/Internal/FileSystem/Event/Darwin.m b/src/Streamly/Internal/FileSystem/Event/Darwin.c similarity index 100% rename from src/Streamly/Internal/FileSystem/Event/Darwin.m rename to src/Streamly/Internal/FileSystem/Event/Darwin.c diff --git a/streamly.cabal b/streamly.cabal index 6f0d82d858..01269cd78f 100644 --- a/streamly.cabal +++ b/streamly.cabal @@ -442,7 +442,7 @@ library if os(darwin) include-dirs: src/Streamly/Internal - c-sources: src/Streamly/Internal/FileSystem/Event/Darwin.m + c-sources: src/Streamly/Internal/FileSystem/Event/Darwin.c exposed-modules: Streamly.Internal.FileSystem.Event.Darwin if os(linux) diff --git a/test/Streamly/Test/Data/Parser.hs b/test/Streamly/Test/Data/Parser.hs index f17e214c9d..6bb7b9294d 100644 --- a/test/Streamly/Test/Data/Parser.hs +++ b/test/Streamly/Test/Data/Parser.hs @@ -1378,6 +1378,15 @@ expectedResult moves inp = go 0 0 [] moves P.Done n () -> (Right ys, slice_ (max (i - n + 1) j) inp) P.Error err -> (Left (ParseError err), slice_ j inp) +expectedResultMany :: [Move] -> [Int] -> [Either ParseError [Int]] +expectedResultMany _ [] = [] +expectedResultMany moves inp = + let (res, rest) = expectedResult moves inp + in + case res of + Left err -> [Left err] + Right val -> Right val : expectedResultMany moves rest + createPaths :: [a] -> [[a]] createPaths xs = Prelude.map (flip Prelude.take xs) [1..length xs] @@ -1485,6 +1494,18 @@ sanityParseBreakChunksK jumps = it (show jumps) $ do lst <- Prelude.map A.toList <$> K.toList rest (val, concat lst) `shouldBe` (expectedResult jumps tape) +sanityParseMany :: [Move] -> SpecWith () +sanityParseMany jumps = it (show jumps) $ do + res <- S.toList $ SI.parseMany (jumpParser jumps) $ S.fromList tape + res `shouldBe` (expectedResultMany jumps tape) + +sanityParseIterate :: [Move] -> SpecWith () +sanityParseIterate jumps = it (show jumps) $ do + res <- + S.toList + $ SI.parseIterate (const (jumpParser jumps)) [] $ S.fromList tape + res `shouldBe` (expectedResultMany jumps tape) + ------------------------------------------------------------------------------- -- Main ------------------------------------------------------------------------------- @@ -1501,6 +1522,8 @@ main = parserSanityTests "Stream.parseBreak" sanityParseBreak parserSanityTests "StreamK.parseDBreak" sanityParseDBreak parserSanityTests "A.sanityParseBreakChunksK" sanityParseBreakChunksK + parserSanityTests "Stream.parseMany" sanityParseMany + parserSanityTests "Stream.parseIterate" sanityParseIterate describe "Instances" $ do prop "applicative" applicative prop "Alternative: end of input 1" altEOF1