assert: add strict functionality export#17002
assert: add strict functionality export#17002BridgeAR wants to merge 2 commits intonodejs:masterfrom
Conversation
Trott
left a comment
There was a problem hiding this comment.
Bold move. I like it in theory, but I'd caution that we are probably never going to be able to get rid of legacy mode, so we will need to support both strict and legacy mode forever... I'm not objecting, but I am being cautious...;.
doc/api/assert.md
Outdated
There was a problem hiding this comment.
Micro-nit: Add a blank line before this one?
doc/api/assert.md
Outdated
There was a problem hiding this comment.
Micro-nit: backticks around strict mode and assert?
doc/api/assert.md
Outdated
There was a problem hiding this comment.
Micro-nit: comma before and after for example?
doc/api/assert.md
Outdated
doc/api/assert.md
Outdated
There was a problem hiding this comment.
Nit: Put everything after e.g. and up to the closing . in parentheses.
Nit: Here and several places above, function names should be followed by () I believe. So assert.deepEqual() rather than assert.deepEqual. That said, if there's already a lot of no-parentheses examples in the doc, never mind. :-D
doc/api/assert.md
Outdated
There was a problem hiding this comment.
Nit: They're called non-strict, legacy, and loose throughout the document. I'd suggest picking just one of those and sticking with it.
Nit: are often not sufficient might be better expressed as can often have surprising results.
There was a problem hiding this comment.
I rephrased it and hope it is clearer now :-)
ad10d9f to
3142402
Compare
|
@Trott I addressed all comments. I know it might seem a strong move but we do not have to remove the legacy mode ever and that is also why I only wanted a doc only deprecation. |
doc/api/assert.md
Outdated
There was a problem hiding this comment.
Would it be just #assert_strict_mode? As it is not an assert API part, just a simple heading.
doc/api/assert.md
Outdated
There was a problem hiding this comment.
[ strict mode`][]: space instead of a backtick.
|
Ping @BridgeAR this needs a rebase. |
3d43614 to
811df7f
Compare
|
Rebased |
|
Needs another rebase :-) |
1) Separate all loose and strict functions. 2) Stronger outline the used comparison rules in (not)deepStrictEqual 3) Fix SameValue comparison info
Requireing the strict version will allow to use `assert.equal`, `assert.deepEqual` and there negated counterparts to be used with strict comparison instead of using e.g. `assert.strictEqual`. The API is identical to the regular assert export and only differs in the way that all functions use strict compairson.
811df7f to
9692df7
Compare
|
Rebased plus some tiny documentation improvements while doing so (it is actually the SameValue comparison used by Object.is() and not the Object.is() comparison). |
1) Separate all loose and strict functions. 2) Stronger outline the used comparison rules in (not)deepStrictEqual 3) Fix SameValue comparison info PR-URL: #17002 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
Requireing the strict version will allow to use `assert.equal`, `assert.deepEqual` and there negated counterparts to be used with strict comparison instead of using e.g. `assert.strictEqual`. The API is identical to the regular assert export and only differs in the way that all functions use strict compairson. PR-URL: #17002 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
|
Should this be backported to |
1) Separate all loose and strict functions. 2) Stronger outline the used comparison rules in (not)deepStrictEqual 3) Fix SameValue comparison info PR-URL: nodejs#17002 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
Requireing the strict version will allow to use `assert.equal`, `assert.deepEqual` and there negated counterparts to be used with strict comparison instead of using e.g. `assert.strictEqual`. The API is identical to the regular assert export and only differs in the way that all functions use strict compairson. PR-URL: nodejs#17002 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
|
Backport opened in #19230 |
1) Separate all loose and strict functions. 2) Stronger outline the used comparison rules in (not)deepStrictEqual 3) Fix SameValue comparison info Backport-PR-URL: #19230 PR-URL: #17002 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
Requireing the strict version will allow to use `assert.equal`, `assert.deepEqual` and there negated counterparts to be used with strict comparison instead of using e.g. `assert.strictEqual`. The API is identical to the regular assert export and only differs in the way that all functions use strict compairson. Backport-PR-URL: #19230 PR-URL: #17002 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
Requireing the strict version will allow to use `assert.equal`, `assert.deepEqual` and there negated counterparts to be used with strict comparison instead of using e.g. `assert.strictEqual`. The API is identical to the regular assert export and only differs in the way that all functions use strict compairson. Backport-PR-URL: #19230 PR-URL: #17002 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
|
Requested backport to 8.x in #19230 |
Requireing the strict version will allow to use `assert.equal`, `assert.deepEqual` and there negated counterparts to be used with strict comparison instead of using e.g. `assert.strictEqual`. The API is identical to the regular assert export and only differs in the way that all functions use strict compairson. PR-URL: nodejs#17002 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
Requireing the strict version will allow to use `assert.equal`, `assert.deepEqual` and there negated counterparts to be used with strict comparison instead of using e.g. `assert.strictEqual`. The API is identical to the regular assert export and only differs in the way that all functions use strict compairson. Backport-PR-URL: #23223 PR-URL: #17002 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
To further improve assert this adds a strict export. When used, all functions will use the strict equality instead of a loose one.
At the same time this is a doc only deprecation of the legacy loose mode. It is not intended to remove the old functionality as it is wildly used a lot and removing it does not seem to be a option.
I also improved the assert documentation in general a bit. It now outlines the used rules a bit better and clearly separates loose and strict equality.
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passesAffected core subsystem(s)
doc,assert