diff options
author | Ruben Bridgewater <ruben@bridgewater.de> | 2019-12-05 14:41:49 +0100 |
---|---|---|
committer | Ruben Bridgewater <ruben@bridgewater.de> | 2019-12-10 00:23:23 +0100 |
commit | 6bdf8d106009e4ed0f3c323d0f0874a51acc8e08 (patch) | |
tree | 57153227fef5cac26ae147e44bf571eee646feef /test/parallel/test-repl-history-navigation.js | |
parent | 02a0c74861c3107e6a9a1752e91540f8d4c49a76 (diff) | |
download | android-node-v8-6bdf8d106009e4ed0f3c323d0f0874a51acc8e08.tar.gz android-node-v8-6bdf8d106009e4ed0f3c323d0f0874a51acc8e08.tar.bz2 android-node-v8-6bdf8d106009e4ed0f3c323d0f0874a51acc8e08.zip |
repl: support previews by eager evaluating input
This adds input previews by using the inspectors eager evaluation
functionality.
It is implemented as additional line that is not counted towards
the actual input. In case no colors are supported, it will be visible
as comment. Otherwise it's grey.
It will be triggered on any line change. It is heavily tested against
edge cases and adheres to "dumb" terminals (previews are deactived
in that case).
PR-URL: https://github.com/nodejs/node/pull/30811
Fixes: https://github.com/nodejs/node/issues/20977
Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
Reviewed-By: Michaƫl Zasso <targos@protonmail.com>
Diffstat (limited to 'test/parallel/test-repl-history-navigation.js')
-rw-r--r-- | test/parallel/test-repl-history-navigation.js | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/test/parallel/test-repl-history-navigation.js b/test/parallel/test-repl-history-navigation.js index b00f932aa9..3bd198880f 100644 --- a/test/parallel/test-repl-history-navigation.js +++ b/test/parallel/test-repl-history-navigation.js @@ -46,28 +46,50 @@ ActionStream.prototype.readable = true; const ENTER = { name: 'enter' }; const UP = { name: 'up' }; const DOWN = { name: 'down' }; +const LEFT = { name: 'left' }; +const DELETE = { name: 'delete' }; const prompt = '> '; +const prev = process.features.inspector; + const tests = [ { // Creates few history to navigate for env: { NODE_REPL_HISTORY: defaultHistoryPath }, test: [ 'let ab = 45', ENTER, '555 + 909', ENTER, - '{key : {key2 :[] }}', ENTER], + '{key : {key2 :[] }}', ENTER, + 'Array(100).fill(1).map((e, i) => i ** i)', LEFT, LEFT, DELETE, + '2', ENTER], expected: [], clean: false }, { env: { NODE_REPL_HISTORY: defaultHistoryPath }, - test: [UP, UP, UP, UP, DOWN, DOWN, DOWN], + test: [UP, UP, UP, UP, UP, DOWN, DOWN, DOWN, DOWN], expected: [prompt, + `${prompt}Array(100).fill(1).map((e, i) => i ** 2)`, + prev && '\n// [ 0, 1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, ' + + '144, 169, 196, 225, 256, 289, 324, 361, 400, 441, 484, 529,' + + ' 576, 625, 676, 729, 784, 841, 900, 961, 1024, 1089, 1156, ' + + '1225, 1296, 1369, 1444, 1521, 1600, 1681, 1764, 1849, 1936,' + + ' 2025, 2116, 2209, ...', `${prompt}{key : {key2 :[] }}`, + prev && '\n// { key: { key2: [] } }', `${prompt}555 + 909`, + prev && '\n// 1464', `${prompt}let ab = 45`, `${prompt}555 + 909`, + prev && '\n// 1464', `${prompt}{key : {key2 :[] }}`, - prompt], + prev && '\n// { key: { key2: [] } }', + `${prompt}Array(100).fill(1).map((e, i) => i ** 2)`, + prev && '\n// [ 0, 1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, ' + + '144, 169, 196, 225, 256, 289, 324, 361, 400, 441, 484, 529,' + + ' 576, 625, 676, 729, 784, 841, 900, 961, 1024, 1089, 1156, ' + + '1225, 1296, 1369, 1444, 1521, 1600, 1681, 1764, 1849, 1936,' + + ' 2025, 2116, 2209, ...', + prompt].filter((e) => typeof e === 'string'), clean: true } ]; |