forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
repl: Empty command should be sent to eval function
This fixes a regression introduced in nodejs#6171
- Loading branch information
Jan Krems
committed
Mar 15, 2017
1 parent
b5eccc4
commit 7683ef3
Showing
2 changed files
with
29 additions
and
6 deletions.
There are no files selected for viewing
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
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,29 @@ | ||
'use strict'; | ||
const common = require('../common'); | ||
const assert = require('assert'); | ||
const repl = require('repl'); | ||
|
||
{ | ||
let evalCalledWithExpectedArgs = false; | ||
|
||
const options = { | ||
eval: common.mustCall((cmd, context) => { | ||
// Assertions here will not cause the test to exit with an error code | ||
// so set a boolean that is checked in process.on('exit',...) instead. | ||
evalCalledWithExpectedArgs = (cmd === '\n'); | ||
}) | ||
}; | ||
|
||
const r = repl.start(options); | ||
|
||
try { | ||
// Empty strings should be sent to the repl's eval function | ||
r.write('\n'); | ||
} finally { | ||
r.write('.exit\n'); | ||
} | ||
|
||
process.on('exit', () => { | ||
assert(evalCalledWithExpectedArgs); | ||
}); | ||
} |