node/test/parallel/test-repl-function-definition-edge-case.js
Alexey Orlenko 205f4e5006 test: fix repl-function-redefinition-edge-case
`test/known_issues/test-repl-function-redefinition-edge-case.js` had
been introduced as a part of https://github.com/nodejs/node/pull/7624
but the meat of the test became fixed in
007386ee81. Despite that, the test
continued to fail since it was broken itself: there was a missing colon
in the expected output.

This commit adds the missing colon and moves the test from
`test/known_issues` to `test/parallel`.

PR-URL: https://github.com/nodejs/node/pull/11772
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2017-03-14 17:27:22 -07:00

39 lines
883 B
JavaScript

// 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.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: ''
});
}