Skip to content
Snippets Groups Projects
Commit 11d63cc2 authored by Etienne Kneuss's avatar Etienne Kneuss
Browse files

Fix tests with new synthesis refactoring

parent 06c268ab
No related branches found
No related tags found
No related merge requests found
...@@ -91,8 +91,8 @@ class StablePrintingSuite extends LeonTestSuite { ...@@ -91,8 +91,8 @@ class StablePrintingSuite extends LeonTestSuite {
for (a <- apps) { for (a <- apps) {
a.apply(sctx) match { a.apply(sctx) match {
case RuleSuccess(sol, isTrusted) => case RuleClosed(sols) =>
case RuleDecomposed(sub) => case RuleExpanded(sub) =>
a.onSuccess(sub.map(Solution.choose(_))) match { a.onSuccess(sub.map(Solution.choose(_))) match {
case Some(sol) => case Some(sol) =>
val result = sol.toSimplifiedExpr(ctx, pgm) val result = sol.toSimplifiedExpr(ctx, pgm)
...@@ -106,8 +106,6 @@ class StablePrintingSuite extends LeonTestSuite { ...@@ -106,8 +106,6 @@ class StablePrintingSuite extends LeonTestSuite {
workList push Job(newContent, (i to i+sub.size).toSet, a.toString :: j.rules) workList push Job(newContent, (i to i+sub.size).toSet, a.toString :: j.rules)
case None => case None =>
} }
case RuleApplicationImpossible =>
} }
} }
} }
......
...@@ -41,8 +41,8 @@ class SynthesisRegressionSuite extends LeonTestSuite { ...@@ -41,8 +41,8 @@ class SynthesisRegressionSuite extends LeonTestSuite {
for (ci <- chooses) { for (ci <- chooses) {
test(cat+": "+f.getName()+" - "+ci.fd.id.name) { test(cat+": "+f.getName()+" - "+ci.fd.id.name) {
val (sol, isComplete) = ci.synthesizer.synthesize() val (search, sols) = ci.synthesizer.synthesize()
if (!isComplete) { if (sols.isEmpty) {
fail("Solution was not found. (Search bound: "+bound+")") fail("Solution was not found. (Search bound: "+bound+")")
} }
} }
......
...@@ -64,16 +64,14 @@ class SynthesisSuite extends LeonTestSuite { ...@@ -64,16 +64,14 @@ class SynthesisSuite extends LeonTestSuite {
apps.filter(matchingDesc(_, ss)) match { apps.filter(matchingDesc(_, ss)) match {
case app :: Nil => case app :: Nil =>
app.apply(sctx) match { app.apply(sctx) match {
case RuleSuccess(sol, trusted) => case RuleClosed(sols) =>
assert(sols.nonEmpty)
assert(ss.andThen.isEmpty) assert(ss.andThen.isEmpty)
sol sols.head
case RuleDecomposed(sub) => case RuleExpanded(sub) =>
val subSols = (sub zip ss.andThen) map { case (p, ss) => synthesizeWith(sctx, p, ss) } val subSols = (sub zip ss.andThen) map { case (p, ss) => synthesizeWith(sctx, p, ss) }
app.onSuccess(subSols).get app.onSuccess(subSols).get
case _ =>
throw new AssertionError("Failed to apply "+app+" on "+p)
} }
case Nil => case Nil =>
...@@ -108,8 +106,8 @@ class SynthesisSuite extends LeonTestSuite { ...@@ -108,8 +106,8 @@ class SynthesisSuite extends LeonTestSuite {
def assertRuleSuccess(sctx: SynthesisContext, rr: RuleInstantiation): Option[Solution] = { def assertRuleSuccess(sctx: SynthesisContext, rr: RuleInstantiation): Option[Solution] = {
rr.apply(sctx) match { rr.apply(sctx) match {
case RuleSuccess(sol, trusted) => case RuleClosed(sols) if sols.nonEmpty =>
Some(sol) sols.headOption
case _ => case _ =>
assert(false, "Rule did not succeed") assert(false, "Rule did not succeed")
None None
...@@ -189,13 +187,13 @@ object Injection { ...@@ -189,13 +187,13 @@ object Injection {
) { ) {
case (sctx, fd, p) => case (sctx, fd, p) =>
rules.CEGIS.instantiateOn(sctx, p).head.apply(sctx) match { rules.CEGIS.instantiateOn(sctx, p).head.apply(sctx) match {
case RuleSuccess(sol, trusted) => case RuleClosed(sols) if sols.nonEmpty =>
assert(false, "CEGIS should have failed, but found : %s".format(sol)) assert(false, "CEGIS should have failed, but found : %s".format(sols.head))
case _ => case _ =>
} }
rules.ADTSplit.instantiateOn(sctx, p).head.apply(sctx) match { rules.ADTSplit.instantiateOn(sctx, p).head.apply(sctx) match {
case RuleDecomposed(subs) => case RuleExpanded(subs) =>
for (sub <- subs; alt <- rules.CEGIS.instantiateOn(sctx, sub)) { for (sub <- subs; alt <- rules.CEGIS.instantiateOn(sctx, sub)) {
assertRuleSuccess(sctx, alt) assertRuleSuccess(sctx, alt)
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment