@@ -21,13 +21,20 @@ func TestRegister(t *testing.T) {
2121 return "Hello, " + strings .Join (args , " " ), nil
2222 })
2323
24+ type testEval struct {
25+ BaseDir string `eval:"fnamemodify(getcwd(), ':t')"`
26+ }
27+ p .HandleFunction (& plugin.FunctionOptions {Name : "EvalTest" , Eval : "*" }, func (args []string , eval * testEval ) (string , error ) {
28+ return fmt .Sprintf ("BaseDir: %s" , eval .BaseDir ), nil
29+ })
30+
2431 if err := p .RegisterForTests (); err != nil {
2532 t .Fatalf ("register for test: %v" , err )
2633 }
2734
2835 result , err := p .Nvim .Exec (`:echo Hello('John', 'Doe')` , true )
2936 if err != nil {
30- t .Fatalf ("exec echo command : %v" , err )
37+ t .Fatalf ("exec ' echo Hello' function : %v" , err )
3138 }
3239 expected := `Hello, John Doe`
3340 if result != expected {
@@ -43,6 +50,16 @@ func TestRegister(t *testing.T) {
4350 if result2 != expected2 {
4451 t .Fatalf ("hello returned %q, want %q" , result2 , expected2 )
4552 }
53+
54+ var result3 string
55+ if err := p .Nvim .Eval (`EvalTest()` , & result3 ); err != nil {
56+ t .Fatalf ("eval 'EvalTest()' function: %v" , err )
57+ }
58+
59+ expected3 := "BaseDir: plugin"
60+ if result3 != expected3 {
61+ t .Fatalf ("EvalTest returned %q, want %q" , result3 , expected3 )
62+ }
4663}
4764
4865func TestSubscribe (t * testing.T ) {
0 commit comments