@@ -21,13 +21,20 @@ func TestRegister(t *testing.T) {
21
21
return "Hello, " + strings .Join (args , " " ), nil
22
22
})
23
23
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
+
24
31
if err := p .RegisterForTests (); err != nil {
25
32
t .Fatalf ("register for test: %v" , err )
26
33
}
27
34
28
35
result , err := p .Nvim .Exec (`:echo Hello('John', 'Doe')` , true )
29
36
if err != nil {
30
- t .Fatalf ("exec echo command : %v" , err )
37
+ t .Fatalf ("exec ' echo Hello' function : %v" , err )
31
38
}
32
39
expected := `Hello, John Doe`
33
40
if result != expected {
@@ -43,6 +50,16 @@ func TestRegister(t *testing.T) {
43
50
if result2 != expected2 {
44
51
t .Fatalf ("hello returned %q, want %q" , result2 , expected2 )
45
52
}
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
+ }
46
63
}
47
64
48
65
func TestSubscribe (t * testing.T ) {
0 commit comments