Browse Source

Merge pull request #6 from teppeis/catch-up-node-assert

Catch up Node.js assert updates
deapstrictequal
Roman Shtylman 10 years ago
parent
commit
60bea69f09
  1. 11
      assert.js
  2. 5
      test.js

11
assert.js

@ -86,7 +86,7 @@ function replacer(key, value) {
if (util.isUndefined(value)) { if (util.isUndefined(value)) {
return '' + value; return '' + value;
} }
if (util.isNumber(value) && (isNaN(value) || !isFinite(value))) { if (util.isNumber(value) && !isFinite(value)) {
return value.toString(); return value.toString();
} }
if (util.isFunction(value) || util.isRegExp(value)) { if (util.isFunction(value) || util.isRegExp(value)) {
@ -227,10 +227,11 @@ function objEquiv(a, b) {
if (a.prototype !== b.prototype) return false; if (a.prototype !== b.prototype) return false;
//~~~I've managed to break Object.keys through screwy arguments passing. //~~~I've managed to break Object.keys through screwy arguments passing.
// Converting to array solves the problem. // Converting to array solves the problem.
if (isArguments(a)) { var aIsArgs = isArguments(a),
if (!isArguments(b)) { bIsArgs = isArguments(b);
return false; if ((aIsArgs && !bIsArgs) || (!aIsArgs && bIsArgs))
} return false;
if (aIsArgs) {
a = pSlice.call(a); a = pSlice.call(a);
b = pSlice.call(b); b = pSlice.call(b);
return _deepEqual(a, b); return _deepEqual(a, b);

5
test.js

@ -264,6 +264,11 @@ test('assert - Make sure deepEqual doesn\'t loop forever on circular refs', func
assert.ok(gotError); assert.ok(gotError);
}); });
test('assert - Ensure reflexivity of deepEqual with `arguments` objects', function() {
var args = (function() { return arguments; })();
assert.throws(makeBlock(assert.deepEqual, [], args), assert.AssertionError);
assert.throws(makeBlock(assert.deepEqual, args, []), assert.AssertionError);
});
test('assert - test assertion message', function () { test('assert - test assertion message', function () {
function testAssertionMessage(actual, expected) { function testAssertionMessage(actual, expected) {

Loading…
Cancel
Save