-
Notifications
You must be signed in to change notification settings - Fork 30k
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 #6171 PR-URL: #11871 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
- Loading branch information
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); | ||
}); | ||
} |