File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change
1
+ 'use strict' ;
2
+ const repl = require ( 'repl' ) ;
3
+ const { describe, it } = require ( "node:test" ) ;
4
+ const ArrayStream = require ( '../common/arraystream' ) ;
5
+ const assert = require ( 'assert' ) ;
6
+ const outputStream = new ArrayStream ( ) ;
7
+ let accum = '' ;
8
+ outputStream . write = ( data ) => accum += data . replace ( '\r' , '' ) ;
9
+
10
+ function prepareREPL ( ) {
11
+ const replServer = repl . start ( {
12
+ prompt : '' ,
13
+ input : new ArrayStream ( ) ,
14
+ output : outputStream ,
15
+ allowBlockingCompletions : true ,
16
+ } ) ;
17
+
18
+
19
+ return replServer ;
20
+ }
21
+
22
+
23
+ describe ( 'REPL tab completion without side effects' , ( ) => {
24
+ const code = [
25
+ 'typeof Reflect.construct' ,
26
+ 'typeof Reflect.const' ,
27
+ ] ;
28
+
29
+ it ( `should return values ` , async ( ) => {
30
+ const { replServer, input } = prepareREPL ( ) ;
31
+ input . run ( code ) ;
32
+ assert . strictEqual ( accum , '\'function\'\n\'undefined\'\n' ) ;
33
+ } ) ;
34
+ } ) ;
You can’t perform that action at this time.
0 commit comments