@@ -23,11 +23,32 @@ trait TestValueDomainWithInterpreter[T] {
23
23
case AllVarsInAbstract
24
24
case VarsLiveInBlock
25
25
26
+ case class InterpreterTestResult (stopCondition : ExecutionContinuation , checks : List [CheckResult ]) {
27
+ def getFailures = {
28
+ // require nonzero number of checks to ensure test is not vacuous
29
+ var noChecks = if (checks.isEmpty) then Seq (" no checks hit" ) else Seq ()
30
+ val termination =
31
+ if (! normalTermination(stopCondition)) then Seq (s " Stopped with error condition: ${stopCondition}" ) else Seq ()
32
+ termination ++ noChecks ++ checksFailed
33
+ }
34
+
35
+ def checksFailed = {
36
+ // collected breakpoints evaluate to true
37
+ checks.flatMap(b => {
38
+ val loc = b.breakpoint.location match {
39
+ case BreakPointLoc .CMD (c) => c.parent.label
40
+ case _ => ??? /* not used here */
41
+ }
42
+ if (b.evaluatedTestExpr != TrueLiteral ) then Seq (s " ${b.name} @ $loc" ) else Seq ()
43
+ })
44
+ }
45
+ }
46
+
26
47
def runTestInterpreter (
27
48
ictx : IRContext ,
28
49
testResultBefore : Map [Block , Map [Variable , T ]],
29
50
testVars : Heuristic = Heuristic .AllVarsInAbstract
30
- ): List [ CheckResult ] = {
51
+ ): InterpreterTestResult = {
31
52
32
53
val breaks : List [BreakPoint ] = ictx.program.collect {
33
54
// convert analysis result to a list of breakpoints, each which evaluates an expression describing
@@ -56,25 +77,14 @@ trait TestValueDomainWithInterpreter[T] {
56
77
// run the interpreter evaluating the analysis result at each command with a breakpoint
57
78
val interpretResult = interpretWithBreakPoints(ictx, breaks.toList, NormalInterpreter , InterpreterState ())
58
79
59
- assert(interpretResult._1.nextCmd == Stopped ())
60
80
val breakres : List [(BreakPoint , _, List [(String , Expr , Expr )])] = interpretResult._2
61
- breakres.flatMap { case (bp, _, l) =>
81
+ val checkResults = breakres.flatMap { case (bp, _, l) =>
62
82
l.map { case (name, test, evaled) =>
63
83
CheckResult (name, bp, test, evaled)
64
84
}
65
85
}.toList
66
- }
67
-
68
- def assertCorrectResult (breakres : List [CheckResult ]) = {
69
- assert(breakres.nonEmpty)
70
86
71
- // assert all the collected breakpoint watches have evaluated to true
72
- for (b <- breakres) {
73
- val loc = b.breakpoint.location match {
74
- case BreakPointLoc .CMD (c) => c.parent.label
75
- case _ => ??? /* not used here */
76
- }
77
- assert(b.evaluatedTestExpr == TrueLiteral , s " ${b.name} @ $loc" )
78
- }
87
+ InterpreterTestResult (interpretResult._1.nextCmd, checkResults)
79
88
}
89
+
80
90
}
0 commit comments