Skip to content

Commit

Permalink
test: add test that fails without the changes of #46742
Browse files Browse the repository at this point in the history
  • Loading branch information
Theo-Steiner committed Feb 27, 2023
1 parent 2b0871d commit 3cc2379
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 47 deletions.
31 changes: 31 additions & 0 deletions test/parallel/test-readline-recursive-writes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
'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;

rli.on('line', function onLine() {
// Abort in case of infinite loop
if (recursionDepth > 2) {
return
}
recursionDepth++
// Write something recursively to readline
rli.write('foo');
return;
});

// minimal reproduction for #46731
const testInput = ' \n}\n';
rli.write(testInput);

assert.strictEqual(recursionDepth, testInput.match(/\n/g).length, "infinite loop");
47 changes: 0 additions & 47 deletions test/parallel/test-repl-load-multiline-function.js

This file was deleted.

0 comments on commit 3cc2379

Please sign in to comment.