edit: Move a test.

This commit is contained in:
Qi Xiao 2017-12-18 13:32:53 +00:00
parent b64227e498
commit 71ea7b41de
2 changed files with 29 additions and 28 deletions

View File

@ -1,6 +1,8 @@
package edit
import (
"reflect"
"sort"
"testing"
"github.com/elves/elvish/eval"
@ -23,3 +25,30 @@ func TestFindIndexComplContext(t *testing.T) {
{"a[x][", nil},
})
}
func TestComplIndexInner(t *testing.T) {
m := eval.ConvertToMap(map[eval.Value]eval.Value{
eval.String("foo"): eval.String("bar"),
eval.String("lorem"): eval.String("ipsum"),
})
var (
candidates rawCandidates
wantCandidates = rawCandidates{
plainCandidate("foo"), plainCandidate("lorem"),
}
)
gets := make(chan rawCandidate)
go func() {
defer close(gets)
complIndexInner(m, gets)
}()
for v := range gets {
candidates = append(candidates, v)
}
sort.Sort(candidates)
if !reflect.DeepEqual(candidates, wantCandidates) {
t.Errorf("complIndexInner(%v) = %v, want %v",
m, candidates, wantCandidates)
}
}

View File

@ -10,37 +10,9 @@ import (
"testing"
"github.com/elves/elvish/edit/ui"
"github.com/elves/elvish/eval"
"github.com/elves/elvish/util"
)
func TestComplIndexInner(t *testing.T) {
m := eval.ConvertToMap(map[eval.Value]eval.Value{
eval.String("foo"): eval.String("bar"),
eval.String("lorem"): eval.String("ipsum"),
})
var (
candidates rawCandidates
wantCandidates = rawCandidates{
plainCandidate("foo"), plainCandidate("lorem"),
}
)
gets := make(chan rawCandidate)
go func() {
defer close(gets)
complIndexInner(m, gets)
}()
for v := range gets {
candidates = append(candidates, v)
}
sort.Sort(candidates)
if !reflect.DeepEqual(candidates, wantCandidates) {
t.Errorf("complIndexInner(%v) = %v, want %v",
m, candidates, wantCandidates)
}
}
var (
fileStyle = ui.StylesFromString("1")
exeStyle = ui.StylesFromString("2")