readline: remove max limit of crlfDelay · nodejs/node@8604772
@@ -40,14 +40,25 @@ function isWarned(emitter) {
4040}
41414242{
43-// Maximum crlfDelay is 2000ms
43+// set crlfDelay to float 100.5ms
4444const fi = new FakeInput();
4545const rli = new readline.Interface({
4646input: fi,
4747output: fi,
48-crlfDelay: 1 << 30
48+crlfDelay: 100.5
4949});
50-assert.strictEqual(rli.crlfDelay, 2000);
50+assert.strictEqual(rli.crlfDelay, 100.5);
51+rli.close();
52+}
53+54+{
55+const fi = new FakeInput();
56+const rli = new readline.Interface({
57+input: fi,
58+output: fi,
59+crlfDelay: 5000
60+});
61+assert.strictEqual(rli.crlfDelay, 5000);
5162rli.close();
5263}
5364@@ -225,7 +236,7 @@ function isWarned(emitter) {
225236rli.close();
226237227238// Emit two line events when the delay
228-// between \r and \n exceeds crlfDelay
239+// between \r and \n exceeds crlfDelay
229240{
230241const fi = new FakeInput();
231242const delay = 200;
@@ -247,8 +258,55 @@ function isWarned(emitter) {
247258}), delay * 2);
248259}
249260261+// Emit one line events when the delay between \r and \n is
262+// over the default crlfDelay but within the setting value
263+{
264+const fi = new FakeInput();
265+const delay = 200;
266+const crlfDelay = 500;
267+const rli = new readline.Interface({
268+input: fi,
269+output: fi,
270+terminal: terminal,
271+ crlfDelay
272+});
273+let callCount = 0;
274+rli.on('line', function(line) {
275+callCount++;
276+});
277+fi.emit('data', '\r');
278+setTimeout(common.mustCall(() => {
279+fi.emit('data', '\n');
280+assert.strictEqual(callCount, 1);
281+rli.close();
282+}), delay);
283+}
284+285+// set crlfDelay to `Infinity` is allowed
286+{
287+const fi = new FakeInput();
288+const delay = 200;
289+const crlfDelay = Infinity;
290+const rli = new readline.Interface({
291+input: fi,
292+output: fi,
293+terminal: terminal,
294+ crlfDelay
295+});
296+let callCount = 0;
297+rli.on('line', function(line) {
298+callCount++;
299+});
300+fi.emit('data', '\r');
301+setTimeout(common.mustCall(() => {
302+fi.emit('data', '\n');
303+assert.strictEqual(callCount, 1);
304+rli.close();
305+}), delay);
306+}
307+250308// \t when there is no completer function should behave like an ordinary
251-// character
309+// character
252310fi = new FakeInput();
253311rli = new readline.Interface({ input: fi, output: fi, terminal: true });
254312called = false;
@@ -494,7 +552,7 @@ function isWarned(emitter) {
494552assert.strictEqual(isWarned(process.stdout._events), false);
495553}
496554497-//can create a new readline Interface with a null output arugument
555+// can create a new readline Interface with a null output arugument
498556fi = new FakeInput();
499557rli = new readline.Interface({input: fi, output: null, terminal: terminal });
500558