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

Function TestDisableShortCircuit

expr_test.go:2927–2950  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

2925}
2926
2927func TestDisableShortCircuit(t *testing.T) {
2928 count := 0
2929 exprStr := "foo() or bar()"
2930 env := map[string]any{
2931 "foo": func() bool {
2932 count++
2933 return true
2934 },
2935 "bar": func() bool {
2936 count++
2937 return true
2938 },
2939 }
2940
2941 program, _ := expr.Compile(exprStr, expr.DisableShortCircuit())
2942 got, _ := expr.Run(program, env)
2943 assert.Equal(t, 2, count)
2944 assert.True(t, got.(bool))
2945
2946 program, _ = expr.Compile(exprStr)
2947 got, _ = expr.Run(program, env)
2948 assert.Equal(t, 3, count)
2949 assert.True(t, got.(bool))
2950}
2951
2952func TestBytesLiteral(t *testing.T) {
2953 tests := []struct {

Callers

nothing calls this directly

Calls 5

CompileFunction · 0.92
DisableShortCircuitFunction · 0.92
RunFunction · 0.92
EqualFunction · 0.92
TrueFunction · 0.92

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…