Skip to content

Commit 60bea69

Browse files
committed
Merge pull request #6 from teppeis/catch-up-node-assert
Catch up Node.js assert updates
2 parents 2c34238 + ae6abd7 commit 60bea69

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

assert.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ function replacer(key, value) {
8686
if (util.isUndefined(value)) {
8787
return '' + value;
8888
}
89-
if (util.isNumber(value) && (isNaN(value) || !isFinite(value))) {
89+
if (util.isNumber(value) && !isFinite(value)) {
9090
return value.toString();
9191
}
9292
if (util.isFunction(value) || util.isRegExp(value)) {
@@ -227,10 +227,11 @@ function objEquiv(a, b) {
227227
if (a.prototype !== b.prototype) return false;
228228
//~~~I've managed to break Object.keys through screwy arguments passing.
229229
// Converting to array solves the problem.
230-
if (isArguments(a)) {
231-
if (!isArguments(b)) {
232-
return false;
233-
}
230+
var aIsArgs = isArguments(a),
231+
bIsArgs = isArguments(b);
232+
if ((aIsArgs && !bIsArgs) || (!aIsArgs && bIsArgs))
233+
return false;
234+
if (aIsArgs) {
234235
a = pSlice.call(a);
235236
b = pSlice.call(b);
236237
return _deepEqual(a, b);

test.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,11 @@ test('assert - Make sure deepEqual doesn\'t loop forever on circular refs', func
264264
assert.ok(gotError);
265265
});
266266

267+
test('assert - Ensure reflexivity of deepEqual with `arguments` objects', function() {
268+
var args = (function() { return arguments; })();
269+
assert.throws(makeBlock(assert.deepEqual, [], args), assert.AssertionError);
270+
assert.throws(makeBlock(assert.deepEqual, args, []), assert.AssertionError);
271+
});
267272

268273
test('assert - test assertion message', function () {
269274
function testAssertionMessage(actual, expected) {

0 commit comments

Comments
 (0)