File tree Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Original file line number Diff line number Diff line change
1
+ // Reference: https://github.com/nodejs/node/pull/7624
2
+ 'use strict';
3
+ const common = require('../common');
4
+ const assert = require('assert');
5
+ const repl = require('repl');
6
+ const stream = require('stream');
7
+
8
+ common.globalCheck = false;
9
+
10
+ const r = initRepl();
11
+
12
+ r.input.emit('data', 'function a() { return 42; } (1)\n');
13
+ r.input.emit('data', 'a\n');
14
+ r.input.emit('data', '.exit');
15
+
16
+ const expected = '1\n[Function a]\n';
17
+ const got = r.output.accumulator.join('');
18
+ assert.equal(got, expected);
19
+
20
+ function initRepl() {
21
+ const input = new stream();
22
+ input.write = input.pause = input.resume = () => {};
23
+ input.readable = true;
24
+
25
+ const output = new stream();
26
+ output.writable = true;
27
+ output.accumulator = [];
28
+
29
+ output.write = (data) => output.accumulator.push(data);
30
+
31
+ return repl.start({
32
+ input,
33
+ output,
34
+ useColors: false,
35
+ terminal: false,
36
+ prompt: ''
37
+ });
38
+ }
39
+
40
+
You can’t perform that action at this time.
0 commit comments