GeezerVison is showing github.com — assert: remove unneeded arguments special handling · nodejs/node@40211e8
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: lib/assert.js -6Lines changed: 0 additions & 6 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 28 | 28 | const compare = process.binding('buffer').compare; | 29 | 29 | const util = require('util'); | 30 | 30 | const Buffer = require('buffer').Buffer; | 31 | | -const pSlice = Array.prototype.slice; | 32 | 31 | const pToString = (obj) => Object.prototype.toString.call(obj); | 33 | 32 |
| 34 | 33 | // 1. The assert module provides functions that throw | @@ -223,11 +222,6 @@ function objEquiv(a, b, strict, actualVisitedObjects) { | 223 | 222 | const bIsArgs = isArguments(b); | 224 | 223 | if ((aIsArgs && !bIsArgs) || (!aIsArgs && bIsArgs)) | 225 | 224 | return false; | 226 | | - if (aIsArgs) { | 227 | | - a = pSlice.call(a); | 228 | | - b = pSlice.call(b); | 229 | | - return _deepEqual(a, b, strict); | 230 | | - } | 231 | 225 | const ka = Object.keys(a); | 232 | 226 | const kb = Object.keys(b); | 233 | 227 | var key, i; | |
Collapse file Copy file name to clipboardExpand all lines: test/parallel/test-assert.js +15-1Lines changed: 15 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -59,7 +59,7 @@ assert.throws(makeBlock(a.strictEqual, null, undefined), | 59 | 59 | assert.doesNotThrow(makeBlock(a.notStrictEqual, 2, '2'), | 60 | 60 | 'notStrictEqual(2, \'2\')'); | 61 | 61 |
| 62 | | -// deepEquals joy! | | 62 | +// deepEqual joy! | 63 | 63 | // 7.2 | 64 | 64 | assert.doesNotThrow(makeBlock(a.deepEqual, new Date(2000, 3, 14), | 65 | 65 | new Date(2000, 3, 14)), | @@ -409,6 +409,20 @@ var args = (function() { return arguments; })(); | 409 | 409 | a.throws(makeBlock(a.deepEqual, [], args)); | 410 | 410 | a.throws(makeBlock(a.deepEqual, args, [])); | 411 | 411 |
| | 412 | +// more checking that arguments objects are handled correctly | | 413 | +{ | | 414 | + const returnArguments = function() { return arguments; }; | | 415 | + | | 416 | + const someArgs = returnArguments('a'); | | 417 | + const sameArgs = returnArguments('a'); | | 418 | + const diffArgs = returnArguments('b'); | | 419 | + | | 420 | + a.throws(makeBlock(a.deepEqual, someArgs, ['a'])); | | 421 | + a.throws(makeBlock(a.deepEqual, ['a'], someArgs)); | | 422 | + a.throws(makeBlock(a.deepEqual, someArgs, {'0': 'a'})); | | 423 | + a.throws(makeBlock(a.deepEqual, someArgs, diffArgs)); | | 424 | + a.doesNotThrow(makeBlock(a.deepEqual, someArgs, sameArgs)); | | 425 | +} | 412 | 426 |
| 413 | 427 | var circular = {y: 1}; | 414 | 428 | circular.x = circular; | |
|