@@ -1092,6 +1092,40 @@ for (let i = 0; i < 12; i++) {
1092
1092
rli . close ( ) ;
1093
1093
}
1094
1094
1095
+ // Call question after close
1096
+ {
1097
+ const [ rli , fi ] = getInterface ( { terminal } ) ;
1098
+ rli . question ( 'What\'s your name?' , common . mustCall ( ( name ) => {
1099
+ assert . strictEqual ( name , 'Node.js' ) ;
1100
+ rli . close ( ) ;
1101
+ assert . throws ( ( ) => {
1102
+ rli . question ( 'How are you?' , common . mustNotCall ( ) ) ;
1103
+ } , {
1104
+ name : 'Error' ,
1105
+ code : 'ERR_USE_AFTER_CLOSE'
1106
+ } ) ;
1107
+ assert . notStrictEqual ( rli . getPrompt ( ) , 'How are you?' ) ;
1108
+ } ) ) ;
1109
+ fi . emit ( 'data' , 'Node.js\n' ) ;
1110
+ }
1111
+
1112
+ // Call promisified question after close
1113
+ {
1114
+ const [ rli , fi ] = getInterface ( { terminal } ) ;
1115
+ const question = util . promisify ( rli . question ) . bind ( rli ) ;
1116
+ question ( 'What\'s your name?' ) . then ( common . mustCall ( ( name ) => {
1117
+ assert . strictEqual ( name , 'Node.js' ) ;
1118
+ rli . close ( ) ;
1119
+ question ( 'How are you?' )
1120
+ . then ( common . mustNotCall ( ) , common . expectsError ( {
1121
+ code : 'ERR_USE_AFTER_CLOSE' ,
1122
+ name : 'Error'
1123
+ } ) ) ;
1124
+ assert . notStrictEqual ( rli . getPrompt ( ) , 'How are you?' ) ;
1125
+ } ) ) ;
1126
+ fi . emit ( 'data' , 'Node.js\n' ) ;
1127
+ }
1128
+
1095
1129
// Can create a new readline Interface with a null output argument
1096
1130
{
1097
1131
const [ rli , fi ] = getInterface ( { output : null , terminal } ) ;
0 commit comments