summaryrefslogtreecommitdiff
path: root/tests/Hakyll
diff options
context:
space:
mode:
authorJasper Van der Jeugt <jaspervdj@gmail.com>2011-03-28 18:35:02 +0200
committerJasper Van der Jeugt <jaspervdj@gmail.com>2011-03-28 18:35:02 +0200
commite9666f78e8fd80d4674afb1e519f23d6e414a223 (patch)
tree9e696ed5cc539f361d8a8aefd18550a6a830b54e /tests/Hakyll
parent241efb1614364b136dfdc4f23e0661d2f34ade24 (diff)
downloadhakyll-e9666f78e8fd80d4674afb1e519f23d6e414a223.tar.gz
Add new dependency analyzer & tests
Diffstat (limited to 'tests/Hakyll')
-rw-r--r--tests/Hakyll/Core/DependencyAnalyzer/Tests.hs70
1 files changed, 70 insertions, 0 deletions
diff --git a/tests/Hakyll/Core/DependencyAnalyzer/Tests.hs b/tests/Hakyll/Core/DependencyAnalyzer/Tests.hs
new file mode 100644
index 0000000..891fa98
--- /dev/null
+++ b/tests/Hakyll/Core/DependencyAnalyzer/Tests.hs
@@ -0,0 +1,70 @@
+module Hakyll.Core.DependencyAnalyzer.Tests where
+
+import Control.Arrow (second)
+import qualified Data.Set as S
+import Data.Monoid (mempty)
+
+import Test.Framework
+import Test.Framework.Providers.HUnit
+import Test.HUnit hiding (Test)
+
+import Hakyll.Core.DirectedGraph
+import Hakyll.Core.DependencyAnalyzer
+
+tests :: [Test]
+tests =
+ [ testCase "step [1]" step1
+ , testCase "step [2]" step2
+ ]
+
+step1 :: Assertion
+step1 = Just (S.fromList [1, 2, 5, 6, 7, 8, 9]) @?=
+ stepAll (makeDependencyAnalyzer graph isOutOfDate prev)
+ where
+ node = curry $ second S.fromList
+
+ graph = fromList
+ [ node (8 :: Int) [2, 4, 6]
+ , node 2 [4, 3]
+ , node 4 [3]
+ , node 6 [4]
+ , node 3 []
+ , node 9 [5]
+ , node 5 [7]
+ , node 1 [7]
+ , node 7 []
+ ]
+
+ prev = fromList
+ [ node 8 [2, 4, 6]
+ , node 2 [4, 3]
+ , node 4 [3]
+ , node 6 [4]
+ , node 3 []
+ , node 9 [5]
+ , node 5 [7]
+ , node 1 [7]
+ , node 7 [8]
+ ]
+
+ isOutOfDate = (`elem` [5, 2, 6])
+
+step2 :: Assertion
+step2 = Nothing @?= stepAll (makeDependencyAnalyzer graph isOutOfDate mempty)
+ where
+ node = curry $ second S.fromList
+
+ -- Cycle: 4 -> 7 -> 5 -> 9 -> 4
+ graph = fromList
+ [ node (1 :: Int) [6]
+ , node 2 [3]
+ , node 3 []
+ , node 4 [1, 7, 8]
+ , node 5 [9]
+ , node 6 [3]
+ , node 7 [5]
+ , node 8 [2]
+ , node 9 [4]
+ ]
+
+ isOutOfDate = const True