mirror of
https://github.com/go-sylixos/elvish.git
synced 2024-12-16 12:58:48 +08:00
edit: Move a test.
This commit is contained in:
parent
b64227e498
commit
71ea7b41de
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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")
|
||||
|
|
Loading…
Reference in New Issue
Block a user