Skip to content

Commit

Permalink
hotfix with new test
Browse files Browse the repository at this point in the history
  • Loading branch information
MaximilianAlgehed committed Apr 25, 2024
1 parent 2f0ad36 commit 8613227
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
6 changes: 5 additions & 1 deletion libs/constrained-generators/src/Constrained/Base.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3783,7 +3783,11 @@ reify t f body =
]

assertReified :: HasSpec fn a => Term fn a -> (a -> Bool) -> Pred fn
assertReified = reifies (lit True)
-- Note, it is necessary to introduce the extra variable from the `exists` here
-- to make things like `assertRealMultiple` work, if you don't have it then the
-- `reifies` isn't a defining constraint for anything any more.
assertReified t f =
reify t f assert

reifies :: (HasSpec fn a, HasSpec fn b) => Term fn b -> Term fn a -> (a -> b) -> Pred fn
reifies = Reifies
Expand Down
7 changes: 7 additions & 0 deletions libs/constrained-generators/src/Constrained/Examples/Basic.hs
Original file line number Diff line number Diff line change
Expand Up @@ -156,3 +156,10 @@ assertReal = constrained $ \x ->
[ assert $ x <=. 10
, assertReified x (<= 10)
]

assertRealMultiple :: Specification BaseFn (Int, Int)
assertRealMultiple = constrained' $ \x y ->
[ assert $ x <=. 10
, assert $ 11 <=. y
, assertReified (pair_ x y) $ uncurry (/=)
]
1 change: 1 addition & 0 deletions libs/constrained-generators/test/Constrained/Test.hs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ tests :: Spec
tests =
describe "constrained" $ do
testSpec "assertReal" assertReal
testSpec "assertRealMultiple" assertRealMultiple
testSpec "setSpec" setSpec
testSpec "leqPair" leqPair
testSpec "setPair" setPair
Expand Down

0 comments on commit 8613227

Please sign in to comment.