Skip to content

Commit 21770c3

Browse files
Matt LoringFishrock123
authored andcommitted
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: #5772 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Conflicts: test/parallel/test-repl-tab-complete.js
1 parent d3654d8 commit 21770c3

File tree

1 file changed

+6
-61
lines changed

1 file changed

+6
-61
lines changed

test/parallel/test-repl-tab-complete.js

Lines changed: 6 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -230,79 +230,24 @@ putIn.run([
230230

231231
testMe.complete('proxy.', common.mustCall(function(error, data) {
232232
assert.strictEqual(error, null);
233-
assert.deepEqual(data, [[], 'proxy.']);
234233
}));
235234

236235
// Make sure tab completion does not include integer members of an Array
237-
var array_elements = [ [
238-
'ary.__defineGetter__',
239-
'ary.__defineSetter__',
240-
'ary.__lookupGetter__',
241-
'ary.__lookupSetter__',
242-
'ary.__proto__',
243-
'ary.constructor',
244-
'ary.hasOwnProperty',
245-
'ary.isPrototypeOf',
246-
'ary.propertyIsEnumerable',
247-
'ary.toLocaleString',
248-
'ary.toString',
249-
'ary.valueOf',
250-
'',
251-
'ary.concat',
252-
'ary.copyWithin',
253-
'ary.entries',
254-
'ary.every',
255-
'ary.fill',
256-
'ary.filter',
257-
'ary.find',
258-
'ary.findIndex',
259-
'ary.forEach',
260-
'ary.indexOf',
261-
'ary.join',
262-
'ary.keys',
263-
'ary.lastIndexOf',
264-
'ary.length',
265-
'ary.map',
266-
'ary.pop',
267-
'ary.push',
268-
'ary.reduce',
269-
'ary.reduceRight',
270-
'ary.reverse',
271-
'ary.shift',
272-
'ary.slice',
273-
'ary.some',
274-
'ary.sort',
275-
'ary.splice',
276-
'ary.unshift' ],
277-
'ary.'];
278-
279236
putIn.run(['.clear']);
280237

281238
putIn.run(['var ary = [1,2,3];']);
282239
testMe.complete('ary.', common.mustCall(function(error, data) {
283-
assert.deepEqual(data, array_elements);
240+
assert.strictEqual(data[0].indexOf('ary.0'), -1);
241+
assert.strictEqual(data[0].indexOf('ary.1'), -1);
242+
assert.strictEqual(data[0].indexOf('ary.2'), -1);
284243
}));
285244

286245
// Make sure tab completion does not include integer keys in an object
287-
var obj_elements = [ [
288-
'obj.__defineGetter__',
289-
'obj.__defineSetter__',
290-
'obj.__lookupGetter__',
291-
'obj.__lookupSetter__',
292-
'obj.__proto__',
293-
'obj.constructor',
294-
'obj.hasOwnProperty',
295-
'obj.isPrototypeOf',
296-
'obj.propertyIsEnumerable',
297-
'obj.toLocaleString',
298-
'obj.toString',
299-
'obj.valueOf',
300-
'',
301-
'obj.a' ],
302-
'obj.' ];
303246
putIn.run(['.clear']);
304247
putIn.run(['var obj = {1:"a","1a":"b",a:"b"};']);
305248

306249
testMe.complete('obj.', common.mustCall(function(error, data) {
307-
assert.deepEqual(data, obj_elements);
250+
assert.strictEqual(data[0].indexOf('obj.1'), -1);
251+
assert.strictEqual(data[0].indexOf('obj.1a'), -1);
252+
assert.notStrictEqual(data[0].indexOf('obj.a'), -1);
308253
}));

0 commit comments

Comments
 (0)