diff options
author | Vse Mozhet Byt <vsemozhetbyt@gmail.com> | 2018-03-11 14:05:04 +0200 |
---|---|---|
committer | Vse Mozhet Byt <vsemozhetbyt@gmail.com> | 2018-03-11 15:48:26 +0200 |
commit | 603afe25c870efb030aed84c2e634652def1a3ec (patch) | |
tree | c7ffc08a042f17c927cb896620fd6b5d26095392 /doc/api/assert.md | |
parent | 599337f43e0e0d66263e69d70edab26b61d3038a (diff) | |
download | android-node-v8-603afe25c870efb030aed84c2e634652def1a3ec.tar.gz android-node-v8-603afe25c870efb030aed84c2e634652def1a3ec.tar.bz2 android-node-v8-603afe25c870efb030aed84c2e634652def1a3ec.zip |
doc: fix some recent nits in assert.md
* add missing bottom reference
* fix possible typos
* fix ABC-order in references and sections
PR-URL: https://github.com/nodejs/node/pull/19284
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Minwoo Jung <minwoo@nodesource.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Diffstat (limited to 'doc/api/assert.md')
-rw-r--r-- | doc/api/assert.md | 75 |
1 files changed, 38 insertions, 37 deletions
diff --git a/doc/api/assert.md b/doc/api/assert.md index 591d26a515..9ce918dab9 100644 --- a/doc/api/assert.md +++ b/doc/api/assert.md @@ -326,7 +326,7 @@ rejected. See [`assert.rejects()`][] for more details. When `assert.doesNotReject()` is called, it will immediately call the `block` function, and awaits for completion. -Besides the async nature to await the completion behaves identical to +Besides the async nature to await the completion behaves identically to [`assert.doesNotThrow()`][]. ```js @@ -844,40 +844,6 @@ assert(0); // assert(0) ``` -## assert.strictEqual(actual, expected[, message]) -<!-- YAML -added: v0.1.21 -changes: - - version: REPLACEME - pr-url: https://github.com/nodejs/node/pull/17003 - description: Used comparison changed from Strict Equality to `Object.is()` ---> -* `actual` {any} -* `expected` {any} -* `message` {any} - -Tests strict equality between the `actual` and `expected` parameters as -determined by the [SameValue Comparison][]. - -```js -const assert = require('assert').strict; - -assert.strictEqual(1, 2); -// AssertionError: 1 strictEqual 2 - -assert.strictEqual(1, 1); -// OK - -assert.strictEqual(1, '1'); -// AssertionError: 1 strictEqual '1' -``` - -If the values are not strictly equal, an `AssertionError` is thrown with a -`message` property set equal to the value of the `message` parameter. If the -`message` parameter is undefined, a default error message is assigned. If the -`message` parameter is an instance of an [`Error`][] then it will be thrown -instead of the `AssertionError`. - ## assert.rejects(block[, error][, message]) <!-- YAML added: REPLACEME @@ -891,7 +857,7 @@ Awaits for promise returned by function `block` to be rejected. When `assert.rejects()` is called, it will immediately call the `block` function, and awaits for completion. -Besides the async nature to await the completion behaves identical to +Besides the async nature to await the completion behaves identically to [`assert.throws()`][]. If specified, `error` can be a constructor, [`RegExp`][], a validation @@ -920,6 +886,40 @@ assert.rejects( }); ``` +## assert.strictEqual(actual, expected[, message]) +<!-- YAML +added: v0.1.21 +changes: + - version: REPLACEME + pr-url: https://github.com/nodejs/node/pull/17003 + description: Used comparison changed from Strict Equality to `Object.is()` +--> +* `actual` {any} +* `expected` {any} +* `message` {any} + +Tests strict equality between the `actual` and `expected` parameters as +determined by the [SameValue Comparison][]. + +```js +const assert = require('assert').strict; + +assert.strictEqual(1, 2); +// AssertionError: 1 strictEqual 2 + +assert.strictEqual(1, 1); +// OK + +assert.strictEqual(1, '1'); +// AssertionError: 1 strictEqual '1' +``` + +If the values are not strictly equal, an `AssertionError` is thrown with a +`message` property set equal to the value of the `message` parameter. If the +`message` parameter is undefined, a default error message is assigned. If the +`message` parameter is an instance of an [`Error`][] then it will be thrown +instead of the `AssertionError`. + ## assert.throws(block[, error][, message]) <!-- YAML added: v0.1.21 @@ -1051,12 +1051,13 @@ second argument. This might lead to difficult-to-spot errors. [`WeakSet`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakSet [`assert.deepEqual()`]: #assert_assert_deepequal_actual_expected_message [`assert.deepStrictEqual()`]: #assert_assert_deepstrictequal_actual_expected_message +[`assert.doesNotThrow()`]: #assert_assert_doesnotthrow_block_error_message [`assert.notDeepStrictEqual()`]: #assert_assert_notdeepstrictequal_actual_expected_message [`assert.notStrictEqual()`]: #assert_assert_notstrictequal_actual_expected_message [`assert.ok()`]: #assert_assert_ok_value_message +[`assert.rejects()`]: #assert_assert_rejects_block_error_message [`assert.strictEqual()`]: #assert_assert_strictequal_actual_expected_message [`assert.throws()`]: #assert_assert_throws_block_error_message -[`assert.rejects()`]: #assert_assert_rejects_block_error_message [`strict mode`]: #assert_strict_mode [Abstract Equality Comparison]: https://tc39.github.io/ecma262/#sec-abstract-equality-comparison [Object.prototype.toString()]: https://tc39.github.io/ecma262/#sec-object.prototype.tostring |