File tree 2 files changed +29
-6
lines changed
2 files changed +29
-6
lines changed Original file line number Diff line number Diff line change @@ -422,12 +422,6 @@ function REPLServer(prompt,
422
422
return ;
423
423
}
424
424
}
425
- } else {
426
- // Print a new line when hitting enter.
427
- if ( ! self . bufferedCommand ) {
428
- finish ( null ) ;
429
- return ;
430
- }
431
425
}
432
426
433
427
const evalCmd = self . bufferedCommand + cmd + '\n' ;
Original file line number Diff line number Diff line change
1
+ 'use strict' ;
2
+ const common = require ( '../common' ) ;
3
+ const assert = require ( 'assert' ) ;
4
+ const repl = require ( 'repl' ) ;
5
+
6
+ {
7
+ let evalCalledWithExpectedArgs = false ;
8
+
9
+ const options = {
10
+ eval : common . mustCall ( ( cmd , context ) => {
11
+ // Assertions here will not cause the test to exit with an error code
12
+ // so set a boolean that is checked in process.on('exit',...) instead.
13
+ evalCalledWithExpectedArgs = ( cmd === '\n' ) ;
14
+ } )
15
+ } ;
16
+
17
+ const r = repl . start ( options ) ;
18
+
19
+ try {
20
+ // Empty strings should be sent to the repl's eval function
21
+ r . write ( '\n' ) ;
22
+ } finally {
23
+ r . write ( '.exit\n' ) ;
24
+ }
25
+
26
+ process . on ( 'exit' , ( ) => {
27
+ assert ( evalCalledWithExpectedArgs ) ;
28
+ } ) ;
29
+ }
You can’t perform that action at this time.
0 commit comments