Commit 3b257514 authored by Hans-Peter Deifel's avatar Hans-Peter Deifel
Browse files

tests: Add tests for collectTouchedBlocks

parent fe73de51
......@@ -138,6 +138,7 @@ test-suite spec
, MA.Coalgebra.ParserSpec
, MA.Parser.LexerSpec
, MA.Algorithm.InitializeSpec
, MA.Algorithm.SplitSpec
default-language: Haskell2010
default-extensions: GADTs
, StandaloneDeriving
......@@ -163,6 +164,7 @@ test-suite spec
, microlens-platform
, unordered-containers
, containers
, mtl
, ma
test-suite doctests
......
......@@ -3,6 +3,8 @@
module MA.Algorithm.Split
( SplitM
, split
-- * Internal functions
, collectTouchedBlocks
) where
import Prelude hiding (pred)
......
module MA.Algorithm.SplitSpec (spec) where
import Test.Hspec
import Control.Monad.ST
import Control.Monad.Reader
import qualified Data.Vector as V
import MA.Algorithm.Types
import MA.Algorithm.Split
import Data.BlockQueue
import Data.Partition.Common
import Data.MorphismEncoding (Encoding)
import qualified Data.MorphismEncoding as Encoding
import MA.RefinementInterface
import MA.Coalgebra.RefinementTypes
import MA.Algorithm.Initialize
import MA.Algorithm.Split
import qualified Data.BlockQueue as Queue
import MA.Functors.Powerset
spec :: Spec
spec = do
collectTouchedBlocksSpec
collectTouchedBlocksSpec :: Spec
collectTouchedBlocksSpec = describe "collectTouchedBlocks" $ do
it "returns an empty list when no predecessors exist" $
withState
@Powerset
(enc [True, False] [(0, (), 1)])
(collectTouchedBlocks (Block 0)) `shouldBe`
[]
it "returns the correct block when predecessors exist" $
withState
@Powerset
(enc [True, False] [(0, (), 1)])
(map fst <$> collectTouchedBlocks (Block 1)) `shouldBe`
[Block 0]
it "doesn't return duplicates" $
withState
@Powerset
(enc [True, True, False] [(0, (), 2), (1, (), 2)])
(map fst <$> collectTouchedBlocks (Block 1)) `shouldBe`
[Block 0]
it "computes the correct v0" $
pending
it "marks the correct states" $
pending
it "addes the correct edges to toSub" $
pending
withState ::
RefinementInterface h
=> Encoding (Label h) (H1 h)
-> (forall s. SplitM s h a)
-> a
withState e action = runST $ do
(q, as) <- initialize e
queue <- Queue.empty 20
mapM_ (Queue.enqueue queue) q
runSplit as queue action
runSplit :: AlgoState s h -> BlockQueue s -> SplitM s h a -> ST s a
runSplit as queue action = runReaderT action (as, queue)
enc :: [h1] -> [(State, label, State)] -> Encoding label h1
enc h1s transitions = Encoding.new (V.fromList h1s) edges
where
edges = V.fromList (map mkEdge transitions)
mkEdge (from, lab, to) = Encoding.Edge from lab to
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment