Permalink
Browse files

Merge pull request #1 from snoyberg/master

Move to conduit 0.4
  • Loading branch information...
2 parents 0d963bd + 150d64f commit 18fd6ad70cd20c3b9f10b311b52f7ca677147849 @yihuang committed Apr 3, 2012
Showing with 21 additions and 24 deletions.
  1. +1 −1 Text/HTML/TagStream/Stream.hs
  2. +4 −6 tagstream-conduit.cabal
  3. +16 −17 tests/Tests.hs
@@ -9,7 +9,7 @@ import Text.HTML.TagStream.Parser
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 =
View
@@ -1,5 +1,5 @@
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.
@@ -32,10 +32,10 @@ Library
, 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
+ , blaze-builder-conduit >= 0.4 && < 0.5
test-suite test
hs-source-dirs: tests
@@ -46,8 +46,6 @@ test-suite test
, conduit >= 0.0.2
, QuickCheck
, HUnit
- , test-framework
- , test-framework-quickcheck2
- , test-framework-hunit
+ , hspec
, tagstream-conduit
ghc-options: -Wall
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 qualified Data.Conduit.List as CL
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 @@ propResultNotEmpty s = either (const False) not_empty . decode $ s
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 (

0 comments on commit 18fd6ad

Please sign in to comment.