Test with operator overloading
(t *testing.T)
| 39 | |
| 40 | // Test with operator overloading |
| 41 | func TestPatchOperator_Count(t *testing.T) { |
| 42 | patcher := countingPatcher{} |
| 43 | |
| 44 | _, err := expr.Compile( |
| 45 | `5 + 5`, |
| 46 | expr.Env(mock.Env{}), |
| 47 | expr.Patch(&patcher), |
| 48 | expr.Operator("+", "_intAdd"), |
| 49 | expr.Function( |
| 50 | "_intAdd", |
| 51 | func(params ...any) (any, error) { |
| 52 | return params[0].(int) + params[1].(int), nil |
| 53 | }, |
| 54 | new(func(int, int) int), |
| 55 | ), |
| 56 | ) |
| 57 | |
| 58 | require.NoError(t, err) |
| 59 | |
| 60 | require.Equal(t, 2, patcher.PatchCount, "Patcher run an unexpected number of times during compile") |
| 61 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…