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

Function TestEnvExtendDisableDeclaration

cel/env_test.go:167–195  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

165}
166
167func TestEnvExtendDisableDeclaration(t *testing.T) {
168 baseEnv, err := NewCustomEnv(
169 Function("foo",
170 Overload("foo_bool", []*Type{BoolType}, BoolType),
171 ),
172 )
173 if err != nil {
174 t.Fatalf("NewCustomEnv() failed: %v", err)
175 }
176 _, iss := baseEnv.Compile("foo(true)")
177 if iss.Err() != nil {
178 t.Fatalf("baseEnv.Compile(foo(true)) failed: %v", iss.Err())
179 }
180
181 childEnv, err := baseEnv.Extend(
182 Function("foo",
183 DisableDeclaration(true),
184 Overload("foo_bool", []*Type{BoolType}, BoolType),
185 ),
186 )
187 if err != nil {
188 t.Fatalf("baseEnv.Extend() failed: %v", err)
189 }
190
191 _, iss = childEnv.Compile("foo(true)")
192 if iss.Err() == nil {
193 t.Errorf("childEnv.Compile(foo(true)) succeeded, wanted error")
194 }
195}
196
197
198func TestEnvCheckExtendRace(t *testing.T) {

Callers

nothing calls this directly

Calls 7

NewCustomEnvFunction · 0.85
ErrMethod · 0.80
FunctionFunction · 0.70
OverloadFunction · 0.70
DisableDeclarationFunction · 0.70
CompileMethod · 0.65
ExtendMethod · 0.45

Tested by

no test coverage detected