diff options
author | Jasper Van der Jeugt <jaspervdj@gmail.com> | 2010-01-24 22:00:51 +0100 |
---|---|---|
committer | Jasper Van der Jeugt <jaspervdj@gmail.com> | 2010-01-24 22:00:51 +0100 |
commit | 7a75e1f4814a36f57558f59d11e5b7b948e03ed5 (patch) | |
tree | 40fad5ed9ba4da9f3aff1590d5400c3f41b130f7 /tests/Template.hs | |
parent | 81e3df1e11481f20294fcc8bc96418e40402c6ba (diff) | |
download | hakyll-7a75e1f4814a36f57558f59d11e5b7b948e03ed5.tar.gz |
test-framework is fixed again, so we use it again.
Diffstat (limited to 'tests/Template.hs')
-rw-r--r-- | tests/Template.hs | 32 |
1 files changed, 25 insertions, 7 deletions
diff --git a/tests/Template.hs b/tests/Template.hs index 9d1d39d..9ba956a 100644 --- a/tests/Template.hs +++ b/tests/Template.hs @@ -1,12 +1,25 @@ -module Template where +module Template + ( templateGroup + ) where import qualified Data.Map as M -import Test.QuickCheck import Data.Binary +import Test.Framework (testGroup) +import Test.Framework.Providers.HUnit +import Test.Framework.Providers.QuickCheck2 +import Test.HUnit import Text.Hakyll.Internal.Template +-- Template test group. +templateGroup = testGroup "Template" + [ testProperty "prop_template_encode_id" prop_template_encode_id + , testProperty "prop_substitute_id" prop_substitute_id + , testCase "test_substitute_1" test_substitute_1 + , testCase "test_substitute_2" test_substitute_2 + ] + -- Test encoding/decoding of templates. prop_template_encode_id :: Template -> Bool prop_template_encode_id template = decode (encode template) == template @@ -16,10 +29,15 @@ prop_substitute_id string = regularSubstitute (fromString string) M.empty == string -- substitute test case 1. -prop_substitute_case1 string1 string2 = - finalSubstitute template context == string1 ++ " costs $" ++ string2 ++ "." +test_substitute_1 = + finalSubstitute template context @?= "Banana costs $4." where template = fromString "$product costs $$$price." - context = M.fromList [ ("product", string1) - , ("price", string2) - ] + context = M.fromList [("product", "Banana"), ("price", "4")] + +-- substitute test case 2. +test_substitute_2 = + regularSubstitute template context @?= "$$root is a special key." + where + template = fromString "$$root is a special $thing." + context = M.fromList [("root", "foo"), ("thing", "key")] |