Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Updated instrumentation behavior (fixes #49)

  • Loading branch information...
commit cb8a88c70798228d7926b85b0fb5ba4a4842e96a 1 parent 32fd2fe
@nzakas nzakas authored
View
BIN  java/build/yuitest-coverage-report.jar
Binary file not shown
View
BIN  java/build/yuitest-coverage.jar
Binary file not shown
View
BIN  java/build/yuitest-selenium-driver.jar
Binary file not shown
View
3  java/src/com/yahoo/platform/yuitest/coverage/ES3YUITestTemplates.stg
@@ -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) ::= <<
View
5 java/tests/com/yahoo/platform/yuitest/coverage/CoverageInstrumentationTest.java
@@ -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");
+ }
+
}
View
3  java/tests/com/yahoo/platform/yuitest/coverage/array-item-covered.js
@@ -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
View
40 java/tests/com/yahoo/platform/yuitest/coverage/labelled-loop-covered.js
@@ -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();
+}
View
4 java/tests/com/yahoo/platform/yuitest/coverage/labelled-loop.js
@@ -0,0 +1,4 @@
+testloop:
+while (true){
+ doSomething();
+}
View
18 java/tests/com/yahoo/platform/yuitest/coverage/nobraces-covered.js
@@ -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);}
}
View
12 java/tests/com/yahoo/platform/yuitest/coverage/string-property-covered.js
@@ -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");
}
};
Please sign in to comment.
Something went wrong with that request. Please try again.