summaryrefslogtreecommitdiff
path: root/tests/Hakyll/Core/DirectedGraph/Tests.hs
blob: 3e04b49b9b30f2a444c8924be03affc7f0354670 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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