File tree Expand file tree Collapse file tree 2 files changed +22
-0
lines changed
examples/Constrained/Examples Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -343,3 +343,23 @@ manyInconsistentTrans = constrained' $ \ [var| a |] [var| b |] c d e [var| f |]
343343 , assert $ f >. 10
344344 , assert $ f <. b
345345 ]
346+
347+ complicatedEither :: Specification (Either Int Int , (Either Int Int , Int , Int ))
348+ complicatedEither = constrained' $ \ [var | i |] [var | t |] ->
349+ [ caseOn i
350+ (branch $ \ a -> a `elem_` lit [1 .. 10 ])
351+ (branch $ \ b -> b `elem_` lit [1 .. 10 ])
352+ , match t $ \ [var | k |] _ _ ->
353+ [ k ==. i
354+ , not_ $ k `elem_` lit [ Left j | j <- [1 .. 9 ] ]
355+ ]
356+ ]
357+
358+ pairCant :: Specification (Int , (Int , Int ))
359+ pairCant = constrained' $ \ [var | i |] [var | p |] ->
360+ [ assert $ i `elem_` lit [1 .. 10 ]
361+ , match p $ \ [var | k |] _ ->
362+ [ k ==. i
363+ , not_ $ k `elem_` lit [1 .. 9 ]
364+ ]
365+ ]
Original file line number Diff line number Diff line change @@ -59,6 +59,8 @@ testAll = hspec $ tests False
5959tests :: Bool -> Spec
6060tests nightly =
6161 describe " constrained" . modifyMaxSuccess (\ ms -> if nightly then ms * 10 else ms) $ do
62+ testSpec " complicatedEither" complicatedEither
63+ testSpec " pairCatn" pairCant
6264 -- TODO: double-shrinking
6365 testSpecNoShrink " reifiesMultiple" reifiesMultiple
6466 testSpec " assertReal" assertReal
You can’t perform that action at this time.
0 commit comments