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

Function TestHasExtension

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

Source from the content-addressed store, hash-verified

429}
430
431func TestHasExtension(t *testing.T) {
432 info := ast.NewSourceInfo(common.NewStringSource("true", "test-only"))
433 info.AddExtension(ast.NewExtension("json_name", ast.NewExtensionVersion(1, 1), ast.ComponentRuntime))
434 if !info.HasExtension("json_name", ast.NewExtensionVersion(1, 0)) {
435 t.Error("info.HasExtension('json_name', 1.0) returned false for v1.1")
436 }
437 if info.HasExtension("json_name", ast.NewExtensionVersion(2, 1)) {
438 t.Error("info.HasExtension() returned true for v2.1 when v1.1 configured")
439 }
440 if info.HasExtension("unrelated", ast.NewExtensionVersion(0, 0)) {
441 t.Error("info.HasExtension() returned true for unrelated extensions not set on AST")
442 }
443}
444
445func mockRelativeSource(t testing.TB, text string, lineOffsets []int32, baseLocation common.Location) common.Source {
446 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