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

Function TestInterpreter_MissingIdentInSelect

interpreter/interpreter_test.go:2270–2301  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

2268}
2269
2270func TestInterpreter_MissingIdentInSelect(t *testing.T) {
2271 src := common.NewTextSource(`a.b.c`)
2272 parsed := testMustParse(t, src)
2273 cont := testContainer("test")
2274 reg := newTestRegistry(t)
2275 env := newTestEnv(t, cont, reg)
2276 env.AddIdents(decls.NewVariable("a.b", types.DynType))
2277 checked, errors := checker.Check(parsed, src, env)
2278 if len(errors.GetErrors()) != 0 {
2279 t.Fatal(errors.ToDisplayString())
2280 }
2281
2282 attrs := NewPartialAttributeFactory(cont, reg, reg)
2283 interp := newStandardInterpreter(t, cont, reg, reg, attrs)
2284 i, _ := interp.NewInterpretable(checked)
2285 vars, _ := NewPartialActivation(
2286 map[string]any{
2287 "a.b": map[string]any{
2288 "d": "hello",
2289 },
2290 },
2291 NewAttributePattern("a.b").QualString("c"))
2292 result := i.Eval(vars)
2293 if !types.IsUnknown(result) {
2294 t.Errorf("Got %v, wanted unknown", result)
2295 }
2296
2297 result = i.Eval(EmptyActivation())
2298 if !types.IsError(result) {
2299 t.Errorf("Got %v, wanted error", result)
2300 }
2301}
2302
2303func TestInterpreter_TypeConversionOpt(t *testing.T) {
2304 tests := []struct {

Callers

nothing calls this directly

Calls 15

EvalMethod · 0.95
NewTextSourceFunction · 0.92
NewVariableFunction · 0.92
CheckFunction · 0.92
IsUnknownFunction · 0.92
IsErrorFunction · 0.92
testMustParseFunction · 0.85
testContainerFunction · 0.85
newStandardInterpreterFunction · 0.85
NewPartialActivationFunction · 0.85
NewAttributePatternFunction · 0.85

Tested by

no test coverage detected