summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAnna Henningsen <anna@addaleax.net>2016-04-14 02:21:49 +0200
committercjihrig <cjihrig@gmail.com>2016-04-14 08:23:23 -0400
commit0b66b8f2d2c3aceba5e65c4b4ba428b7fabd3cb5 (patch)
tree278bc140fb9a88a13e157b1553f48f4e90ac3707 /test
parent0b1d89f35a43c27e4aa666c41defb39e586d39f2 (diff)
downloadandroid-node-v8-0b66b8f2d2c3aceba5e65c4b4ba428b7fabd3cb5.tar.gz
android-node-v8-0b66b8f2d2c3aceba5e65c4b4ba428b7fabd3cb5.tar.bz2
android-node-v8-0b66b8f2d2c3aceba5e65c4b4ba428b7fabd3cb5.zip
repl: don’t complete non-simple expressions
Change the regular expression that recognizes “simple” JS expressions to requiring that the full line needs to match it. Previously, in terms like `a().b.`, `b.` would be a partial match. This meant that completion would evaluate `b` and either fail with a `ReferenceError` or, if `b` was some global, return the properties of the global `b` object. PR-URL: https://github.com/nodejs/node/pull/6192 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Diffstat (limited to 'test')
-rw-r--r--test/parallel/test-repl-tab-complete.js8
1 files changed, 8 insertions, 0 deletions
diff --git a/test/parallel/test-repl-tab-complete.js b/test/parallel/test-repl-tab-complete.js
index ee9cce312e..d52f0068ec 100644
--- a/test/parallel/test-repl-tab-complete.js
+++ b/test/parallel/test-repl-tab-complete.js
@@ -249,3 +249,11 @@ testMe.complete('obj.', common.mustCall(function(error, data) {
assert.strictEqual(data[0].indexOf('obj.1a'), -1);
assert.notStrictEqual(data[0].indexOf('obj.a'), -1);
}));
+
+// Don't try to complete results of non-simple expressions
+putIn.run(['.clear']);
+putIn.run(['function a() {}']);
+
+testMe.complete('a().b.', common.mustCall((error, data) => {
+ assert.deepEqual(data, [[], undefined]);
+}));