summaryrefslogtreecommitdiff
path: root/lib/assert.js
diff options
context:
space:
mode:
authorRuben Bridgewater <ruben@bridgewater.de>2017-11-13 18:15:24 -0200
committerAnna Henningsen <anna@addaleax.net>2017-11-28 03:05:12 +0100
commita319e90807bbc74b6d0e85ee9bec697acb68ebcb (patch)
treead0cc58ffe0278a7edfbf6ec09261354f50cfdaf /lib/assert.js
parent06ab6f2f13981babe71f3a9fe577bebc3c7cb5ac (diff)
downloadandroid-node-v8-a319e90807bbc74b6d0e85ee9bec697acb68ebcb.tar.gz
android-node-v8-a319e90807bbc74b6d0e85ee9bec697acb68ebcb.tar.bz2
android-node-v8-a319e90807bbc74b6d0e85ee9bec697acb68ebcb.zip
assert: add strict functionality export
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: https://github.com/nodejs/node/pull/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>
Diffstat (limited to 'lib/assert.js')
-rw-r--r--lib/assert.js12
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/assert.js b/lib/assert.js
index 304618fb3d..e5cc338c98 100644
--- a/lib/assert.js
+++ b/lib/assert.js
@@ -207,3 +207,15 @@ assert.doesNotThrow = function doesNotThrow(block, error, message) {
};
assert.ifError = function ifError(err) { if (err) throw err; };
+
+// Expose a strict only variant of assert
+function strict(value, message) {
+ if (!value) innerFail(value, true, message, '==', strict);
+}
+assert.strict = Object.assign(strict, assert, {
+ equal: assert.strictEqual,
+ deepEqual: assert.deepStrictEqual,
+ notEqual: assert.notStrictEqual,
+ notDeepEqual: assert.notDeepStrictEqual
+});
+assert.strict.strict = assert.strict;