-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
repl: catch
\v
and \r
in new-line detection
PR-URL: #54512 Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Mohammed Keyvanzadeh <[email protected]> Reviewed-By: LiviaMedeiros <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]>
- Loading branch information
1 parent
111261e
commit 538b1eb
Showing
2 changed files
with
32 additions
and
3 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 ArrayStream = require('../common/arraystream'); | ||
const assert = require('assert'); | ||
const repl = require('repl'); | ||
|
||
common.skipIfInspectorDisabled(); | ||
|
||
const inputStream = new ArrayStream(); | ||
const outputStream = new ArrayStream(); | ||
repl.start({ | ||
input: inputStream, | ||
output: outputStream, | ||
useGlobal: false, | ||
terminal: true, | ||
useColors: true | ||
}); | ||
|
||
let output = ''; | ||
outputStream.write = (chunk) => output += chunk; | ||
|
||
for (const char of ['\\n', '\\v', '\\r']) { | ||
inputStream.emit('data', `"${char}"()`); | ||
// Make sure the output is on a single line | ||
assert.strictEqual(output, `"${char}"()\n\x1B[90mTypeError: "\x1B[39m\x1B[9G\x1B[1A`); | ||
inputStream.run(['']); | ||
output = ''; | ||
} |