Skip to content
Snippets Groups Projects
Commit cd7a4652 authored by Manos Koukoutos's avatar Manos Koukoutos
Browse files

CodegenEvaluatorSuite was doing nothing. Now it does something.

parent fd33cc09
No related branches found
No related tags found
No related merge requests found
...@@ -9,7 +9,7 @@ import leon.purescala.Expressions._ ...@@ -9,7 +9,7 @@ import leon.purescala.Expressions._
import leon.purescala.Types._ import leon.purescala.Types._
import leon.codegen._ import leon.codegen._
class CodegenEvaluatorSuite extends LeonTestSuiteWithProgram { class CodegenEvaluatorSuite extends LeonTestSuiteWithProgram with helpers.ExpressionsDSL{
val sources = List(""" val sources = List("""
import leon.lang._ import leon.lang._
...@@ -316,7 +316,7 @@ class CodegenEvaluatorSuite extends LeonTestSuiteWithProgram { ...@@ -316,7 +316,7 @@ class CodegenEvaluatorSuite extends LeonTestSuiteWithProgram {
"Overrides1" -> Tuple(Seq(BooleanLiteral(false), BooleanLiteral(true))), "Overrides1" -> Tuple(Seq(BooleanLiteral(false), BooleanLiteral(true))),
"Overrides2" -> Tuple(Seq(BooleanLiteral(false), BooleanLiteral(true))), "Overrides2" -> Tuple(Seq(BooleanLiteral(false), BooleanLiteral(true))),
"Arrays1" -> IntLiteral(2), "Arrays1" -> IntLiteral(2),
"Arrays2" -> IntLiteral(6) "Arrays2" -> IntLiteral(10)
) )
for { for {
...@@ -324,29 +324,25 @@ class CodegenEvaluatorSuite extends LeonTestSuiteWithProgram { ...@@ -324,29 +324,25 @@ class CodegenEvaluatorSuite extends LeonTestSuiteWithProgram {
requireMonitor <- Seq(false, true) requireMonitor <- Seq(false, true)
doInstrument <- Seq(false,true) doInstrument <- Seq(false,true)
} { } {
val opts = ((if(requireMonitor) Some("monitor") else None) ++ val opts = (if(requireMonitor) "monitor " else "") +
(if(doInstrument) Some("instrument") else None)).mkString("+") (if(doInstrument) "instrument" else "")
val testName = f"$name%-20s $opts%-18s" val testName = f"$name%-20s $opts%-18s"
test("Evaluation of "+testName) { case (ctx, pgm) => test("Evaluation of "+testName) { implicit fix =>
val eval = new CodeGenEvaluator(ctx, pgm, CodeGenParams( val eval = new CodeGenEvaluator(fix._1, fix._2, CodeGenParams(
maxFunctionInvocations = if (requireMonitor) 1000 else -1, // Monitor calls and abort execution if more than X calls maxFunctionInvocations = if (requireMonitor) 1000 else -1, // Monitor calls and abort execution if more than X calls
checkContracts = true, // Generate calls that checks pre/postconditions checkContracts = true, // Generate calls that checks pre/postconditions
doInstrument = doInstrument // Instrument reads to case classes (mainly for vanuatoo) doInstrument = doInstrument // Instrument reads to case classes (mainly for vanuatoo)
)) ))
val fun = pgm.lookup(name+".test").collect { (eval.eval(fcall(name + ".test")()).result, exp) match {
case fd: FunDef => fd
}.getOrElse {
fail("Failed to lookup '"+name+".test'")
}
(eval.eval(FunctionInvocation(fun.typed(Seq()), Seq())).result, exp) match {
case (Some(res), exp) => case (Some(res), exp) =>
assert(res === exp)
case (None, Error(_, _)) => case (None, Error(_, _)) =>
case (None, _) => // OK
case (_, Error(_, _)) => case _ =>
fail("")
} }
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment