Skip to content

Commit 0b49c30

Browse files
committed
repl: adjust tests
1 parent 69ad98d commit 0b49c30

File tree

2 files changed

+32
-36
lines changed

2 files changed

+32
-36
lines changed

test/parallel/test-repl-history-navigation.js

Lines changed: 13 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
'use strict';
22

33
// Flags: --expose-internals
4-
54
const common = require('../common');
65
const stream = require('stream');
76
const REPL = require('internal/repl');
@@ -244,16 +243,14 @@ const tests = [
244243
// 230 + 2 + 4 + 14
245244
'\x1B[1G', '\x1B[0J',
246245
`${prompt}${' '.repeat(230)} aut`, '\x1B[237G',
247-
' // ocompleteMe', '\x1B[237G',
248-
'\n// 123', '\x1B[237G',
249-
'\x1B[1A', '\x1B[1B', '\x1B[2K', '\x1B[1A',
246+
' // ocompleteMe', '\x1B[237G', ' // ocompleteMe',
247+
'\x1B[237G',
250248
'\x1B[0K',
251249
// 2. UP
252250
'\x1B[1G', '\x1B[0J',
253251
`${prompt}${' '.repeat(229)} aut`, '\x1B[236G',
254-
' // ocompleteMe', '\x1B[236G',
255-
'\n// 123', '\x1B[236G',
256-
'\x1B[1A', '\x1B[1B', '\x1B[2K', '\x1B[1A',
252+
' // ocompleteMe', '\x1B[236G', ' // ocompleteMe',
253+
'\x1B[236G',
257254
// Preview cleanup
258255
'\x1B[0K',
259256
// 3. UP
@@ -362,24 +359,19 @@ const tests = [
362359
'\x1B[1G', '\x1B[0J', prompt, '\x1B[3G', 'a',
363360
// 'u'
364361
'u', ' // tocompleteMe', '\x1B[5G',
365-
'\n// 123', '\x1B[5G',
366-
'\x1B[1A', '\x1B[1B', '\x1B[2K', '\x1B[1A',
367-
// 't' - Cleanup
368362
'\x1B[0K',
363+
// 't' - Cleanup
369364
't', ' // ocompleteMe', '\x1B[6G',
370-
'\n// 123', '\x1B[6G',
371-
'\x1B[1A', '\x1B[1B', '\x1B[2K', '\x1B[1A',
372-
// 1. Right. Cleanup
373365
'\x1B[0K',
366+
// 1. Right. Cleanup
374367
'ocompleteMe',
375368
'\n// 123', '\x1B[17G',
376369
'\x1B[1A', '\x1B[1B', '\x1B[2K', '\x1B[1A',
377370
// 2. Backspace. Refresh
378371
'\x1B[1G', '\x1B[0J', `${prompt}autocompleteM`, '\x1B[16G',
379372
// Autocomplete and refresh?
380373
' // e', '\x1B[16G',
381-
'\n// 123', '\x1B[16G',
382-
'\x1B[1A', '\x1B[1B', '\x1B[2K', '\x1B[1A',
374+
' // e', '\x1B[16G',
383375
// 3. Left. Cleanup
384376
'\x1B[0K',
385377
'\x1B[1D', '\x1B[16G', ' // e', '\x1B[15G',
@@ -404,14 +396,11 @@ const tests = [
404396
'\x1B[1G', '\x1B[0J', `${prompt}autocompleteM`, '\x1B[16G',
405397
// Autocomplete
406398
' // e', '\x1B[16G',
407-
'\n// 123', '\x1B[16G',
408-
'\x1B[1A', '\x1B[1B', '\x1B[2K', '\x1B[1A',
399+
' // e', '\x1B[16G',
409400
// 9. Word left. Cleanup
410401
'\x1B[0K', '\x1B[13D', '\x1B[16G', ' // e', '\x1B[3G', '\x1B[16G',
411402
// 10. Word right. Cleanup
412403
'\x1B[0K', '\x1B[3G', '\x1B[13C', ' // e', '\x1B[16G',
413-
'\n// 123', '\x1B[16G',
414-
'\x1B[1A', '\x1B[1B', '\x1B[2K', '\x1B[1A',
415404
// 11. ESCAPE
416405
'\x1B[0K',
417406
// 12. ENTER
@@ -422,8 +411,7 @@ const tests = [
422411
prompt, '\x1B[3G', '\x1B[1G', '\x1B[0J',
423412
`${prompt}autocompleteM`, '\x1B[16G',
424413
' // e', '\x1B[16G',
425-
'\n// 123', '\x1B[16G',
426-
'\x1B[1A', '\x1B[1B', '\x1B[2K', '\x1B[1A',
414+
' // e', '\x1B[16G',
427415
// 14. LEFT
428416
'\x1B[0K', '\x1B[1D', '\x1B[16G',
429417
' // e', '\x1B[15G', '\x1B[16G',
@@ -437,12 +425,11 @@ const tests = [
437425
'\x1B[1G', '\x1B[0J',
438426
`${prompt}autocompleteM`, '\x1B[16G',
439427
' // e', '\x1B[16G',
440-
'\n// 123', '\x1B[16G',
441-
'\x1B[1A', '\x1B[1B', '\x1B[2K', '\x1B[1A',
428+
' // e', '\x1B[16G',
442429
'\x1B[0K',
443430
// 17. ENTER
444-
'e', '\r\n',
445-
'123\n',
431+
'\r\n',
432+
'Uncaught ReferenceError: autocompleteM is not defined\n',
446433
'\x1B[1G', '\x1B[0J',
447434
prompt, '\x1B[3G',
448435
'\r\n',
@@ -587,7 +574,7 @@ const tests = [
587574
prompt, ...'const util = {}',
588575
'undefined\n',
589576
prompt, ...'ut', ...(prev ? [' // il', '\n// {}',
590-
'il', '\n// {}'] : ['il']),
577+
'\n// {}', '\n// {}'] : ['il']),
591578
'{}\n',
592579
prompt,
593580
],

test/parallel/test-repl-preview.js

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ class REPLStream extends Stream {
2525
for (const entry of data) {
2626
this.emit('data', entry);
2727
}
28+
this.emit('data', '\t');
2829
this.emit('data', '\n');
2930
}
3031
write(chunk) {
@@ -76,18 +77,16 @@ async function tests(options) {
7677
noPreview: '[Function: foo]',
7778
preview: [
7879
'foo',
80+
'\x1B[90m[Function: foo]\x1B[39m\x1B[11G\x1B[1A\x1B[1B\x1B[2K\x1B[1A',
7981
'\x1B[90m[Function: foo]\x1B[39m\x1B[11G\x1B[1A\x1B[1B\x1B[2K\x1B[1A\r',
8082
'\x1B[36m[Function: foo]\x1B[39m',
8183
]
8284
}, {
8385
input: 'koo',
8486
noPreview: '[Function: koo]',
8587
preview: [
86-
'k\x1B[90moo\x1B[39m\x1B[9G',
87-
'\x1B[90m[Function: koo]\x1B[39m\x1B[9G\x1B[1A\x1B[1B\x1B[2K\x1B[1A' +
88-
'\x1B[0Ko\x1B[90mo\x1B[39m\x1B[10G',
89-
'\x1B[90m[Function: koo]\x1B[39m\x1B[10G\x1B[1A\x1B[1B\x1B[2K\x1B[1A' +
90-
'\x1B[0Ko',
88+
'k\x1B[90moo\x1B[39m\x1B[9G\x1B[0Ko\x1B[90mo\x1B[39m\x1B[10G\x1B[0Ko',
89+
'\x1B[90m[Function: koo]\x1B[39m\x1B[11G\x1B[1A\x1B[1B\x1B[2K\x1B[1A',
9190
'\x1B[90m[Function: koo]\x1B[39m\x1B[11G\x1B[1A\x1B[1B\x1B[2K\x1B[1A\r',
9291
'\x1B[36m[Function: koo]\x1B[39m',
9392
]
@@ -99,10 +98,12 @@ async function tests(options) {
9998
input: " { b: 1 }['b'] === 1",
10099
noPreview: '\x1B[33mtrue\x1B[39m',
101100
preview: [
102-
" { b: 1 }['b']",
103-
'\x1B[90m1\x1B[39m\x1B[22G\x1B[1A\x1B[1B\x1B[2K\x1B[1A ',
104-
'\x1B[90m1\x1B[39m\x1B[23G\x1B[1A\x1B[1B\x1B[2K\x1B[1A=== 1',
105-
'\x1B[90mtrue\x1B[39m\x1B[28G\x1B[1A\x1B[1B\x1B[2K\x1B[1A\r',
101+
' { b: 1 }',
102+
"\x1B[90m1\x1B[39m\x1B[17G\x1B[1A\x1B[1B\x1B[2K\x1B[1A['b']",
103+
"\x1B[90m[ 'b' ]\x1B[39m\x1B[22G\x1B[1A\x1B[1B\x1B[2K\x1B[1A ",
104+
"\x1B[90m[ 'b' ]\x1B[39m\x1B[23G\x1B[1A\x1B[1B\x1B[2K\x1B[1A=== 1",
105+
'\x1B[90mfalse\x1B[39m\x1B[28G\x1B[1A\x1B[1B\x1B[2K\x1B[1A',
106+
'\x1B[90mfalse\x1B[39m\x1B[28G\x1B[1A\x1B[1B\x1B[2K\x1B[1A\r',
106107
'\x1B[33mtrue\x1B[39m',
107108
]
108109
}, {
@@ -113,6 +114,7 @@ async function tests(options) {
113114
'\x1B[90m1\x1B[39m\x1B[21G\x1B[1A\x1B[1B\x1B[2K\x1B[1A ',
114115
'\x1B[90m1\x1B[39m\x1B[22G\x1B[1A\x1B[1B\x1B[2K\x1B[1A=== 1',
115116
'\x1B[90mtrue\x1B[39m\x1B[27G\x1B[1A\x1B[1B\x1B[2K\x1B[1A;',
117+
'\x1B[90mfalse\x1B[39m\x1B[28G\x1B[1A\x1B[1B\x1B[2K\x1B[1A',
116118
'\x1B[90mfalse\x1B[39m\x1B[28G\x1B[1A\x1B[1B\x1B[2K\x1B[1A\r',
117119
'\x1B[33mfalse\x1B[39m',
118120
]
@@ -128,6 +130,7 @@ async function tests(options) {
128130
noPreview: '\x1B[33mtrue\x1B[39m',
129131
preview: [
130132
'{ a: tru\x1B[90me\x1B[39m\x1B[16G\x1B[0Ke };',
133+
'\x1B[90mtrue\x1B[39m\x1B[20G\x1B[1A\x1B[1B\x1B[2K\x1B[1A',
131134
'\x1B[90mtrue\x1B[39m\x1B[20G\x1B[1A\x1B[1B\x1B[2K\x1B[1A\r',
132135
'\x1B[33mtrue\x1B[39m',
133136
]
@@ -136,7 +139,8 @@ async function tests(options) {
136139
noPreview: '\x1B[33mtrue\x1B[39m',
137140
preview: [
138141
' { a: tru\x1B[90me\x1B[39m\x1B[18G\x1B[0Ke}',
139-
'\x1B[90m{ a: true }\x1B[39m\x1B[20G\x1B[1A\x1B[1B\x1B[2K\x1B[1A;',
142+
'\x1B[90mtrue\x1B[39m\x1B[20G\x1B[1A\x1B[1B\x1B[2K\x1B[1A;',
143+
'\x1B[90mtrue\x1B[39m\x1B[21G\x1B[1A\x1B[1B\x1B[2K\x1B[1A',
140144
'\x1B[90mtrue\x1B[39m\x1B[21G\x1B[1A\x1B[1B\x1B[2K\x1B[1A\r',
141145
'\x1B[33mtrue\x1B[39m',
142146
]
@@ -146,6 +150,7 @@ async function tests(options) {
146150
preview: [
147151
'1n + 2',
148152
'\x1B[90mType[39m\x1B[14G\x1B[1A\x1B[1B\x1B[2K\x1B[1An',
153+
'\x1B[90m3n\x1B[39m\x1B[15G\x1B[1A\x1B[1B\x1B[2K\x1B[1A',
149154
'\x1B[90m3n\x1B[39m\x1B[15G\x1B[1A\x1B[1B\x1B[2K\x1B[1A\r',
150155
'\x1B[33m3n\x1B[39m',
151156
]
@@ -154,6 +159,7 @@ async function tests(options) {
154159
noPreview: '\x1B[33m1\x1B[39m',
155160
preview: [
156161
'{};1',
162+
'\x1B[90m1\x1B[39m\x1B[12G\x1B[1A\x1B[1B\x1B[2K\x1B[1A',
157163
'\x1B[90m1\x1B[39m\x1B[12G\x1B[1A\x1B[1B\x1B[2K\x1B[1A\r',
158164
'\x1B[33m1\x1B[39m',
159165
]
@@ -196,6 +202,7 @@ async function tests(options) {
196202
noPreview: "{ \x1B[32m'{'\x1B[39m: \x1B[33m0\x1B[39m }",
197203
preview: [
198204
"{'{':0}",
205+
"\x1B[90m{ '{': 0 }\x1B[39m\x1B[15G\x1B[1A\x1B[1B\x1B[2K\x1B[1A",
199206
"\x1B[90m{ '{': 0 }\x1B[39m\x1B[15G\x1B[1A\x1B[1B\x1B[2K\x1B[1A\r",
200207
"{ \x1B[32m'{'\x1B[39m: \x1B[33m0\x1B[39m }",
201208
],
@@ -211,6 +218,7 @@ async function tests(options) {
211218
noPreview: '{}',
212219
preview: [
213220
'{},{}',
221+
'\x1B[90m{}\x1B[39m\x1B[13G\x1B[1A\x1B[1B\x1B[2K\x1B[1A',
214222
'\x1B[90m{}\x1B[39m\x1B[13G\x1B[1A\x1B[1B\x1B[2K\x1B[1A\r',
215223
'{}',
216224
],
@@ -231,6 +239,7 @@ async function tests(options) {
231239
noPreview: 'Uncaught \x1B[33m0\x1B[39m',
232240
preview: [
233241
'{throw 0}',
242+
'\x1B[90m0\x1B[39m\x1B[17G\x1B[1A\x1B[1B\x1B[2K\x1B[1A',
234243
'\x1B[90m0\x1B[39m\x1B[17G\x1B[1A\x1B[1B\x1B[2K\x1B[1A\r',
235244
'Uncaught \x1B[33m0\x1B[39m',
236245
],

0 commit comments

Comments
 (0)