mirror of https://github.com/lukechilds/node.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
883 B
39 lines
883 B
9 years ago
|
// Reference: https://github.com/nodejs/node/pull/7624
|
||
|
'use strict';
|
||
|
const common = require('../common');
|
||
|
const assert = require('assert');
|
||
|
const repl = require('repl');
|
||
|
const stream = require('stream');
|
||
|
|
||
|
common.globalCheck = false;
|
||
|
|
||
|
const r = initRepl();
|
||
|
|
||
|
r.input.emit('data', 'function a() { return 42; } (1)\n');
|
||
|
r.input.emit('data', 'a\n');
|
||
|
r.input.emit('data', '.exit');
|
||
|
|
||
8 years ago
|
const expected = '1\n[Function: a]\n';
|
||
9 years ago
|
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: ''
|
||
|
});
|
||
|
}
|