-
Notifications
You must be signed in to change notification settings - Fork 29.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
db8d809
commit f1eb84e
Showing
1 changed file
with
40 additions
and
0 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
test/known_issues/test-repl-function-redefinition-edge-case.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: '' | ||
}); | ||
} | ||
|
||
|