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

Recursive focusing now relies on correct tests

parent ea116aa3
No related branches found
No related tags found
No related merge requests found
...@@ -42,10 +42,10 @@ case object Focus extends Rule("Focus") { ...@@ -42,10 +42,10 @@ case object Focus extends Rule("Focus") {
// - returns Some(true) if for all tests e evaluates to true // - returns Some(true) if for all tests e evaluates to true
// - returns Some(false) if for all tests e evaluates to false // - returns Some(false) if for all tests e evaluates to false
// - returns None otherwise // - returns None otherwise
def forAllTests(tests: Seq[Example])(e: Expr, env: Map[Identifier, Expr], evaluator: Evaluator): Option[Boolean] = { def forAllTestsOf(p: Problem)(e: Expr, env: Map[Identifier, Expr], evaluator: Evaluator): Option[Boolean] = {
var soFar: Option[Boolean] = None var soFar: Option[Boolean] = None
tests.foreach { ex => p.tb.invalids.foreach { ex =>
evaluator.eval(e, (p.as zip ex.ins).toMap ++ env) match { evaluator.eval(e, (p.as zip ex.ins).toMap ++ env) match {
case EvaluationResults.Successful(BooleanLiteral(b)) => case EvaluationResults.Successful(BooleanLiteral(b)) =>
soFar match { soFar match {
...@@ -74,7 +74,7 @@ case object Focus extends Rule("Focus") { ...@@ -74,7 +74,7 @@ case object Focus extends Rule("Focus") {
} }
def focus(p: Problem): Traversable[RuleInstantiation] = { def focus(p: Problem): Traversable[RuleInstantiation] = {
val faTests = forAllTests(p.tb.invalids) _ val faTests = forAllTestsOf(p) _
val TopLevelAnds(clauses) = p.ws val TopLevelAnds(clauses) = p.ws
......
...@@ -136,7 +136,6 @@ case class TestBank(valids: Seq[Example], invalids: Seq[Example]) { ...@@ -136,7 +136,6 @@ case class TestBank(valids: Seq[Example], invalids: Seq[Example]) {
"No tests." "No tests."
} }
} }
} }
object TestBank { object TestBank {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment