|
@ -32,7 +32,7 @@ testMe.complete('console.lo', common.mustCall(function(error, data) { |
|
|
assert.deepStrictEqual(data, [['console.log'], 'console.lo']); |
|
|
assert.deepStrictEqual(data, [['console.log'], 'console.lo']); |
|
|
})); |
|
|
})); |
|
|
|
|
|
|
|
|
// Tab Complete will return globaly scoped variables
|
|
|
// Tab Complete will return globally scoped variables
|
|
|
putIn.run(['};']); |
|
|
putIn.run(['};']); |
|
|
testMe.complete('inner.o', common.mustCall(function(error, data) { |
|
|
testMe.complete('inner.o', common.mustCall(function(error, data) { |
|
|
assert.deepStrictEqual(data, works); |
|
|
assert.deepStrictEqual(data, works); |
|
@ -283,3 +283,68 @@ if (typeof Intl === 'object') { |
|
|
testNonGlobal.complete('I', common.mustCall((error, data) => { |
|
|
testNonGlobal.complete('I', common.mustCall((error, data) => { |
|
|
assert.deepStrictEqual(data, builtins); |
|
|
assert.deepStrictEqual(data, builtins); |
|
|
})); |
|
|
})); |
|
|
|
|
|
|
|
|
|
|
|
// To test custom completer function.
|
|
|
|
|
|
// Sync mode.
|
|
|
|
|
|
const customCompletions = 'aaa aa1 aa2 bbb bb1 bb2 bb3 ccc ddd eee'.split(' '); |
|
|
|
|
|
const testCustomCompleterSyncMode = repl.start({ |
|
|
|
|
|
prompt: '', |
|
|
|
|
|
input: putIn, |
|
|
|
|
|
output: putIn, |
|
|
|
|
|
completer: function completerSyncMode(line) { |
|
|
|
|
|
const hits = customCompletions.filter((c) => { |
|
|
|
|
|
return c.indexOf(line) === 0; |
|
|
|
|
|
}); |
|
|
|
|
|
// Show all completions if none found.
|
|
|
|
|
|
return [hits.length ? hits : customCompletions, line]; |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
// On empty line should output all the custom completions
|
|
|
|
|
|
// without complete anything.
|
|
|
|
|
|
testCustomCompleterSyncMode.complete('', common.mustCall((error, data) => { |
|
|
|
|
|
assert.deepStrictEqual(data, [ |
|
|
|
|
|
customCompletions, |
|
|
|
|
|
'' |
|
|
|
|
|
]); |
|
|
|
|
|
})); |
|
|
|
|
|
|
|
|
|
|
|
// On `a` should output `aaa aa1 aa2` and complete until `aa`.
|
|
|
|
|
|
testCustomCompleterSyncMode.complete('a', common.mustCall((error, data) => { |
|
|
|
|
|
assert.deepStrictEqual(data, [ |
|
|
|
|
|
'aaa aa1 aa2'.split(' '), |
|
|
|
|
|
'a' |
|
|
|
|
|
]); |
|
|
|
|
|
})); |
|
|
|
|
|
|
|
|
|
|
|
// To test custom completer function.
|
|
|
|
|
|
// Async mode.
|
|
|
|
|
|
const testCustomCompleterAsyncMode = repl.start({ |
|
|
|
|
|
prompt: '', |
|
|
|
|
|
input: putIn, |
|
|
|
|
|
output: putIn, |
|
|
|
|
|
completer: function completerAsyncMode(line, callback) { |
|
|
|
|
|
const hits = customCompletions.filter((c) => { |
|
|
|
|
|
return c.indexOf(line) === 0; |
|
|
|
|
|
}); |
|
|
|
|
|
// Show all completions if none found.
|
|
|
|
|
|
callback(null, [hits.length ? hits : customCompletions, line]); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
// On empty line should output all the custom completions
|
|
|
|
|
|
// without complete anything.
|
|
|
|
|
|
testCustomCompleterAsyncMode.complete('', common.mustCall((error, data) => { |
|
|
|
|
|
assert.deepStrictEqual(data, [ |
|
|
|
|
|
customCompletions, |
|
|
|
|
|
'' |
|
|
|
|
|
]); |
|
|
|
|
|
})); |
|
|
|
|
|
|
|
|
|
|
|
// On `a` should output `aaa aa1 aa2` and complete until `aa`.
|
|
|
|
|
|
testCustomCompleterAsyncMode.complete('a', common.mustCall((error, data) => { |
|
|
|
|
|
assert.deepStrictEqual(data, [ |
|
|
|
|
|
'aaa aa1 aa2'.split(' '), |
|
|
|
|
|
'a' |
|
|
|
|
|
]); |
|
|
|
|
|
})); |
|
|