summaryrefslogtreecommitdiff
path: root/tests/Hakyll/Core
diff options
context:
space:
mode:
Diffstat (limited to 'tests/Hakyll/Core')
-rw-r--r--tests/Hakyll/Core/DirectedGraph/Tests.hs36
-rw-r--r--tests/Hakyll/Core/Identifier/Tests.hs22
-rw-r--r--tests/Hakyll/Core/Routes/Tests.hs24
3 files changed, 82 insertions, 0 deletions
diff --git a/tests/Hakyll/Core/DirectedGraph/Tests.hs b/tests/Hakyll/Core/DirectedGraph/Tests.hs
new file mode 100644
index 0000000..3e04b49
--- /dev/null
+++ b/tests/Hakyll/Core/DirectedGraph/Tests.hs
@@ -0,0 +1,36 @@
+module Hakyll.Core.DirectedGraph.Tests
+ ( tests
+ ) where
+
+import Data.Set (Set)
+import qualified Data.Set as S
+
+import Test.Framework
+import Test.Framework.Providers.HUnit
+import Test.HUnit hiding (Test)
+
+import Hakyll.Core.DirectedGraph
+import Hakyll.Core.DirectedGraph.DependencySolver
+
+tests :: [Test]
+tests =
+ [ testCase "solveDependencies [1]" solveDependencies1
+ ]
+
+node :: Ord a => a -> [a] -> (a, Set a)
+node t n = (t, S.fromList n)
+
+testGraph01 :: DirectedGraph Int
+testGraph01 = fromList
+ [ node 8 [2, 4, 6]
+ , node 2 [4, 3]
+ , node 4 [3]
+ , node 6 [4]
+ , node 3 []
+ ]
+
+solveDependencies1 :: Assertion
+solveDependencies1 = result == [3, 4, 2, 6, 8] || result == [3, 4, 2, 6, 8]
+ @? "solveDependencies1"
+ where
+ result = solveDependencies testGraph01
diff --git a/tests/Hakyll/Core/Identifier/Tests.hs b/tests/Hakyll/Core/Identifier/Tests.hs
new file mode 100644
index 0000000..43dd6c1
--- /dev/null
+++ b/tests/Hakyll/Core/Identifier/Tests.hs
@@ -0,0 +1,22 @@
+{-# LANGUAGE OverloadedStrings #-}
+module Hakyll.Core.Identifier.Tests
+ ( tests
+ ) where
+
+import Test.Framework
+import Test.HUnit hiding (Test)
+
+import Hakyll.Core.Identifier.Pattern
+import TestSuite.Util
+
+tests :: [Test]
+tests = fromAssertions "match"
+ [ Just ["bar"] @=? match "foo/**" "foo/bar"
+ , Just ["foo/bar"] @=? match "**" "foo/bar"
+ , Nothing @=? match "*" "foo/bar"
+ , Just [] @=? match "foo" "foo"
+ , Just ["foo"] @=? match "*/bar" "foo/bar"
+ , Just ["foo/bar"] @=? match "**/qux" "foo/bar/qux"
+ , Just ["foo/bar", "qux"] @=? match "**/*" "foo/bar/qux"
+ , Just ["foo", "bar/qux"] @=? match "*/**" "foo/bar/qux"
+ ]
diff --git a/tests/Hakyll/Core/Routes/Tests.hs b/tests/Hakyll/Core/Routes/Tests.hs
new file mode 100644
index 0000000..3361846
--- /dev/null
+++ b/tests/Hakyll/Core/Routes/Tests.hs
@@ -0,0 +1,24 @@
+{-# LANGUAGE OverloadedStrings #-}
+module Hakyll.Core.Routes.Tests
+ ( tests
+ ) where
+
+import Test.Framework
+import Test.HUnit hiding (Test)
+
+import Hakyll.Core.Routes
+import TestSuite.Util
+
+tests :: [Test]
+tests = fromAssertions "runRoutes"
+ [ Just "foo.html" @=? runRoutes (setExtension "html") "foo"
+ , Just "foo.html" @=? runRoutes (setExtension ".html") "foo"
+ , Just "foo.html" @=? runRoutes (setExtension "html") "foo.markdown"
+ , Just "foo.html" @=? runRoutes (setExtension ".html") "foo.markdown"
+
+ , Just "tags/bar.xml" @=?
+ runRoutes (gsubRoute "rss/" (const "")) "tags/rss/bar.xml"
+ , Just "tags/bar.xml" @=?
+ runRoutes (gsubRoute "rss/" (const "") `composeRoutes`
+ setExtension "xml") "tags/rss/bar"
+ ]