I have some javascript开发者_运维百科 code with do while outer loop and switch inner loop, inner switch loop contains break outerloop. below is simplified version of code.
While generating code coverage with jstestdriver coverage plugin, I am getting error "Label not found" at line "break loop1". var a = 2;
var c = 5;
loop1:
do {
switch (c) {
case 1 :
break;
default :
break loop1;
}
a--;
} while (a !=0);
Any help??
This is because of a bug in the JsTestDriver coverage plugin. Until fixed, the solution would be to refactor your code to not use labels to break loops.
The code coverage plugin inserts statements on each line to record which lines have been executed, even between the label and the do
statement. This detaches them from each other.
The code executed with coverage enabled would look something like this:
// ...
LCOV_1f[3]++; loop1:
LCOV_1f[4]++; do {
// ...
} while (a !=0);
精彩评论