test: add tests to assert.ok and improve coverage

Refs: https://coverage.nodejs.org/coverage-1a4f27ae21698d0c/lib/assert.js.html#L364

PR-URL: https://github.com/nodejs/node/pull/28355
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
This commit is contained in:
estrada9166 2019-06-21 16:55:38 -05:00 committed by Anna Henningsen
parent 26b048effb
commit 6e9d795642
No known key found for this signature in database
GPG Key ID: 9C63F3A6CD2AD8F9

View File

@ -44,6 +44,19 @@ assert.ok(a.AssertionError.prototype instanceof Error,
assert.throws(() => a(false), a.AssertionError, 'ok(false)');
assert.throws(() => a.ok(false), a.AssertionError, 'ok(false)');
// Throw message if the message is instanceof Error.
{
let threw = false;
try {
assert.ok(false, new Error('ok(false)'));
} catch (e) {
threw = true;
assert.ok(e instanceof Error);
}
assert.ok(threw, 'Error: ok(false)');
}
a(true);
a('test', 'ok(\'test\')');
a.ok(true);