mirror of
https://github.com/nodejs/node.git
synced 2026-11-29 14:27:57 -05:00
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: https://github.com/nodejs/node/pull/33972 Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
1 parent
3fe1ceec5d
commit
1fcfc4179d
2 files changed
+12
No files matched your search
@@ -93,6 +93,7 @@ int RunNodeInstance(MultiIsolatePlatform* platform,
|
||||
"const publicRequire ="
|
||||
" require('module').createRequire(process.cwd() + '/');"
|
||||
"globalThis.require = publicRequire;"
|
||||
"globalThis.embedVars = { nön_ascıı: '🏳️🌈' };"
|
||||
"require('vm').runInThisContext(process.argv[1]);");
|
||||
|
||||
if (loadenv_ret.IsEmpty()) // There has been a JS exception.
|
||||
|
||||
@@ -6,12 +6,23 @@ const child_process = require('child_process');
|
||||
const path = require('path');
|
||||
|
||||
common.allowGlobals(global.require);
|
||||
common.allowGlobals(global.embedVars);
|
||||
let binary = `out/${common.buildType}/embedtest`;
|
||||
if (common.isWindows) {
|
||||
binary += '.exe';
|
||||
}
|
||||
binary = path.resolve(__dirname, '..', '..', binary);
|
||||
|
||||
assert.strictEqual(
|
||||
child_process.spawnSync(binary, ['console.log(42)'])
|
||||
.stdout.toString().trim(),
|
||||
'42');
|
||||
|
||||
assert.strictEqual(
|
||||
child_process.spawnSync(binary, ['console.log(embedVars.nön_ascıı)'])
|
||||
.stdout.toString().trim(),
|
||||
'🏳️🌈');
|
||||
|
||||
assert.strictEqual(
|
||||
child_process.spawnSync(binary, ['console.log(42)'])
|
||||
.stdout.toString().trim(),
|
||||
|
||||
Reference in new issue
Block a user