Skip to content

Commit d5909bb

Browse files
committed
improve issue test
1 parent 69b27af commit d5909bb

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

test/issues/840/issue_test.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,28 @@ import (
88
)
99

1010
func TestEnvFieldMethods(t *testing.T) {
11-
program, err := expr.Compile(`Func(0)`, expr.Env(&Env{}))
11+
program, err := expr.Compile(`Func() + Int`, expr.Env(&Env{}))
1212
require.NoError(t, err)
1313

1414
env := &Env{}
1515
env.Func = func() int {
16-
return 42
16+
return 40
17+
}
18+
env.EmbeddedEnv = &EmbeddedEnv{
19+
Int: 2,
1720
}
1821

19-
out, err := expr.Run(program, Env{})
22+
out, err := expr.Run(program, env)
2023
require.NoError(t, err)
2124

2225
require.Equal(t, 42, out)
2326
}
2427

2528
type Env struct {
26-
EmbeddedEnv
29+
*EmbeddedEnv
2730
Func func() int
2831
}
2932

30-
type EmbeddedEnv struct{}
33+
type EmbeddedEnv struct {
34+
Int int
35+
}

0 commit comments

Comments
 (0)