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

Function TestAbbrevsCompiled

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

Source from the content-addressed store, hash-verified

151}
152
153func TestAbbrevsCompiled(t *testing.T) {
154 // Test whether abbreviations successfully resolve at type-check time (compile time).
155 env := testEnv(t,
156 Abbrevs("qualified.identifier.name"),
157 Variable("qualified.identifier.name.first", StringType),
158 )
159 prg := compile(t, env, `"hello "+ name.first`) // abbreviation resolved here.
160 out, _, err := prg.Eval(
161 map[string]any{
162 "qualified.identifier.name.first": "Jim",
163 },
164 )
165 if err != nil {
166 t.Fatal(err)
167 }
168 if out.Value() != "hello Jim" {
169 t.Errorf("got %v, wanted 'hello Jim'", out)
170 }
171}
172
173func TestAbbrevsParsed(t *testing.T) {
174 // 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