From bee253e428d0dae03fd1510f4868a57de8132dd9 Mon Sep 17 00:00:00 2001 From: vi Date: Mon, 23 Jun 2014 13:19:43 +0800 Subject: [PATCH 1/3] Remove definition of shouldParse (it's in hspec-attoparsec), and dependency on hspec-expectations. --- taggy.cabal | 2 +- tests/Text/Taggy/ParserSpec.hs | 16 +--------------- 2 files changed, 2 insertions(+), 16 deletions(-) diff --git a/taggy.cabal b/taggy.cabal index b79a60d..5de7c84 100644 --- a/taggy.cabal +++ b/taggy.cabal @@ -68,7 +68,7 @@ test-suite spec base == 4.* , text , hspec - , hspec-expectations + , hspec-attoparsec , vector , attoparsec , unordered-containers diff --git a/tests/Text/Taggy/ParserSpec.hs b/tests/Text/Taggy/ParserSpec.hs index 3643ebe..f9168c6 100644 --- a/tests/Text/Taggy/ParserSpec.hs +++ b/tests/Text/Taggy/ParserSpec.hs @@ -2,10 +2,10 @@ module Text.Taggy.ParserSpec where -import Control.Monad import Data.Attoparsec.Text.Lazy import Data.Text.Lazy import Test.Hspec +import Test.Hspec.Attoparsec (shouldParse) import Text.Taggy.Parser import Text.Taggy.Types @@ -101,17 +101,3 @@ spec = do (~>) :: Text -> Parser a -> Either String a t ~> p = eitherResult $ parse p t - -shouldParse :: (Eq a, Show a) => Either String a -> a -> Expectation -res `shouldParse` expectedVal = - either (expectationFailure . errmsg) - checkEquality - res - - where errmsg err = " expected: " ++ show expectedVal - ++ "\n but parse failed with error: " ++ err - - checkEquality parsedVal = - when (parsedVal /= expectedVal) $ - expectationFailure $ " expected: " ++ show expectedVal - ++ "\n but got: " ++ show parsedVal \ No newline at end of file From a608e0494d8de543a476cc52c75ba21f35dd3e45 Mon Sep 17 00:00:00 2001 From: vi Date: Mon, 23 Jun 2014 13:24:12 +0800 Subject: [PATCH 2/3] Define ~> as a specialisation of the version in Hspec.Attoparsec.Source. --- tests/Text/Taggy/ParserSpec.hs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/Text/Taggy/ParserSpec.hs b/tests/Text/Taggy/ParserSpec.hs index f9168c6..dbf48d4 100644 --- a/tests/Text/Taggy/ParserSpec.hs +++ b/tests/Text/Taggy/ParserSpec.hs @@ -6,6 +6,7 @@ import Data.Attoparsec.Text.Lazy import Data.Text.Lazy import Test.Hspec import Test.Hspec.Attoparsec (shouldParse) +import qualified Test.Hspec.Attoparsec.Source (Source((~>))) import Text.Taggy.Parser import Text.Taggy.Types @@ -100,4 +101,4 @@ spec = do ] (~>) :: Text -> Parser a -> Either String a -t ~> p = eitherResult $ parse p t +(~>) = (Test.Hspec.Attoparsec.Source.~>) From 5a673ab3ffb2a1673ef120ab430eefcc7ea0f4f7 Mon Sep 17 00:00:00 2001 From: vi Date: Mon, 23 Jun 2014 13:43:01 +0800 Subject: [PATCH 3/3] Remove main from ParserSpec; we've only one spec, so this is redundant with Spec.main. --- tests/Text/Taggy/ParserSpec.hs | 3 --- 1 file changed, 3 deletions(-) diff --git a/tests/Text/Taggy/ParserSpec.hs b/tests/Text/Taggy/ParserSpec.hs index dbf48d4..7d1381a 100644 --- a/tests/Text/Taggy/ParserSpec.hs +++ b/tests/Text/Taggy/ParserSpec.hs @@ -10,9 +10,6 @@ import qualified Test.Hspec.Attoparsec.Source (Source((~>))) import Text.Taggy.Parser import Text.Taggy.Types -main :: IO () -main = hspec spec - spec :: Spec spec = do describe "tagopen parser" $ do