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

Side by Side Diff: pkg/analyzer/test/src/summary/resynthesize_test.dart

Issue 1995763003: Build top-level variables and property accessors lazily. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 7 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
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 library test.src.serialization.elements_test; 5 library test.src.serialization.elements_test;
6 6
7 import 'dart:convert'; 7 import 'dart:convert';
8 8
9 import 'package:analyzer/dart/ast/ast.dart'; 9 import 'package:analyzer/dart/ast/ast.dart';
10 import 'package:analyzer/dart/constant/value.dart'; 10 import 'package:analyzer/dart/constant/value.dart';
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 compareTypes(r.type, o.type, desc); 253 compareTypes(r.type, o.type, desc);
254 expect(r.hasBeenInferred, o.hasBeenInferred, reason: desc); 254 expect(r.hasBeenInferred, o.hasBeenInferred, reason: desc);
255 } 255 }
256 256
257 void compareCompilationUnitElements(CompilationUnitElementImpl resynthesized, 257 void compareCompilationUnitElements(CompilationUnitElementImpl resynthesized,
258 CompilationUnitElementImpl original) { 258 CompilationUnitElementImpl original) {
259 String desc = 'Compilation unit ${original.source.uri}'; 259 String desc = 'Compilation unit ${original.source.uri}';
260 compareUriReferencedElements(resynthesized, original, desc); 260 compareUriReferencedElements(resynthesized, original, desc);
261 expect(resynthesized.source, original.source); 261 expect(resynthesized.source, original.source);
262 expect(resynthesized.librarySource, original.librarySource); 262 expect(resynthesized.librarySource, original.librarySource);
263 expect(resynthesized.types.length, original.types.length); 263 expect(resynthesized.types.length, original.types.length, reason: 'types');
Paul Berry 2016/05/19 11:27:30 Please include `$desc` in the reason (e.g. `reason
scheglov 2016/05/19 16:54:57 Done.
264 for (int i = 0; i < resynthesized.types.length; i++) { 264 for (int i = 0; i < resynthesized.types.length; i++) {
265 compareClassElements( 265 compareClassElements(
266 resynthesized.types[i], original.types[i], original.types[i].name); 266 resynthesized.types[i], original.types[i], original.types[i].name);
267 } 267 }
268 expect(resynthesized.topLevelVariables.length, 268 expect(resynthesized.topLevelVariables.length,
269 original.topLevelVariables.length); 269 original.topLevelVariables.length,
270 reason: 'topLevelVariables');
270 for (int i = 0; i < resynthesized.topLevelVariables.length; i++) { 271 for (int i = 0; i < resynthesized.topLevelVariables.length; i++) {
271 String name = resynthesized.topLevelVariables[i].name; 272 String name = resynthesized.topLevelVariables[i].name;
272 compareTopLevelVariableElements( 273 compareTopLevelVariableElements(
273 resynthesized.topLevelVariables[i], 274 resynthesized.topLevelVariables[i],
274 original.topLevelVariables 275 original.topLevelVariables
275 .singleWhere((TopLevelVariableElement e) => e.name == name), 276 .singleWhere((TopLevelVariableElement e) => e.name == name),
276 'variable $name'); 277 'variable $name');
277 } 278 }
278 expect(resynthesized.functions.length, original.functions.length); 279 expect(resynthesized.functions.length, original.functions.length,
280 reason: 'functions');
279 for (int i = 0; i < resynthesized.functions.length; i++) { 281 for (int i = 0; i < resynthesized.functions.length; i++) {
280 compareFunctionElements(resynthesized.functions[i], original.functions[i], 282 compareFunctionElements(resynthesized.functions[i], original.functions[i],
281 'function ${original.functions[i].name}'); 283 'function ${original.functions[i].name}');
282 } 284 }
283 expect(resynthesized.functionTypeAliases.length, 285 expect(resynthesized.functionTypeAliases.length,
284 original.functionTypeAliases.length); 286 original.functionTypeAliases.length,
287 reason: 'functionTypeAliases');
285 for (int i = 0; i < resynthesized.functionTypeAliases.length; i++) { 288 for (int i = 0; i < resynthesized.functionTypeAliases.length; i++) {
286 compareFunctionTypeAliasElements( 289 compareFunctionTypeAliasElements(
287 resynthesized.functionTypeAliases[i], 290 resynthesized.functionTypeAliases[i],
288 original.functionTypeAliases[i], 291 original.functionTypeAliases[i],
289 original.functionTypeAliases[i].name); 292 original.functionTypeAliases[i].name);
290 } 293 }
291 expect(resynthesized.enums.length, original.enums.length); 294 expect(resynthesized.enums.length, original.enums.length, reason: 'enums');
292 for (int i = 0; i < resynthesized.enums.length; i++) { 295 for (int i = 0; i < resynthesized.enums.length; i++) {
293 compareClassElements( 296 compareClassElements(
294 resynthesized.enums[i], original.enums[i], original.enums[i].name); 297 resynthesized.enums[i], original.enums[i], original.enums[i].name);
295 } 298 }
296 expect(resynthesized.accessors.length, original.accessors.length); 299 expect(resynthesized.accessors.length, original.accessors.length,
300 reason: 'accessors');
297 for (int i = 0; i < resynthesized.accessors.length; i++) { 301 for (int i = 0; i < resynthesized.accessors.length; i++) {
298 String name = resynthesized.accessors[i].name; 302 String name = resynthesized.accessors[i].name;
299 if (original.accessors[i].isGetter) { 303 if (original.accessors[i].isGetter) {
300 comparePropertyAccessorElements( 304 comparePropertyAccessorElements(
301 resynthesized.accessors[i], 305 resynthesized.accessors[i],
302 original.accessors 306 original.accessors
303 .singleWhere((PropertyAccessorElement e) => e.name == name), 307 .singleWhere((PropertyAccessorElement e) => e.name == name),
304 'getter $name'); 308 'getter $name');
305 } else { 309 } else {
306 comparePropertyAccessorElements( 310 comparePropertyAccessorElements(
(...skipping 4215 matching lines...) Expand 10 before | Expand all | Expand 10 after
4522 fail('Unexpectedly tried to get unlinked summary for $uri'); 4526 fail('Unexpectedly tried to get unlinked summary for $uri');
4523 } 4527 }
4524 return serializedUnit; 4528 return serializedUnit;
4525 } 4529 }
4526 4530
4527 @override 4531 @override
4528 bool hasLibrarySummary(String uri) { 4532 bool hasLibrarySummary(String uri) {
4529 return true; 4533 return true;
4530 } 4534 }
4531 } 4535 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698