(t *testing.T)
| 611 | } |
| 612 | |
| 613 | func TestNavigableSelectExpr_TestOnly(t *testing.T) { |
| 614 | checked := mustTypeCheck(t, `has(msg.single_int32)`) |
| 615 | expr := ast.NavigateAST(checked) |
| 616 | if expr.Kind() != ast.SelectKind { |
| 617 | t.Errorf("Kind() got %v, wanted SelectKind", expr.Kind()) |
| 618 | } |
| 619 | sel := expr.AsSelect() |
| 620 | if sel.FieldName() != "single_int32" { |
| 621 | t.Errorf("FieldName() got %s, wanted single_int32", sel.FieldName()) |
| 622 | } |
| 623 | if sel.Operand().Kind() != ast.IdentKind { |
| 624 | t.Fatalf("Operand() kind got %v, wanted ident", sel.Operand().Kind()) |
| 625 | } |
| 626 | if sel.Operand().AsIdent() != "msg" { |
| 627 | t.Errorf("Operand() got %v, wanted ident 'msg'", sel.Operand()) |
| 628 | } |
| 629 | if !sel.IsTestOnly() { |
| 630 | t.Error("IsTestOnly() got false, wanted true") |
| 631 | } |
| 632 | } |
| 633 | |
| 634 | func mustTypeCheck(t testing.TB, expr string, opts ...any) *ast.AST { |
| 635 | t.Helper() |
nothing calls this directly
no test coverage detected