You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

45 lines
857 B

'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', common.mustNotCall('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');
}