summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJasper Van der Jeugt <jaspervdj@gmail.com>2010-12-23 14:32:43 +0100
committerJasper Van der Jeugt <jaspervdj@gmail.com>2010-12-23 14:32:43 +0100
commiteabc26812d5deb6ef818c20b2ed4c4d07e14feaa (patch)
tree238503a400e26500eb9d7f7d5bef64db7902a7ba /tests
parentad6712121ffc3e41f6bd2a9833267252315b6f65 (diff)
downloadhakyll-eabc26812d5deb6ef818c20b2ed4c4d07e14feaa.tar.gz
Remove old tests for now
Diffstat (limited to 'tests')
-rw-r--r--tests/CompressCss.hs42
-rw-r--r--tests/File.hs62
-rw-r--r--tests/Main.hs22
-rw-r--r--tests/Page.hs92
-rw-r--r--tests/Regex.hs24
-rw-r--r--tests/Template.hs70
-rw-r--r--tests/Util.hs54
7 files changed, 0 insertions, 366 deletions
diff --git a/tests/CompressCss.hs b/tests/CompressCss.hs
deleted file mode 100644
index 164df59..0000000
--- a/tests/CompressCss.hs
+++ /dev/null
@@ -1,42 +0,0 @@
--- | Module testing @Text.Hakyll.Internal.CompressCss@.
-module CompressCss
- ( compressCssGroup
- ) where
-
-import qualified Data.Map as M
-
-import Data.Binary
-import Test.Framework (testGroup)
-import Test.Framework.Providers.HUnit
-import Test.Framework.Providers.QuickCheck2
-import Test.HUnit
-
-import Text.Hakyll.Internal.CompressCss
-
--- CompressCss test group.
-compressCssGroup = testGroup "CompressCss"
- [ testProperty "prop_compressCss_length" prop_compressCss_length
- , testCase "test_compressCss_1" test_compressCss_1
- , testCase "test_compressCss_2" test_compressCss_2
- , testCase "test_compressCss_3" test_compressCss_3
- , testCase "test_compressCss_4" test_compressCss_4
- ]
-
--- | Css compression should always decrease the text length.
-prop_compressCss_length str = length str >= length (compressCss str)
-
--- | compressCss test case 1.
-test_compressCss_1 = compressCss "a { \n color : red; }" @?= "a{color:red}"
-
--- | compressCss test case 2.
-test_compressCss_2 = compressCss "img {border :none;;;; }"
- @?= "img{border:none}"
-
--- | compressCss test case 3.
-test_compressCss_3 =
- compressCss "p {font-size : 90%;} h1 {color :white;;; }"
- @?= "p{font-size:90%}h1{color:white}"
-
--- | compressCss test case 4.
-test_compressCss_4 = compressCss "a { /* /* red is pretty cool */ color: red; }"
- @?= "a{color:red}"
diff --git a/tests/File.hs b/tests/File.hs
deleted file mode 100644
index 9c1ae67..0000000
--- a/tests/File.hs
+++ /dev/null
@@ -1,62 +0,0 @@
-module File
- ( fileGroup
- ) where
-
-import qualified Data.Map as M
-
-import Control.Applicative ((<$>))
-import Data.Binary
-import Test.Framework (testGroup)
-import Test.Framework.Providers.HUnit
-import Test.Framework.Providers.QuickCheck2
-import Test.HUnit
-import Test.QuickCheck
-
-import Text.Hakyll (runDefaultHakyll)
-import Text.Hakyll.File
-
--- File test group.
-fileGroup = testGroup "File"
- [ testCase "test_toRoot_1" test_toRoot_1
- , testCase "test_toRoot_2" test_toRoot_2
- , testCase "test_toRoot_3" test_toRoot_3
- , testCase "test_inHakyllDirectory_1" test_inHakyllDirectory_1
- , testCase "test_inHakyllDirectory_2" test_inHakyllDirectory_2
- , testCase "test_inHakyllDirectory_3" test_inHakyllDirectory_3
- , testCase "test_inHakyllDirectory_4" test_inHakyllDirectory_4
- , testCase "test_removeSpaces_1" test_removeSpaces_1
- , testCase "test_removeSpaces_2" test_removeSpaces_2
- , testCase "test_havingExtension_1" test_havingExtension_1
- , testCase "test_havingExtension_2" test_havingExtension_2
- ]
-
-
--- toRoot test cases
-test_toRoot_1 = toRoot "/posts/foo.html" @?= ".."
-test_toRoot_2 = toRoot "posts/foo.html" @?= ".."
-test_toRoot_3 = toRoot "foo.html" @?= "."
-
--- inHakyllDirectory test cases
-test_inHakyllDirectory_1 =
- (runDefaultHakyll $ inHakyllDirectory "_site/foo.html")
- @? "test_inHakyllDirectory_1"
-test_inHakyllDirectory_2 =
- (not <$> (runDefaultHakyll $ inHakyllDirectory "posts/foo.html"))
- @? "test_inHakyllDirectory_2"
-test_inHakyllDirectory_3 =
- (not <$> (runDefaultHakyll $ inHakyllDirectory "index.html"))
- @? "test_inHakyllDirectory_3"
-test_inHakyllDirectory_4 =
- (runDefaultHakyll $ inHakyllDirectory "_cache/index.html")
- @? "test_inHakyllDirectory_4"
-
--- removeSpaces test cases
-test_removeSpaces_1 = removeSpaces "$root/tags/random crap.html"
- @?= "$root/tags/random-crap.html"
-test_removeSpaces_2 = removeSpaces "another simple example.zip"
- @?= "another-simple-example.zip"
-
--- Having extension test cases
-test_havingExtension_1 = havingExtension ".foo" ["file.bar", "file.txt"] @?= []
-test_havingExtension_2 = havingExtension ".foo" ["file.foo", "file.txt"]
- @?= ["file.foo"]
diff --git a/tests/Main.hs b/tests/Main.hs
deleted file mode 100644
index adcb613..0000000
--- a/tests/Main.hs
+++ /dev/null
@@ -1,22 +0,0 @@
-module Main where
-
-import Test.Framework (defaultMain, testGroup)
-import Test.Framework.Providers.HUnit
-import Test.Framework.Providers.QuickCheck2
-
-import CompressCss
-import File
-import Page
-import Regex
-import Template
-import Util
-
--- | Run all tests.
-main :: IO ()
-main = defaultMain [ compressCssGroup
- , fileGroup
- , pageGroup
- , regexGroup
- , templateGroup
- , utilGroup
- ]
diff --git a/tests/Page.hs b/tests/Page.hs
deleted file mode 100644
index be49ad0..0000000
--- a/tests/Page.hs
+++ /dev/null
@@ -1,92 +0,0 @@
-module Page
- ( pageGroup
- ) where
-
-import qualified Data.Map as M
-
-import Control.Monad.Reader (runReaderT)
-import Data.Binary
-import Test.Framework (testGroup)
-import Test.Framework.Providers.HUnit
-import Test.Framework.Providers.QuickCheck2
-import Test.HUnit
-import System.Directory (getTemporaryDirectory, removeFile)
-import System.FilePath ((</>))
-
-import Text.Hakyll.Page
-import Text.Hakyll.Pandoc
-import Text.Hakyll.Context
-import Text.Hakyll.HakyllAction
-import Text.Hakyll
-
--- Page test group.
-pageGroup = testGroup "Page"
- [ testCase "test_readPage_1" test_readPage_1
- , testCase "test_readPage_2" test_readPage_2
- , testCase "test_readPage_3" test_readPage_3
- , testCase "test_readPage_4" test_readPage_4
- ]
-
--- | An abstract function to test page reading.
-test_readPage :: FilePath -- ^ Filename to give to the temporary file.
- -> String -- ^ Content to put in the file.
- -> (Context -> Bool) -- ^ Assertion to run on the result Context.
- -> IO Bool -- ^ Result of the assertion.
-test_readPage fileName content assertion = do
- temporaryDir <- getTemporaryDirectory
- let temporaryFile = temporaryDir </> fileName
- writeFile temporaryFile content
- page <- runDefaultHakyll (runHakyllAction $ createPage temporaryFile)
- removeFile temporaryFile
- return $ assertion page
-
--- | readPage test case 1.
-test_readPage_1 = test_readPage fileName content assertion @? "test_readPage_1"
- where
- fileName = "test_readPage_1.markdown"
- content = unlines [ "---"
- , "author: Eric Cartman"
- , "---"
- , "This is a simple test."
- ]
- assertion page = M.lookup "author" (unContext page) == Just "Eric Cartman"
-
--- | readPage test case 2.
-test_readPage_2 = test_readPage fileName content assertion @? "test_readPage_2"
- where
- fileName = "test_readPage_2.txt"
- content = unlines [ "--- someSection"
- , "This is a section."
- , "---"
- , "This is the body."
- ]
- assertion page =
- let m = unContext page
- in M.lookup "someSection" m == Just "This is a section.\n"
- && M.lookup "body" m == Just "This is the body.\n"
-
--- | readPage test case 3.
-test_readPage_3 = test_readPage fileName content assertion @? "test_readPage_3"
- where
- fileName = "test_readPage_3.txt"
- content = unlines [ "No metadata here, sorry."
- ]
- assertion page =
- M.lookup "body" (unContext page) == Just "No metadata here, sorry.\n"
-
--- | readPage test case 4.
-test_readPage_4 = test_readPage fileName content assertion @? "test_readPage_4"
- where
- fileName = "test_readPage_4.txt"
- content = unlines [ "--- section"
- , "This is a section."
- , "---"
- , "Header"
- , "------"
- , "The header is not a separate section."
- ]
- assertion page = M.lookup "body" (unContext page) == Just body
- body = unlines [ "Header"
- , "------"
- , "The header is not a separate section."
- ]
diff --git a/tests/Regex.hs b/tests/Regex.hs
deleted file mode 100644
index 5aac932..0000000
--- a/tests/Regex.hs
+++ /dev/null
@@ -1,24 +0,0 @@
-module Regex
- ( regexGroup
- ) where
-
-import qualified Data.Map as M
-
-import Data.Binary
-import Test.Framework (testGroup)
-import Test.Framework.Providers.HUnit
-import Test.Framework.Providers.QuickCheck2
-import Test.HUnit
-import Test.QuickCheck
-
-import Text.Hakyll.Regex
-
--- Regex test group.
-regexGroup = testGroup "Regex"
- [ testCase "test_splitRegex_1" test_splitRegex_1
- , testCase "test_splitRegex_2" test_splitRegex_2
- ]
-
--- Split Regex test cases.
-test_splitRegex_1 = splitRegex "," "1,2,3" @?= ["1", "2", "3"]
-test_splitRegex_2 = splitRegex "," ",1,2," @?= ["1", "2"]
diff --git a/tests/Template.hs b/tests/Template.hs
deleted file mode 100644
index 648e3de..0000000
--- a/tests/Template.hs
+++ /dev/null
@@ -1,70 +0,0 @@
-module Template
- ( templateGroup
- ) where
-
-import qualified Data.Map as M
-import Control.Applicative ((<$>))
-import Control.Monad (replicateM)
-import Data.Monoid (mempty)
-
-import Data.Binary
-import Test.Framework (testGroup)
-import Test.Framework.Providers.HUnit
-import Test.Framework.Providers.QuickCheck2
-import Test.HUnit
-import Test.QuickCheck
-
-import Text.Hakyll.Context (Context (..))
-import Text.Hakyll.Internal.Template
-import Text.Hakyll.Internal.Template.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
- ]
-
--- | Generate arbitrary templates from a given length.
---
-instance Arbitrary TemplateElement where
- arbitrary = oneof
- -- Random chunk
- [ Chunk <$> do
- string <- arbitrary
- let sanitized = filter (/= '$') string
- return $ if null sanitized then "foo" else sanitized
- -- Random identifier
- , fmap Identifier $
- choose (5, 10) >>= flip replicateM (choose ('a', 'z'))
- -- Escape character
- , return EscapeCharacter
- ]
-
--- | Make @Template@ testable.
-instance Arbitrary Template where
- arbitrary = Template <$> arbitrary
- shrink = map Template . shrink . unTemplate
-
--- Test encoding/decoding of templates.
-prop_template_encode_id :: Template -> Bool
-prop_template_encode_id template = decode (encode template) == template
-
--- Check we get the same sting with empty substitutions.
-prop_substitute_id string =
- regularSubstitute (fromString string) mempty == string
-
--- substitute test case 1.
-test_substitute_1 =
- finalSubstitute template context @?= "Banana costs $4."
- where
- template = fromString "$product costs $$$price."
- context = 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 = Context $ M.fromList [("root", "foo"), ("thing", "key")]
diff --git a/tests/Util.hs b/tests/Util.hs
deleted file mode 100644
index 4b29f5f..0000000
--- a/tests/Util.hs
+++ /dev/null
@@ -1,54 +0,0 @@
-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 Test.HUnit
-
-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
- , testCase "test_stripHtml_1" test_stripHtml_1
- , testCase "test_stripHtml_2" test_stripHtml_2
- , testCase "test_stripHtml_3" test_stripHtml_3
- , testCase "test_link_1" test_link_1
- , testCase "test_link_2" test_link_2
- ]
-
--- Test that a string always becomes shorter when trimmed.
-prop_trim_length str = length str >= length (trim str)
-
--- Check that a string which does not start or end with a space is not trimmed.
-prop_trim_id str = (not $ null str) && isAlreadyTrimmed ==> str == (trim str)
- where
- isAlreadyTrimmed :: Bool
- isAlreadyTrimmed = (not $ isSpace $ head str) && (not $ isSpace $ last str)
-
--- Check that a stripped string is shorter.
-prop_stripHtml_length str = length str >= length (stripHtml str)
-
--- Check that strings without tags remain untouched.
-prop_stripHtml_id str = (not $ any (`elem` ['>', '<']) str)
- ==> str == stripHtml str
-
--- Strip Html test cases.
-test_stripHtml_1 = stripHtml "<b>text</b>" @?= "text"
-test_stripHtml_2 = stripHtml "text" @?= "text"
-test_stripHtml_3 =
- stripHtml "<b>Hakyll</b>, a <i>website</i> generator<img src=\"foo.png\" />"
- @?= "Hakyll, a website generator"
-
--- Link test cases.
-test_link_1 = link "foo bar" "/foo/bar.html"
- @?= "<a href=\"/foo/bar.html\">foo bar</a>"
-test_link_2 = link "back home" "/" @?= "<a href=\"/\">back home</a>"