MCPcopy Index your code
hub / github.com/expr-lang/expr / TestPatchOperator_Count

Function TestPatchOperator_Count

test/patch/patch_count_test.go:41–61  ·  view source on GitHub ↗

Test with operator overloading

(t *testing.T)

Source from the content-addressed store, hash-verified

39
40// Test with operator overloading
41func 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}

Callers

nothing calls this directly

Calls 7

CompileFunction · 0.92
EnvStruct · 0.92
PatchFunction · 0.92
OperatorFunction · 0.92
FunctionFunction · 0.92
NoErrorFunction · 0.92
EqualFunction · 0.92

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…