Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 65691d6

Browse filesBrowse files
davidtaikochaevanlucas
authored andcommitted
test: increase coverage of internal/util
PR-URL: #10964 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
1 parent ccdc922 commit 65691d6
Copy full SHA for 65691d6

File tree

Expand file treeCollapse file tree

2 files changed

+30
-1
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+30
-1
lines changed
Open diff view settings
Collapse file
+12Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Flags: --expose-internals
2+
'use strict';
3+
require('../common');
4+
const assert = require('assert');
5+
const util = require('internal/util');
6+
7+
if (!process.versions.openssl) {
8+
assert.throws(() => util.assertCrypto(),
9+
/^Node.js is not compiled with openssl crypto support$/);
10+
} else {
11+
assert.doesNotThrow(() => util.assertCrypto());
12+
}
Collapse file

‎…rallel/test-util-decorate-error-stack.js‎ ‎…st-internal-util-decorate-error-stack.js‎test/parallel/test-util-decorate-error-stack.js renamed to test/parallel/test-internal-util-decorate-error-stack.js test/parallel/test-util-decorate-error-stack.js renamed to test/parallel/test-internal-util-decorate-error-stack.js

Copy file name to clipboardExpand all lines: test/parallel/test-internal-util-decorate-error-stack.js
+18-1Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,13 @@
33
const common = require('../common');
44
const assert = require('assert');
55
const internalUtil = require('internal/util');
6+
const binding = process.binding('util');
67
const spawnSync = require('child_process').spawnSync;
78
const path = require('path');
89

10+
const kArrowMessagePrivateSymbolIndex = binding['arrow_message_private_symbol'];
11+
const kDecoratedPrivateSymbolIndex = binding['decorated_private_symbol'];
12+
913
assert.doesNotThrow(function() {
1014
internalUtil.decorateErrorStack();
1115
internalUtil.decorateErrorStack(null);
@@ -53,6 +57,19 @@ checkStack(result.stderr);
5357

5458
// Verify that the stack is unchanged when there is no arrow message
5559
err = new Error('foo');
56-
const originalStack = err.stack;
60+
let originalStack = err.stack;
5761
internalUtil.decorateErrorStack(err);
5862
assert.strictEqual(originalStack, err.stack);
63+
64+
// Verify that the arrow message is added to the start of the stack when it
65+
// exists
66+
const arrowMessage = 'arrow_message';
67+
err = new Error('foo');
68+
originalStack = err.stack;
69+
70+
internalUtil.setHiddenValue(err, kArrowMessagePrivateSymbolIndex, arrowMessage);
71+
internalUtil.decorateErrorStack(err);
72+
73+
assert.strictEqual(err.stack, `${arrowMessage}${originalStack}`);
74+
assert.strictEqual(internalUtil
75+
.getHiddenValue(err, kDecoratedPrivateSymbolIndex), true);

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.