Skip to content

Commit a9cda30

Browse files
committed
Test for issue 756
Fixes #756
1 parent 2bc0eed commit a9cda30

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

test/issues/756/issue_test.go

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package issue_test
2+
3+
import (
4+
"context"
5+
"testing"
6+
7+
"github.com/expr-lang/expr"
8+
"github.com/expr-lang/expr/internal/testify/require"
9+
)
10+
11+
type X struct{}
12+
13+
func (x *X) HelloCtx(ctx context.Context, text string) error {
14+
return nil
15+
}
16+
17+
func TestIssue756(t *testing.T) {
18+
env := map[string]any{
19+
"_goctx_": context.TODO(),
20+
"_g_": map[string]*X{
21+
"rpc": {},
22+
},
23+
"text": "еуче",
24+
}
25+
exprStr := `let v = _g_.rpc.HelloCtx(text); v`
26+
program, err := expr.Compile(exprStr, expr.Env(env), expr.WithContext("_goctx_"))
27+
require.NoError(t, err)
28+
29+
_, err = expr.Run(program, env)
30+
require.NoError(t, err)
31+
}

0 commit comments

Comments
 (0)