MCPcopy Create free account
hub / github.com/cel-expr/cel-go / TestOptionalOperatorsLegacyEval

Function TestOptionalOperatorsLegacyEval

cel/cel_test.go:4161–4197  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

4159}
4160
4161func TestOptionalOperatorsLegacyEval(t *testing.T) {
4162 tests := []struct {
4163 name string
4164 expr interpreter.Interpretable
4165 want ref.Val
4166 }{
4167 {
4168 name: "optional or",
4169 expr: &evalOptionalOr{
4170 id: 1,
4171 lhs: interpreter.NewConstValue(2, types.OptionalOf(types.True)),
4172 rhs: interpreter.NewConstValue(3, types.False),
4173 },
4174 want: types.OptionalOf(types.True),
4175 },
4176 {
4177 name: "optional or value mismatch",
4178 expr: &evalOptionalOrValue{
4179 id: 4,
4180 lhs: interpreter.NewConstValue(5, types.True),
4181 rhs: interpreter.NewConstValue(6, types.False),
4182 },
4183 want: types.NoSuchOverloadErr(),
4184 },
4185 }
4186 for _, tc := range tests {
4187 t.Run(tc.name, func(t *testing.T) {
4188 got := tc.expr.Eval(NoVars())
4189 if got.Equal(tc.want) != types.True && !types.IsError(got) {
4190 t.Errorf("Eval() = %v, wanted %v", got, tc.want)
4191 }
4192 if types.IsError(got) && got.(*types.Err).Error() != tc.want.(*types.Err).Error() {
4193 t.Errorf("Eval() = %v, wanted %v", got, tc.want)
4194 }
4195 })
4196 }
4197}

Callers

nothing calls this directly

Calls 8

NewConstValueFunction · 0.92
OptionalOfFunction · 0.92
NoSuchOverloadErrFunction · 0.92
IsErrorFunction · 0.92
NoVarsFunction · 0.85
EvalMethod · 0.65
EqualMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected