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

Function TestAbbrevsCompiled

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

Source from the content-addressed store, hash-verified

171}
172
173func TestAbbrevsCompiled(t *testing.T) {
174 // Test whether abbreviations successfully resolve at type-check time (compile time).
175 env := testEnv(t,
176 Abbrevs("qualified.identifier.name"),
177 Variable("qualified.identifier.name.first", StringType),
178 )
179 prg := compile(t, env, `"hello "+ name.first`) // abbreviation resolved here.
180 out, _, err := prg.Eval(
181 map[string]any{
182 "qualified.identifier.name.first": "Jim",
183 },
184 )
185 if err != nil {
186 t.Fatal(err)
187 }
188 if out.Value() != "hello Jim" {
189 t.Errorf("got %v, wanted 'hello Jim'", out)
190 }
191}
192
193func TestAbbrevsParsed(t *testing.T) {
194 // Test whether abbreviations are resolved properly at evaluation time.

Callers

nothing calls this directly

Calls 6

testEnvFunction · 0.70
AbbrevsFunction · 0.70
VariableFunction · 0.70
compileFunction · 0.70
EvalMethod · 0.65
ValueMethod · 0.65

Tested by

no test coverage detected