summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJasper Van der Jeugt <jaspervdj@gmail.com>2010-01-24 22:00:51 +0100
committerJasper Van der Jeugt <jaspervdj@gmail.com>2010-01-24 22:00:51 +0100
commit7a75e1f4814a36f57558f59d11e5b7b948e03ed5 (patch)
tree40fad5ed9ba4da9f3aff1590d5400c3f41b130f7 /tests
parent81e3df1e11481f20294fcc8bc96418e40402c6ba (diff)
downloadhakyll-7a75e1f4814a36f57558f59d11e5b7b948e03ed5.tar.gz
test-framework is fixed again, so we use it again.
Diffstat (limited to 'tests')
-rw-r--r--tests/Main.hs23
-rw-r--r--tests/Template.hs32
-rw-r--r--tests/Util.hs15
3 files changed, 45 insertions, 25 deletions
diff --git a/tests/Main.hs b/tests/Main.hs
index 3654340..e3a673d 100644
--- a/tests/Main.hs
+++ b/tests/Main.hs
@@ -1,23 +1,12 @@
module Main where
-import Control.Monad (mapM_)
-import Test.QuickCheck
+import Test.Framework (defaultMain, testGroup)
+import Test.Framework.Providers.HUnit
+import Test.Framework.Providers.QuickCheck2
import Template
import Util
-main = do
- runTests "Template" $ do
- quickCheck prop_template_encode_id
- quickCheck prop_substitute_id
- quickCheck prop_substitute_case1
-
- runTests "Util" $ do
- quickCheck prop_trim_length
- quickCheck prop_trim_id
- quickCheck prop_stripHTML_length
- quickCheck prop_stripHTML_id
-
- where
- runTests name action = do putStrLn name
- action
+main = defaultMain [ templateGroup
+ , utilGroup
+ ]
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")]
diff --git a/tests/Util.hs b/tests/Util.hs
index 9e2a0dd..087edbd 100644
--- a/tests/Util.hs
+++ b/tests/Util.hs
@@ -1,11 +1,24 @@
-module Util where
+module Util
+ ( utilGroup
+ ) where
import Data.Char
import Test.QuickCheck
+import Test.Framework (testGroup)
+import Test.Framework.Providers.HUnit
+import Test.Framework.Providers.QuickCheck2
import Text.Hakyll.Util
+-- Util test group.
+utilGroup = testGroup "Util"
+ [ testProperty "prop_trim_length" prop_trim_length
+ , testProperty "prop_trim_id" prop_trim_id
+ , testProperty "prop_stripHTML_length" prop_stripHTML_length
+ , testProperty "prop_stripHTML_id" prop_stripHTML_id
+ ]
+
-- Test that a string always becomes shorter when trimmed.
prop_trim_length str = length str >= length (trim str)