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

Function TestAbbrevsCompiled

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

Source from the content-addressed store, hash-verified

256}
257
258func TestAbbrevsCompiled(t *testing.T) {
259 // Test whether abbreviations successfully resolve at type-check time (compile time).
260 env := testEnv(t,
261 Abbrevs("qualified.identifier.name"),
262 Variable("qualified.identifier.name.first", StringType),
263 )
264 prg := compile(t, env, `"hello "+ name.first`) // abbreviation resolved here.
265 out, _, err := prg.Eval(
266 map[string]any{
267 "qualified.identifier.name.first": "Jim",
268 },
269 )
270 if err != nil {
271 t.Fatal(err)
272 }
273 if out.Value() != "hello Jim" {
274 t.Errorf("got %v, wanted 'hello Jim'", out)
275 }
276}
277
278func TestAbbrevsParsed(t *testing.T) {
279 // 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