Skip to content

Commit e796646

Browse files
add failing tests
1 parent 8a90cf2 commit e796646

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

examples/Constrained/Examples/Basic.hs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff 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+
]

test/Constrained/Tests.hs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ testAll = hspec $ tests False
5959
tests :: Bool -> Spec
6060
tests 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

0 commit comments

Comments
 (0)