on master help sign in
Minor refactoring
commita8accd36b117c0a8cadb8dc5161c5a60d62a0aeb authorJasper Van der Jeugt <jaspervdj@gmail.com> dateFri 8 Apr 2011, 22:17 (16 years ago) parente4545f9
3 files changed+5−53
src/Hakyll/Core/DirectedGraph.hs+3−12 tests/Hakyll/Core/DirectedGraph/Tests.hs−36 tests/TestSuite.hs+2−5
src/Hakyll/Core/DirectedGraph.hs+3−12
@@ -10,7 +10,6 @@ module Hakyll.Core.DirectedGraph
1010 , neighbours
1111 , reverse
1212 , reachableNodes
13− , sanitize
1413 ) where
1514
1615import Prelude hiding (reverse)
@@ -77,17 +76,9 @@ reachableNodes set graph = reachable (setNeighbours set) set
7776 where
7877 reachable next visited
7978 | S.null next = visited
80− | otherwise = reachable (sanitize' neighbours') (next `S.union` visited)
79+ | otherwise = reachable (sanitize neighbours') (next `S.union` visited)
8180 where
82− sanitize' = S.filter (`S.notMember` visited)
83− neighbours' = setNeighbours (sanitize' next)
81+ sanitize = S.filter (`S.notMember` visited)
82+ neighbours' = setNeighbours (sanitize next)
8483
8584 setNeighbours = S.unions . map (`neighbours` graph) . S.toList
86−
87−-- | Remove all dangling pointers, i.e. references to notes that do
88−-- not actually exist in the graph.
89−--
90−sanitize :: Ord a => DirectedGraph a -> DirectedGraph a
91−sanitize (DirectedGraph graph) = DirectedGraph $ M.map sanitize' graph
92− where
93− sanitize' (Node t n) = Node t $ S.filter (`M.member` graph) n
tests/Hakyll/Core/DirectedGraph/Tests.hsdeleted−36
@@ -1,36 +0,0 @@
1−module Hakyll.Core.DirectedGraph.Tests
2− ( tests
3− ) where
4−
5−import Data.Set (Set)
6−import qualified Data.Set as S
7−
8−import Test.Framework
9−import Test.Framework.Providers.HUnit
10−import Test.HUnit hiding (Test)
11−
12−import Hakyll.Core.DirectedGraph
13−import Hakyll.Core.DirectedGraph.DependencySolver
14−
15−tests :: [Test]
16−tests =
17− [ testCase "solveDependencies [1]" solveDependencies1
18− ]
19−
20−node :: Ord a => a -> [a] -> (a, Set a)
21−node t n = (t, S.fromList n)
22−
23−testGraph01 :: DirectedGraph Int
24−testGraph01 = fromList
25− [ node 8 [2, 4, 6]
26− , node 2 [4, 3]
27− , node 4 [3]
28− , node 6 [4]
29− , node 3 []
30− ]
31−
32−solveDependencies1 :: Assertion
33−solveDependencies1 = result == [3, 4, 2, 6, 8] || result == [3, 4, 2, 6, 8]
34− @? "solveDependencies1"
35− where
36− result = solveDependencies testGraph01
tests/TestSuite.hs+2−5
@@ -1,8 +1,7 @@
1−module TestSuite where
1+module Main where
22
33import Test.Framework (defaultMain, testGroup)
44
5−import qualified Hakyll.Core.DirectedGraph.Tests
65import qualified Hakyll.Core.DependencyAnalyzer.Tests
76import qualified Hakyll.Core.Identifier.Tests
87import qualified Hakyll.Core.Routes.Tests
@@ -14,9 +13,7 @@ import qualified Hakyll.Web.Util.Url.Tests
1413
1514main :: IO ()
1615main = defaultMain
17− [ testGroup "Hakyll.Core.DirectedGraph.Tests"
18− Hakyll.Core.DirectedGraph.Tests.tests
19− , testGroup "Hakyll.Core.DependencyAnalyzer.Tests"
16+ [ testGroup "Hakyll.Core.DependencyAnalyzer.Tests"
2017 Hakyll.Core.DependencyAnalyzer.Tests.tests
2118 , testGroup "Hakyll.Core.Identifier.Tests"
2219 Hakyll.Core.Identifier.Tests.tests