diff options
-rw-r--r-- | src/Hakyll/Core/DirectedGraph.hs | 15 | ||||
-rw-r--r-- | tests/Hakyll/Core/DirectedGraph/Tests.hs | 36 | ||||
-rw-r--r-- | tests/TestSuite.hs | 7 |
3 files changed, 5 insertions, 53 deletions
diff --git a/src/Hakyll/Core/DirectedGraph.hs b/src/Hakyll/Core/DirectedGraph.hs index 6be5c5c..ff9121a 100644 --- a/src/Hakyll/Core/DirectedGraph.hs +++ b/src/Hakyll/Core/DirectedGraph.hs @@ -10,7 +10,6 @@ module Hakyll.Core.DirectedGraph , neighbours , reverse , reachableNodes - , sanitize ) where import Prelude hiding (reverse) @@ -77,17 +76,9 @@ reachableNodes set graph = reachable (setNeighbours set) set where reachable next visited | S.null next = visited - | otherwise = reachable (sanitize' neighbours') (next `S.union` visited) + | otherwise = reachable (sanitize neighbours') (next `S.union` visited) where - sanitize' = S.filter (`S.notMember` visited) - neighbours' = setNeighbours (sanitize' next) + sanitize = S.filter (`S.notMember` visited) + neighbours' = setNeighbours (sanitize next) setNeighbours = S.unions . map (`neighbours` graph) . S.toList - --- | Remove all dangling pointers, i.e. references to notes that do --- not actually exist in the graph. --- -sanitize :: Ord a => DirectedGraph a -> DirectedGraph a -sanitize (DirectedGraph graph) = DirectedGraph $ M.map sanitize' graph - where - sanitize' (Node t n) = Node t $ S.filter (`M.member` graph) n diff --git a/tests/Hakyll/Core/DirectedGraph/Tests.hs b/tests/Hakyll/Core/DirectedGraph/Tests.hs deleted file mode 100644 index 3e04b49..0000000 --- a/tests/Hakyll/Core/DirectedGraph/Tests.hs +++ /dev/null @@ -1,36 +0,0 @@ -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/TestSuite.hs b/tests/TestSuite.hs index 7fd288d..4d2c95d 100644 --- a/tests/TestSuite.hs +++ b/tests/TestSuite.hs @@ -1,8 +1,7 @@ -module TestSuite where +module Main 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 @@ -14,9 +13,7 @@ import qualified Hakyll.Web.Util.Url.Tests main :: IO () main = defaultMain - [ testGroup "Hakyll.Core.DirectedGraph.Tests" - Hakyll.Core.DirectedGraph.Tests.tests - , testGroup "Hakyll.Core.DependencyAnalyzer.Tests" + [ testGroup "Hakyll.Core.DependencyAnalyzer.Tests" Hakyll.Core.DependencyAnalyzer.Tests.tests , testGroup "Hakyll.Core.Identifier.Tests" Hakyll.Core.Identifier.Tests.tests |