Commit 7806150c 7806150ca114e35c99a36d10d098262f26b76197 by Laurent Jouanneau

Fixes jshint issues

1 parent adff559f
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
29 */ 29 */
30 30
31 /*global process, console, phantom, require:true*/ 31 /*global process, console, phantom, require:true*/
32 /*jshint maxstatements:33, maxcomplexity:10*/ 32 /*jshint maxstatements:34, maxcomplexity:10*/
33 33
34 // node check 34 // node check
35 if ('process' in this && process.title === "node") { 35 if ('process' in this && process.title === "node") {
......
...@@ -1219,6 +1219,33 @@ Tester.prototype.pass = function pass(message) { ...@@ -1219,6 +1219,33 @@ Tester.prototype.pass = function pass(message) {
1219 }); 1219 });
1220 }; 1220 };
1221 1221
1222 function getStackEntry(error, testFile) {
1223 "use strict";
1224 if ("stackArray" in error) {
1225 // PhantomJS has changed the API of the Error object :-/
1226 // https://github.com/ariya/phantomjs/commit/c9cf14f221f58a3daf585c47313da6fced0276bc
1227 return error.stackArray.filter(function(entry) {
1228 return testFile === entry.sourceURL;
1229 })[0];
1230 }
1231
1232 if (! ('stack' in error))
1233 return null;
1234
1235 var r = /^\s*(.*)@(.*):(\d+)\s*$/gm;
1236 var m;
1237 while ((m = r.exec(error.stack))) {
1238 var sourceURL = m[2];
1239 if (sourceURL.indexOf('->') !== -1) {
1240 sourceURL = sourceURL.split('->')[1].trim();
1241 }
1242 if (sourceURL === testFile) {
1243 return { sourceURL: sourceURL, line: m[3]}
1244 }
1245 }
1246 return null;
1247 }
1248
1222 /** 1249 /**
1223 * Processes an assertion error. 1250 * Processes an assertion error.
1224 * 1251 *
...@@ -1230,27 +1257,7 @@ Tester.prototype.processAssertionError = function(error) { ...@@ -1230,27 +1257,7 @@ Tester.prototype.processAssertionError = function(error) {
1230 testFile = this.currentTestFile, 1257 testFile = this.currentTestFile,
1231 stackEntry; 1258 stackEntry;
1232 try { 1259 try {
1233 if ("stackArray" in error) { 1260 stackEntry = getStackEntry(error, testFile);
1234 // PhantomJS has changed the API of the Error object :-/
1235 // https://github.com/ariya/phantomjs/commit/c9cf14f221f58a3daf585c47313da6fced0276bc
1236 stackEntry = error.stackArray.filter(function(entry) {
1237 return testFile === entry.sourceURL;
1238 })[0];
1239 }
1240 else if ('stack' in error) {
1241 var r = /^\s*(.*)@(.*):(\d+)\s*$/gm;
1242 var m;
1243 while ((m = r.exec(e.stack))) {
1244 var sourceURL = m[2];
1245 if (sourceURL.indexOf('->') != -1) {
1246 sourceURL = sourceURL.split('->')[1].trim();
1247 }
1248 if (sourceURL == testFile) {
1249 stackEntry = { sourceURL: sourceURL, line: m[3]}
1250 break;
1251 }
1252 }
1253 }
1254 } catch (e) {} 1261 } catch (e) {}
1255 if (stackEntry) { 1262 if (stackEntry) {
1256 result.line = stackEntry.line; 1263 result.line = stackEntry.line;
......
...@@ -53,9 +53,9 @@ function betterTypeOf(input) { ...@@ -53,9 +53,9 @@ function betterTypeOf(input) {
53 default: 53 default:
54 try { 54 try {
55 var type = Object.prototype.toString.call(input).match(/^\[object\s(.*)\]$/)[1].toLowerCase(); 55 var type = Object.prototype.toString.call(input).match(/^\[object\s(.*)\]$/)[1].toLowerCase();
56 if (type == 'object' 56 if (type === 'object' &&
57 && phantom.casperEngine != "phantomjs" 57 phantom.casperEngine !== "phantomjs" &&
58 && '__type' in input) { 58 '__type' in input) {
59 type = input.__type; 59 type = input.__type;
60 } 60 }
61 return type; 61 return type;
......