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

Function TestInliningOptimizerPresenceTests

cel/inlining_test.go:116–316  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

114}
115
116func TestInliningOptimizerPresenceTests(t *testing.T) {
117 type varExpr struct {
118 name string
119 alias string
120 t *cel.Type
121 expr string
122 }
123 tests := []struct {
124 name string
125 expr string
126 vars []varExpr
127 inlined string
128 }{
129 {
130 name: "presence with bool literal",
131 expr: `has(msg.single_any.processing_purpose)`,
132 vars: []varExpr{
133 {
134 name: "msg.single_any.processing_purpose",
135 t: cel.BoolType,
136 expr: "true",
137 },
138 },
139 inlined: `true != false`,
140 },
141 {
142 name: "presence with bytes literal",
143 expr: `has(msg.single_any.processing_purpose)`,
144 vars: []varExpr{
145 {
146 name: "msg.single_any.processing_purpose",
147 t: cel.BytesType,
148 expr: "b'abc'",
149 },
150 },
151 inlined: `b"\141\142\143".size() != 0`,
152 },
153 {
154 name: "presence with double literal",
155 expr: `has(msg.single_any.processing_purpose)`,
156 vars: []varExpr{
157 {
158 name: "msg.single_any.processing_purpose",
159 t: cel.DoubleType,
160 expr: "42.0",
161 },
162 },
163 inlined: `42.0 != 0.0`,
164 },
165 {
166 name: "presence with duration literal",
167 expr: `has(msg.single_any.processing_purpose)`,
168 vars: []varExpr{
169 {
170 name: "msg.single_any.processing_purpose",
171 t: cel.DurationType,
172 expr: "duration('1s')",
173 },

Callers

nothing calls this directly

Calls 14

CompileMethod · 0.95
OptimizeMethod · 0.95
ContainerFunction · 0.92
TypesFunction · 0.92
VariableFunction · 0.92
OptionalTypesFunction · 0.92
EnableMacroCallTrackingFunction · 0.92
NewEnvFunction · 0.92
NewInlineVariableFunction · 0.92
NewStaticOptimizerFunction · 0.92
NewInliningOptimizerFunction · 0.92

Tested by

no test coverage detected