diff options
| author | Eyal Posener <[email protected]> | 2017-05-11 20:28:31 +0300 |
|---|---|---|
| committer | Eyal Posener <[email protected]> | 2017-05-11 20:33:29 +0300 |
| commit | 967bae76f3132c210e6275653f9b603593973858 (patch) | |
| tree | 0f71371443e6d5dde4fcf9e49c63b9afbab28a55 /gocomplete/tests.go | |
| parent | a28594d28ea9a838f174641a411fd537c2c495b9 (diff) | |
Add Predictor interface
Diffstat (limited to 'gocomplete/tests.go')
| -rw-r--r-- | gocomplete/tests.go | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/gocomplete/tests.go b/gocomplete/tests.go index 40210d4..4be3f0d 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 m := match.Prefix(t); m.Match(a.Last) { + prediction = append(prediction, m.String()) + } } - return options - } + return + }) } // get all test names in current directory |
