Commit 7806150c 7806150ca114e35c99a36d10d098262f26b76197 by Laurent Jouanneau

Fixes jshint issues

1 parent adff559f
......@@ -29,7 +29,7 @@
*/
/*global process, console, phantom, require:true*/
/*jshint maxstatements:33, maxcomplexity:10*/
/*jshint maxstatements:34, maxcomplexity:10*/
// node check
if ('process' in this && process.title === "node") {
......
......@@ -1219,6 +1219,33 @@ Tester.prototype.pass = function pass(message) {
});
};
function getStackEntry(error, testFile) {
"use strict";
if ("stackArray" in error) {
// PhantomJS has changed the API of the Error object :-/
// https://github.com/ariya/phantomjs/commit/c9cf14f221f58a3daf585c47313da6fced0276bc
return error.stackArray.filter(function(entry) {
return testFile === entry.sourceURL;
})[0];
}
if (! ('stack' in error))
return null;
var r = /^\s*(.*)@(.*):(\d+)\s*$/gm;
var m;
while ((m = r.exec(error.stack))) {
var sourceURL = m[2];
if (sourceURL.indexOf('->') !== -1) {
sourceURL = sourceURL.split('->')[1].trim();
}
if (sourceURL === testFile) {
return { sourceURL: sourceURL, line: m[3]}
}
}
return null;
}
/**
* Processes an assertion error.
*
......@@ -1230,27 +1257,7 @@ Tester.prototype.processAssertionError = function(error) {
testFile = this.currentTestFile,
stackEntry;
try {
if ("stackArray" in error) {
// PhantomJS has changed the API of the Error object :-/
// https://github.com/ariya/phantomjs/commit/c9cf14f221f58a3daf585c47313da6fced0276bc
stackEntry = error.stackArray.filter(function(entry) {
return testFile === entry.sourceURL;
})[0];
}
else if ('stack' in error) {
var r = /^\s*(.*)@(.*):(\d+)\s*$/gm;
var m;
while ((m = r.exec(e.stack))) {
var sourceURL = m[2];
if (sourceURL.indexOf('->') != -1) {
sourceURL = sourceURL.split('->')[1].trim();
}
if (sourceURL == testFile) {
stackEntry = { sourceURL: sourceURL, line: m[3]}
break;
}
}
}
stackEntry = getStackEntry(error, testFile);
} catch (e) {}
if (stackEntry) {
result.line = stackEntry.line;
......
......@@ -53,9 +53,9 @@ function betterTypeOf(input) {
default:
try {
var type = Object.prototype.toString.call(input).match(/^\[object\s(.*)\]$/)[1].toLowerCase();
if (type == 'object'
&& phantom.casperEngine != "phantomjs"
&& '__type' in input) {
if (type === 'object' &&
phantom.casperEngine !== "phantomjs" &&
'__type' in input) {
type = input.__type;
}
return type;
......