(t *testing.T)
| 473 | } |
| 474 | |
| 475 | func TestNavigableComprehensionExpr(t *testing.T) { |
| 476 | checked := mustTypeCheck(t, `[true].exists(i, i)`) |
| 477 | expr := ast.NavigateAST(checked) |
| 478 | if expr.Kind() != ast.ComprehensionKind { |
| 479 | t.Errorf("Kind() got %v, wanted ComprehensionKind", expr.Kind()) |
| 480 | } |
| 481 | comp := expr.AsComprehension() |
| 482 | iterRange := comp.IterRange() |
| 483 | if len(ast.MatchSubset([]ast.NavigableExpr{iterRange.(ast.NavigableExpr)}, ast.ConstantValueMatcher())) != 1 { |
| 484 | t.Errorf("IterRange() returned a non-constant list") |
| 485 | } |
| 486 | if comp.IterVar() != "i" { |
| 487 | t.Errorf("IterVar() got %s, wanted 'i'", comp.IterVar()) |
| 488 | } |
| 489 | if comp.HasIterVar2() { |
| 490 | t.Error("HasIterVar2() returned true, wanted false") |
| 491 | } |
| 492 | if comp.IterVar2() != "" { |
| 493 | t.Errorf("IterVar2() returned %s, wanted empty string", comp.IterVar2()) |
| 494 | } |
| 495 | if comp.AccuVar() != "@result" { |
| 496 | t.Errorf("AccuVar() got %s, wanted '@result'", comp.AccuVar()) |
| 497 | } |
| 498 | if comp.AccuInit().AsLiteral() != types.False { |
| 499 | t.Errorf("AccuInit() returned %v, wanted false", comp.AccuInit().AsLiteral()) |
| 500 | } |
| 501 | if comp.Result().Kind() != ast.IdentKind { |
| 502 | t.Errorf("Result() returned %v, wanted ident", comp.Result()) |
| 503 | } |
| 504 | if comp.LoopCondition().Kind() != ast.CallKind { |
| 505 | t.Errorf("LoopCondition() returned %v, wanted call", comp.LoopCondition()) |
| 506 | } |
| 507 | if comp.LoopStep().Kind() != ast.CallKind { |
| 508 | t.Errorf("LoopStep() returned %v, wanted call", comp.LoopStep()) |
| 509 | } |
| 510 | if comp.Result().AsIdent() != "@result" { |
| 511 | t.Errorf("AsIdent() returned %v, wanted @result", comp.Result().AsIdent()) |
| 512 | } |
| 513 | } |
| 514 | |
| 515 | func TestNavigableSelectExpr(t *testing.T) { |
| 516 | checked := mustTypeCheck(t, `msg.single_int32`) |
nothing calls this directly
no test coverage detected