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 4cd7f5f

Browse filesBrowse files
committed
test: add non-ASCII character embedding test
Add a test that verifies that non-ASCII characters may be used in the source code provided to `LoadEnvironment()`. PR-URL: #33972 Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 9173b09 commit 4cd7f5f
Copy full SHA for 4cd7f5f

File tree

Expand file treeCollapse file tree

2 files changed

+12
-0
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+12
-0
lines changed
Open diff view settings
Collapse file

‎test/embedding/embedtest.cc‎

Copy file name to clipboardExpand all lines: test/embedding/embedtest.cc
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ int RunNodeInstance(MultiIsolatePlatform* platform,
9494
"const publicRequire ="
9595
" require('module').createRequire(process.cwd() + '/');"
9696
"globalThis.require = publicRequire;"
97+
"globalThis.embedVars = { nön_ascıı: '🏳️‍🌈' };"
9798
"require('vm').runInThisContext(process.argv[1]);");
9899

99100
if (loadenv_ret.IsEmpty()) // There has been a JS exception.
Collapse file

‎test/embedding/test-embedding.js‎

Copy file name to clipboardExpand all lines: test/embedding/test-embedding.js
+11Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,23 @@ const child_process = require('child_process');
66
const path = require('path');
77

88
common.allowGlobals(global.require);
9+
common.allowGlobals(global.embedVars);
910
let binary = `out/${common.buildType}/embedtest`;
1011
if (common.isWindows) {
1112
binary += '.exe';
1213
}
1314
binary = path.resolve(__dirname, '..', '..', binary);
1415

16+
assert.strictEqual(
17+
child_process.spawnSync(binary, ['console.log(42)'])
18+
.stdout.toString().trim(),
19+
'42');
20+
21+
assert.strictEqual(
22+
child_process.spawnSync(binary, ['console.log(embedVars.nön_ascıı)'])
23+
.stdout.toString().trim(),
24+
'🏳️‍🌈');
25+
1526
assert.strictEqual(
1627
child_process.spawnSync(binary, ['console.log(42)'])
1728
.stdout.toString().trim(),

0 commit comments

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