Skip to content

Commit

Permalink
Updated instrumentation behavior (fixes #49)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicholas C. Zakas committed Nov 23, 2011
1 parent 32fd2fe commit cb8a88c
Show file tree
Hide file tree
Showing 10 changed files with 73 additions and 12 deletions.
Binary file modified java/build/yuitest-coverage-report.jar
Binary file not shown.
Binary file modified java/build/yuitest-coverage.jar
Binary file not shown.
Binary file modified java/build/yuitest-selenium-driver.jar
Binary file not shown.
@@ -1,7 +1,8 @@
group ES3YUITestTemplates;

cover_line(src,code,line) ::= <<
_yuitest_coverline("<src>", <line>); <code>
_yuitest_coverline("<src>", <line>);
<code>
>>

cover_func(src,code,name,line) ::= <<
Expand Down
Expand Up @@ -109,4 +109,9 @@ public void testNoBraces() throws IOException {
assertResultsMatch("nobraces.js", "nobraces-covered.js");
}

@Test
public void testLabelledLoop() throws IOException {
assertResultsMatch("labelled-loop.js", "labelled-loop-covered.js");
}

}
Expand Up @@ -31,7 +31,8 @@ _yuitest_coverage["array-item.js"].lines = {"1":0};
_yuitest_coverage["array-item.js"].functions = {};
_yuitest_coverage["array-item.js"].coveredLines = 1;
_yuitest_coverage["array-item.js"].coveredFunctions = 0;
_yuitest_coverline("array-item.js", 1); var foo = [
_yuitest_coverline("array-item.js", 1);
var foo = [

hello

Expand Down
@@ -0,0 +1,40 @@
if (typeof _yuitest_coverage == "undefined"){
_yuitest_coverage = {};
_yuitest_coverline = function(src, line){
var coverage = _yuitest_coverage[src];
if (!coverage.lines[line]){
coverage.calledLines++;
}
coverage.lines[line]++;
};
_yuitest_coverfunc = function(src, name, line){
var coverage = _yuitest_coverage[src],
funcId = name + ":" + line;
if (!coverage.functions[funcId]){
coverage.calledFunctions++;
}
coverage.functions[funcId]++;
};
}
_yuitest_coverage["labelled-loop.js"] = {
lines: {},
functions: {},
coveredLines: 0,
calledLines: 0,
coveredFunctions: 0,
calledFunctions: 0,
path: "labelled-loop.js",
code: []
};
_yuitest_coverage["labelled-loop.js"].code=["testloop:","while (true){"," doSomething();","}"];
_yuitest_coverage["labelled-loop.js"].lines = {"1":0,"2":0,"3":0};
_yuitest_coverage["labelled-loop.js"].functions = {};
_yuitest_coverage["labelled-loop.js"].coveredLines = 3;
_yuitest_coverage["labelled-loop.js"].coveredFunctions = 0;
_yuitest_coverline("labelled-loop.js", 1);
testloop:
_yuitest_coverline("labelled-loop.js", 2);
while (true){
_yuitest_coverline("labelled-loop.js", 3);
doSomething();
}
@@ -0,0 +1,4 @@
testloop:
while (true){
doSomething();
}
18 changes: 12 additions & 6 deletions java/tests/com/yahoo/platform/yuitest/coverage/nobraces-covered.js
Expand Up @@ -31,16 +31,22 @@ _yuitest_coverage["nobraces.js"].lines = {"1":0,"3":0,"4":0,"5":0,"8":0,"9":0};
_yuitest_coverage["nobraces.js"].functions = {"test:1":0};
_yuitest_coverage["nobraces.js"].coveredLines = 6;
_yuitest_coverage["nobraces.js"].coveredFunctions = 1;
_yuitest_coverline("nobraces.js", 1); function test(){
_yuitest_coverline("nobraces.js", 1);
function test(){

_yuitest_coverfunc("nobraces.js", "test", 1);
_yuitest_coverline("nobraces.js", 3); if(o)
{_yuitest_coverline("nobraces.js", 4); for(var prop in o)
{_yuitest_coverline("nobraces.js", 5); doSomething();}}
_yuitest_coverline("nobraces.js", 3);
if(o)
{_yuitest_coverline("nobraces.js", 4);
for(var prop in o)
{_yuitest_coverline("nobraces.js", 5);
doSomething();}}


_yuitest_coverline("nobraces.js", 8); for(var x=initX;x<str_arr.length;x++)
{_yuitest_coverline("nobraces.js", 9); str_arr[x]=str_arr[x].charAt(0).toUpperCase()+str_arr[x].substring(1);}
_yuitest_coverline("nobraces.js", 8);
for(var x=initX;x<str_arr.length;x++)
{_yuitest_coverline("nobraces.js", 9);
str_arr[x]=str_arr[x].charAt(0).toUpperCase()+str_arr[x].substring(1);}


}
Expand Up @@ -31,21 +31,25 @@ _yuitest_coverage["string-property.js"].lines = {"1":0,"4":0,"8":0,"12":0};
_yuitest_coverage["string-property.js"].functions = {"\"test\":3":0,"foo:7":0,"\'bar\':11":0};
_yuitest_coverage["string-property.js"].coveredLines = 4;
_yuitest_coverage["string-property.js"].coveredFunctions = 3;
_yuitest_coverline("string-property.js", 1); var foo = {
_yuitest_coverline("string-property.js", 1);
var foo = {

"test": function(){
_yuitest_coverfunc("string-property.js", "\"test\"", 3);
_yuitest_coverline("string-property.js", 4); alert("hello");
_yuitest_coverline("string-property.js", 4);
alert("hello");
},

foo: function(){
_yuitest_coverfunc("string-property.js", "foo", 7);
_yuitest_coverline("string-property.js", 8); alert("goodbye");
_yuitest_coverline("string-property.js", 8);
alert("goodbye");
},

'bar': function(){
_yuitest_coverfunc("string-property.js", "\'bar\'", 11);
_yuitest_coverline("string-property.js", 12); alert("Woohoo");
_yuitest_coverline("string-property.js", 12);
alert("Woohoo");
}

};

0 comments on commit cb8a88c

Please sign in to comment.