Skip to content

Commit

Permalink
Add simple QuickCheck test for solver exceptions
Browse files Browse the repository at this point in the history
The solver QuickCheck tests can already detect exceptions, but this test is
simpler and easier to debug.
  • Loading branch information
grayjay committed Jul 30, 2024
1 parent 356c2f4 commit fa651d7
Showing 1 changed file with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,20 @@ import UnitTests.Distribution.Solver.Modular.QuickCheck.Utils

tests :: [TestTree]
tests =
[ -- This test checks that certain solver parameters do not affect the
[ testPropertyWithSeed "solver does not throw exceptions" $
\test goalOrder reorderGoals indepGoals prefOldest ->
let r = solve
(EnableBackjumping True)
(FineGrainedConflicts True)
reorderGoals
(CountConflicts True)
indepGoals
prefOldest
(getBlind <$> goalOrder)
test
in resultPlan r `seq` ()

, -- This test checks that certain solver parameters do not affect the
-- existence of a solution. It runs the solver twice, and only sets those
-- parameters on the second run. The test also applies parameters that
-- can affect the existence of a solution to both runs.
Expand Down Expand Up @@ -516,6 +529,11 @@ instance Arbitrary IndependentGoals where

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

instance Arbitrary PreferOldest where
arbitrary = PreferOldest <$> arbitrary

shrink (PreferOldest prefOldest) = [PreferOldest False | prefOldest]

instance Arbitrary Component where
arbitrary =
oneof
Expand Down

0 comments on commit fa651d7

Please sign in to comment.