From 17888b122c181d76bc1392a13dacd099ec91a5be Mon Sep 17 00:00:00 2001 From: Timothy Gu Date: Mon, 25 Jan 2016 19:56:21 -0800 Subject: [PATCH] doc: fix JSON generation for aliased methods Currently assert/assert.ok currently has the following signature: "signatures": [ { "params": [ { "name": "value" }, { "name": "message])" }, { "name": "assert.ok(value" }, { "name": "message", "optional": true } ] } ] The heading reads assert(value[, message]), assert.ok(value[, message]) Split them into two sections to make it working. PR-URL: https://github.com/nodejs/node/pull/4871 Reviewed-By: Chris Dickinson --- doc/api/assert.markdown | 41 +++++++++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/doc/api/assert.markdown b/doc/api/assert.markdown index 44dafc2fc114b0..1750aed0e1d4d2 100644 --- a/doc/api/assert.markdown +++ b/doc/api/assert.markdown @@ -12,14 +12,9 @@ The API for the `assert` module is [Locked][]. This means that there will be no additions or changes to any of the methods implemented and exposed by the module. -## assert(value[, message]), assert.ok(value[, message]) +## assert(value[, message]) -Tests if `value` is truthy. It is equivalent to -`assert.equal(!!value, true, message)`. - -If `value` is not truthy, 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. +An alias of [`assert.ok()`][] . ```js const assert = require('assert'); @@ -32,15 +27,6 @@ assert(0); // throws "AssertionError: 0 == true" assert(false, 'it\'s false'); // throws "AssertionError: it's false" - -assert.ok(true); // OK -assert.ok(1); // OK -assert.ok(false); - // throws "AssertionError: false == true" -assert.ok(0); - // throws "AssertionError: 0 == true" -assert.ok(false, 'it\'s false'); - // throws "AssertionError: it's false" ``` ## assert.deepEqual(actual, expected[, message]) @@ -329,6 +315,28 @@ If the values are 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. +## assert.ok(value[, message]) + +Tests if `value` is truthy. It is equivalent to +`assert.equal(!!value, true, message)`. + +If `value` is not truthy, 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. + +```js +const assert = require('assert'); + +assert.ok(true); // OK +assert.ok(1); // OK +assert.ok(false); + // throws "AssertionError: false == true" +assert.ok(0); + // throws "AssertionError: 0 == true" +assert.ok(false, 'it\'s false'); + // throws "AssertionError: it's false" +``` + ## assert.strictEqual(actual, expected[, message]) Tests strict equality as determined by the strict equality operator ( `===` ). @@ -396,6 +404,7 @@ assert.throws( [Locked]: documentation.html#documentation_stability_index [`assert.deepEqual`]: #assert_assert_deepequal_actual_expected_message [`assert.deepStrictEqual`]: #assert_assert_deepstrictequal_actual_expected_message +[`assert.ok()`]: #assert_assert_ok_value_message [`assert.throws()`]: #assert_assert_throws_block_error_message [`Error`]: errors.html#errors_class_error [`RegExp`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions