Skip to content

Commit

Permalink
Merge remote-tracking branch 'ry/v0.10'
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacs committed Apr 18, 2013
2 parents 8e190bf + 6101eb1 commit 0bccb34
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 12 deletions.
1 change: 1 addition & 0 deletions doc/download/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ <h2 style="margin-top:1em" id=other-info>Other Info</h2>

<li><a href="http://nodejs.org/dist/__VERSION__">Other release files</a></li>
<li><a href="http://nodejs.org/dist/">Other releases</a></li>
<li><a href="http://jenkins.nodejs.org/html/nightlies.html">Nightly builds</a></li>
</ul>
</div>

Expand Down
18 changes: 6 additions & 12 deletions lib/assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,12 @@ var assert = module.exports = ok;
// expected: expected })

assert.AssertionError = function AssertionError(options) {
this.message = options.message;
this.name = 'AssertionError';
this.actual = options.actual;
this.expected = options.expected;
this.operator = options.operator;
this.message = options.message || getMessage(this)
var stackStartFunction = options.stackStartFunction || fail;

this.name = getName(this, options.message);
Error.captureStackTrace(this, stackStartFunction);
};

Expand Down Expand Up @@ -72,15 +71,10 @@ function truncate(s, n) {
}
}

function getName(self, message) {
if (message) {
return 'AssertionError: ' + message;
} else {
return 'AssertionError: ' +
truncate(JSON.stringify(self.actual, replacer), 128) + ' ' +
self.operator + ' ' +
truncate(JSON.stringify(self.expected, replacer), 128);
}
function getMessage(self) {
return truncate(JSON.stringify(self.actual, replacer), 128) + ' ' +
self.operator + ' ' +
truncate(JSON.stringify(self.expected, replacer), 128);
}

// At present only the three keys mentioned above are used and
Expand Down
13 changes: 13 additions & 0 deletions test/simple/test-assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -293,3 +293,16 @@ try {
assert.equal(e.message, 'Missing expected exception..');
}
assert.ok(threw);

// #5292
try {
assert.equal(1, 2);
} catch (e) {
assert.equal(e.toString().split('\n')[0], 'AssertionError: 1 == 2')
}

try {
assert.equal(1, 2, 'oh no');
} catch (e) {
assert.equal(e.toString().split('\n')[0], 'AssertionError: oh no')
}

0 comments on commit 0bccb34

Please sign in to comment.