blob: 3a0aee5be9d619fe81de1721869d10a3345cbde5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
'use strict';
const common = require('../common');
const ArrayStream = require('../common/arraystream');
const assert = require('assert');
common.skipIfDumbTerminal();
const readline = require('readline');
const rli = new readline.Interface({
terminal: true,
input: new ArrayStream(),
});
let recursionDepth = 0;
// Minimal reproduction for #46731
const testInput = ' \n}\n';
const numberOfExpectedLines = testInput.match(/\n/g).length;
rli.on('line', () => {
// Abort in case of infinite loop
if (recursionDepth > numberOfExpectedLines) {
return;
}
recursionDepth++;
// Write something recursively to readline
rli.write('foo');
});
rli.write(testInput);
assert.strictEqual(recursionDepth, numberOfExpectedLines);
|