Add comment to explain regex in TestFailureError

This commit is contained in:
Scott Kyle 2015-09-28 18:09:59 -07:00
parent 675e26e200
commit 8182c4816f

View File

@ -85,9 +85,13 @@ function TestFailureError(message) {
error = e;
}
// Remove the top two stack frames if possible.
// This regular expression will match stack trace lines provided by JavaScriptCore.
// Example: someMethod@file:///path/to/file.js:10:24
var regex = /^(?:.*?@)?([^\[\(].+?):(\d+)(?::(\d+))?/;
// Remove the top two stack frames and use information from the third, if possible.
var stack = error.stack && error.stack.split('\n');
var match = stack[2] && stack[2].match(/^(?:.*?@)?([^\[\(].+?):(\d+)(?::(\d+))?/);
var match = stack[2] && stack[2].match(regex);
if (match) {
this.sourceURL = match[1];
this.line = +match[2];