(t *testing.T)
| 429 | } |
| 430 | |
| 431 | func 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 | info.AddExtension(ast.NewExtension("cel_block", ast.NewExtensionVersion(1, 1), ast.ComponentRuntime)) |
| 435 | // Adding the same extension again should be a no-op (deduplicated). |
| 436 | info.AddExtension(ast.NewExtension("cel_block", ast.NewExtensionVersion(1, 1), ast.ComponentRuntime)) |
| 437 | if len(info.Extensions()) != 2 { |
| 438 | t.Errorf("len(info.Extensions()) got %d, wanted 2", len(info.Extensions())) |
| 439 | } |
| 440 | if !info.HasExtension("json_name", ast.NewExtensionVersion(1, 0)) { |
| 441 | t.Error("info.HasExtension('json_name', 1.0) returned false for v1.1") |
| 442 | } |
| 443 | if !info.HasExtension("cel_block", ast.NewExtensionVersion(1, 1)) { |
| 444 | t.Error("info.HasExtension('cel_block', 1.1) returned false for v1.1") |
| 445 | } |
| 446 | if info.HasExtension("json_name", ast.NewExtensionVersion(2, 1)) { |
| 447 | t.Error("info.HasExtension() returned true for v2.1 when v1.1 configured") |
| 448 | } |
| 449 | if info.HasExtension("unrelated", ast.NewExtensionVersion(0, 0)) { |
| 450 | t.Error("info.HasExtension() returned true for unrelated extensions not set on AST") |
| 451 | } |
| 452 | } |
| 453 | |
| 454 | func mockRelativeSource(t testing.TB, text string, lineOffsets []int32, baseLocation common.Location) common.Source { |
| 455 | t.Helper() |
nothing calls this directly
no test coverage detected