1- // @dart = 2.9
21// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file
32// for details. All rights reserved. Use of this source code is governed by a
43// BSD-style license that can be found in the LICENSE file.
@@ -19,10 +18,10 @@ main(List<String> args) async {
1918 int index = 0 ;
2019 final int expectedPrefixLength = 'Expected: ' .length;
2120 final int actualPrefixLength = 'Actual: ' .length;
22- TestResult currentResult;
21+ TestResult ? currentResult;
2322 Map <String , List <TestResult >> testsByExpectedAndActual =
2423 < String , List <TestResult >> {};
25- Map <String , List <TestResult >> testsByStackTrace =
24+ Map <String ? , List <TestResult >> testsByStackTrace =
2625 < String , List <TestResult >> {};
2726 while (index < output.length) {
2827 String currentLine = output[index];
@@ -53,7 +52,7 @@ main(List<String> args) async {
5352 }
5453 if (hasStackTrace) {
5554 currentResult.stackTrace = output.sublist (index + 1 , endIndex - 2 );
56- String traceLine = currentResult.traceLine;
55+ var traceLine = currentResult.traceLine;
5756 testsByStackTrace
5857 .putIfAbsent (traceLine, () => < TestResult > [])
5958 .add (currentResult);
@@ -68,11 +67,9 @@ main(List<String> args) async {
6867 List <String > missingCodes = < String > [];
6968 for (List <TestResult > results in testsByExpectedAndActual.values) {
7069 for (TestResult result in results) {
71- String message = result.message;
72- if (message != null ) {
73- if (message.startsWith ('Bad state: Unable to convert (' )) {
74- missingCodes.add (message);
75- }
70+ var message = result.message;
71+ if (message.startsWith ('Bad state: Unable to convert (' )) {
72+ missingCodes.add (message);
7673 }
7774 }
7875 }
@@ -82,15 +79,11 @@ main(List<String> args) async {
8279 List <String > keys = testsByExpectedAndActual.keys.toList ();
8380 keys.sort ();
8481 for (String key in keys) {
85- List < TestResult > results = testsByExpectedAndActual[key];
82+ var results = testsByExpectedAndActual[key]! ;
8683 results.sort ((first, second) => first.testName.compareTo (second.testName));
8784 print ('$key (${results .length })' );
8885 for (TestResult result in results) {
89- if (result.message == null ) {
90- print (' ${result .testName }' );
91- } else {
92- print (' ${result .testName } (${result .message })' );
93- }
86+ print (' ${result .testName } (${result .message })' );
9487 }
9588 }
9689 if (missingCodes.isNotEmpty) {
@@ -104,12 +97,13 @@ main(List<String> args) async {
10497 if (testsByStackTrace.isNotEmpty) {
10598 print ('' );
10699 print ('Unique stack traces (${testsByStackTrace .length }):' );
107- List < String > keys = testsByStackTrace.keys.toList ();
100+ var keys = testsByStackTrace.keys.toList ();
108101 keys.sort ((first, second) {
109- return testsByStackTrace[second].length - testsByStackTrace[first].length;
102+ return testsByStackTrace[second]! .length -
103+ testsByStackTrace[first]! .length;
110104 });
111- for (String traceLine in keys) {
112- print (' (${testsByStackTrace [traceLine ].length }) $traceLine ' );
105+ for (var traceLine in keys) {
106+ print (' (${testsByStackTrace [traceLine ]! .length }) $traceLine ' );
113107 }
114108 }
115109}
@@ -121,14 +115,14 @@ class TestResult {
121115 String testName;
122116 String expected;
123117 String actual;
124- String message;
125- List <String > stackTrace;
118+ late String message;
119+ late List <String > stackTrace;
126120
127121 TestResult (this .testName, this .expected, this .actual);
128122
129- String get traceLine {
123+ String ? get traceLine {
130124 for (int i = 0 ; i < stackTrace.length; i++ ) {
131- String traceLine = stackTrace[i];
125+ var traceLine = stackTrace[i];
132126 if (traceLine.startsWith (framePattern) &&
133127 traceLine.contains ('(package:' )) {
134128 if (traceLine.contains ('ResolutionApplier._get' ) ||
0 commit comments