X-Git-Url: https://git.cielonegro.org/gitweb.cgi?p=Rakka.git;a=blobdiff_plain;f=tests%2FWikiParserTest.hs;fp=tests%2FWikiParserTest.hs;h=d3ee81682c8eb5a21b1ea222779250e0f8a7dc52;hp=856707244b527a24356e048bd1c43f0e5211e3a1;hb=42f51754dea02201aececaacbf194d714cd58aaf;hpb=98fd1cb53a837a9bda7145544c34872acb13a634 diff --git a/tests/WikiParserTest.hs b/tests/WikiParserTest.hs index 8567072..d3ee816 100644 --- a/tests/WikiParserTest.hs +++ b/tests/WikiParserTest.hs @@ -1,30 +1,32 @@ +{-# LANGUAGE + OverloadedStrings + , UnicodeSyntax + #-} module WikiParserTest ( testData ) where - +import Control.Applicative import Data.Maybe +import Data.Text (Text) import Network.URI import Rakka.Wiki import Rakka.Wiki.Parser import Test.HUnit import Text.ParserCombinators.Parsec +cmdTypeOf ∷ Alternative f ⇒ Text → f CommandType +cmdTypeOf "br" = pure InlineCommandType +cmdTypeOf "i" = pure InlineCommandType +cmdTypeOf "b" = pure InlineCommandType +cmdTypeOf "span" = pure InlineCommandType +cmdTypeOf "div" = pure BlockCommandType +cmdTypeOf _ = empty -cmdTypeOf :: String -> Maybe CommandType -cmdTypeOf "br" = Just InlineCommandType -cmdTypeOf "i" = Just InlineCommandType -cmdTypeOf "b" = Just InlineCommandType -cmdTypeOf "span" = Just InlineCommandType -cmdTypeOf "div" = Just BlockCommandType -cmdTypeOf _ = Nothing - - -parseWiki :: String -> Either String WikiPage +parseWiki ∷ String → Either String WikiPage parseWiki src = case parse (wikiPage cmdTypeOf) "" src of - Left err -> Left (show err) - Right page -> Right page - + Left err → Left (show err) + Right page → Right page testData :: [Test] testData = [ (parseWiki ""