tagstream-conduit 0.2.2 → 0.3.0
raw patch · 3 files changed
+23/−26 lines, 3 filesdep +hspecdep −test-frameworkdep −test-framework-hunitdep −test-framework-quickcheck2dep ~blaze-builder-conduitdep ~conduitnew-uploaderPVP ok
version bump matches the API change (PVP)
Dependencies added: hspec
Dependencies removed: test-framework, test-framework-hunit, test-framework-quickcheck2
Dependency ranges changed: blaze-builder-conduit, conduit
API changes (from Hackage documentation)
- Text.HTML.TagStream: tokenStream :: Resource m => Conduit ByteString m Token
+ Text.HTML.TagStream: tokenStream :: Monad m => Conduit ByteString m Token
- Text.HTML.TagStream.Stream: tokenStream :: Resource m => Conduit ByteString m Token
+ Text.HTML.TagStream.Stream: tokenStream :: Monad m => Conduit ByteString m Token
Files
- Text/HTML/TagStream/Stream.hs +1/−1
- tagstream-conduit.cabal +6/−8
- tests/Tests.hs +16/−17
Text/HTML/TagStream/Stream.hs view
@@ -9,7 +9,7 @@ import Text.HTML.TagStream.Types -- | html parser conduit.-tokenStream :: Resource m => Conduit ByteString m Token+tokenStream :: Monad m => Conduit ByteString m Token tokenStream = conduitState S.empty push close where push accum input =
tagstream-conduit.cabal view
@@ -1,10 +1,10 @@ Name: tagstream-conduit-Version: 0.2.2+Version: 0.3.0 Synopsis: streamlined html tag parser Description: Tag-stream is a library for parsing HTML//XML to a token stream. It can parse unstructured and malformed HTML from the web.- It provides a Conduit to parse html streamlined, which consumes constant memory.+ It also provides an Enumeratee which can parse streamline html, which means it consumes constant memory. You can start from the `tests/Tests.hs` module to see what it can do. Homepage: http://github.com/yihuang/tagstream-conduit@@ -32,10 +32,10 @@ , Text.HTML.TagStream.Utils Build-depends: base >= 4 && < 5 , bytestring- , conduit >= 0.2.0+ , conduit >= 0.4 && < 0.5 , attoparsec , blaze-builder- , blaze-builder-conduit >= 0.2.0+ , blaze-builder-conduit >= 0.4 && < 0.5 test-suite test hs-source-dirs: tests@@ -43,11 +43,9 @@ type: exitcode-stdio-1.0 build-depends: base >= 4 && < 5 , bytestring- , conduit >= 0.2.0+ , conduit >= 0.0.2 , QuickCheck , HUnit- , test-framework- , test-framework-quickcheck2- , test-framework-hunit+ , hspec , tagstream-conduit ghc-options: -Wall
tests/Tests.hs view
@@ -1,10 +1,11 @@ {-# LANGUAGE FlexibleInstances, OverloadedStrings #-}+{-# OPTIONS_GHC -fno-warn-orphans #-} module Main where import Control.Applicative-import Test.Framework (defaultMain, testGroup, Test)-import Test.Framework.Providers.HUnit-import Test.Framework.Providers.QuickCheck2+import Test.Hspec.Monadic+import Test.Hspec.HUnit ()+import Test.Hspec.QuickCheck (prop) import Test.HUnit hiding (Test) import Test.QuickCheck import Data.ByteString (ByteString)@@ -14,14 +15,12 @@ import Text.HTML.TagStream main :: IO ()-main = defaultMain- [ testGroup "Property"- [ testProperty "Text nodes can't be empty" propTextNotEmpty- , testProperty "Parse results can't empty" propResultNotEmpty- ]- , testGroup "One pass parse" onePassTests- , testGroup "Streamline parse" streamlineTests- ]+main = hspecX $ do+ describe "Property" $ do+ prop "Text nodes can't be empty" propTextNotEmpty+ prop "Parse results can't empty" propResultNotEmpty+ describe "One pass parse" onePassTests+ describe "Streamline parse" streamlineTests propTextNotEmpty :: ByteString -> Bool propTextNotEmpty = either (const False) text_not_empty . decode@@ -34,19 +33,19 @@ where not_empty tokens = (S.null s && null tokens) || (not (S.null s) && not (null tokens)) -onePassTests :: [Test]-onePassTests = map one testcases+onePassTests :: Specs+onePassTests = mapM_ one testcases where- one (str, tokens) = testCase (S.unpack str) $ do+ one (str, tokens) = it (S.unpack str) $ do result <- combineText <$> assertDecode str assertEqual "one-pass parse result incorrect" tokens result -streamlineTests :: [Test]-streamlineTests = map one testcases+streamlineTests :: Specs+streamlineTests = mapM_ one testcases where isIncomplete (Incomplete _) = True isIncomplete _ = False- one (str, tokens) = testCase (S.unpack str) $ do+ one (str, tokens) = it (S.unpack str) $ do -- streamline parse result don't contain the trailing Incomplete token. let tokens' = reverse . dropWhile isIncomplete . reverse $ tokens result <- combineText <$> C.runResourceT (