network-attoparsec 0.11.1 → 0.11.2
raw patch · 3 files changed
+6/−7 lines, 3 files
Files
network-attoparsec.cabal view
@@ -1,6 +1,6 @@ name: network-attoparsec category: Network, Parsing -version: 0.11.1 +version: 0.11.2 license: MIT license-file: LICENSE copyright: (c) 2015 Leon Mergen
src/Network/Attoparsec.hs view
@@ -55,7 +55,6 @@ -> m (ParseC a, [a]) -- ^ Next parser state with parsed values parseMany s p0 pCur = do buf <- readAvailable s - liftIO $ putStrLn ("got buf: " ++ show buf) (p1, xs) <- parseBuffer p0 Many buf pCur return (p1, xs) @@ -79,7 +78,6 @@ -> m a -- ^ Parsed value parseOne s p0 = do buf <- readAvailable s - liftIO $ putStrLn ("got buf: " ++ show buf) (p1, value) <- parseBuffer p0 Single buf p0 case value of
test/Network/AttoparsecSpec.hs view
@@ -7,6 +7,7 @@ import Control.Monad.Catch import Control.Monad.IO.Class +import System.IO.Error (isUserError) import qualified Data.Attoparsec.ByteString as Atto @@ -76,14 +77,14 @@ readSocket s = Atto.parseOne s (Atto.parse numberParser) numberParser = decimal - in (pairSockets writeSocket readSocket) `shouldThrow` anyIOException + in (pairSockets writeSocket readSocket) `shouldThrow` isUserError it "it should throw an error when the provided data is incorrect" $ let writeSocket s = NS.send s "ab" readSocket s = Atto.parseOne s (Atto.parse numberParser) numberParser = decimal - in (pairSockets writeSocket readSocket) `shouldThrow` anyIOException + in (pairSockets writeSocket readSocket) `shouldThrow` isUserError it "it should throw an error when the socket is closed before parsing could be completed" $ let writeSocket s = NS.send s "12" @@ -93,7 +94,7 @@ _ <- endOfLine return () - in (pairSockets writeSocket readSocket) `shouldThrow` anyIOException + in (pairSockets writeSocket readSocket) `shouldThrow` isUserError describe "when parsing multiple matching objects" $ do let numberParser :: Atto.Parser Integer @@ -106,7 +107,7 @@ let writeSocket s = NS.send s "1234\n5678\n" readSocket s = Atto.parseOne s (Atto.parse numberParser) - in (pairSockets writeSocket readSocket) `shouldThrow` anyIOException + in (pairSockets writeSocket readSocket) `shouldThrow` isUserError it "should return multiple objects when using multi object parser" $ let writeSocket s = NS.send s "1234\n5678\n"