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

tests: Add tests for addBlocksToQueue

parent 37cbfe5d
......@@ -31,6 +31,8 @@ spec = do
collectTouchedBlocksSpec
updateBlockSpec
splitBlockSpec
addBlocksToQueueSpec
collectTouchedBlocksSpec :: Spec
collectTouchedBlocksSpec = describe "collectTouchedBlocks" $ do
......@@ -197,6 +199,32 @@ splitBlockSpec = describe "splitBlock" $ do
in res `shouldMatchList` [Block 0, Block 2]
addBlocksToQueueSpec :: Spec
addBlocksToQueueSpec = describe "addBlocksToQueue" $ do
it "doesn't add the largest block to the queue"
$ let res =
withState @(MonoidValued Int)
(enc [1, 1, 2, 3] [(0, 1, 0), (1, 1, 1), (2, 2, 2), (3, 3, 3)])
$ do
lift . Queue.clear =<< view _2
addBlocksToQueue (Block 0) (map Block [0, 1, 2])
q <- lift . Queue.toList =<< view _2
p <- view (_1 . partitionL)
lift $ forM q $ \b -> Partition.blockSize p b
in res `shouldMatchList` ([1, 1])
it "does add all new blocks, if the original was already queued"
$ let res =
withState @(MonoidValued Int)
(enc [1, 1, 2, 3] [(0, 1, 0), (1, 1, 1), (2, 2, 2), (3, 3, 3)])
$ do
queue <- view _2
lift (Queue.clear queue)
lift (Queue.enqueue queue (Block 0))
addBlocksToQueue (Block 0) (map Block [0, 1, 2])
lift (Queue.toList queue)
in res `shouldMatchList` (map Block [0, 1, 2])
withState
:: RefinementInterface h
......
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