Skip to content

Commit

Permalink
doc,assert: rename "mode" to "assertion mode"
Browse files Browse the repository at this point in the history
Rename "strict mode" in the assert module to "strict assertion mode".
This is to avoid confusion with the more typical meaning of "strict
mode" in ECMAScript.

This necessitates a corresponding change of "legacy mode" to "legacy
assertion mode".

PR-URL: #31635
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
  • Loading branch information
Trott authored and codebytere committed Feb 17, 2020
1 parent 23fefba commit 6874dee
Showing 1 changed file with 28 additions and 24 deletions.
52 changes: 28 additions & 24 deletions doc/api/assert.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
> Stability: 2 - Stable
The `assert` module provides a set of assertion functions for verifying
invariants. The module provides a recommended [`strict` mode][] and a more
lenient legacy mode.
invariants. The module provides a recommended [strict assertion mode][]
and a more lenient legacy assertion mode.

## Class: assert.AssertionError

Expand Down Expand Up @@ -68,26 +68,30 @@ try {
}
```

## Strict mode
## Strict assertion mode
<!-- YAML
added: v9.9.0
changes:
- version: REPLACEME
description: Changed "strict mode" to "strict assertion mode" and "legacy
mode" to "legacy assertion mode" to avoid confusion with the
more usual meaining of "strict mode".
- version: v9.9.0
pr-url: https://github.com/nodejs/node/pull/17615
description: Added error diffs to the strict mode
description: Added error diffs to the strict assertion mode.
- version: v9.9.0
pr-url: https://github.com/nodejs/node/pull/17002
description: Added strict mode to the assert module.
description: Added strict assertion mode to the assert module.
-->

In `strict` mode (not to be confused with `"use strict"`), `assert` functions
use the comparison in the corresponding strict functions. For example,
[`assert.deepEqual()`][] will behave like [`assert.deepStrictEqual()`][].
In strict assertion mode, `assert` functions use the comparison in the
corresponding strict functions. For example, [`assert.deepEqual()`][] will
behave like [`assert.deepStrictEqual()`][].

In `strict` mode, error messages for objects display a diff. In legacy mode,
error messages for objects display the objects, often truncated.
In strict assertion mode, error messages for objects display a diff. In legacy
assertion mode, error messages for objects display the objects, often truncated.

To use `strict` mode:
To use strict assertion mode:

```js
const assert = require('assert').strict;
Expand Down Expand Up @@ -121,22 +125,22 @@ This will also deactivate the colors in the REPL.
For more on the color support in terminal environments, read
the tty [getColorDepth()](tty.html#tty_writestream_getcolordepth_env) doc.

## Legacy mode
## Legacy assertion mode

Legacy mode uses the [Abstract Equality Comparison][] in:
Legacy assertion mode uses the [Abstract Equality Comparison][] in:

* [`assert.deepEqual()`][]
* [`assert.equal()`][]
* [`assert.notDeepEqual()`][]
* [`assert.notEqual()`][]

To use legacy mode:
To use legacy assertion mode:

```js
const assert = require('assert');
```

Whenever possible, use the [`strict` mode][] instead. Otherwise, the
Whenever possible, use the [strict assertion mode][] instead. Otherwise, the
[Abstract Equality Comparison][] may cause surprising results. This is
especially true for [`assert.deepEqual()`][], where the comparison rules are
lax:
Expand Down Expand Up @@ -185,11 +189,11 @@ changes:
* `expected` {any}
* `message` {string|Error}

**Strict mode**
**Strict assertion mode**

An alias of [`assert.deepStrictEqual()`][].

**Legacy mode**
**Legacy assertion mode**

> Stability: 0 - Deprecated: Use [`assert.deepStrictEqual()`][] instead.
Expand Down Expand Up @@ -596,11 +600,11 @@ added: v0.1.21
* `expected` {any}
* `message` {string|Error}

**Strict mode**
**Strict assertion mode**

An alias of [`assert.strictEqual()`][].

**Legacy mode**
**Legacy assertion mode**

> Stability: 0 - Deprecated: Use [`assert.strictEqual()`][] instead.
Expand Down Expand Up @@ -825,11 +829,11 @@ changes:
* `expected` {any}
* `message` {string|Error}

**Strict mode**
**Strict assertion mode**

An alias of [`assert.notDeepStrictEqual()`][].

**Legacy mode**
**Legacy assertion mode**

> Stability: 0 - Deprecated: Use [`assert.notDeepStrictEqual()`][] instead.
Expand Down Expand Up @@ -931,11 +935,11 @@ added: v0.1.21
* `expected` {any}
* `message` {string|Error}

**Strict mode**
**Strict assertion mode**

An alias of [`assert.notStrictEqual()`][].

**Legacy mode**
**Legacy assertion mode**

> Stability: 0 - Deprecated: Use [`assert.notStrictEqual()`][] instead.
Expand Down Expand Up @@ -1395,7 +1399,7 @@ argument.
[`assert.ok()`]: #assert_assert_ok_value_message
[`assert.strictEqual()`]: #assert_assert_strictequal_actual_expected_message
[`assert.throws()`]: #assert_assert_throws_fn_error_message
[`strict` mode]: #assert_strict_mode
[strict assertion mode]: #assert_strict_assertion_mode
[Abstract Equality Comparison]: https://tc39.github.io/ecma262/#sec-abstract-equality-comparison
[Object wrappers]: https://developer.mozilla.org/en-US/docs/Glossary/Primitive#Primitive_wrapper_objects_in_JavaScript
[Object.prototype.toString()]: https://tc39.github.io/ecma262/#sec-object.prototype.tostring
Expand Down

0 comments on commit 6874dee

Please sign in to comment.