From bcf0e5d67619df698f697496555126034291f7bc Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Sat, 19 Aug 2017 02:39:03 -0300 Subject: [PATCH] assert: handle errors properly with deep*Equal PR-URL: /~https://github.com/nodejs/node/pull/15001 Reviewed-By: Rich Trott Reviewed-By: Benjamin Gruenbaum Reviewed-By: Refael Ackermann Reviewed-By: James M Snell --- doc/api/assert.md | 7 +++++-- lib/assert.js | 11 +++++++++++ test/parallel/test-assert-deep.js | 28 ++++++++++++++++++++-------- 3 files changed, 36 insertions(+), 10 deletions(-) diff --git a/doc/api/assert.md b/doc/api/assert.md index c2dff91d0391c2..9c5c142a96e937 100644 --- a/doc/api/assert.md +++ b/doc/api/assert.md @@ -47,12 +47,12 @@ Only [enumerable "own" properties][] are considered. The non-enumerable properties — for such checks, consider using [`assert.deepStrictEqual()`][] instead. This can lead to some potentially surprising results. For example, the following example does not -throw an `AssertionError` because the properties on the [`Error`][] object are +throw an `AssertionError` because the properties on the [`RegExp`][] object are not enumerable: ```js // WARNING: This does not throw an AssertionError! -assert.deepEqual(Error('a'), Error('b')); +assert.deepEqual(/a/gi, new Date()); ``` An exception is made for [`Map`][] and [`Set`][]. Maps and Sets have their @@ -104,6 +104,9 @@ parameter is undefined, a default error message is assigned.