Skip to content

Commit

Permalink
Fixed recursive call of assertion errors which led to a huge delay wh…
Browse files Browse the repository at this point in the history
…en a test failed - Fixes #278
  • Loading branch information
ppmathis authored and indexzero committed Nov 17, 2014
1 parent bc7cad0 commit 5dced8e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion lib/assert/error.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,12 @@ function errorDiff(err, type) {
}).join('');
}

require('assert').AssertionError.prototype.toString = function () {
/*
Do not override .toString() when this.stack is used,
otherwise this will end in an endless recursive call...
See issue https://github.com/cloudhead/vows/issues/278#issuecomment-22837493
*/
require('assert').AssertionError.prototype.toStringEx = function () {
var that = this,
source;

Expand Down
2 changes: 1 addition & 1 deletion lib/vows.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ function addVow(vow) {
output('honored');
} catch (e) {
if (e.name && e.name.match(/AssertionError/)) {
output('broken', e.toString().replace(/\`/g, '`'));
output('broken', e.toStringEx().replace(/\`/g, '`'));
} else {
output('errored', e.stack || e.message || e);
}
Expand Down

0 comments on commit 5dced8e

Please sign in to comment.