diff options
author | Anna Henningsen <anna@addaleax.net> | 2016-04-14 03:21:49 +0300 |
---|---|---|
committer | cjihrig <cjihrig@gmail.com> | 2016-04-14 15:23:23 +0300 |
commit | 0b66b8f2d2c3aceba5e65c4b4ba428b7fabd3cb5 (patch) | |
tree | 278bc140fb9a88a13e157b1553f48f4e90ac3707 /test | |
parent | 0b1d89f35a43c27e4aa666c41defb39e586d39f2 (diff) |
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.js | 8 |
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 ee9cce312e8..d52f0068ec3 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]); +})); |