mirror of
https://github.com/nodejs/node.git
synced 2025-05-09 05:41:13 +00:00

For use in built-in modules that could benefit from `assert()` without having to load the entire module (unless an AssertionError actually occurs): lib/internal/assert.js. PR-URL: https://github.com/nodejs/node/pull/25956 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Minwoo Jung <minwoo@nodesource.com>
16 lines
429 B
JavaScript
16 lines
429 B
JavaScript
// Flags: --expose-internals
|
|
'use strict';
|
|
|
|
require('../common');
|
|
|
|
const assert = require('assert');
|
|
const internalAssert = require('internal/assert');
|
|
|
|
// Should not throw.
|
|
internalAssert(true);
|
|
internalAssert(true, 'fhqwhgads');
|
|
|
|
assert.throws(() => { internalAssert(false); }, assert.AssertionError);
|
|
assert.throws(() => { internalAssert(false, 'fhqwhgads'); },
|
|
{ code: 'ERR_ASSERTION', message: 'fhqwhgads' });
|