diff options
author | Jasper Van der Jeugt <m@jaspervdj.be> | 2013-02-26 19:20:55 +0100 |
---|---|---|
committer | Jasper Van der Jeugt <m@jaspervdj.be> | 2013-02-26 19:20:55 +0100 |
commit | d993ebce58acee1e53ee5693743463c5c402919e (patch) | |
tree | 3e8108bf28edd8903cb3ad5c7ebefcb8df748a71 /tests/Hakyll | |
parent | ac527bd91e7f5a053f78a3bfa08525a290d82450 (diff) | |
download | hakyll-d993ebce58acee1e53ee5693743463c5c402919e.tar.gz |
Add testcase for #115
Diffstat (limited to 'tests/Hakyll')
-rw-r--r-- | tests/Hakyll/Core/Provider/Metadata/Tests.hs | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/tests/Hakyll/Core/Provider/Metadata/Tests.hs b/tests/Hakyll/Core/Provider/Metadata/Tests.hs new file mode 100644 index 0000000..1217180 --- /dev/null +++ b/tests/Hakyll/Core/Provider/Metadata/Tests.hs @@ -0,0 +1,53 @@ +-------------------------------------------------------------------------------- +module Hakyll.Core.Provider.Metadata.Tests + ( tests + ) where + + +-------------------------------------------------------------------------------- +import Test.Framework (Test, testGroup) +import Test.HUnit (Assertion, (@=?)) +import Text.Parsec as P +import Text.Parsec.String (Parser) + + +-------------------------------------------------------------------------------- +import Hakyll.Core.Provider.Metadata +import TestSuite.Util + + +-------------------------------------------------------------------------------- +tests :: Test +tests = testGroup "Hakyll.Core.Provider.Metadata.Tests" $ + fromAssertions "page" [testPage01, testPage02] + + +-------------------------------------------------------------------------------- +testPage01 :: Assertion +testPage01 = testParse page ([("foo", "bar")], "qux\n") + "---\n\ + \foo: bar\n\ + \---\n\ + \qux\n" + + +-------------------------------------------------------------------------------- +testPage02 :: Assertion +testPage02 = testParse page + ([("description", descr)], "Hello I am dog\n") + "---\n\ + \description: A long description that would look better if it\n\ + \ spanned multiple lines and was indented\n\ + \---\n\ + \Hello I am dog\n" + where + descr = + "A long description that would look better if it \ + \spanned multiple lines and was indented" + + +-------------------------------------------------------------------------------- +testParse :: (Eq a, Show a) => Parser a -> a -> String -> Assertion +testParse parser expected input = case P.parse parser "<inline>" input of + Left err -> error $ show err + Right x -> expected @=? x |