Skip to content

Commit 2c568c8

Browse files
addaleaxcodebytere
authored andcommitted
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 <[email protected]>
1 parent 9760c6c commit 2c568c8

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

test/embedding/embedtest.cc

+1
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ int RunNodeInstance(MultiIsolatePlatform* platform,
9393
"const publicRequire ="
9494
" require('module').createRequire(process.cwd() + '/');"
9595
"globalThis.require = publicRequire;"
96+
"globalThis.embedVars = { nön_ascıı: '🏳️‍🌈' };"
9697
"require('vm').runInThisContext(process.argv[1]);");
9798

9899
if (loadenv_ret.IsEmpty()) // There has been a JS exception.

test/embedding/test-embedding.js

+11
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)