packages feed

conduit-extra 1.1.3.1 → 1.1.3.2

raw patch · 3 files changed

+30/−4 lines, 3 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

Data/Conduit/Attoparsec.hs view
@@ -124,7 +124,7 @@ -- Since 0.5.0 conduitParser :: (AttoparsecInput a, MonadThrow m) => A.Parser a b -> Conduit a m (PositionRange, b) conduitParser parser =-    conduit $ Position 1 0+    conduit $ Position 1 1        where          conduit !pos = await >>= maybe (return ()) go              where@@ -151,7 +151,7 @@     => A.Parser a b     -> Conduit a m (Either ParseError (PositionRange, b)) conduitParserEither parser =-    conduit $ Position 1 0+    conduit $ Position 1 1   where     conduit !pos = await >>= maybe (return ()) go       where
conduit-extra.cabal view
@@ -1,5 +1,5 @@ Name:                conduit-extra-Version:             1.1.3.1+Version:             1.1.3.2 Synopsis:            Batteries included conduit: adapters for common libraries. Description:     The conduit package itself maintains relative small dependencies. The purpose of this package is to collect commonly used utility functions wrapping other library dependencies, without depending on heavier-weight dependencies. The basic idea is that this package should only depend on haskell-platform packages and conduit.
test/Data/Conduit/AttoparsecSpec.hs view
@@ -1,5 +1,6 @@ {-# LANGUAGE CPP               #-} {-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE TupleSections     #-} {-# OPTIONS_GHC -fno-warn-incomplete-patterns #-} module Data.Conduit.AttoparsecSpec (spec) where import           Control.Exception                (fromException)@@ -89,6 +90,18 @@                     case fromException e of                         Just pe -> do                             errorPosition pe `shouldBe` Position badLine badCol+        it "works for first line" $ do+            let input = ["aab\na", "aaa\n\n", "aaa", "aab\n\naaaa"]+                badLine = 1+                badCol = 3+                parser = Data.Attoparsec.Text.endOfInput <|> (Data.Attoparsec.Text.notChar 'b' >> parser)+                sink = sinkParser parser+            ea <- runExceptionT $ CL.sourceList input $$ sink+            case ea of+                Left e ->+                    case fromException e of+                        Just pe -> do+                            errorPosition pe `shouldBe` Position badLine badCol      describe "conduitParser" $ do         it "parses a repeated stream" $ do@@ -99,10 +112,23 @@             let chk a = case a of                           Left{} -> False                           Right (_, xs) -> xs == "aaa"-                chkp 1 = (PositionRange (Position 1 0) (Position 2 1))                 chkp l = (PositionRange (Position l 1) (Position (l+1) 1))             forM_ ea $ \ a -> a `shouldSatisfy` chk :: Expectation             forM_ (zip ea [1..]) $ \ (Right (pos, _), l) -> pos `shouldBe` chkp l             length ea `shouldBe` 4 +        it "positions on first line" $ do+            results <- yield "hihihi\nhihi"+                $$ conduitParser (Data.Attoparsec.Text.string "\n" <|> Data.Attoparsec.Text.string "hi")+                =$ CL.consume+            let f (a, b, c, d, e) = (PositionRange (Position a b) (Position c d), e)+            results `shouldBe` map f+                [ (1, 1, 1, 3, "hi")+                , (1, 3, 1, 5, "hi")+                , (1, 5, 1, 7, "hi") +                , (1, 7, 2, 1, "\n")++                , (2, 1, 2, 3, "hi")+                , (2, 3, 2, 5, "hi")+                ]