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

Fix tests with new rules API

parent 6a5b1b67
No related branches found
No related tags found
No related merge requests found
...@@ -60,19 +60,19 @@ object SynthesisBenchmarks extends App { ...@@ -60,19 +60,19 @@ object SynthesisBenchmarks extends App {
val (results, solver) = pipeline.run(ctx)(file.getPath :: Nil) val (results, solver) = pipeline.run(ctx)(file.getPath :: Nil)
val sctx = SynthesisContext(solver, new SilentReporter) val sctx = SynthesisContext(solver, new SilentReporter, new java.util.concurrent.atomic.AtomicBoolean)
for ((f, ps) <- results; p <- ps) { for ((f, ps) <- results; p <- ps) {
val ts = System.currentTimeMillis val ts = System.currentTimeMillis
val rr = rules.CEGIS.attemptToApplyOn(sctx, p) val rr = rules.CEGIS.instantiateOn(sctx, p)
val nAlt = rr.alternatives.size val nAlt = rr.size
var nSuccess, nInnap, nDecomp = 0 var nSuccess, nInnap, nDecomp = 0
for (alt <- rr.alternatives) { for (alt <- rr) {
alt.apply() match { alt.apply(sctx) match {
case RuleApplicationImpossible => case RuleApplicationImpossible =>
nInnap += 1 nInnap += 1
case s: RuleDecomposed => case s: RuleDecomposed =>
......
...@@ -104,22 +104,17 @@ class SynthesisSuite extends FunSuite { ...@@ -104,22 +104,17 @@ class SynthesisSuite extends FunSuite {
} }
} }
def synthesisStep(s: Solver, r: Rule, p: Problem): RuleResult = { def assertRuleSuccess(sctx: SynthesisContext, rr: Traversable[RuleInstantiation]) {
val sctx = SynthesisContext(s, new SilentReporter) assert(rr.isEmpty === false, "No rule alternative while the rule should have succeeded")
r.attemptToApplyOn(sctx, p) assert(rr.exists(alt => alt.apply(sctx).isInstanceOf[RuleSuccess]) === true, "Rule did not succeed")
}
def assertRuleSuccess(rr: RuleResult) {
assert(rr.alternatives.isEmpty === false, "No rule alternative while the rule should have succeeded")
assert(rr.alternatives.exists(alt => alt.apply().isInstanceOf[RuleSuccess]) === true, "Rule did not succeed")
} }
def assertFastEnough(rr: RuleResult, timeoutMs: Long) { def assertFastEnough(sctx: SynthesisContext, rr: Traversable[RuleInstantiation], timeoutMs: Long) {
for (alt <- rr.alternatives) { for (alt <- rr) {
val ts = System.currentTimeMillis val ts = System.currentTimeMillis
val res = alt.apply() val res = alt.apply(sctx)
val t = System.currentTimeMillis - ts val t = System.currentTimeMillis - ts
...@@ -130,7 +125,9 @@ class SynthesisSuite extends FunSuite { ...@@ -130,7 +125,9 @@ class SynthesisSuite extends FunSuite {
testFile("synthesis/Cegis1.scala") { testFile("synthesis/Cegis1.scala") {
case (solver, fd, p) => case (solver, fd, p) =>
assertRuleSuccess(synthesisStep(solver, rules.CEGIS, p)) val sctx = SynthesisContext(solver, new SilentReporter, new java.util.concurrent.atomic.AtomicBoolean)
assertFastEnough(synthesisStep(solver, rules.CEGIS, p), 100)
assertRuleSuccess(sctx, rules.CEGIS.instantiateOn(sctx, p))
assertFastEnough(sctx, rules.CEGIS.instantiateOn(sctx, p), 100)
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment