CoverageFormat.js revision 33d85edf47749fa345d7b636b9b4b9d0d0386f44
/**
* An object object containing coverage result formatting methods.
* @namespace YUITest
* @class CoverageFormat
* @static
*/
YUITest.CoverageFormat = {
/**
* Returns the coverage report in JSON format. This is the straight
* JSON representation of the native coverage report.
* @param {Object} coverage The coverage report object.
* @return {String} A JSON-formatted string of coverage data.
* @method JSON
* @namespace YUITest.CoverageFormat
*/
JSON: function(coverage){
return YUITest.Util.JSON.stringify(coverage);
},
/**
* Returns the coverage report in a JSON format compatible with
* Xdebug. See <a href="http://www.xdebug.com/docs/code_coverage">Xdebug Documentation</a>
* for more information. Note: function coverage is not available
* in this format.
* @param {Object} coverage The coverage report object.
* @return {String} A JSON-formatted string of coverage data.
* @method XdebugJSON
* @namespace YUITest.CoverageFormat
*/
XdebugJSON: function(coverage){
var report = {};
for (var prop in coverage){
if (coverage.hasOwnProperty(prop)){
report[prop] = coverage[prop].lines;
}
}
return YUITest.Util.JSON.stringify(coverage);
}
};