File tree Expand file tree Collapse file tree 2 files changed +14
-0
lines changed
examples/Constrained/Examples Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -125,3 +125,16 @@ mapSetSmall = constrained $ \x ->
125125mapIsJust :: Specification (Int , Int )
126126mapIsJust = 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+ ]
Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments