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

Function TestAbbrevsCompiled

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

Source from the content-addressed store, hash-verified

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