CEL lazy map: add test for boolean short-circuiting

This commit is contained in:
Jiahui Feng 2023-07-25 14:37:20 -07:00
parent ef4907eddd
commit 66aa2af097

View File

@ -93,6 +93,17 @@ func TestLazyMapType(t *testing.T) {
if evalCounter != 1 {
t.Errorf("expected eval %d times but got %d", 1, evalCounter)
}
// unused due to boolean short-circuiting
// if `variables.unused` is evaluated, the whole test will have a fatal error and exit.
exp = "variables.dict.a == 'wrong' && variables.unused == 'unused'"
v, err = compileAndRun(env, activation, exp)
if err != nil {
t.Fatalf("%q: %v", exp, err)
}
if v.Value().(bool) != false {
t.Errorf("%q: wrong result: %v", exp, v.Value())
}
}
type testActivation struct {