summaryrefslogtreecommitdiff
path: root/gocomplete/tests.go
diff options
context:
space:
mode:
Diffstat (limited to 'gocomplete/tests.go')
-rw-r--r--gocomplete/tests.go15
1 files changed, 8 insertions, 7 deletions
diff --git a/gocomplete/tests.go b/gocomplete/tests.go
index 40210d4..d2c32e7 100644
--- a/gocomplete/tests.go
+++ b/gocomplete/tests.go
@@ -17,15 +17,16 @@ import (
// and then all the relevant function names.
// for test names use prefix of 'Test' or 'Example', and for benchmark
// test names use 'Benchmark'
-func predictTest(funcPrefix ...string) complete.Predicate {
- return func(last string) []match.Matcher {
+func predictTest(funcPrefix ...string) complete.Predictor {
+ return complete.PredictFunc(func(a complete.Args) (prediction []string) {
tests := testNames(funcPrefix)
- options := make([]match.Matcher, len(tests))
- for i := range tests {
- options[i] = match.Prefix(tests[i])
+ for _, t := range tests {
+ if match.Prefix(t, a.Last) {
+ prediction = append(prediction, t)
+ }
}
- return options
- }
+ return
+ })
}
// get all test names in current directory