(t *testing.T)
| 71 | } |
| 72 | |
| 73 | func TestWithContext_env_struct(t *testing.T) { |
| 74 | withContext := patcher.WithContext{Name: "ctx"} |
| 75 | |
| 76 | program, err := expr.Compile(`Fn(40)`, expr.Env(testEnvContext{}), expr.Patch(withContext)) |
| 77 | require.NoError(t, err) |
| 78 | |
| 79 | ctx := context.WithValue(context.Background(), "value", 2) |
| 80 | env := testEnvContext{ |
| 81 | Context: ctx, |
| 82 | } |
| 83 | |
| 84 | output, err := expr.Run(program, env) |
| 85 | require.NoError(t, err) |
| 86 | require.Equal(t, 42, output) |
| 87 | } |
| 88 | |
| 89 | type TestFoo struct { |
| 90 | contextValue int |