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

Function TestHasExtension

common/ast/ast_test.go:421–433  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

419}
420
421func TestHasExtension(t *testing.T) {
422 info := ast.NewSourceInfo(common.NewStringSource("true", "test-only"))
423 info.AddExtension(ast.NewExtension("json_name", ast.NewExtensionVersion(1, 1), ast.ComponentRuntime))
424 if !info.HasExtension("json_name", ast.NewExtensionVersion(1, 0)) {
425 t.Error("info.HasExtension('json_name', 1.0) returned false for v1.1")
426 }
427 if info.HasExtension("json_name", ast.NewExtensionVersion(2, 1)) {
428 t.Error("info.HasExtension() returned true for v2.1 when v1.1 configured")
429 }
430 if info.HasExtension("unrelated", ast.NewExtensionVersion(0, 0)) {
431 t.Error("info.HasExtension() returned true for unrelated extensions not set on AST")
432 }
433}
434
435func mockRelativeSource(t testing.TB, text string, lineOffsets []int32, baseLocation common.Location) common.Source {
436 t.Helper()

Callers

nothing calls this directly

Calls 7

AddExtensionMethod · 0.95
HasExtensionMethod · 0.95
NewSourceInfoFunction · 0.92
NewStringSourceFunction · 0.92
NewExtensionFunction · 0.92
NewExtensionVersionFunction · 0.92
ErrorMethod · 0.45

Tested by

no test coverage detected