From 402ca5ef71538be5f0c09bd041845bf54cb421f8 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Thu, 27 Apr 2017 17:05:29 +0200 Subject: [PATCH 1/2] test: increase readline coverage --- test/parallel/test-readline.js | 45 ++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 test/parallel/test-readline.js diff --git a/test/parallel/test-readline.js b/test/parallel/test-readline.js new file mode 100644 index 00000000000000..4c8b6ce8976032 --- /dev/null +++ b/test/parallel/test-readline.js @@ -0,0 +1,45 @@ +'use strict'; +const common = require('../common'); +const { PassThrough } = require('stream'); +const readline = require('readline'); +const assert = require('assert'); + +{ + const input = new PassThrough(); + const rl = readline.createInterface({ + terminal: true, + input: input + }); + + rl.on('line', common.mustCall((data) => { + assert.strictEqual(data, 'abc'); + })); + + input.end('abc'); +} + +{ + const input = new PassThrough(); + const rl = readline.createInterface({ + terminal: true, + input: input + }); + + rl.on('line', () => assert.fail('must not be called before newline')); + + input.write('abc'); +} + +{ + const input = new PassThrough(); + const rl = readline.createInterface({ + terminal: true, + input: input + }); + + rl.on('line', common.mustCall((data) => { + assert.strictEqual(data, 'abc'); + })); + + input.write('abc\n'); +} From 82b845f9ab0b7c72a3088aea7c2f862d419c66d5 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Sun, 30 Apr 2017 17:00:15 +0200 Subject: [PATCH 2/2] =?UTF-8?q?[squash]=20assert.fail=20=E2=86=92=20common?= =?UTF-8?q?.mustNotCall?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/parallel/test-readline.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/parallel/test-readline.js b/test/parallel/test-readline.js index 4c8b6ce8976032..62a4fe6f4830fd 100644 --- a/test/parallel/test-readline.js +++ b/test/parallel/test-readline.js @@ -25,7 +25,7 @@ const assert = require('assert'); input: input }); - rl.on('line', () => assert.fail('must not be called before newline')); + rl.on('line', common.mustNotCall('must not be called before newline')); input.write('abc'); }