Skip to content

Commit

Permalink
Add known issue test
Browse files Browse the repository at this point in the history
  • Loading branch information
princejwesley committed Jul 10, 2016
1 parent db8d809 commit f1eb84e
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions test/known_issues/test-repl-function-redefinition-edge-case.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// 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');

const expected = '1\n[Function a]\n';
const got = r.output.accumulator.join('');
assert.equal(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: ''
});
}


0 comments on commit f1eb84e

Please sign in to comment.