Skip to content

Commit aee21a5

Browse files
another test for issue Neil talked about
1 parent ff3afd7 commit aee21a5

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

examples/Constrained/Examples/Map.hs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,3 +125,16 @@ mapSetSmall = constrained $ \x ->
125125
mapIsJust :: Specification (Int, Int)
126126
mapIsJust = constrained' $ \ [var| x |] [var| y |] ->
127127
just_ x ==. lookup_ y (lit $ Map.fromList [(z, z) | z <- [100 .. 102]])
128+
129+
eitherKeys :: Specification ([Int], [Int], Map (Either Int Int) Int)
130+
eitherKeys = constrained' $ \ [var| as |] [var| bs |] [var| m |] ->
131+
[
132+
forAll' m $ \ [var| k |] _v ->
133+
[ caseOn k
134+
(branch $ \ a -> a `elem_` as)
135+
(branch $ \ b -> b `elem_` bs)
136+
, reify as (map Left) $ \ ls ->
137+
reify bs (map Right) $ \ rs ->
138+
k `elem_` ls ++. rs
139+
]
140+
]

test/Constrained/Tests.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ tests nightly =
8585
testSpec "mapElemKeySpec" mapElemKeySpec
8686
-- TODO: double shrinking
8787
testSpecNoShrink "mapIsJust" mapIsJust
88+
testSpecNoShrink "eitherKeys" eitherKeys
8889
testSpecNoShrink "intSpec" intSpec
8990
testSpecNoShrink "mapPairSpec" mapPairSpec
9091
testSpecNoShrink "mapEmptyDomainSpec" mapEmptyDomainSpec

0 commit comments

Comments
 (0)