From 33ff4ff10eb133929b910895429ede0e73f09a85 Mon Sep 17 00:00:00 2001 From: pimterry Date: Thu, 28 Mar 2013 00:04:02 +0000 Subject: [PATCH 1/3] Switched forEach out to for(var; < length; ++) to allow compatibility with other browsers --- tasks/jasmine/reporters/PhantomReporter.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/tasks/jasmine/reporters/PhantomReporter.js b/tasks/jasmine/reporters/PhantomReporter.js index ebc3595..df5e3ab 100644 --- a/tasks/jasmine/reporters/PhantomReporter.js +++ b/tasks/jasmine/reporters/PhantomReporter.js @@ -150,14 +150,15 @@ phantom.sendMessage = function() { this.results_[spec.id] = results; // Quick hack to alleviate cyclical object breaking JSONification. - results.messages.forEach(function(item){ + for (var ii = 0; ii < results.messages.length; ii++) { + var item = results.messages[ii]; if (item.expected) { item.expected = stringify(item.expected); } if (item.actual) { item.actual = stringify(item.actual); } - }); + } phantom.sendMessage( 'jasmine.reportSpecResults', spec.id, results, this.getFullName(spec)); }; @@ -224,11 +225,13 @@ phantom.sendMessage = function() { var failureMessages = []; if (spec.results().failedCount) { failures++; - spec.results().items_.forEach(function(expectation) { + var resultsItems = spec.results().items_; + for (var ii = 0; ii < resultsItems; ii++) { + var expectation = resultsItems[ii]; if (!expectation.passed()) { failureMessages.push(expectation.message); } - }); + }; } return { assertions: spec.results().items_.length, From f22ec9c1782f903ce5d74e70a7f0b910ee50843d Mon Sep 17 00:00:00 2001 From: Tim Perry Date: Thu, 28 Mar 2013 12:54:47 +0000 Subject: [PATCH 2/3] Whoops, stripped leftover semi-colon that makes jshint unhappy --- tasks/jasmine/reporters/PhantomReporter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks/jasmine/reporters/PhantomReporter.js b/tasks/jasmine/reporters/PhantomReporter.js index df5e3ab..ff01343 100644 --- a/tasks/jasmine/reporters/PhantomReporter.js +++ b/tasks/jasmine/reporters/PhantomReporter.js @@ -231,7 +231,7 @@ phantom.sendMessage = function() { if (!expectation.passed()) { failureMessages.push(expectation.message); } - }; + } } return { assertions: spec.results().items_.length, From 9a773a188a0fe73e996e252fd88ec17209387bdf Mon Sep 17 00:00:00 2001 From: Tim Perry Date: Thu, 28 Mar 2013 12:59:27 +0000 Subject: [PATCH 3/3] Added explicit map implementation too, for further IE compatibility --- tasks/jasmine/reporters/PhantomReporter.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/tasks/jasmine/reporters/PhantomReporter.js b/tasks/jasmine/reporters/PhantomReporter.js index ff01343..a0c72e9 100644 --- a/tasks/jasmine/reporters/PhantomReporter.js +++ b/tasks/jasmine/reporters/PhantomReporter.js @@ -82,9 +82,17 @@ phantom.sendMessage = function() { return this.results_[specId]; }; + function map(values, f) { + var result = []; + for (var ii = 0; ii < values.length; ii++) { + result.push(f(values[ii])); + } + return result; + } + PhantomReporter.prototype.reportRunnerResults = function(runner) { this.finished = true; - var specIds = runner.specs().map(function(a){return a.id;}); + var specIds = map(runner.specs(), function(a){return a.id;}); var summary = this.resultsForSpecs(specIds); phantom.sendMessage('jasmine.reportRunnerResults',summary); phantom.sendMessage('jasmine.reportJUnitResults', this.generateJUnitSummary(runner)); @@ -218,10 +226,10 @@ phantom.sendMessage = function() { PhantomReporter.prototype.generateJUnitSummary = function(runner) { var consolidatedSuites = {}, - suites = runner.suites().map(function(suite) { + suites = map(runner.suites(), function(suite) { var failures = 0; - var testcases = suite.specs().map(function(spec) { + var testcases = map(suite.specs(), function(spec) { var failureMessages = []; if (spec.results().failedCount) { failures++;