1
- // @dart = 2.9
2
1
// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file
3
2
// for details. All rights reserved. Use of this source code is governed by a
4
3
// BSD-style license that can be found in the LICENSE file.
@@ -19,10 +18,10 @@ main(List<String> args) async {
19
18
int index = 0 ;
20
19
final int expectedPrefixLength = 'Expected: ' .length;
21
20
final int actualPrefixLength = 'Actual: ' .length;
22
- TestResult currentResult;
21
+ TestResult ? currentResult;
23
22
Map <String , List <TestResult >> testsByExpectedAndActual =
24
23
< String , List <TestResult >> {};
25
- Map <String , List <TestResult >> testsByStackTrace =
24
+ Map <String ? , List <TestResult >> testsByStackTrace =
26
25
< String , List <TestResult >> {};
27
26
while (index < output.length) {
28
27
String currentLine = output[index];
@@ -53,7 +52,7 @@ main(List<String> args) async {
53
52
}
54
53
if (hasStackTrace) {
55
54
currentResult.stackTrace = output.sublist (index + 1 , endIndex - 2 );
56
- String traceLine = currentResult.traceLine;
55
+ var traceLine = currentResult.traceLine;
57
56
testsByStackTrace
58
57
.putIfAbsent (traceLine, () => < TestResult > [])
59
58
.add (currentResult);
@@ -68,11 +67,9 @@ main(List<String> args) async {
68
67
List <String > missingCodes = < String > [];
69
68
for (List <TestResult > results in testsByExpectedAndActual.values) {
70
69
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);
76
73
}
77
74
}
78
75
}
@@ -82,15 +79,11 @@ main(List<String> args) async {
82
79
List <String > keys = testsByExpectedAndActual.keys.toList ();
83
80
keys.sort ();
84
81
for (String key in keys) {
85
- List < TestResult > results = testsByExpectedAndActual[key];
82
+ var results = testsByExpectedAndActual[key]! ;
86
83
results.sort ((first, second) => first.testName.compareTo (second.testName));
87
84
print ('$key (${results .length })' );
88
85
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 })' );
94
87
}
95
88
}
96
89
if (missingCodes.isNotEmpty) {
@@ -104,12 +97,13 @@ main(List<String> args) async {
104
97
if (testsByStackTrace.isNotEmpty) {
105
98
print ('' );
106
99
print ('Unique stack traces (${testsByStackTrace .length }):' );
107
- List < String > keys = testsByStackTrace.keys.toList ();
100
+ var keys = testsByStackTrace.keys.toList ();
108
101
keys.sort ((first, second) {
109
- return testsByStackTrace[second].length - testsByStackTrace[first].length;
102
+ return testsByStackTrace[second]! .length -
103
+ testsByStackTrace[first]! .length;
110
104
});
111
- for (String traceLine in keys) {
112
- print (' (${testsByStackTrace [traceLine ].length }) $traceLine ' );
105
+ for (var traceLine in keys) {
106
+ print (' (${testsByStackTrace [traceLine ]! .length }) $traceLine ' );
113
107
}
114
108
}
115
109
}
@@ -121,14 +115,14 @@ class TestResult {
121
115
String testName;
122
116
String expected;
123
117
String actual;
124
- String message;
125
- List <String > stackTrace;
118
+ late String message;
119
+ late List <String > stackTrace;
126
120
127
121
TestResult (this .testName, this .expected, this .actual);
128
122
129
- String get traceLine {
123
+ String ? get traceLine {
130
124
for (int i = 0 ; i < stackTrace.length; i++ ) {
131
- String traceLine = stackTrace[i];
125
+ var traceLine = stackTrace[i];
132
126
if (traceLine.startsWith (framePattern) &&
133
127
traceLine.contains ('(package:' )) {
134
128
if (traceLine.contains ('ResolutionApplier._get' ) ||
0 commit comments