Skip to content

Commit

Permalink
Check for empty bindings after getValues
Browse files Browse the repository at this point in the history
  • Loading branch information
nickbattle committed Nov 10, 2024
1 parent dd0e054 commit e9cf63e
Showing 1 changed file with 23 additions and 5 deletions.
28 changes: 23 additions & 5 deletions quickcheck/src/main/java/quickcheck/QuickCheck.java
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,8 @@ else if (e.number == 4024) // 'not yet specified' expression reached
String desc = "";
po.setWitness(null);
po.setProvedBy(null);
po.setCounterexample(null);
po.setMessage(null);

if (timedOut)
{
Expand All @@ -566,8 +568,17 @@ else if (po.isExistential())
else if (sresults.hasAllValues && execCompleted)
{
outcome = POStatus.PROVABLE; // All values were tested and passed, so PROVABLE
desc = " by finite types";
po.setProvedBy("finite");

if (bindings.isEmpty())
{
desc = " in all cases";
po.setProvedBy("fixed");
}
else
{
desc = " by finite types";
po.setProvedBy("finite");
}
}
else
{
Expand All @@ -576,8 +587,6 @@ else if (sresults.hasAllValues && execCompleted)

infof(outcome, "PO #%d, %s%s %s\n", po.number, outcome.toString().toUpperCase(), desc, duration(before, after));
po.setStatus(outcome);
po.setCounterexample(null);
po.setMessage(null);
}
else
{
Expand Down Expand Up @@ -622,7 +631,16 @@ else if (globals.hasMaybe() && execCompleted)
infof(POStatus.FAILED, "PO #%d, FAILED %s: ", po.number, duration(before, after));
po.setStatus(POStatus.FAILED);
printCounterexample(bindings);
po.setCounterexample(globals.getCounterexample());

if (bindings.isEmpty()) // Failed with no binds - eg. Test() with no params
{
po.setCounterexample(new Context(po.location, "Empty", null));
}
else
{
po.setCounterexample(globals.getCounterexample());
}

po.setWitness(null);

if (execException != null)
Expand Down

0 comments on commit e9cf63e

Please sign in to comment.