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

Side by Side Diff: tests/compiler/dart2js/serialization/equivalence_test.dart

Issue 2150533002: Serialize data for LibraryElement.getImportsFor (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 years, 5 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 dart2js.serialization_test; 5 library dart2js.serialization_test;
6 6
7 import 'dart:io'; 7 import 'dart:io';
8 import '../memory_compiler.dart'; 8 import '../memory_compiler.dart';
9 import 'package:async_helper/async_helper.dart'; 9 import 'package:async_helper/async_helper.dart';
10 import 'package:compiler/src/commandline_options.dart'; 10 import 'package:compiler/src/commandline_options.dart';
(...skipping 29 matching lines...) Expand all
40 genericMethod<T>() {} 40 genericMethod<T>() {}
41 41
42 class Class1 { 42 class Class1 {
43 factory Class1.deferred() = prefix.DeferredClass; 43 factory Class1.deferred() = prefix.DeferredClass;
44 factory Class1.unresolved() = Unresolved; 44 factory Class1.unresolved() = Unresolved;
45 } 45 }
46 ''', 46 ''',
47 'deferred_library.dart': ''' 47 'deferred_library.dart': '''
48 class DeferredClass { 48 class DeferredClass {
49 } 49 }
50
51 get getter => 0;
52 set setter(_) {}
53 get property => 0;
54 set property(_) {}
50 ''', 55 ''',
51 'library.dart': ''' 56 'library.dart': '''
52 class Type {} 57 class Type {}
53 ''', 58 ''',
54 }; 59 };
55 60
56 main(List<String> arguments) { 61 main(List<String> arguments) {
57 // Ensure that we can print out constant expressions. 62 // Ensure that we can print out constant expressions.
58 DEBUG_MODE = true; 63 DEBUG_MODE = true;
59 64
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 check(object1, object2, property, 295 check(object1, object2, property,
291 metadata1, metadata2, areMetadataAnnotationsEquivalent); 296 metadata1, metadata2, areMetadataAnnotationsEquivalent);
292 } 297 }
293 298
294 /// Visitor that checks for equivalence of [Element] properties. 299 /// Visitor that checks for equivalence of [Element] properties.
295 class ElementPropertyEquivalence extends BaseElementVisitor<dynamic, Element> { 300 class ElementPropertyEquivalence extends BaseElementVisitor<dynamic, Element> {
296 const ElementPropertyEquivalence(); 301 const ElementPropertyEquivalence();
297 302
298 void visit(Element element1, Element element2) { 303 void visit(Element element1, Element element2) {
299 if (element1 == null && element2 == null) return; 304 if (element1 == null && element2 == null) return;
305 if (element1 == null || element2 == null) {
306 throw currentCheck;
307 }
300 element1 = element1.declaration; 308 element1 = element1.declaration;
301 element2 = element2.declaration; 309 element2 = element2.declaration;
302 if (element1 == element2) return; 310 if (element1 == element2) return;
303 check(element1, element2, 'kind', element1.kind, element2.kind); 311 check(element1, element2, 'kind', element1.kind, element2.kind);
304 element1.accept(this, element2); 312 element1.accept(this, element2);
305 check(element1, element2, 'isSynthesized', 313 check(element1, element2, 'isSynthesized',
306 element1.isSynthesized, element2.isSynthesized); 314 element1.isSynthesized, element2.isSynthesized);
307 check(element1, element2, 'isLocal', 315 check(element1, element2, 'isLocal',
308 element1.isLocal, element2.isLocal); 316 element1.isLocal, element2.isLocal);
309 check(element1, element2, 'isFinal', 317 check(element1, element2, 'isFinal',
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 LibrarySerializer.getCompilationUnits(element1), 361 LibrarySerializer.getCompilationUnits(element1),
354 LibrarySerializer.getCompilationUnits(element2)); 362 LibrarySerializer.getCompilationUnits(element2));
355 363
356 checkElementLists( 364 checkElementLists(
357 element1, element2, 'imports', 365 element1, element2, 'imports',
358 LibrarySerializer.getImports(element1), 366 LibrarySerializer.getImports(element1),
359 LibrarySerializer.getImports(element2)); 367 LibrarySerializer.getImports(element2));
360 checkElementLists( 368 checkElementLists(
361 element1, element2, 'exports', element1.exports, element2.exports); 369 element1, element2, 'exports', element1.exports, element2.exports);
362 370
371 List<Element> imported1 = LibrarySerializer.getImportedElements(element1);
372 List<Element> imported2 = LibrarySerializer.getImportedElements(element2);
363 checkElementListIdentities( 373 checkElementListIdentities(
364 element1, element2, 'importScope', 374 element1, element2, 'importScope', imported1, imported2);
365 LibrarySerializer.getImportedElements(element1),
366 LibrarySerializer.getImportedElements(element2));
367 375
368 checkElementListIdentities( 376 checkElementListIdentities(
369 element1, element2, 'exportScope', 377 element1, element2, 'exportScope',
370 LibrarySerializer.getExportedElements(element1), 378 LibrarySerializer.getExportedElements(element1),
371 LibrarySerializer.getExportedElements(element2)); 379 LibrarySerializer.getExportedElements(element2));
380
381 for (int index = 0; index < imported1.length; index++) {
382 checkImportsFor(element1, element2, imported1[index], imported2[index]);
383 }
384 }
385
386 void checkImportsFor(Element element1, Element element2,
387 Element import1, Element import2) {
388 List<ImportElement> imports1 = element1.library.getImportsFor(import1);
389 List<ImportElement> imports2 = element2.library.getImportsFor(import2);
390 checkElementListIdentities(
391 element1, element2, 'importsFor($import1/$import2)',
392 imports1, imports2);
372 } 393 }
373 394
374 @override 395 @override
375 void visitCompilationUnitElement(CompilationUnitElement element1, 396 void visitCompilationUnitElement(CompilationUnitElement element1,
376 CompilationUnitElement element2) { 397 CompilationUnitElement element2) {
377 check(element1, element2, 398 check(element1, element2,
378 'name', 399 'name',
379 element1.name, element2.name); 400 element1.name, element2.name);
380 checkElementIdentities( 401 checkElementIdentities(
381 element1, element2, 'library', 402 element1, element2, 'library',
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after
848 element1.deferredImport, element2.deferredImport); 869 element1.deferredImport, element2.deferredImport);
849 if (element1.isDeferred) { 870 if (element1.isDeferred) {
850 checkElementProperties(element1, element2, 871 checkElementProperties(element1, element2,
851 'loadLibrary', element1.loadLibrary, element2.loadLibrary); 872 'loadLibrary', element1.loadLibrary, element2.loadLibrary);
852 } 873 }
853 element1.forEachLocalMember((Element member1) { 874 element1.forEachLocalMember((Element member1) {
854 String name = member1.name; 875 String name = member1.name;
855 Element member2 = element2.lookupLocalMember(name); 876 Element member2 = element2.lookupLocalMember(name);
856 checkElementIdentities(element1, element2, 'lookupLocalMember:$name', 877 checkElementIdentities(element1, element2, 'lookupLocalMember:$name',
857 member1, member2); 878 member1, member2);
879 checkImportsFor(element1, element2, member1, member2);
858 }); 880 });
859 } 881 }
860 882
861 @override 883 @override
862 void visitErroneousElement( 884 void visitErroneousElement(
863 ErroneousElement element1, ErroneousElement element2) { 885 ErroneousElement element1, ErroneousElement element2) {
864 check(element1, element2, 'messageKind', 886 check(element1, element2, 'messageKind',
865 element1.messageKind, element2.messageKind); 887 element1.messageKind, element2.messageKind);
866 } 888 }
867 } 889 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698