{-# LANGUAGE OverloadedStrings #-} module Main where import Data.Attoparsec.Text import qualified Data.Text as T import Test.Tasty import Test.Tasty.Hspec as HS import Hasciidoc main :: IO () main = defaultMain tests tests :: TestTree tests = testGroup "Tests" [specs] -- Hspec Tests specs :: TestTree specs = testGroup "Specifications" [ HS.testCase "Header Parsing" headerParseSpec ] headerParseSpec :: Spec headerParseSpec = do describe "Document Header" $ do describe "Document Title" $ do describe "pTitle" $ do it "parses a one-line level 0 title with no right-hand delimiter" $ parseOnly pTitle "= This is a level 0 title\n" `shouldBe` Right (0, "This is a level 0 title") it "parses a one-line level 0 title with a right-hand delimeter" $ parseOnly pTitle "= This is another level 0 title =\n" `shouldBe` Right (0, "This is another level 0 title") it "parses a two-line level 0 title with a full-length underline" $ parseOnly pTitle "This is a two-line level 0 title\n\ \================================\n" `shouldBe` Right (0, "This is a two-line level 0 title") it "parses a two-line level 0 title with a minimal underline" $ parseOnly pTitle "Another two-line level 0 title\n\ \==\n" `shouldBe` Right (0, "Another two-line level 0 title") it "parses a one-line level 1 title" $ parseOnly pTitle "== Level 1\n" `shouldBe` Right (1, "Level 1") it "parses a one-line level 1 title with right-delimiter" $ parseOnly pTitle "== Level 1 ==\n" `shouldBe` Right (1, "Level 1") it "parses a one-line level 2 title" $ parseOnly pTitle "=== Level 2\n" `shouldBe` Right (2, "Level 2") it "parses a one-line level 2 title with right-delimiter" $ parseOnly pTitle "=== Level 2 ===\n" `shouldBe` Right (2, "Level 2") it "parses a one-line level 3 title" $ parseOnly pTitle "==== Level 3\n" `shouldBe` Right (3, "Level 3") it "parses a one-line level 3 title with right-delimiter" $ parseOnly pTitle "==== Level 3 ====\n" `shouldBe` Right (3, "Level 3") it "parses a one-line level 4 title" $ parseOnly pTitle "===== Level 4\n" `shouldBe` Right (4, "Level 4") it "parses a one-line level 4 title with right-delimiter" $ parseOnly pTitle "===== Level 4 =====\n" `shouldBe` Right (4, "Level 4") it "parses a two-line level 1 title" $ parseOnly pTitle "A two-line level 1 title\n--\n" `shouldBe` Right (1, "A two-line level 1 title") it "parses a two-line level 2 title" $ parseOnly pTitle "A two-line level 2 title\n~~\n" `shouldBe` Right (2, "A two-line level 2 title") it "parses a two-line level 3 title" $ parseOnly pTitle "A two-line level 3 title\n^^\n" `shouldBe` Right (3, "A two-line level 3 title") it "parses a two-line level 4 title" $ parseOnly pTitle "A two-line level 4 title\n++\n" `shouldBe` Right (4, "A two-line level 4 title")