summaryrefslogtreecommitdiff
path: root/test/parallel/test-repl-tab-complete.js
diff options
context:
space:
mode:
authorMatt Loring <mattloring@google.com>2016-03-17 16:36:51 -0700
committerJames M Snell <jasnell@gmail.com>2016-03-18 17:17:58 -0700
commit0eb3ed50baf680577f30097bccf3cf00854f5ff1 (patch)
tree54f9a31ade7262a5d5d798ffa8c5fa7b7a3f50e3 /test/parallel/test-repl-tab-complete.js
parenta38d6ad4be02528c8975c1e6c796556531de68e1 (diff)
downloadandroid-node-v8-0eb3ed50baf680577f30097bccf3cf00854f5ff1.tar.gz
android-node-v8-0eb3ed50baf680577f30097bccf3cf00854f5ff1.tar.bz2
android-node-v8-0eb3ed50baf680577f30097bccf3cf00854f5ff1.zip
test: reduce brittleness of tab complete test
test-repl-tab-complete includes tests that ensure that certain keys do not appear in tab completions or that completion does not crash the repl. It performed these tests by comparing completion output to a hardcoded list of expected keys. This list is made incorrect by any api changes that occur when new versions of V8 are introduced. With this change, we assert that the specific keys to be avoided are not present in the output instead. PR-URL: https://github.com/nodejs/node/pull/5772 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'test/parallel/test-repl-tab-complete.js')
-rw-r--r--test/parallel/test-repl-tab-complete.js83
1 files changed, 6 insertions, 77 deletions
diff --git a/test/parallel/test-repl-tab-complete.js b/test/parallel/test-repl-tab-complete.js
index 3ec92432df..ee9cce312e 100644
--- a/test/parallel/test-repl-tab-complete.js
+++ b/test/parallel/test-repl-tab-complete.js
@@ -226,97 +226,26 @@ putIn.run([
'var proxy = new Proxy({}, {ownKeys: () => { throw new Error(); }});'
]);
-const proxyElements = [ [
- 'proxy.__defineGetter__',
- 'proxy.__defineSetter__',
- 'proxy.__lookupGetter__',
- 'proxy.__lookupSetter__',
- 'proxy.__proto__',
- 'proxy.constructor',
- 'proxy.hasOwnProperty',
- 'proxy.isPrototypeOf',
- 'proxy.propertyIsEnumerable',
- 'proxy.toLocaleString',
- 'proxy.toString',
- 'proxy.valueOf' ],
- 'proxy.' ];
-
testMe.complete('proxy.', common.mustCall(function(error, data) {
assert.strictEqual(error, null);
- assert.deepEqual(data, proxyElements);
}));
// Make sure tab completion does not include integer members of an Array
-var array_elements = [ [
- 'ary.__defineGetter__',
- 'ary.__defineSetter__',
- 'ary.__lookupGetter__',
- 'ary.__lookupSetter__',
- 'ary.__proto__',
- 'ary.constructor',
- 'ary.hasOwnProperty',
- 'ary.isPrototypeOf',
- 'ary.propertyIsEnumerable',
- 'ary.toLocaleString',
- 'ary.toString',
- 'ary.valueOf',
- '',
- 'ary.concat',
- 'ary.copyWithin',
- 'ary.entries',
- 'ary.every',
- 'ary.fill',
- 'ary.filter',
- 'ary.find',
- 'ary.findIndex',
- 'ary.forEach',
- 'ary.includes',
- 'ary.indexOf',
- 'ary.join',
- 'ary.keys',
- 'ary.lastIndexOf',
- 'ary.length',
- 'ary.map',
- 'ary.pop',
- 'ary.push',
- 'ary.reduce',
- 'ary.reduceRight',
- 'ary.reverse',
- 'ary.shift',
- 'ary.slice',
- 'ary.some',
- 'ary.sort',
- 'ary.splice',
- 'ary.unshift' ],
- 'ary.'];
-
putIn.run(['.clear']);
putIn.run(['var ary = [1,2,3];']);
testMe.complete('ary.', common.mustCall(function(error, data) {
- assert.deepEqual(data, array_elements);
+ assert.strictEqual(data[0].indexOf('ary.0'), -1);
+ assert.strictEqual(data[0].indexOf('ary.1'), -1);
+ assert.strictEqual(data[0].indexOf('ary.2'), -1);
}));
// Make sure tab completion does not include integer keys in an object
-var obj_elements = [ [
- 'obj.__defineGetter__',
- 'obj.__defineSetter__',
- 'obj.__lookupGetter__',
- 'obj.__lookupSetter__',
- 'obj.__proto__',
- 'obj.constructor',
- 'obj.hasOwnProperty',
- 'obj.isPrototypeOf',
- 'obj.propertyIsEnumerable',
- 'obj.toLocaleString',
- 'obj.toString',
- 'obj.valueOf',
- '',
- 'obj.a' ],
- 'obj.' ];
putIn.run(['.clear']);
putIn.run(['var obj = {1:"a","1a":"b",a:"b"};']);
testMe.complete('obj.', common.mustCall(function(error, data) {
- assert.deepEqual(data, obj_elements);
+ assert.strictEqual(data[0].indexOf('obj.1'), -1);
+ assert.strictEqual(data[0].indexOf('obj.1a'), -1);
+ assert.notStrictEqual(data[0].indexOf('obj.a'), -1);
}));