summaryrefslogtreecommitdiff
path: root/gocomplete/tests.go
diff options
context:
space:
mode:
authorEyal Posener <[email protected]>2017-05-11 20:54:26 +0300
committerGitHub <[email protected]>2017-05-11 20:54:26 +0300
commitd3bbb859d52b45987e3cd2098e28423f32edd999 (patch)
tree4265893d0c665ba0e763482a70c9044fa983a1ed /gocomplete/tests.go
parentdd2171d085ef5957a1c5c0794d6007822e47849b (diff)
parentba23c350c73d2dfdf071c14c22152bcaf7e7fd7b (diff)
Merge pull request #12 from posener/improves
Enhance program structure and data structures
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