node/test/parallel/test-internal-assert.js
Rich Trott 5d609bb11c assert: create internal/assert micro-module
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>
2019-02-08 00:01:09 -08:00

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' });