mirror of
https://github.com/nodejs/node.git
synced 2025-05-20 17:41:40 +00:00

Tests relying on synchronous timing have been migrated to use events. PR-URL: https://github.com/nodejs/node/pull/17828 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com>
30 lines
683 B
JavaScript
30 lines
683 B
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const repl = require('repl');
|
|
|
|
const exitTests = [];
|
|
process.on('exit', () => {
|
|
for (const test of exitTests) test();
|
|
});
|
|
const CONTEXT = { animal: 'Sterrance' };
|
|
const stream = new common.ArrayStream();
|
|
const options = {
|
|
eval: common.mustCall((cmd, context) => {
|
|
// need to escape the domain
|
|
exitTests.push(common.mustCall(() => {
|
|
assert.strictEqual(cmd, '.scope');
|
|
assert.ok(context === CONTEXT);
|
|
}));
|
|
}),
|
|
input: stream,
|
|
output: stream,
|
|
terminal: true
|
|
};
|
|
|
|
const r = repl.start(options);
|
|
r.context = CONTEXT;
|
|
|
|
stream.emit('data', '\t');
|
|
stream.emit('.exit\n');
|