Files
sdk/pkg
Robert Nystrom 527cf27633 Smarter error reporting in static error tests.
The old code to report the difference between a tests's expected and
actual errors was easily confused by missing or unexpected errors.
Those would misalign the lists of errors causing all subsequent errors
to be reported as wrong. This fixes that. Before, this test containing
a single unexpected error:

  main() {
    int a = "s";
    //      ^^^
    // [analyzer] STATIC_TYPE_WARNING.INVALID_ASSIGNMENT

    unknownFunction();

    int b = "s";
    //      ^^^
    // [analyzer] STATIC_TYPE_WARNING.INVALID_ASSIGNMENT

    int c = "s";
    //      ^^^
    // [analyzer] STATIC_TYPE_WARNING.INVALID_ASSIGNMENT
  }

Would cause the test runner to output:

  incorrect static errors:
  Error at line 6, column 3, length 15
  - Expected on line 8 but was on 6.
  - Expected on column 11 but was on 3.
  - Expected length 3 but was 15.
  - Expected error code STATIC_TYPE_WARNING.INVALID_ASSIGNMENT but was STATIC_TYPE_WARNING.UNDEFINED_FUNCTION.

  Error at line 8, column 11, length 3
  - Expected on line 12 but was on 8.

  reported unexpected static errors:
  Error at line 12, column 11, length 3
  STATIC_TYPE_WARNING.INVALID_ASSIGNMENT

Oof. Now it prints:

  static error failures:
  Unexpected static error at line 6, column 3, length 15:
  - Had error code STATIC_TYPE_WARNING.UNDEFINED_FUNCTION.

Change-Id: I1b22b2a542c6f8049f92fda3627ae69144bfd52a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/114240
Auto-Submit: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Leaf Petersen <leafp@google.com>
Commit-Queue: Bob Nystrom <rnystrom@google.com>
2019-08-22 23:32:53 +00:00
..
2019-08-20 22:18:43 +00:00
2019-08-19 17:52:57 +00:00
2019-07-12 15:51:23 +00:00