node/test/embedding/test-embedding.js
Anna Henningsen db6e6e3b26
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>
2020-06-26 10:13:13 -07:00

44 lines
1.1 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

'use strict';
const common = require('../common');
const fixtures = require('../common/fixtures');
const assert = require('assert');
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(),
'42');
assert.strictEqual(
child_process.spawnSync(binary, ['throw new Error()']).status,
1);
assert.strictEqual(
child_process.spawnSync(binary, ['process.exitCode = 8']).status,
8);
const fixturePath = JSON.stringify(fixtures.path('exit.js'));
assert.strictEqual(
child_process.spawnSync(binary, [`require(${fixturePath})`, 92]).status,
92);