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

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

Issue 2012163003: Fix several element properties in serialization. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: dartfmt Created 4 years, 6 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 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 LibraryElement library1, LibraryElement library2) { 128 LibraryElement library1, LibraryElement library2) {
129 checkElementProperties(object1, object2, property, library1, library2); 129 checkElementProperties(object1, object2, property, library1, library2);
130 } 130 }
131 131
132 /// Check the equivalence of [element1] and [element2] and their properties. 132 /// Check the equivalence of [element1] and [element2] and their properties.
133 /// 133 ///
134 /// Uses [object1], [object2] and [property] to provide context for failures. 134 /// Uses [object1], [object2] and [property] to provide context for failures.
135 checkElementProperties( 135 checkElementProperties(
136 Object object1, object2, String property, 136 Object object1, object2, String property,
137 Element element1, Element element2) { 137 Element element1, Element element2) {
138 currentCheck =
139 new Check(currentCheck, object1, object2, property, element1, element2);
138 const ElementPropertyEquivalence().visit(element1, element2); 140 const ElementPropertyEquivalence().visit(element1, element2);
141 currentCheck = currentCheck.parent;
139 } 142 }
140 143
141 /// Checks the equivalence of [constructor1] and [constructor2]. 144 /// Checks the equivalence of [constructor1] and [constructor2].
142 void constantConstructorEquivalence(ConstantConstructor constructor1, 145 void constantConstructorEquivalence(ConstantConstructor constructor1,
143 ConstantConstructor constructor2) { 146 ConstantConstructor constructor2) {
144 const ConstantConstructorEquivalence().visit(constructor1, constructor2); 147 const ConstantConstructorEquivalence().visit(constructor1, constructor2);
145 } 148 }
146 149
147 /// Visitor that checks the equivalence of [ConstantConstructor]s. 150 /// Visitor that checks the equivalence of [ConstantConstructor]s.
148 class ConstantConstructorEquivalence 151 class ConstantConstructorEquivalence
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 check(element1, element2, 'kind', element1.kind, element2.kind); 251 check(element1, element2, 'kind', element1.kind, element2.kind);
249 element1.accept(this, element2); 252 element1.accept(this, element2);
250 check(element1, element2, 'isSynthesized', 253 check(element1, element2, 'isSynthesized',
251 element1.isSynthesized, element2.isSynthesized); 254 element1.isSynthesized, element2.isSynthesized);
252 check(element1, element2, 'isLocal', 255 check(element1, element2, 'isLocal',
253 element1.isLocal, element2.isLocal); 256 element1.isLocal, element2.isLocal);
254 check(element1, element2, 'isFinal', 257 check(element1, element2, 'isFinal',
255 element1.isFinal, element2.isFinal); 258 element1.isFinal, element2.isFinal);
256 check(element1, element2, 'isConst', 259 check(element1, element2, 'isConst',
257 element1.isConst, element2.isConst); 260 element1.isConst, element2.isConst);
261 check(element1, element2, 'isAbstract',
262 element1.isAbstract, element2.isAbstract);
263 check(element1, element2, 'isStatic',
264 element1.isStatic, element2.isStatic);
265 check(element1, element2, 'isTopLevel',
266 element1.isTopLevel, element2.isTopLevel);
267 check(element1, element2, 'isClassMember',
268 element1.isClassMember, element2.isClassMember);
269 check(element1, element2, 'isInstanceMember',
270 element1.isInstanceMember, element2.isInstanceMember);
258 } 271 }
259 272
260 @override 273 @override
261 void visitElement(Element e, Element arg) { 274 void visitElement(Element e, Element arg) {
262 throw new UnsupportedError("Unsupported element $e"); 275 throw new UnsupportedError("Unsupported element $e");
263 } 276 }
264 277
265 @override 278 @override
266 void visitLibraryElement(LibraryElement element1, LibraryElement element2) { 279 void visitLibraryElement(LibraryElement element1, LibraryElement element2) {
267 checkElementIdentities(null, null, null, element1, element2); 280 checkElementIdentities(null, null, null, element1, element2);
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 String message = 366 String message =
354 'Missing member for $member1 in\n ${members2.join('\n ')}'; 367 'Missing member for $member1 in\n ${members2.join('\n ')}';
355 if (member1.isAbstractField) { 368 if (member1.isAbstractField) {
356 // TODO(johnniwinther): Ensure abstract fields are handled correctly. 369 // TODO(johnniwinther): Ensure abstract fields are handled correctly.
357 //print(message); 370 //print(message);
358 continue; 371 continue;
359 } else { 372 } else {
360 throw message; 373 throw message;
361 } 374 }
362 } 375 }
376 currentCheck = new Check(currentCheck, element1, element1,
377 'member:$name', member1, member2);
363 visit(member1, member2); 378 visit(member1, member2);
379 currentCheck = currentCheck.parent;
364 } 380 }
365 } 381 }
366 382
367 @override 383 @override
368 void visitClassElement(ClassElement element1, ClassElement element2) { 384 void visitClassElement(ClassElement element1, ClassElement element2) {
369 checkElementIdentities(null, null, null, element1, element2); 385 checkElementIdentities(null, null, null, element1, element2);
370 check(element1, element2, 'name', 386 check(element1, element2, 'name',
371 element1.name, element2.name); 387 element1.name, element2.name);
372 check(element1, element2, 'sourcePosition', 388 if (!element1.isUnnamedMixinApplication) {
389 check(element1, element2, 'sourcePosition',
373 element1.sourcePosition, element2.sourcePosition); 390 element1.sourcePosition, element2.sourcePosition);
391 } else {
392 check(element1, element2, 'sourcePosition.uri',
393 element1.sourcePosition.uri, element2.sourcePosition.uri);
394 }
374 checkElementIdentities( 395 checkElementIdentities(
375 element1, element2, 'library', 396 element1, element2, 'library',
376 element1.library, element2.library); 397 element1.library, element2.library);
377 checkElementIdentities( 398 checkElementIdentities(
378 element1, element2, 'compilationUnit', 399 element1, element2, 'compilationUnit',
379 element1.compilationUnit, element2.compilationUnit); 400 element1.compilationUnit, element2.compilationUnit);
401 checkTypeLists(
402 element1, element2, 'typeVariables',
403 element1.typeVariables, element2.typeVariables);
404 checkTypes(
405 element1, element2, 'thisType',
406 element1.thisType, element2.thisType);
407 checkTypes(
408 element1, element2, 'rawType',
409 element1.rawType, element2.rawType);
380 check(element1, element2, 'isObject', 410 check(element1, element2, 'isObject',
381 element1.isObject, element2.isObject); 411 element1.isObject, element2.isObject);
382 checkTypeLists(element1, element2, 'typeVariables', 412 checkTypeLists(element1, element2, 'typeVariables',
383 element1.typeVariables, element2.typeVariables); 413 element1.typeVariables, element2.typeVariables);
384 check(element1, element2, 'isAbstract', 414 check(element1, element2, 'isAbstract',
385 element1.isAbstract, element2.isAbstract); 415 element1.isAbstract, element2.isAbstract);
386 check(element1, element2, 'isUnnamedMixinApplication', 416 check(element1, element2, 'isUnnamedMixinApplication',
387 element1.isUnnamedMixinApplication, element2.isUnnamedMixinApplication); 417 element1.isUnnamedMixinApplication, element2.isUnnamedMixinApplication);
388 check(element1, element2, 'isEnumClass', 418 check(element1, element2, 'isEnumClass',
389 element1.isEnumClass, element2.isEnumClass); 419 element1.isEnumClass, element2.isEnumClass);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
429 List<ConstructorElement> getConstructors(ClassElement cls) { 459 List<ConstructorElement> getConstructors(ClassElement cls) {
430 return cls.implementation.constructors.map((c) => c.declaration).toList(); 460 return cls.implementation.constructors.map((c) => c.declaration).toList();
431 } 461 }
432 462
433 checkElementLists( 463 checkElementLists(
434 element1, element2, 'constructors', 464 element1, element2, 'constructors',
435 getConstructors(element1), 465 getConstructors(element1),
436 getConstructors(element2)); 466 getConstructors(element2));
437 467
438 visitMembers(element1, element2); 468 visitMembers(element1, element2);
469
470 ClassElement superclass1 = element1.superclass;
471 ClassElement superclass2 = element2.superclass;
472 while (superclass1 != null && superclass1.isMixinApplication) {
473 checkElementProperties(element1, element2, 'supermixin',
474 superclass1, superclass2);
475 superclass1 = superclass1.superclass;
476 superclass2 = superclass2.superclass;
477 }
439 } 478 }
440 479
441 @override 480 @override
442 void visitFieldElement(FieldElement element1, FieldElement element2) { 481 void visitFieldElement(FieldElement element1, FieldElement element2) {
443 checkElementIdentities(null, null, null, element1, element2); 482 checkElementIdentities(null, null, null, element1, element2);
444 check(element1, element2, 'name', 483 check(element1, element2, 'name',
445 element1.name, element2.name); 484 element1.name, element2.name);
446 check(element1, element2, 'sourcePosition', 485 check(element1, element2, 'sourcePosition',
447 element1.sourcePosition, element2.sourcePosition); 486 element1.sourcePosition, element2.sourcePosition);
448 checkTypes( 487 checkTypes(
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
543 @override 582 @override
544 void visitConstructorElement(ConstructorElement element1, 583 void visitConstructorElement(ConstructorElement element1,
545 ConstructorElement element2) { 584 ConstructorElement element2) {
546 checkElementIdentities(null, null, null, element1, element2); 585 checkElementIdentities(null, null, null, element1, element2);
547 checkElementIdentities( 586 checkElementIdentities(
548 element1, element2, 'enclosingClass', 587 element1, element2, 'enclosingClass',
549 element1.enclosingClass, element2.enclosingClass); 588 element1.enclosingClass, element2.enclosingClass);
550 check( 589 check(
551 element1, element2, 'name', 590 element1, element2, 'name',
552 element1.name, element2.name); 591 element1.name, element2.name);
553 check(element1, element2, 'sourcePosition', 592 if (!element1.isSynthesized) {
593 check(element1, element2, 'sourcePosition',
554 element1.sourcePosition, element2.sourcePosition); 594 element1.sourcePosition, element2.sourcePosition);
595 } else {
596 check(element1, element2, 'sourcePosition.uri',
597 element1.sourcePosition.uri, element2.sourcePosition.uri);
598 }
555 checkListEquivalence( 599 checkListEquivalence(
556 element1, element2, 'parameters', 600 element1, element2, 'parameters',
557 element1.parameters, element2.parameters, 601 element1.parameters, element2.parameters,
558 checkElementProperties); 602 checkElementProperties);
559 checkTypes( 603 checkTypes(
560 element1, element2, 'type', 604 element1, element2, 'type',
561 element1.type, element2.type); 605 element1.type, element2.type);
562 check(element1, element2, 'isExternal', 606 check(element1, element2, 'isExternal',
563 element1.isExternal, element2.isExternal); 607 element1.isExternal, element2.isExternal);
564 if (element1.isConst && !element1.isExternal) { 608 if (element1.isConst && !element1.isExternal) {
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
701 void visitPrefixElement(PrefixElement element1, PrefixElement element2) { 745 void visitPrefixElement(PrefixElement element1, PrefixElement element2) {
702 check( 746 check(
703 element1, element2, 'isDeferred', 747 element1, element2, 'isDeferred',
704 element1.isDeferred, element2.isDeferred); 748 element1.isDeferred, element2.isDeferred);
705 checkElementIdentities( 749 checkElementIdentities(
706 element1, element2, 'importedLibrary', 750 element1, element2, 'importedLibrary',
707 element1.deferredImport, element2.deferredImport); 751 element1.deferredImport, element2.deferredImport);
708 // TODO(johnniwinther): Check members. 752 // TODO(johnniwinther): Check members.
709 } 753 }
710 } 754 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/serialization/modelz.dart ('k') | tests/compiler/dart2js/serialization/test_helper.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698