mirror of
https://github.com/nodejs/node.git
synced 2026-10-14 10:26:26 -04:00
test: increase coverage of internal/util
PR-URL: https://github.com/nodejs/node/pull/10964 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
This commit is contained in:
1 parent
5587ff1ccd
commit
a7172b5d3c
2 files changed
+30
-1
No files matched your search
@@ -0,0 +1,12 @@
|
||||
// Flags: --expose-internals
|
||||
'use strict';
|
||||
require('../common');
|
||||
const assert = require('assert');
|
||||
const util = require('internal/util');
|
||||
|
||||
if (!process.versions.openssl) {
|
||||
assert.throws(() => util.assertCrypto(),
|
||||
/^Node.js is not compiled with openssl crypto support$/);
|
||||
} else {
|
||||
assert.doesNotThrow(() => util.assertCrypto());
|
||||
}
|
||||
+18
-1
@@ -3,9 +3,13 @@
|
||||
const common = require('../common');
|
||||
const assert = require('assert');
|
||||
const internalUtil = require('internal/util');
|
||||
const binding = process.binding('util');
|
||||
const spawnSync = require('child_process').spawnSync;
|
||||
const path = require('path');
|
||||
|
||||
const kArrowMessagePrivateSymbolIndex = binding['arrow_message_private_symbol'];
|
||||
const kDecoratedPrivateSymbolIndex = binding['decorated_private_symbol'];
|
||||
|
||||
assert.doesNotThrow(function() {
|
||||
internalUtil.decorateErrorStack();
|
||||
internalUtil.decorateErrorStack(null);
|
||||
@@ -53,6 +57,19 @@ checkStack(result.stderr);
|
||||
|
||||
// Verify that the stack is unchanged when there is no arrow message
|
||||
err = new Error('foo');
|
||||
const originalStack = err.stack;
|
||||
let originalStack = err.stack;
|
||||
internalUtil.decorateErrorStack(err);
|
||||
assert.strictEqual(originalStack, err.stack);
|
||||
|
||||
// Verify that the arrow message is added to the start of the stack when it
|
||||
// exists
|
||||
const arrowMessage = 'arrow_message';
|
||||
err = new Error('foo');
|
||||
originalStack = err.stack;
|
||||
|
||||
internalUtil.setHiddenValue(err, kArrowMessagePrivateSymbolIndex, arrowMessage);
|
||||
internalUtil.decorateErrorStack(err);
|
||||
|
||||
assert.strictEqual(err.stack, `${arrowMessage}${originalStack}`);
|
||||
assert.strictEqual(internalUtil
|
||||
.getHiddenValue(err, kDecoratedPrivateSymbolIndex), true);
|
||||
Reference in new issue
Block a user