(t *testing.T)
| 550 | } |
| 551 | |
| 552 | func TestNavigableComprehensionExpr(t *testing.T) { |
| 553 | checked := mustTypeCheck(t, `[true].exists(i, i)`) |
| 554 | expr := ast.NavigateAST(checked) |
| 555 | if expr.Kind() != ast.ComprehensionKind { |
| 556 | t.Errorf("Kind() got %v, wanted ComprehensionKind", expr.Kind()) |
| 557 | } |
| 558 | comp := expr.AsComprehension() |
| 559 | iterRange := comp.IterRange() |
| 560 | if len(ast.MatchSubset([]ast.NavigableExpr{iterRange.(ast.NavigableExpr)}, ast.ConstantValueMatcher())) != 1 { |
| 561 | t.Errorf("IterRange() returned a non-constant list") |
| 562 | } |
| 563 | if comp.IterVar() != "i" { |
| 564 | t.Errorf("IterVar() got %s, wanted 'i'", comp.IterVar()) |
| 565 | } |
| 566 | if comp.HasIterVar2() { |
| 567 | t.Error("HasIterVar2() returned true, wanted false") |
| 568 | } |
| 569 | if comp.IterVar2() != "" { |
| 570 | t.Errorf("IterVar2() returned %s, wanted empty string", comp.IterVar2()) |
| 571 | } |
| 572 | if comp.AccuVar() != "@result" { |
| 573 | t.Errorf("AccuVar() got %s, wanted '@result'", comp.AccuVar()) |
| 574 | } |
| 575 | if comp.AccuInit().AsLiteral() != types.False { |
| 576 | t.Errorf("AccuInit() returned %v, wanted false", comp.AccuInit().AsLiteral()) |
| 577 | } |
| 578 | if comp.Result().Kind() != ast.IdentKind { |
| 579 | t.Errorf("Result() returned %v, wanted ident", comp.Result()) |
| 580 | } |
| 581 | if comp.LoopCondition().Kind() != ast.CallKind { |
| 582 | t.Errorf("LoopCondition() returned %v, wanted call", comp.LoopCondition()) |
| 583 | } |
| 584 | if comp.LoopStep().Kind() != ast.CallKind { |
| 585 | t.Errorf("LoopStep() returned %v, wanted call", comp.LoopStep()) |
| 586 | } |
| 587 | if comp.Result().AsIdent() != "@result" { |
| 588 | t.Errorf("AsIdent() returned %v, wanted @result", comp.Result().AsIdent()) |
| 589 | } |
| 590 | } |
| 591 | |
| 592 | func TestNavigableSelectExpr(t *testing.T) { |
| 593 | checked := mustTypeCheck(t, `msg.single_int32`) |
nothing calls this directly
no test coverage detected