mirror of
https://github.com/nodejs/node.git
synced 2026-11-09 15:11:11 -05:00
Signed-off-by: Aviv Keller <me@aviv.sh> PR-URL: https://github.com/nodejs/node/pull/64034 Fixes: https://github.com/nodejs/node/issues/64523 Closes: https://github.com/nodejs/node/pull/64534 Fixes: https://github.com/nodejs/node/issues/39387 Closes: https://github.com/nodejs/node/pull/39392 Fixes: https://github.com/nodejs/node/issues/61390 Fixes: https://github.com/nodejs/node/issues/63126 Fixes: https://github.com/nodejs/node/issues/38503 Fixes: https://github.com/nodejs/node/issues/37445 Fixes: https://github.com/nodejs/node/issues/38145 Fixes: https://github.com/nodejs/node/issues/33369 Fixes: https://github.com/nodejs/node/issues/48131 Fixes: https://github.com/nodejs/node/issues/8309 Fixes: https://github.com/nodejs/node/issues/39689 Fixes: https://github.com/nodejs/node/issues/18931 Reviewed-By: Dario Piotrowicz <dario.piotrowicz@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Filip Skokan <panva.ip@gmail.com>
49 lines
1.4 KiB
JavaScript
49 lines
1.4 KiB
JavaScript
import '../common/index.mjs';
|
|
import assert from 'node:assert';
|
|
import { startNewREPLServer } from '../common/repl.js';
|
|
|
|
// Array of [useGlobal, expectedResult] pairs
|
|
const globalTestCases = [
|
|
[false, 'undefined'],
|
|
[true, '\'tacos\''],
|
|
[undefined, 'undefined'],
|
|
];
|
|
|
|
// Test how the global object behaves in each state for useGlobal.
|
|
for (const [useGlobal, expected] of globalTestCases) {
|
|
const { replServer, output, run } = startNewREPLServer({
|
|
terminal: false,
|
|
useColors: false,
|
|
useGlobal,
|
|
});
|
|
|
|
globalThis.lunch = 'tacos';
|
|
await run('globalThis.lunch;\n');
|
|
replServer.close();
|
|
delete globalThis.lunch;
|
|
|
|
assert.strictEqual(output.accumulator.trim(), expected);
|
|
}
|
|
|
|
// Test how shadowing the process object via `let` behaves in each useGlobal
|
|
// state. Note: we can't actually test the state when useGlobal is true,
|
|
// because the exception that's generated is caught (see below), but errors
|
|
// are printed, and the test suite is aware of it, causing a failure to be
|
|
// flagged.
|
|
const processTestCases = [false, undefined];
|
|
|
|
for (const useGlobal of processTestCases) {
|
|
const { replServer, output, run } = startNewREPLServer({
|
|
terminal: false,
|
|
useColors: false,
|
|
useGlobal,
|
|
});
|
|
|
|
// If useGlobal is false, then `let process` should work.
|
|
await run('let process;\n');
|
|
await run('21 * 2;\n');
|
|
replServer.close();
|
|
|
|
assert.strictEqual(output.accumulator.trim(), 'undefined\n42');
|
|
}
|