diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Hakyll/Core/DependencyAnalyzer/Tests.hs | 70 | ||||
-rw-r--r-- | tests/TestSuite.hs | 3 |
2 files changed, 73 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 diff --git a/tests/TestSuite.hs b/tests/TestSuite.hs index cb6113d..ba77139 100644 --- a/tests/TestSuite.hs +++ b/tests/TestSuite.hs @@ -3,6 +3,7 @@ module TestSuite where import Test.Framework (defaultMain, testGroup) import qualified Hakyll.Core.DirectedGraph.Tests +import qualified Hakyll.Core.DependencyAnalyzer.Tests import qualified Hakyll.Core.Identifier.Tests import qualified Hakyll.Core.Routes.Tests import qualified Hakyll.Web.Page.Tests @@ -14,6 +15,8 @@ main :: IO () main = defaultMain [ testGroup "Hakyll.Core.DirectedGraph.Tests" Hakyll.Core.DirectedGraph.Tests.tests + , testGroup "Hakyll.Core.DependencyAnalyzer.Tests" + Hakyll.Core.DependencyAnalyzer.Tests.tests , testGroup "Hakyll.Core.Identifier.Tests" Hakyll.Core.Identifier.Tests.tests , testGroup "Hakyll.Core.Routes.Tests" |