Skip to content

Commit 1eb0bb2

Browse files
authored
Merge pull request #10234 from grayjay/quickcheck-solver-exceptions
Add simple QuickCheck test for solver exceptions
2 parents 72e5439 + 3347001 commit 1eb0bb2

File tree

1 file changed

+19
-1
lines changed
  • cabal-install/tests/UnitTests/Distribution/Solver/Modular

1 file changed

+19
-1
lines changed

cabal-install/tests/UnitTests/Distribution/Solver/Modular/QuickCheck.hs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,20 @@ import UnitTests.Distribution.Solver.Modular.QuickCheck.Utils
5252

5353
tests :: [TestTree]
5454
tests =
55-
[ -- This test checks that certain solver parameters do not affect the
55+
[ testPropertyWithSeed "solver does not throw exceptions" $
56+
\test goalOrder reorderGoals indepGoals prefOldest ->
57+
let r =
58+
solve
59+
(EnableBackjumping True)
60+
(FineGrainedConflicts True)
61+
reorderGoals
62+
(CountConflicts True)
63+
indepGoals
64+
prefOldest
65+
(getBlind <$> goalOrder)
66+
test
67+
in resultPlan r `seq` ()
68+
, -- This test checks that certain solver parameters do not affect the
5669
-- existence of a solution. It runs the solver twice, and only sets those
5770
-- parameters on the second run. The test also applies parameters that
5871
-- can affect the existence of a solution to both runs.
@@ -516,6 +529,11 @@ instance Arbitrary IndependentGoals where
516529

517530
shrink (IndependentGoals indep) = [IndependentGoals False | indep]
518531

532+
instance Arbitrary PreferOldest where
533+
arbitrary = PreferOldest <$> arbitrary
534+
535+
shrink (PreferOldest prefOldest) = [PreferOldest False | prefOldest]
536+
519537
instance Arbitrary Component where
520538
arbitrary =
521539
oneof

0 commit comments

Comments
 (0)