1
1
mirror of https://github.com/github/semantic.git synced 2024-12-22 06:11:49 +03:00
semantic/test/Data/Graph/Spec.hs

21 lines
745 B
Haskell
Raw Normal View History

2018-10-31 19:20:38 +03:00
{-# LANGUAGE PackageImports #-}
module Data.Graph.Spec (spec) where
2018-10-31 19:20:38 +03:00
import SpecHelpers
import "semantic" Data.Graph
import qualified Algebra.Graph.Class as Class
spec :: Spec
spec = describe "Data.Graph" $
it "has a valid topological sort" $ do
let topo = topologicalSort
topo (Class.path "ab") `shouldBe` "ba"
topo (Class.path "abc") `shouldBe` "cba"
topo ((vertex 'a' `connect` vertex 'b') `connect` vertex 'c') `shouldBe` "cba"
topo (vertex 'a' `connect` (vertex 'b' `connect` vertex 'c')) `shouldBe` "cba"
topo ((vertex 'a' `connect` vertex 'b') <> (vertex 'a' `connect` vertex 'c')) `shouldBe` "cba"
topo (Class.path "abd" <> Class.path "acd") `shouldBe` "dcba"
topo (Class.path "aba") `shouldBe` "ab"