(t *testing.T)
| 534 | } |
| 535 | |
| 536 | func TestNavigableSelectExpr_TestOnly(t *testing.T) { |
| 537 | checked := mustTypeCheck(t, `has(msg.single_int32)`) |
| 538 | expr := ast.NavigateAST(checked) |
| 539 | if expr.Kind() != ast.SelectKind { |
| 540 | t.Errorf("Kind() got %v, wanted SelectKind", expr.Kind()) |
| 541 | } |
| 542 | sel := expr.AsSelect() |
| 543 | if sel.FieldName() != "single_int32" { |
| 544 | t.Errorf("FieldName() got %s, wanted single_int32", sel.FieldName()) |
| 545 | } |
| 546 | if sel.Operand().Kind() != ast.IdentKind { |
| 547 | t.Fatalf("Operand() kind got %v, wanted ident", sel.Operand().Kind()) |
| 548 | } |
| 549 | if sel.Operand().AsIdent() != "msg" { |
| 550 | t.Errorf("Operand() got %v, wanted ident 'msg'", sel.Operand()) |
| 551 | } |
| 552 | if !sel.IsTestOnly() { |
| 553 | t.Error("IsTestOnly() got false, wanted true") |
| 554 | } |
| 555 | } |
| 556 | |
| 557 | func mustTypeCheck(t testing.TB, expr string, opts ...any) *ast.AST { |
| 558 | t.Helper() |
nothing calls this directly
no test coverage detected