Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
AliceRixte committed Oct 13, 2024
1 parent 3c4e847 commit 5914fa3
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion streamly.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
23 changes: 23 additions & 0 deletions test/Streamly/Test/Data/Parser.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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
-------------------------------------------------------------------------------
Expand All @@ -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
Expand Down

0 comments on commit 5914fa3

Please sign in to comment.