Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit d6786d2

Browse filesBrowse files
cjihrigMylesBorins
authored andcommitted
test: add multiline repl input regression test
This commit adds a regression test for de848ac, which broke multiline input in the REPL. PR-URL: #18718 Refs: #17828 Refs: #18715 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
1 parent 18c4933 commit d6786d2
Copy full SHA for d6786d2

File tree

Expand file treeCollapse file tree

1 file changed

+35
-0
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+35
-0
lines changed
Open diff view settings
Collapse file
+35Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
'use strict';
2+
const common = require('../common');
3+
const assert = require('assert');
4+
const repl = require('repl');
5+
const inputStream = new common.ArrayStream();
6+
const outputStream = new common.ArrayStream();
7+
const input = ['var foo = {', '};', 'foo;'];
8+
let output = '';
9+
10+
outputStream.write = (data) => { output += data.replace('\r', ''); };
11+
12+
const r = repl.start({
13+
prompt: '',
14+
input: inputStream,
15+
output: outputStream,
16+
terminal: true,
17+
useColors: false
18+
});
19+
20+
r.on('exit', common.mustCall(() => {
21+
const actual = output.split('\n');
22+
23+
// Validate the output, which contains terminal escape codes.
24+
assert.strictEqual(actual.length, 6);
25+
assert.ok(actual[0].endsWith(input[0]));
26+
assert.ok(actual[1].includes('... '));
27+
assert.ok(actual[1].endsWith(input[1]));
28+
assert.strictEqual(actual[2], 'undefined');
29+
assert.ok(actual[3].endsWith(input[2]));
30+
assert.strictEqual(actual[4], '{}');
31+
// Ignore the last line, which is nothing but escape codes.
32+
}));
33+
34+
inputStream.run(input);
35+
r.close();

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.