github.com/oweisse/u-root@v0.0.0-20181109060735-d005ad25fef1/cmds/elvish/edit/completion/candidate_test.go (about) 1 package completion 2 3 import ( 4 "testing" 5 6 "github.com/u-root/u-root/cmds/elvish/eval" 7 "github.com/u-root/u-root/cmds/elvish/eval/vals" 8 ) 9 10 func TestRawFilterCandidates(t *testing.T) { 11 passAll := eval.NewBuiltinFn("test:passAll", 12 func(fm *eval.Frame, opts eval.RawOptions, pattern string, inputs eval.Inputs) { 13 out := fm.OutputChan() 14 inputs(func(v interface{}) { 15 out <- vals.Bool(true) 16 }) 17 }) 18 blockAll := eval.NewBuiltinFn("test:blockAll", 19 func(fm *eval.Frame, opts eval.RawOptions, pattern string, inputs eval.Inputs) { 20 out := fm.OutputChan() 21 inputs(func(v interface{}) { 22 out <- vals.Bool(false) 23 }) 24 }) 25 26 tests := []filterRawCandidatesTest{ 27 { 28 name: "passAll", 29 matcher: passAll, 30 src: []string{"1", "2", "3"}, 31 want: []string{"1", "2", "3"}, 32 }, 33 { 34 name: "blockAll", 35 matcher: blockAll, 36 src: []string{"1", "2", "3"}, 37 want: []string{}, 38 }, 39 } 40 41 testRawFilterCandidates(t, tests) 42 }