blob: 952fba4103cc265c5ccf7d137c2f4d1eabfa16be (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
// Reference: https://github.com/nodejs/node/pull/7624
'use strict';
require('../common');
const assert = require('assert');
const repl = require('repl');
const stream = require('stream');
const r = initRepl();
r.input.emit('data', 'function a() { return 42; } (1)\n');
r.input.emit('data', 'a\n');
r.input.emit('data', '.exit');
const expected = '1\n[Function: a]\n';
const got = r.output.accumulator.join('');
assert.strictEqual(got, expected);
function initRepl() {
const input = new stream();
input.write = input.pause = input.resume = () => {};
input.readable = true;
const output = new stream();
output.writable = true;
output.accumulator = [];
output.write = (data) => output.accumulator.push(data);
return repl.start({
input,
output,
useColors: false,
terminal: false,
prompt: ''
});
}
|