Merge pull request #1 from fmapfmapfmap/simplify-tests

Use Test.Hspec.Attoparsec.
This commit is contained in:
Alp Mestanogullari 2014-06-23 09:47:46 +02:00
commit 9f0d0c2568
2 changed files with 4 additions and 20 deletions

View File

@ -68,7 +68,7 @@ test-suite spec
base == 4.*
, text
, hspec
, hspec-expectations
, hspec-attoparsec
, vector
, attoparsec
, unordered-containers

View File

@ -2,16 +2,14 @@
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 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
@ -100,18 +98,4 @@ 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
(~>) = (Test.Hspec.Attoparsec.Source.~>)