mirror of
https://github.com/go-sylixos/elvish.git
synced 2024-12-14 19:27:58 +08:00
40 lines
854 B
Go
40 lines
854 B
Go
package newedit
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/elves/elvish/eval"
|
|
"github.com/elves/elvish/eval/vals"
|
|
)
|
|
|
|
func TestInitBeforeReadline(t *testing.T) {
|
|
variable, cb := initBeforeReadline(eval.NewEvaler())
|
|
called := 0
|
|
variable.Set(vals.EmptyList.Cons(eval.NewGoFn("[test]", func() {
|
|
called++
|
|
})))
|
|
cb()
|
|
if called != 1 {
|
|
t.Errorf("Called %d times, want once", called)
|
|
}
|
|
// TODO: Test input and output
|
|
}
|
|
|
|
func TestInitAfterReadline(t *testing.T) {
|
|
variable, cb := initAfterReadline(eval.NewEvaler())
|
|
called := 0
|
|
calledWith := ""
|
|
variable.Set(vals.EmptyList.Cons(eval.NewGoFn("[test]", func(s string) {
|
|
called++
|
|
calledWith = s
|
|
})))
|
|
cb("code")
|
|
if called != 1 {
|
|
t.Errorf("Called %d times, want once", called)
|
|
}
|
|
if calledWith != "code" {
|
|
t.Errorf("Called with %q, want %q", calledWith, "code")
|
|
}
|
|
// TODO: Test input and output
|
|
}
|