summaryrefslogtreecommitdiff
path: root/test/parallel/test-repl-tab-complete-crash.js
diff options
context:
space:
mode:
authorEvan Lucas <evanlucas@me.com>2016-07-22 07:11:56 -0500
committerEvan Lucas <evanlucas@me.com>2016-07-26 09:14:43 -0500
commit392c70a8273e270b9a0b1d04905138733a6efaff (patch)
treec68e272887a59cd3c68c7e23a1babd384f6d67d5 /test/parallel/test-repl-tab-complete-crash.js
parentd525e6c92aa4a5806a12cfc9206e85724cafa9bc (diff)
downloadandroid-node-v8-392c70a8273e270b9a0b1d04905138733a6efaff.tar.gz
android-node-v8-392c70a8273e270b9a0b1d04905138733a6efaff.tar.bz2
android-node-v8-392c70a8273e270b9a0b1d04905138733a6efaff.zip
repl: prevent undefined ref in completion
Fixes: https://github.com/nodejs/node/issues/7716 PR-URL: https://github.com/nodejs/node/pull/7718 Reviewed-By: Anna Henningsen <anna@addaleax.net>
Diffstat (limited to 'test/parallel/test-repl-tab-complete-crash.js')
-rw-r--r--test/parallel/test-repl-tab-complete-crash.js26
1 files changed, 13 insertions, 13 deletions
diff --git a/test/parallel/test-repl-tab-complete-crash.js b/test/parallel/test-repl-tab-complete-crash.js
index ce28375743..0874ba41f0 100644
--- a/test/parallel/test-repl-tab-complete-crash.js
+++ b/test/parallel/test-repl-tab-complete-crash.js
@@ -4,24 +4,24 @@ const common = require('../common');
const assert = require('assert');
const repl = require('repl');
-var referenceErrorCount = 0;
-
-common.ArrayStream.prototype.write = function(msg) {
- if (msg.startsWith('ReferenceError: ')) {
- referenceErrorCount++;
- }
-};
+common.ArrayStream.prototype.write = function(msg) {};
const putIn = new common.ArrayStream();
const testMe = repl.start('', putIn);
// https://github.com/nodejs/node/issues/3346
-// Tab-completion for an undefined variable inside a function should report a
-// ReferenceError.
+// Tab-completion should be empty
putIn.run(['.clear']);
putIn.run(['function () {']);
-testMe.complete('arguments.');
+testMe.complete('arguments.', common.mustCall((err, completions) => {
+ assert.strictEqual(err, null);
+ assert.deepStrictEqual(completions, [[], 'arguments.']);
+}));
-process.on('exit', function() {
- assert.strictEqual(referenceErrorCount, 1);
-});
+putIn.run(['.clear']);
+putIn.run(['function () {']);
+putIn.run(['undef;']);
+testMe.complete('undef.', common.mustCall((err, completions) => {
+ assert.strictEqual(err, null);
+ assert.deepStrictEqual(completions, [[], 'undef.']);
+}));