]> gitweb @ CieloNegro.org - Rakka.git/blobdiff - tests/WikiParserTest.hs
Exodus to GHC 6.8.1
[Rakka.git] / tests / WikiParserTest.hs
index 9bfdc4efa4538e8342169c1c903fba99e15184f2..a7c5c70087ecf9c41918ac06fdd847f94e4829d0 100644 (file)
@@ -3,6 +3,8 @@ module WikiParserTest
     )
     where
 
+import           Data.Maybe
+import           Network.URI
 import           Rakka.Wiki
 import           Rakka.Wiki.Parser
 import           Test.HUnit
@@ -117,6 +119,14 @@ testData = [ (parseWiki ""
               ~?=
               (Right []))
 
+           , (parseWiki "[[[Page]]]"
+              ~?=
+              (Right [ Paragraph [ ObjectLink "Page" Nothing ] ]))
+
+           , (parseWiki "[[[Page|foo]]]"
+              ~?=
+              (Right [ Paragraph [ ObjectLink "Page" (Just "foo") ] ]))
+
            , (parseWiki "[[Page]]"
               ~?= 
               (Right [ Paragraph [ PageLink (Just "Page") Nothing Nothing ]
@@ -196,44 +206,44 @@ testData = [ (parseWiki ""
 
            , (parseWiki "* a"
               ~?=
-              (Right [ List (ListElement Bullet [[Right (Text "a")]]) ]))
+              (Right [ List Bullet [[Inline (Text "a")]] ]))
 
            , (parseWiki "* a*"
               ~?=
-              (Right [ List (ListElement Bullet [[Right (Text "a*")]]) ]))
+              (Right [ List Bullet [[Inline (Text "a*")]] ]))
 
            , (parseWiki "* a\n* b\n"
               ~?=
-              (Right [ List (ListElement Bullet [ [Right (Text "a")]
-                                                , [Right (Text "b")]
-                                                ])
+              (Right [ List Bullet [ [Inline (Text "a")]
+                                   , [Inline (Text "b")]
+                                   ]
                      ]))
 
            , (parseWiki "*a\n*#b\n*#c\n"
               ~?=
-              (Right [ List (ListElement Bullet [ [ Right (Text "a")
-                                                  , Left (ListElement Numbered [ [Right (Text "b")]
-                                                                               , [Right (Text "c")]
-                                                                               ])
-                                                  ]
-                                                ])
+              (Right [ List Bullet [ [ Inline (Text "a")
+                                     , Block  (List Numbered [ [Inline (Text "b")]
+                                                             , [Inline (Text "c")]
+                                                             ])
+                                     ]
+                                   ]
                      ]))
 
            , (parseWiki "*a\n#b"
               ~?=
-              (Right [ List (ListElement Bullet   [ [Right (Text "a")] ])
-                     , List (ListElement Numbered [ [Right (Text "b")] ])
+              (Right [ List Bullet   [ [Inline (Text "a")] ]
+                     , List Numbered [ [Inline (Text "b")] ]
                      ]))
 
            , (parseWiki "*a<!-- comment -->"
               ~?=
-              (Right [ List (ListElement Bullet [ [Right (Text "a")] ]) ]))
+              (Right [ List Bullet [ [Inline (Text "a")] ] ]))
 
            , (parseWiki "*a<!-- comment -->\n*b"
               ~?=
-              (Right [ List (ListElement Bullet [ [Right (Text "a")]
-                                                , [Right (Text "b")]
-                                                ])
+              (Right [ List Bullet [ [Inline (Text "a")]
+                                   , [Inline (Text "b")]
+                                   ]
                      ]))
 
            , (parseWiki "foo:bar"
@@ -260,15 +270,15 @@ testData = [ (parseWiki ""
                                       ]
                      ]))
 
-           , (parseWiki "<![CDATA[foo [[bar]] baz]]>"
+           , (parseWiki "<!nowiki[foo [[bar]] baz]>"
               ~?=
               (Right [ Paragraph [ Text "foo [[bar]] baz" ] ]))
 
-           , (parseWiki "<![PDATA[foo [[bar]] baz]]>"
+           , (parseWiki "<!verbatim[foo [[bar]] baz]>"
               ~?=
               (Right [ Preformatted [ Text "foo [[bar]] baz" ] ]))
 
-           , (parseWiki "<![PDATA[\nfoo [[bar]] baz\n]]>"
+           , (parseWiki "<!verbatim[\nfoo [[bar]] baz\n]>"
               ~?=
               (Right [ Preformatted [ Text "foo [[bar]] baz" ] ]))
 
@@ -340,4 +350,16 @@ testData = [ (parseWiki ""
               (Right [ Paragraph [Text "foo"]
                      , BlockCmd (BlockCommand "div" [("id", "bar")] [])
                      ]))
+
+           , (parseWiki "[http://example.org/]"
+              ~?=
+              (Right [ Paragraph [ExternalLink (fromJust $ parseURI "http://example.org/") Nothing] ]))
+
+           , (parseWiki "[http://example.org/ example.org]"
+              ~?=
+              (Right [ Paragraph [ExternalLink
+                                  (fromJust $ parseURI "http://example.org/")
+                                  (Just "example.org")
+                                 ]
+                     ]))
            ]