@@ -17,6 +17,7 @@ const testContents = [
1717 'line 1',
1818 'line 1\nline 2 南越国是前203年至前111年存在于岭南地区的一个国家\nline 3\ntrailing',
1919 'line 1\nline 2\nline 3 ends with newline\n',
20+ Array(1e4).fill(0).map((_, i) => i).join('\n'), // More that 2 * highWaterMark
2021];
2122
2223async function testSimple() {
@@ -43,6 +44,29 @@ async function testSimple() {
4344 }
4445}
4546
47+ // Same as testSimple, but with Readable.from() instead of fs.createReadStream
48+ async function testReadableFrom() {
49+ for (const fileContent of testContents) {
50+ const readable = Readable.from([fileContent]);
51+ const rli = readline.createInterface({
52+ input: readable,
53+ crlfDelay: Infinity
54+ });
55+
56+ const iteratedLines = [];
57+ for await (const k of rli) {
58+ iteratedLines.push(k);
59+ }
60+
61+ const expectedLines = fileContent.split('\n');
62+ if (expectedLines[expectedLines.length - 1] === '') {
63+ expectedLines.pop();
64+ }
65+ assert.deepStrictEqual(iteratedLines, expectedLines);
66+ assert.strictEqual(iteratedLines.join(''), fileContent.replace(/\n/g, ''));
67+ }
68+ }
69+
4670async function testMutual() {
4771 for (const fileContent of testContents) {
4872 fs.writeFileSync(filename, fileContent);
@@ -115,6 +139,7 @@ async function testSlowStreamForLeaks() {
115139}
116140
117141testSimple()
142+ .then(testReadableFrom)
118143 .then(testMutual)
119144 .then(testSlowStreamForLeaks)
120145 .then(common.mustCall());
0 commit comments