diff options
author | cjihrig <cjihrig@gmail.com> | 2018-02-11 15:58:55 -0500 |
---|---|---|
committer | cjihrig <cjihrig@gmail.com> | 2018-02-14 11:44:50 -0500 |
commit | 92c86fd84d5f9be1a22388dd5ebb91ee8039e839 (patch) | |
tree | 5218527b4148e188d6c70101ccc4c8266c42f458 | |
parent | 755e07cb738558841880e32795b6f1df4005c5b9 (diff) | |
download | android-node-v8-92c86fd84d5f9be1a22388dd5ebb91ee8039e839.tar.gz android-node-v8-92c86fd84d5f9be1a22388dd5ebb91ee8039e839.tar.bz2 android-node-v8-92c86fd84d5f9be1a22388dd5ebb91ee8039e839.zip |
test: add multiline repl input regression test
This commit adds a regression test for
de848ac1e0483327a2ce8716c3f8567eaeacb660, which broke
multiline input in the REPL.
PR-URL: https://github.com/nodejs/node/pull/18718
Refs: https://github.com/nodejs/node/pull/17828
Refs: https://github.com/nodejs/node/pull/18715
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
-rw-r--r-- | test/parallel/test-repl-multiline.js | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/test/parallel/test-repl-multiline.js b/test/parallel/test-repl-multiline.js new file mode 100644 index 0000000000..54048bf31f --- /dev/null +++ b/test/parallel/test-repl-multiline.js @@ -0,0 +1,35 @@ +'use strict'; +const common = require('../common'); +const assert = require('assert'); +const repl = require('repl'); +const inputStream = new common.ArrayStream(); +const outputStream = new common.ArrayStream(); +const input = ['var foo = {', '};', 'foo;']; +let output = ''; + +outputStream.write = (data) => { output += data.replace('\r', ''); }; + +const r = repl.start({ + prompt: '', + input: inputStream, + output: outputStream, + terminal: true, + useColors: false +}); + +r.on('exit', common.mustCall(() => { + const actual = output.split('\n'); + + // Validate the output, which contains terminal escape codes. + assert.strictEqual(actual.length, 6); + assert.ok(actual[0].endsWith(input[0])); + assert.ok(actual[1].includes('... ')); + assert.ok(actual[1].endsWith(input[1])); + assert.strictEqual(actual[2], 'undefined'); + assert.ok(actual[3].endsWith(input[2])); + assert.strictEqual(actual[4], '{}'); + // Ignore the last line, which is nothing but escape codes. +})); + +inputStream.run(input); +r.close(); |