mirror of
https://github.com/nodejs/node.git
synced 2026-10-28 18:25:13 +08: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>
71 lines
1.8 KiB
JavaScript
71 lines
1.8 KiB
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const { spawn } = require('child_process');
|
|
|
|
common.skipIfInspectorDisabled();
|
|
|
|
const replProcess = spawn(process.argv0, ['--interactive'], {
|
|
stdio: ['pipe', 'pipe', 'inherit'],
|
|
windowsHide: true,
|
|
});
|
|
|
|
replProcess.on('error', common.mustNotCall());
|
|
|
|
const replReadyState = (async function* () {
|
|
let ready;
|
|
const SPACE = ' '.charCodeAt();
|
|
const BRACKET = '>'.charCodeAt();
|
|
const DOT = '.'.charCodeAt();
|
|
replProcess.stdout.on('data', (data) => {
|
|
ready = data[data.length - 1] === SPACE && (
|
|
data[data.length - 2] === BRACKET || (
|
|
data[data.length - 2] === DOT &&
|
|
data[data.length - 3] === DOT &&
|
|
data[data.length - 4] === DOT
|
|
));
|
|
});
|
|
|
|
const processCrashed = new Promise((resolve, reject) =>
|
|
replProcess.on('exit', reject)
|
|
);
|
|
while (true) {
|
|
await Promise.race([new Promise(setImmediate), processCrashed]);
|
|
if (ready) {
|
|
ready = false;
|
|
yield;
|
|
}
|
|
}
|
|
})();
|
|
async function writeLn(data, expectedOutput) {
|
|
await replReadyState.next();
|
|
if (expectedOutput) {
|
|
replProcess.stdout.once('data', common.mustCall((data) =>
|
|
assert.match(data.toString('utf8'), expectedOutput)
|
|
));
|
|
}
|
|
await new Promise((resolve, reject) => replProcess.stdin.write(
|
|
`${data}\n`,
|
|
(err) => (err ? reject(err) : resolve())
|
|
));
|
|
}
|
|
|
|
async function main() {
|
|
await writeLn(
|
|
'const ArrayIteratorPrototype =' +
|
|
' Object.getPrototypeOf(Array.prototype[Symbol.iterator]());'
|
|
);
|
|
await writeLn('delete Array.prototype[Symbol.iterator];');
|
|
await writeLn('delete ArrayIteratorPrototype.next;');
|
|
|
|
await writeLn(
|
|
'for(const x of [3, 2, 1]);',
|
|
/Uncaught TypeError: \[3,2,1\] is not iterable/
|
|
);
|
|
await writeLn('.exit');
|
|
|
|
assert(!replProcess.connected);
|
|
}
|
|
|
|
main().then(common.mustCall());
|