From f70ec4a0beb4d52ca87f05d9b9593fee99567907 Mon Sep 17 00:00:00 2001 From: Alp Mestanogullari Date: Mon, 16 Jun 2014 16:38:29 +0200 Subject: [PATCH] add some basic tests for the parser --- taggy.cabal | 20 ++++++ tests/Spec.hs | 1 + tests/Text/Taggy/ParserSpec.hs | 117 +++++++++++++++++++++++++++++++++ 3 files changed, 138 insertions(+) create mode 100644 tests/Spec.hs create mode 100644 tests/Text/Taggy/ParserSpec.hs diff --git a/taggy.cabal b/taggy.cabal index 26bd5bf..b79a60d 100644 --- a/taggy.cabal +++ b/taggy.cabal @@ -54,3 +54,23 @@ benchmark taggytagsoup criterion, vector default-language: Haskell2010 + +test-suite spec + type: + exitcode-stdio-1.0 + ghc-options: + -Wall -O -fno-warn-unused-do-bind + hs-source-dirs: + src, tests + main-is: + Spec.hs + build-depends: + base == 4.* + , text + , hspec + , hspec-expectations + , vector + , attoparsec + , unordered-containers + default-language: + Haskell2010 diff --git a/tests/Spec.hs b/tests/Spec.hs new file mode 100644 index 0000000..a824f8c --- /dev/null +++ b/tests/Spec.hs @@ -0,0 +1 @@ +{-# OPTIONS_GHC -F -pgmF hspec-discover #-} diff --git a/tests/Text/Taggy/ParserSpec.hs b/tests/Text/Taggy/ParserSpec.hs new file mode 100644 index 0000000..3643ebe --- /dev/null +++ b/tests/Text/Taggy/ParserSpec.hs @@ -0,0 +1,117 @@ +{-# LANGUAGE OverloadedStrings #-} + +module Text.Taggy.ParserSpec where + +import Control.Monad +import Data.Attoparsec.Text.Lazy +import Data.Text.Lazy +import Test.Hspec +import Text.Taggy.Parser +import Text.Taggy.Types + +main :: IO () +main = hspec spec + +spec :: Spec +spec = do + describe "tagopen parser" $ do + it "successfully parses " $ + "" ~> tagopen False + `shouldParse` TagOpen "b" [] False + + it "successfully parses " $ + "" ~> tagopen False + `shouldParse` TagOpen "a" [Attribute "href" "/home"] False + + it "successfully parses