Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
CoPaR
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Informatik 8
CoPaR
Commits
ea68f6c1
Commit
ea68f6c1
authored
6 years ago
by
Hans-Peter Deifel
Browse files
Options
Downloads
Patches
Plain Diff
tests: Add tests for `split`
parent
b24d4c02
No related branches found
No related tags found
No related merge requests found
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/MA/Algorithm/SplitSpec.hs
+55
-1
55 additions, 1 deletion
tests/MA/Algorithm/SplitSpec.hs
with
55 additions
and
1 deletion
tests/MA/Algorithm/SplitSpec.hs
+
55
−
1
View file @
ea68f6c1
...
...
@@ -4,6 +4,7 @@ import Test.Hspec
import
Control.Monad.ST
import
Data.STRef
import
Data.List
(
sort
)
import
Control.Monad.Reader
import
qualified
Data.Vector
as
V
...
...
@@ -12,7 +13,7 @@ import Lens.Micro.Platform
import
MA.Algorithm.Types
import
MA.Algorithm.Split
import
Data.BlockQueue
import
Data.BlockQueue
(
BlockQueue
)
import
Data.Partition.Common
import
Data.MorphismEncoding
(
fromEdgeRef
,
Encoding
...
...
@@ -25,6 +26,8 @@ import qualified Data.BlockQueue as Queue
import
MA.Functors.Powerset
import
MA.Functors.MonoidValued
import
qualified
Data.RefinablePartition
as
Partition
import
qualified
Data.Partition
as
Partition
(
toBlocks
)
spec
::
Spec
spec
=
do
...
...
@@ -32,6 +35,7 @@ spec = do
updateBlockSpec
splitBlockSpec
addBlocksToQueueSpec
splitSpec
collectTouchedBlocksSpec
::
Spec
...
...
@@ -226,6 +230,56 @@ addBlocksToQueueSpec = describe "addBlocksToQueue" $ do
in
res
`
shouldMatchList
`
(
map
Block
[
0
,
1
,
2
])
splitSpec
::
Spec
splitSpec
=
describe
"split"
$
do
let
encoding
=
(
enc
[
10
,
10
,
10
,
1
,
1
,
20
,
20
,
0
]
[
(
0
,
1
,
7
)
,
(
0
,
9
,
0
)
,
(
1
,
2
,
7
)
,
(
1
,
8
,
1
)
,
(
2
,
3
,
7
)
,
(
2
,
7
,
2
)
,
(
3
,
1
,
7
)
,
(
4
,
1
,
4
)
,
(
5
,
20
,
6
)
,
(
6
,
20
,
5
)
]
)
it
"splits all touched blocks correctly"
$
let
res
=
withState
@
(
MonoidValued
Int
)
encoding
$
do
p
<-
view
(
_1
.
partitionL
)
b
<-
lift
(
Partition
.
blockOfState
p
7
)
split
b
Partition
.
toBlocks
<$>
lift
(
Partition
.
freeze
p
)
in
(
map
sort
res
)
`
shouldMatchList
`
[[
0
],
[
1
],
[
2
],
[
3
],
[
4
],
[
5
,
6
],
[
7
]]
it
"adds the correct blocks to the queue"
$
let
res
=
withState
@
(
MonoidValued
Int
)
encoding
$
do
p
<-
view
(
_1
.
partitionL
)
b
<-
lift
(
Partition
.
blockOfState
p
7
)
b3
<-
lift
(
Partition
.
blockOfState
p
3
)
(
lift
.
Queue
.
delete
b
)
=<<
view
_2
(
lift
.
Queue
.
delete
b3
)
=<<
view
_2
split
b
queuedBlocks
<-
lift
.
Queue
.
toList
=<<
view
_2
lift
(
mapM
(
fmap
VU
.
toList
.
Partition
.
statesOfBlock
p
)
queuedBlocks
)
in
res
`
shouldSatisfy
`
(
\
l
->
([
0
]
`
elem
`
l
)
&&
([
1
]
`
elem
`
l
)
&&
([
2
]
`
elem
`
l
)
&&
([
5
,
6
]
`
elem
`
l
)
&&
(
([
3
]
`
elem
`
l
&&
not
([
4
]
`
elem
`
l
))
||
([
4
]
`
elem
`
l
&&
not
([
3
]
`
elem
`
l
))
)
)
withState
::
RefinementInterface
h
=>
Encoding
(
Label
h
)
(
H1
h
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment