Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(299)

Side by Side Diff: pkg/analyzer/test/generated/test_support.dart

Issue 229653004: New analyzer snapshot with MapIterator. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pkg/analyzer/test/generated/scanner_test.dart ('k') | tests/co19/co19-analyzer2.status » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 // This code was auto-generated, is not intended to be edited, and is subject to 5 // This code was auto-generated, is not intended to be edited, and is subject to
6 // significant change. Please see the README file for more information. 6 // significant change. Please see the README file for more information.
7 7
8 library engine.test_support; 8 library engine.test_support;
9 9
10 import 'package:analyzer/src/generated/java_core.dart'; 10 import 'package:analyzer/src/generated/java_core.dart';
11 import 'package:analyzer/src/generated/java_junit.dart'; 11 import 'package:analyzer/src/generated/java_junit.dart';
12 import 'package:analyzer/src/generated/java_engine.dart'; 12 import 'package:analyzer/src/generated/java_engine.dart';
13 import 'package:analyzer/src/generated/utilities_collection.dart';
13 import 'package:analyzer/src/generated/source.dart'; 14 import 'package:analyzer/src/generated/source.dart';
14 import 'package:analyzer/src/generated/error.dart'; 15 import 'package:analyzer/src/generated/error.dart';
15 import 'package:analyzer/src/generated/scanner.dart'; 16 import 'package:analyzer/src/generated/scanner.dart';
16 import 'package:analyzer/src/generated/ast.dart' show AstNode, NodeLocator; 17 import 'package:analyzer/src/generated/ast.dart' show AstNode, NodeLocator;
17 import 'package:analyzer/src/generated/element.dart' show InterfaceType, MethodE lement, PropertyAccessorElement; 18 import 'package:analyzer/src/generated/element.dart' show InterfaceType, MethodE lement, PropertyAccessorElement;
18 import 'package:analyzer/src/generated/engine.dart'; 19 import 'package:analyzer/src/generated/engine.dart';
19 import 'package:unittest/unittest.dart' as _ut; 20 import 'package:unittest/unittest.dart' as _ut;
20 21
21 /** 22 /**
22 * Instances of the class `GatheringErrorListener` implement an error listener t hat collects 23 * Instances of the class `GatheringErrorListener` implement an error listener t hat collects
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 List<AnalysisError> list = errorsByCode[code]; 136 List<AnalysisError> list = errorsByCode[code];
136 if (list == null) { 137 if (list == null) {
137 list = new List<AnalysisError>(); 138 list = new List<AnalysisError>();
138 errorsByCode[code] = list; 139 errorsByCode[code] = list;
139 } 140 }
140 list.add(error); 141 list.add(error);
141 } 142 }
142 // 143 //
143 // Compare the expected and actual number of each type of error. 144 // Compare the expected and actual number of each type of error.
144 // 145 //
145 for (MapEntry<ErrorCode, int> entry in getMapEntrySet(expectedCounts)) { 146 for (MapIterator<ErrorCode, int> iter = SingleMapIterator.forMap(expectedCou nts); iter.moveNext();) {
146 ErrorCode code = entry.getKey(); 147 ErrorCode code = iter.key;
147 int expectedCount = entry.getValue(); 148 int expectedCount = iter.value;
148 int actualCount; 149 int actualCount;
149 List<AnalysisError> list = errorsByCode.remove(code); 150 List<AnalysisError> list = errorsByCode.remove(code);
150 if (list == null) { 151 if (list == null) {
151 actualCount = 0; 152 actualCount = 0;
152 } else { 153 } else {
153 actualCount = list.length; 154 actualCount = list.length;
154 } 155 }
155 if (actualCount != expectedCount) { 156 if (actualCount != expectedCount) {
156 if (builder.length == 0) { 157 if (builder.length == 0) {
157 builder.append("Expected "); 158 builder.append("Expected ");
158 } else { 159 } else {
159 builder.append("; "); 160 builder.append("; ");
160 } 161 }
161 builder.append(expectedCount); 162 builder.append(expectedCount);
162 builder.append(" errors of type "); 163 builder.append(" errors of type ");
163 builder.append("${code.runtimeType.toString()}.${code}"); 164 builder.append("${code.runtimeType.toString()}.${code}");
164 builder.append(", found "); 165 builder.append(", found ");
165 builder.append(actualCount); 166 builder.append(actualCount);
166 } 167 }
167 } 168 }
168 // 169 //
169 // Check that there are no more errors in the actual-errors map, otherwise, record message. 170 // Check that there are no more errors in the actual-errors map, otherwise, record message.
170 // 171 //
171 for (MapEntry<ErrorCode, List<AnalysisError>> entry in getMapEntrySet(errors ByCode)) { 172 for (MapIterator<ErrorCode, List<AnalysisError>> iter = SingleMapIterator.fo rMap(errorsByCode); iter.moveNext();) {
172 ErrorCode code = entry.getKey(); 173 ErrorCode code = iter.key;
173 List<AnalysisError> actualErrors = entry.getValue(); 174 List<AnalysisError> actualErrors = iter.value;
174 int actualCount = actualErrors.length; 175 int actualCount = actualErrors.length;
175 if (builder.length == 0) { 176 if (builder.length == 0) {
176 builder.append("Expected "); 177 builder.append("Expected ");
177 } else { 178 } else {
178 builder.append("; "); 179 builder.append("; ");
179 } 180 }
180 builder.append("0 errors of type "); 181 builder.append("0 errors of type ");
181 builder.append("${code.runtimeType.toString()}.${code}"); 182 builder.append("${code.runtimeType.toString()}.${code}");
182 builder.append(", found "); 183 builder.append(", found ");
183 builder.append(actualCount); 184 builder.append(actualCount);
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 * @param targetError the error being searched for 395 * @param targetError the error being searched for
395 * @return `true` if the error is found and removed from the list 396 * @return `true` if the error is found and removed from the list
396 */ 397 */
397 bool _foundAndRemoved(List<AnalysisError> errors, AnalysisError targetError) { 398 bool _foundAndRemoved(List<AnalysisError> errors, AnalysisError targetError) {
398 for (AnalysisError error in errors) { 399 for (AnalysisError error in errors) {
399 if (_equalErrors(error, targetError)) { 400 if (_equalErrors(error, targetError)) {
400 errors.remove(error); 401 errors.remove(error);
401 return true; 402 return true;
402 } 403 }
403 } 404 }
404 return true; 405 return false;
405 } 406 }
406 } 407 }
407 408
408 /** 409 /**
409 * The class `EngineTestCase` defines utility methods for making assertions. 410 * The class `EngineTestCase` defines utility methods for making assertions.
410 */ 411 */
411 class EngineTestCase extends JUnitTestCase { 412 class EngineTestCase extends JUnitTestCase {
412 static int _PRINT_RANGE = 6; 413 static int _PRINT_RANGE = 6;
413 414
414 /** 415 /**
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after
852 Source resolveRelative(Uri uri) { 853 Source resolveRelative(Uri uri) {
853 throw new UnsupportedOperationException(); 854 throw new UnsupportedOperationException();
854 } 855 }
855 UriKind get uriKind { 856 UriKind get uriKind {
856 throw new UnsupportedOperationException(); 857 throw new UnsupportedOperationException();
857 } 858 }
858 TimestampedData<String> get contents { 859 TimestampedData<String> get contents {
859 throw new UnsupportedOperationException(); 860 throw new UnsupportedOperationException();
860 } 861 }
861 } 862 }
OLDNEW
« no previous file with comments | « pkg/analyzer/test/generated/scanner_test.dart ('k') | tests/co19/co19-analyzer2.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698