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,38 +1219,45 @@ Tester.prototype.pass = function pass(message) {
});
};
/**
* Processes an assertion error.
*
* @param AssertionError error
*/
Tester.prototype.processAssertionError = function(error) {
function getStackEntry(error, testFile) {
"use strict";
var result = error && error.result || {},
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 error.stackArray.filter(function(entry) {
return testFile === entry.sourceURL;
})[0];
}
else if ('stack' in error) {
if (! ('stack' in error))
return null;
var r = /^\s*(.*)@(.*):(\d+)\s*$/gm;
var m;
while ((m = r.exec(e.stack))) {
while ((m = r.exec(error.stack))) {
var sourceURL = m[2];
if (sourceURL.indexOf('->') != -1) {
if (sourceURL.indexOf('->') !== -1) {
sourceURL = sourceURL.split('->')[1].trim();
}
if (sourceURL == testFile) {
stackEntry = { sourceURL: sourceURL, line: m[3]}
break;
}
if (sourceURL === testFile) {
return { sourceURL: sourceURL, line: m[3]}
}
}
return null;
}
/**
* Processes an assertion error.
*
* @param AssertionError error
*/
Tester.prototype.processAssertionError = function(error) {
"use strict";
var result = error && error.result || {},
testFile = this.currentTestFile,
stackEntry;
try {
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;
......