From 946266262e1959140e0d639cd5c05f7e0c242895 Mon Sep 17 00:00:00 2001 From: Reid Burke Date: Tue, 12 Mar 2013 17:44:02 -0700 Subject: [PATCH 1/2] Object.keys -> Y.Object.keys. Fix for IE 6-8. --- src/test-console/js/test-console.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test-console/js/test-console.js b/src/test-console/js/test-console.js index 0935c6bcd1e..ec70e7e5660 100644 --- a/src/test-console/js/test-console.js +++ b/src/test-console/js/test-console.js @@ -62,7 +62,7 @@ Y.namespace('Test').Console = Y.extend(TestConsole, Y.Console, { * @return {Boolean} True if this is Istanbul Coverage */ _isIstanbul: function(json) { - var first = Object.keys(json)[0], + var first = Y.Object.keys(json)[0], ret = false; if (json[first].s !== undefined && json[first].fnMap !== undefined) { From ccc2b9d06e4d39339f67455c4b952725f2873827 Mon Sep 17 00:00:00 2001 From: Reid Burke Date: Tue, 12 Mar 2013 17:47:46 -0700 Subject: [PATCH 2/2] Build test-console. --- build/test-console/test-console-coverage.js | 4 ++-- build/test-console/test-console-debug.js | 2 +- build/test-console/test-console-min.js | 2 +- build/test-console/test-console.js | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/build/test-console/test-console-coverage.js b/build/test-console/test-console-coverage.js index ecede888dcc..05be2bec7e8 100644 --- a/build/test-console/test-console-coverage.js +++ b/build/test-console/test-console-coverage.js @@ -26,7 +26,7 @@ _yuitest_coverage["build/test-console/test-console.js"] = { path: "build/test-console/test-console.js", code: [] }; -_yuitest_coverage["build/test-console/test-console.js"].code=["YUI.add('test-console', function (Y, NAME) {","","/**","Provides a specialized log console widget that's pre-configured to display YUI","Test output with no extra configuration.","","@example","","
",""," ","","@module test-console","@namespace Test","@class Console","@extends Console","@constructor","","@param {Object} [config] Config attributes."," @param {Object} [config.filters] Category filter configuration.","","@since 3.5.0","**/","","function TestConsole() {"," TestConsole.superclass.constructor.apply(this, arguments);","}","","Y.namespace('Test').Console = Y.extend(TestConsole, Y.Console, {"," initializer: function (config) {"," this.on('entry', this._onEntry);",""," this.plug(Y.Plugin.ConsoleFilters, {"," category: Y.merge({"," info : true,"," pass : false,"," fail : true,"," status: false"," }, (config && config.filters) || {}),",""," defaultVisibility: false,",""," source: {"," TestRunner: true"," }"," });",""," Y.Test.Runner.on('complete', Y.bind(this._parseCoverage, this));"," },",""," // -- Protected Coverage Parser ---------------------------------------------"," /**"," * Scans the coverage data to determine if it's an Istanbul coverage object."," * @method _isIstanbul"," * @param {Object} json The coverage data to scan"," * @return {Boolean} True if this is Istanbul Coverage"," */"," _isIstanbul: function(json) {"," var first = Object.keys(json)[0],"," ret = false;",""," if (json[first].s !== undefined && json[first].fnMap !== undefined) {"," ret = true;"," } ",""," if (json.s !== undefined && json.fnMap !== undefined) {"," ret = true;"," } "," return ret;"," },"," /**"," * Parses and logs a summary of YUITest coverage data."," * @method parseYUITest"," * @param {Object} coverage The YUITest Coverage JSON data"," */"," parseYUITestCoverage: function (coverage) {"," var cov = {"," lines: {"," hit: 0,"," miss: 0,"," total: 0,"," percent: 0"," },"," functions: {"," hit: 0,"," miss: 0,"," total: 0,"," percent: 0"," }"," }, coverageLog;",""," Y.Object.each(coverage, function(info) {"," cov.lines.total += info.coveredLines;"," cov.lines.hit += info.calledLines;"," cov.lines.miss += (info.coveredLines - info.calledLines);"," cov.lines.percent = Math.floor((cov.lines.hit / cov.lines.total) * 100);"," "," cov.functions.total += info.coveredFunctions;"," cov.functions.hit += info.calledFunctions;"," cov.functions.miss += (info.coveredFunctions - info.calledFunctions);"," cov.functions.percent = Math.floor((cov.functions.hit / cov.functions.total) * 100);"," });",""," "," coverageLog = 'Lines: Hit:' + cov.lines.hit + ' Missed:' + cov.lines.miss + ' Total:' + cov.lines.total + ' Percent:' + cov.lines.percent + '%\\n';"," coverageLog += 'Functions: Hit:' + cov.functions.hit + ' Missed:' + cov.functions.miss + ' Total:' + cov.functions.total + ' Percent:' + cov.functions.percent + '%';",""," this.log('Coverage: ' + coverageLog, 'info', 'TestRunner');"," },"," /**"," * Generates a generic summary object used for Istanbul conversions."," * @method _blankSummary"," * @return {Object} Generic summary object"," */"," _blankSummary: function () {"," return {"," lines: {"," total: 0,"," covered: 0,"," pct: 'Unknown'"," },"," statements: {"," total: 0,"," covered: 0,"," pct: 'Unknown'"," },"," functions: {"," total: 0,"," covered: 0,"," pct: 'Unknown'"," },"," branches: {"," total: 0,"," covered: 0,"," pct: 'Unknown'"," }"," };"," },"," /**"," * Calculates line numbers from statement coverage"," * @method _addDerivedInfoForFile"," * @private"," * @param {Object} fileCoverage JSON coverage data"," */"," _addDerivedInfoForFile: function (fileCoverage) {"," var statementMap = fileCoverage.statementMap,"," statements = fileCoverage.s,"," lineMap;",""," if (!fileCoverage.l) {"," fileCoverage.l = lineMap = {};"," Y.Object.each(statements, function (value, st) {"," var line = statementMap[st].start.line,"," count = statements[st],"," prevVal = lineMap[line];"," if (typeof prevVal === 'undefined' || prevVal < count) {"," lineMap[line] = count;"," }"," });"," }"," },"," /**"," * Generic percent calculator"," * @method _percent"," * @param {Number} covered The covered amount"," * @param {Number} total The total"," * @private"," */"," _percent: function (covered, total) {"," var tmp, pct = 100.00;"," if (total > 0) {"," tmp = 1000 * 100 * covered / total + 5;"," pct = Math.floor(tmp / 10) / 100;"," }"," return pct;"," },"," /**"," * Summarize simple properties in the coverage data"," * @method _computSimpleTotals"," * @private"," * @param {Object} fileCoverage JSON coverage data"," * @param {String} property The property to summarize"," */"," _computeSimpleTotals: function (fileCoverage, property) {"," var stats = fileCoverage[property],"," ret = { total: 0, covered: 0 };",""," Y.Object.each(stats, function(val) {"," ret.total += 1;"," if (val) {"," ret.covered += 1;"," } "," }); "," ret.pct = this._percent(ret.covered, ret.total);"," return ret;"," },"," /**"," * Noramlizes branch data from Istanbul"," * @method _computeBranchTotals"," * @private"," * @param {Object} fileCoverage JSON coverage data"," */"," _computeBranchTotals: function (fileCoverage) {"," var stats = fileCoverage.b,"," ret = { total: 0, covered: 0 };",""," Y.Object.each(stats, function (branches) {"," var covered = Y.Array.filter(branches, function (num) { return num > 0; }); "," ret.total += branches.length;"," ret.covered += covered.length;"," }); "," ret.pct = this._percent(ret.covered, ret.total);"," return ret;"," },"," /**"," * Takes an Istanbul coverage object, normalizes it and prints a log with a summary"," * @method parseInstanbul"," * @param {Object} coverage The coverage object to normalize and log"," */"," parseIstanbul: function (coverage) {"," var self = this,"," str = 'Coverage Report:\\n';",""," Y.Object.each(coverage, function(fileCoverage, file) {"," var ret = self._blankSummary();",""," self._addDerivedInfoForFile(fileCoverage);"," ret.lines = self._computeSimpleTotals(fileCoverage, 'l');"," ret.functions = self._computeSimpleTotals(fileCoverage, 'f');"," ret.statements = self._computeSimpleTotals(fileCoverage, 's');"," ret.branches = self._computeBranchTotals(fileCoverage);"," str += file + ':\\n';"," Y.Array.each(['lines','functions','statements','branches'], function(key) {"," str += ' ' + key +': ' + ret[key].covered + '/' + ret[key].total + ' : ' + ret[key].pct + '%\\n';"," });",""," });"," this.log(str, 'info', 'TestRunner');",""," },"," /**"," * Parses YUITest or Istanbul coverage results if they are available and logs them."," * @method _parseCoverage"," * @private"," */"," _parseCoverage: function() {"," var coverage = Y.Test.Runner.getCoverage();"," if (!coverage) {"," return;"," }"," if (this._isIstanbul(coverage)) {"," this.parseIstanbul(coverage);"," } else {"," this.parseYUITestCoverage(coverage);"," }"," },",""," // -- Protected Event Handlers ---------------------------------------------"," _onEntry: function (e) {"," var msg = e.message;",""," if (msg.category === 'info'"," && /\\s(?:case|suite)\\s|yuitests\\d+|began/.test(msg.message)) {"," msg.category = 'status';"," } else if (msg.category === 'fail') {"," this.printBuffer();"," }"," }","}, {"," NAME: 'testConsole',",""," ATTRS: {"," entryTemplate: {"," value:"," '
' +"," '
{message}
' +"," '
'"," },",""," height: {"," value: '350px'"," },",""," newestOnTop: {"," value: false"," },",""," style: {"," value: 'block'"," },",""," width: {"," value: Y.UA.ie && Y.UA.ie < 9 ? '100%' : 'inherit'"," }"," }","});","","","}, '@VERSION@', {\"requires\": [\"console-filters\", \"test\", \"array-extras\"], \"skinnable\": true});"]; +_yuitest_coverage["build/test-console/test-console.js"].code=["YUI.add('test-console', function (Y, NAME) {","","/**","Provides a specialized log console widget that's pre-configured to display YUI","Test output with no extra configuration.","","@example","","
",""," ","","@module test-console","@namespace Test","@class Console","@extends Console","@constructor","","@param {Object} [config] Config attributes."," @param {Object} [config.filters] Category filter configuration.","","@since 3.5.0","**/","","function TestConsole() {"," TestConsole.superclass.constructor.apply(this, arguments);","}","","Y.namespace('Test').Console = Y.extend(TestConsole, Y.Console, {"," initializer: function (config) {"," this.on('entry', this._onEntry);",""," this.plug(Y.Plugin.ConsoleFilters, {"," category: Y.merge({"," info : true,"," pass : false,"," fail : true,"," status: false"," }, (config && config.filters) || {}),",""," defaultVisibility: false,",""," source: {"," TestRunner: true"," }"," });",""," Y.Test.Runner.on('complete', Y.bind(this._parseCoverage, this));"," },",""," // -- Protected Coverage Parser ---------------------------------------------"," /**"," * Scans the coverage data to determine if it's an Istanbul coverage object."," * @method _isIstanbul"," * @param {Object} json The coverage data to scan"," * @return {Boolean} True if this is Istanbul Coverage"," */"," _isIstanbul: function(json) {"," var first = Y.Object.keys(json)[0],"," ret = false;",""," if (json[first].s !== undefined && json[first].fnMap !== undefined) {"," ret = true;"," } ",""," if (json.s !== undefined && json.fnMap !== undefined) {"," ret = true;"," } "," return ret;"," },"," /**"," * Parses and logs a summary of YUITest coverage data."," * @method parseYUITest"," * @param {Object} coverage The YUITest Coverage JSON data"," */"," parseYUITestCoverage: function (coverage) {"," var cov = {"," lines: {"," hit: 0,"," miss: 0,"," total: 0,"," percent: 0"," },"," functions: {"," hit: 0,"," miss: 0,"," total: 0,"," percent: 0"," }"," }, coverageLog;",""," Y.Object.each(coverage, function(info) {"," cov.lines.total += info.coveredLines;"," cov.lines.hit += info.calledLines;"," cov.lines.miss += (info.coveredLines - info.calledLines);"," cov.lines.percent = Math.floor((cov.lines.hit / cov.lines.total) * 100);"," "," cov.functions.total += info.coveredFunctions;"," cov.functions.hit += info.calledFunctions;"," cov.functions.miss += (info.coveredFunctions - info.calledFunctions);"," cov.functions.percent = Math.floor((cov.functions.hit / cov.functions.total) * 100);"," });",""," "," coverageLog = 'Lines: Hit:' + cov.lines.hit + ' Missed:' + cov.lines.miss + ' Total:' + cov.lines.total + ' Percent:' + cov.lines.percent + '%\\n';"," coverageLog += 'Functions: Hit:' + cov.functions.hit + ' Missed:' + cov.functions.miss + ' Total:' + cov.functions.total + ' Percent:' + cov.functions.percent + '%';",""," this.log('Coverage: ' + coverageLog, 'info', 'TestRunner');"," },"," /**"," * Generates a generic summary object used for Istanbul conversions."," * @method _blankSummary"," * @return {Object} Generic summary object"," */"," _blankSummary: function () {"," return {"," lines: {"," total: 0,"," covered: 0,"," pct: 'Unknown'"," },"," statements: {"," total: 0,"," covered: 0,"," pct: 'Unknown'"," },"," functions: {"," total: 0,"," covered: 0,"," pct: 'Unknown'"," },"," branches: {"," total: 0,"," covered: 0,"," pct: 'Unknown'"," }"," };"," },"," /**"," * Calculates line numbers from statement coverage"," * @method _addDerivedInfoForFile"," * @private"," * @param {Object} fileCoverage JSON coverage data"," */"," _addDerivedInfoForFile: function (fileCoverage) {"," var statementMap = fileCoverage.statementMap,"," statements = fileCoverage.s,"," lineMap;",""," if (!fileCoverage.l) {"," fileCoverage.l = lineMap = {};"," Y.Object.each(statements, function (value, st) {"," var line = statementMap[st].start.line,"," count = statements[st],"," prevVal = lineMap[line];"," if (typeof prevVal === 'undefined' || prevVal < count) {"," lineMap[line] = count;"," }"," });"," }"," },"," /**"," * Generic percent calculator"," * @method _percent"," * @param {Number} covered The covered amount"," * @param {Number} total The total"," * @private"," */"," _percent: function (covered, total) {"," var tmp, pct = 100.00;"," if (total > 0) {"," tmp = 1000 * 100 * covered / total + 5;"," pct = Math.floor(tmp / 10) / 100;"," }"," return pct;"," },"," /**"," * Summarize simple properties in the coverage data"," * @method _computSimpleTotals"," * @private"," * @param {Object} fileCoverage JSON coverage data"," * @param {String} property The property to summarize"," */"," _computeSimpleTotals: function (fileCoverage, property) {"," var stats = fileCoverage[property],"," ret = { total: 0, covered: 0 };",""," Y.Object.each(stats, function(val) {"," ret.total += 1;"," if (val) {"," ret.covered += 1;"," } "," }); "," ret.pct = this._percent(ret.covered, ret.total);"," return ret;"," },"," /**"," * Noramlizes branch data from Istanbul"," * @method _computeBranchTotals"," * @private"," * @param {Object} fileCoverage JSON coverage data"," */"," _computeBranchTotals: function (fileCoverage) {"," var stats = fileCoverage.b,"," ret = { total: 0, covered: 0 };",""," Y.Object.each(stats, function (branches) {"," var covered = Y.Array.filter(branches, function (num) { return num > 0; }); "," ret.total += branches.length;"," ret.covered += covered.length;"," }); "," ret.pct = this._percent(ret.covered, ret.total);"," return ret;"," },"," /**"," * Takes an Istanbul coverage object, normalizes it and prints a log with a summary"," * @method parseInstanbul"," * @param {Object} coverage The coverage object to normalize and log"," */"," parseIstanbul: function (coverage) {"," var self = this,"," str = 'Coverage Report:\\n';",""," Y.Object.each(coverage, function(fileCoverage, file) {"," var ret = self._blankSummary();",""," self._addDerivedInfoForFile(fileCoverage);"," ret.lines = self._computeSimpleTotals(fileCoverage, 'l');"," ret.functions = self._computeSimpleTotals(fileCoverage, 'f');"," ret.statements = self._computeSimpleTotals(fileCoverage, 's');"," ret.branches = self._computeBranchTotals(fileCoverage);"," str += file + ':\\n';"," Y.Array.each(['lines','functions','statements','branches'], function(key) {"," str += ' ' + key +': ' + ret[key].covered + '/' + ret[key].total + ' : ' + ret[key].pct + '%\\n';"," });",""," });"," this.log(str, 'info', 'TestRunner');",""," },"," /**"," * Parses YUITest or Istanbul coverage results if they are available and logs them."," * @method _parseCoverage"," * @private"," */"," _parseCoverage: function() {"," var coverage = Y.Test.Runner.getCoverage();"," if (!coverage) {"," return;"," }"," if (this._isIstanbul(coverage)) {"," this.parseIstanbul(coverage);"," } else {"," this.parseYUITestCoverage(coverage);"," }"," },",""," // -- Protected Event Handlers ---------------------------------------------"," _onEntry: function (e) {"," var msg = e.message;",""," if (msg.category === 'info'"," && /\\s(?:case|suite)\\s|yuitests\\d+|began/.test(msg.message)) {"," msg.category = 'status';"," } else if (msg.category === 'fail') {"," this.printBuffer();"," }"," }","}, {"," NAME: 'testConsole',",""," ATTRS: {"," entryTemplate: {"," value:"," '
' +"," '
{message}
' +"," '
'"," },",""," height: {"," value: '350px'"," },",""," newestOnTop: {"," value: false"," },",""," style: {"," value: 'block'"," },",""," width: {"," value: Y.UA.ie && Y.UA.ie < 9 ? '100%' : 'inherit'"," }"," }","});","","","}, '@VERSION@', {\"requires\": [\"console-filters\", \"test\", \"array-extras\"], \"skinnable\": true});"]; _yuitest_coverage["build/test-console/test-console.js"].lines = {"1":0,"33":0,"34":0,"37":0,"39":0,"41":0,"56":0,"67":0,"70":0,"71":0,"74":0,"75":0,"77":0,"85":0,"100":0,"101":0,"102":0,"103":0,"104":0,"106":0,"107":0,"108":0,"109":0,"113":0,"114":0,"116":0,"124":0,"154":0,"158":0,"159":0,"160":0,"161":0,"164":0,"165":0,"178":0,"179":0,"180":0,"181":0,"183":0,"193":0,"196":0,"197":0,"198":0,"199":0,"202":0,"203":0,"212":0,"215":0,"216":0,"217":0,"218":0,"220":0,"221":0,"229":0,"232":0,"233":0,"235":0,"236":0,"237":0,"238":0,"239":0,"240":0,"241":0,"242":0,"246":0,"255":0,"256":0,"257":0,"259":0,"260":0,"262":0,"268":0,"270":0,"272":0,"273":0,"274":0}; _yuitest_coverage["build/test-console/test-console.js"].functions = {"TestConsole:33":0,"initializer:38":0,"_isIstanbul:66":0,"(anonymous 2):100":0,"parseYUITestCoverage:84":0,"_blankSummary:123":0,"(anonymous 3):160":0,"_addDerivedInfoForFile:153":0,"_percent:177":0,"(anonymous 4):196":0,"_computeSimpleTotals:192":0,"(anonymous 6):216":0,"(anonymous 5):215":0,"_computeBranchTotals:211":0,"(anonymous 8):241":0,"(anonymous 7):232":0,"parseIstanbul:228":0,"_parseCoverage:254":0,"_onEntry:267":0,"(anonymous 1):1":0}; _yuitest_coverage["build/test-console/test-console.js"].coveredLines = 76; @@ -109,7 +109,7 @@ Y.Test.Runner.on('complete', Y.bind(this._parseCoverage, this)); _isIstanbul: function(json) { _yuitest_coverfunc("build/test-console/test-console.js", "_isIstanbul", 66); _yuitest_coverline("build/test-console/test-console.js", 67); -var first = Object.keys(json)[0], +var first = Y.Object.keys(json)[0], ret = false; _yuitest_coverline("build/test-console/test-console.js", 70); diff --git a/build/test-console/test-console-debug.js b/build/test-console/test-console-debug.js index a8f358762ad..b7ae60c7187 100644 --- a/build/test-console/test-console-debug.js +++ b/build/test-console/test-console-debug.js @@ -64,7 +64,7 @@ Y.namespace('Test').Console = Y.extend(TestConsole, Y.Console, { * @return {Boolean} True if this is Istanbul Coverage */ _isIstanbul: function(json) { - var first = Object.keys(json)[0], + var first = Y.Object.keys(json)[0], ret = false; if (json[first].s !== undefined && json[first].fnMap !== undefined) { diff --git a/build/test-console/test-console-min.js b/build/test-console/test-console-min.js index a194876222a..eab82179b7f 100644 --- a/build/test-console/test-console-min.js +++ b/build/test-console/test-console-min.js @@ -1 +1 @@ -YUI.add("test-console",function(e,t){function n(){n.superclass.constructor.apply(this,arguments)}e.namespace("Test").Console=e.extend(n,e.Console,{initializer:function(t){this.on("entry",this._onEntry),this.plug(e.Plugin.ConsoleFilters,{category:e.merge({info:!0,pass:!1,fail:!0,status:!1},t&&t.filters||{}),defaultVisibility:!1,source:{TestRunner:!0}}),e.Test.Runner.on("complete",e.bind(this._parseCoverage,this))},_isIstanbul:function(e){var t=Object.keys(e)[0],n=!1;return e[t].s!==undefined&&e[t].fnMap!==undefined&&(n=!0),e.s!==undefined&&e.fnMap!==undefined&&(n=!0),n},parseYUITestCoverage:function(t){var n={lines:{hit:0,miss:0,total:0,percent:0},functions:{hit:0,miss:0,total:0,percent:0}},r;e.Object.each(t,function(e){n.lines.total+=e.coveredLines,n.lines.hit+=e.calledLines,n.lines.miss+=e.coveredLines-e.calledLines,n.lines.percent=Math.floor(n.lines.hit/n.lines.total*100),n.functions.total+=e.coveredFunctions,n.functions.hit+=e.calledFunctions,n.functions.miss+=e.coveredFunctions-e.calledFunctions,n.functions.percent=Math.floor(n.functions.hit/n.functions.total*100)}),r="Lines: Hit:"+n.lines.hit+" Missed:"+n.lines.miss+" Total:"+n.lines.total+" Percent:"+n.lines.percent+"%\n",r+="Functions: Hit:"+n.functions.hit+" Missed:"+n.functions.miss+" Total:"+n.functions.total+" Percent:"+n.functions.percent+"%",this.log("Coverage: "+r,"info","TestRunner")},_blankSummary:function(){return{lines:{total:0,covered:0,pct:"Unknown"},statements:{total:0,covered:0,pct:"Unknown"},functions:{total:0,covered:0,pct:"Unknown"},branches:{total:0,covered:0,pct:"Unknown"}}},_addDerivedInfoForFile:function(t){var n=t.statementMap,r=t.s,i;t.l||(t.l=i={},e.Object.each(r,function(e,t){var s=n[t].start.line,o=r[t],u=i[s];if(typeof u=="undefined"||u0&&(n=1e5*e/t+5,r=Math.floor(n/10)/100),r},_computeSimpleTotals:function(t,n){var r=t[n],i={total:0,covered:0};return e.Object.each(r,function(e){i.total+=1,e&&(i.covered+=1)}),i.pct=this._percent(i.covered,i.total),i},_computeBranchTotals:function(t){var n=t.b,r={total:0,covered:0};return e.Object.each(n,function(t){var n=e.Array.filter(t,function(e){return e>0});r.total+=t.length,r.covered+=n.length}),r.pct=this._percent(r.covered,r.total),r},parseIstanbul:function(t){var n=this,r="Coverage Report:\n";e.Object.each(t,function(t,i){var s=n._blankSummary();n._addDerivedInfoForFile(t),s.lines=n._computeSimpleTotals(t,"l"),s.functions=n._computeSimpleTotals(t,"f"),s.statements=n._computeSimpleTotals(t,"s"),s.branches=n._computeBranchTotals(t),r+=i+":\n",e.Array.each(["lines","functions","statements","branches"],function(e){r+=" "+e+": "+s[e].covered+"/"+s[e].total+" : "+s[e].pct+"%\n"})}),this.log(r,"info","TestRunner")},_parseCoverage:function(){var t=e.Test.Runner.getCoverage();if(!t)return;this._isIstanbul(t)?this.parseIstanbul(t):this.parseYUITestCoverage(t)},_onEntry:function(e){var t=e.message;t.category==="info"&&/\s(?:case|suite)\s|yuitests\d+|began/.test(t.message)?t.category="status":t.category==="fail"&&this.printBuffer()}},{NAME:"testConsole",ATTRS:{entryTemplate:{value:'
{message}
'},height:{value:"350px"},newestOnTop:{value:!1},style:{value:"block"},width:{value:e.UA.ie&&e.UA.ie<9?"100%":"inherit"}}})},"@VERSION@",{requires:["console-filters","test","array-extras"],skinnable:!0}); +YUI.add("test-console",function(e,t){function n(){n.superclass.constructor.apply(this,arguments)}e.namespace("Test").Console=e.extend(n,e.Console,{initializer:function(t){this.on("entry",this._onEntry),this.plug(e.Plugin.ConsoleFilters,{category:e.merge({info:!0,pass:!1,fail:!0,status:!1},t&&t.filters||{}),defaultVisibility:!1,source:{TestRunner:!0}}),e.Test.Runner.on("complete",e.bind(this._parseCoverage,this))},_isIstanbul:function(t){var n=e.Object.keys(t)[0],r=!1;return t[n].s!==undefined&&t[n].fnMap!==undefined&&(r=!0),t.s!==undefined&&t.fnMap!==undefined&&(r=!0),r},parseYUITestCoverage:function(t){var n={lines:{hit:0,miss:0,total:0,percent:0},functions:{hit:0,miss:0,total:0,percent:0}},r;e.Object.each(t,function(e){n.lines.total+=e.coveredLines,n.lines.hit+=e.calledLines,n.lines.miss+=e.coveredLines-e.calledLines,n.lines.percent=Math.floor(n.lines.hit/n.lines.total*100),n.functions.total+=e.coveredFunctions,n.functions.hit+=e.calledFunctions,n.functions.miss+=e.coveredFunctions-e.calledFunctions,n.functions.percent=Math.floor(n.functions.hit/n.functions.total*100)}),r="Lines: Hit:"+n.lines.hit+" Missed:"+n.lines.miss+" Total:"+n.lines.total+" Percent:"+n.lines.percent+"%\n",r+="Functions: Hit:"+n.functions.hit+" Missed:"+n.functions.miss+" Total:"+n.functions.total+" Percent:"+n.functions.percent+"%",this.log("Coverage: "+r,"info","TestRunner")},_blankSummary:function(){return{lines:{total:0,covered:0,pct:"Unknown"},statements:{total:0,covered:0,pct:"Unknown"},functions:{total:0,covered:0,pct:"Unknown"},branches:{total:0,covered:0,pct:"Unknown"}}},_addDerivedInfoForFile:function(t){var n=t.statementMap,r=t.s,i;t.l||(t.l=i={},e.Object.each(r,function(e,t){var s=n[t].start.line,o=r[t],u=i[s];if(typeof u=="undefined"||u0&&(n=1e5*e/t+5,r=Math.floor(n/10)/100),r},_computeSimpleTotals:function(t,n){var r=t[n],i={total:0,covered:0};return e.Object.each(r,function(e){i.total+=1,e&&(i.covered+=1)}),i.pct=this._percent(i.covered,i.total),i},_computeBranchTotals:function(t){var n=t.b,r={total:0,covered:0};return e.Object.each(n,function(t){var n=e.Array.filter(t,function(e){return e>0});r.total+=t.length,r.covered+=n.length}),r.pct=this._percent(r.covered,r.total),r},parseIstanbul:function(t){var n=this,r="Coverage Report:\n";e.Object.each(t,function(t,i){var s=n._blankSummary();n._addDerivedInfoForFile(t),s.lines=n._computeSimpleTotals(t,"l"),s.functions=n._computeSimpleTotals(t,"f"),s.statements=n._computeSimpleTotals(t,"s"),s.branches=n._computeBranchTotals(t),r+=i+":\n",e.Array.each(["lines","functions","statements","branches"],function(e){r+=" "+e+": "+s[e].covered+"/"+s[e].total+" : "+s[e].pct+"%\n"})}),this.log(r,"info","TestRunner")},_parseCoverage:function(){var t=e.Test.Runner.getCoverage();if(!t)return;this._isIstanbul(t)?this.parseIstanbul(t):this.parseYUITestCoverage(t)},_onEntry:function(e){var t=e.message;t.category==="info"&&/\s(?:case|suite)\s|yuitests\d+|began/.test(t.message)?t.category="status":t.category==="fail"&&this.printBuffer()}},{NAME:"testConsole",ATTRS:{entryTemplate:{value:'
{message}
'},height:{value:"350px"},newestOnTop:{value:!1},style:{value:"block"},width:{value:e.UA.ie&&e.UA.ie<9?"100%":"inherit"}}})},"@VERSION@",{requires:["console-filters","test","array-extras"],skinnable:!0}); diff --git a/build/test-console/test-console.js b/build/test-console/test-console.js index a8f358762ad..b7ae60c7187 100644 --- a/build/test-console/test-console.js +++ b/build/test-console/test-console.js @@ -64,7 +64,7 @@ Y.namespace('Test').Console = Y.extend(TestConsole, Y.Console, { * @return {Boolean} True if this is Istanbul Coverage */ _isIstanbul: function(json) { - var first = Object.keys(json)[0], + var first = Y.Object.keys(json)[0], ret = false; if (json[first].s !== undefined && json[first].fnMap !== undefined) {