Fixes jshint issues
Showing
3 changed files
with
29 additions
and
22 deletions
... | @@ -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,38 +1219,45 @@ Tester.prototype.pass = function pass(message) { | ... | @@ -1219,38 +1219,45 @@ Tester.prototype.pass = function pass(message) { |
1219 | }); | 1219 | }); |
1220 | }; | 1220 | }; |
1221 | 1221 | ||
1222 | /** | 1222 | function getStackEntry(error, testFile) { |
1223 | * Processes an assertion error. | ||
1224 | * | ||
1225 | * @param AssertionError error | ||
1226 | */ | ||
1227 | Tester.prototype.processAssertionError = function(error) { | ||
1228 | "use strict"; | 1223 | "use strict"; |
1229 | var result = error && error.result || {}, | ||
1230 | testFile = this.currentTestFile, | ||
1231 | stackEntry; | ||
1232 | try { | ||
1233 | if ("stackArray" in error) { | 1224 | if ("stackArray" in error) { |
1234 | // PhantomJS has changed the API of the Error object :-/ | 1225 | // PhantomJS has changed the API of the Error object :-/ |
1235 | // https://github.com/ariya/phantomjs/commit/c9cf14f221f58a3daf585c47313da6fced0276bc | 1226 | // https://github.com/ariya/phantomjs/commit/c9cf14f221f58a3daf585c47313da6fced0276bc |
1236 | stackEntry = error.stackArray.filter(function(entry) { | 1227 | return error.stackArray.filter(function(entry) { |
1237 | return testFile === entry.sourceURL; | 1228 | return testFile === entry.sourceURL; |
1238 | })[0]; | 1229 | })[0]; |
1239 | } | 1230 | } |
1240 | else if ('stack' in error) { | 1231 | |
1232 | if (! ('stack' in error)) | ||
1233 | return null; | ||
1234 | |||
1241 | var r = /^\s*(.*)@(.*):(\d+)\s*$/gm; | 1235 | var r = /^\s*(.*)@(.*):(\d+)\s*$/gm; |
1242 | var m; | 1236 | var m; |
1243 | while ((m = r.exec(e.stack))) { | 1237 | while ((m = r.exec(error.stack))) { |
1244 | var sourceURL = m[2]; | 1238 | var sourceURL = m[2]; |
1245 | if (sourceURL.indexOf('->') != -1) { | 1239 | if (sourceURL.indexOf('->') !== -1) { |
1246 | sourceURL = sourceURL.split('->')[1].trim(); | 1240 | sourceURL = sourceURL.split('->')[1].trim(); |
1247 | } | 1241 | } |
1248 | if (sourceURL == testFile) { | 1242 | if (sourceURL === testFile) { |
1249 | stackEntry = { sourceURL: sourceURL, line: m[3]} | 1243 | return { sourceURL: sourceURL, line: m[3]} |
1250 | break; | ||
1251 | } | ||
1252 | } | 1244 | } |
1253 | } | 1245 | } |
1246 | return null; | ||
1247 | } | ||
1248 | |||
1249 | /** | ||
1250 | * Processes an assertion error. | ||
1251 | * | ||
1252 | * @param AssertionError error | ||
1253 | */ | ||
1254 | Tester.prototype.processAssertionError = function(error) { | ||
1255 | "use strict"; | ||
1256 | var result = error && error.result || {}, | ||
1257 | testFile = this.currentTestFile, | ||
1258 | stackEntry; | ||
1259 | try { | ||
1260 | stackEntry = getStackEntry(error, testFile); | ||
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; | ... | ... |
-
Please register or sign in to post a comment