summaryrefslogtreecommitdiff
path: root/tests/Hakyll/Core
diff options
context:
space:
mode:
authorJasper Van der Jeugt <m@jaspervdj.be>2012-11-12 14:31:33 +0100
committerJasper Van der Jeugt <m@jaspervdj.be>2012-11-12 14:31:33 +0100
commitc7d3c60c54926b54847bfc691e27f24dc644dd65 (patch)
tree73a8f88ca1fe552f83b6fbe7b35988c7272ac5b9 /tests/Hakyll/Core
parentede51e822f558a2c59d4ab76401b597f8acf59b4 (diff)
downloadhakyll-c7d3c60c54926b54847bfc691e27f24dc644dd65.tar.gz
Yet Another dependency analyzer
Diffstat (limited to 'tests/Hakyll/Core')
-rw-r--r--tests/Hakyll/Core/Dependencies/Tests.hs73
1 files changed, 73 insertions, 0 deletions
diff --git a/tests/Hakyll/Core/Dependencies/Tests.hs b/tests/Hakyll/Core/Dependencies/Tests.hs
new file mode 100644
index 0000000..3117386
--- /dev/null
+++ b/tests/Hakyll/Core/Dependencies/Tests.hs
@@ -0,0 +1,73 @@
+--------------------------------------------------------------------------------
+{-# LANGUAGE OverloadedStrings #-}
+module Hakyll.Core.Dependencies.Tests
+ ( tests
+ ) where
+
+
+--------------------------------------------------------------------------------
+import Data.List (delete)
+import qualified Data.Map as M
+import qualified Data.Set as S
+import Test.Framework (Test, testGroup)
+import Test.Framework.Providers.HUnit (testCase)
+import Test.HUnit (Assertion, (@=?))
+
+
+--------------------------------------------------------------------------------
+import Hakyll.Core.Dependencies
+import Hakyll.Core.Identifier
+
+
+--------------------------------------------------------------------------------
+tests :: Test
+tests = testGroup "Hakyll.Core.Dependencies.Tests"
+ [ testCase "case01" case01
+ , testCase "case02" case02
+ , testCase "case03" case03
+ ]
+
+
+--------------------------------------------------------------------------------
+oldUniverse :: [Identifier ()]
+oldUniverse = M.keys oldFacts
+
+
+--------------------------------------------------------------------------------
+oldFacts :: DependencyFacts
+oldFacts = M.fromList
+ [ ("posts/01.md",
+ [])
+ , ("posts/02.md",
+ [])
+ , ("index.md",
+ [ Pattern "posts/*" ["posts/01.md", "posts/02.md"]
+ , Identifier "posts/01.md"
+ , Identifier "posts/02.md"
+ ])
+ ]
+
+
+--------------------------------------------------------------------------------
+-- | posts/02.md has changed
+case01 :: Assertion
+case01 = S.fromList ["posts/02.md", "index.md"] @=? ood
+ where
+ (ood, _, _) = outOfDate oldUniverse (S.singleton "posts/02.md") oldFacts
+
+
+--------------------------------------------------------------------------------
+-- | about.md was added
+case02 :: Assertion
+case02 = S.singleton "about.md" @=? ood
+ where
+ (ood, _, _) = outOfDate ("about.md" : oldUniverse) S.empty oldFacts
+
+
+--------------------------------------------------------------------------------
+-- | posts/01.md was removed
+case03 :: Assertion
+case03 = S.singleton "index.md" @=? ood
+ where
+ (ood, _, _) =
+ outOfDate ("posts/01.md" `delete` oldUniverse) S.empty oldFacts