+{-# 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 ""