| OLD | NEW |
| 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_model_test; | 5 library dart2js.serialization_model_test; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:io'; | 8 import 'dart:io'; |
| 9 import 'package:async_helper/async_helper.dart'; | 9 import 'package:async_helper/async_helper.dart'; |
| 10 import 'package:expect/expect.dart'; | 10 import 'package:expect/expect.dart'; |
| (...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 | 311 |
| 312 void checkClassHierarchyNodes( | 312 void checkClassHierarchyNodes( |
| 313 ClosedWorld closedWorld1, | 313 ClosedWorld closedWorld1, |
| 314 ClosedWorld closedWorld2, | 314 ClosedWorld closedWorld2, |
| 315 ClassHierarchyNode node1, | 315 ClassHierarchyNode node1, |
| 316 ClassHierarchyNode node2, | 316 ClassHierarchyNode node2, |
| 317 {bool verbose: false}) { | 317 {bool verbose: false}) { |
| 318 if (verbose) { | 318 if (verbose) { |
| 319 print('Checking $node1 vs $node2'); | 319 print('Checking $node1 vs $node2'); |
| 320 } | 320 } |
| 321 Expect.isTrue(areElementsEquivalent(node1.cls, node2.cls), | 321 ClassElement cls1 = node1.cls; |
| 322 "Element identity mismatch for ${node1.cls} vs ${node2.cls}."); | 322 ClassElement cls2 = node2.cls; |
| 323 Expect.isTrue(areElementsEquivalent(cls1, cls2), |
| 324 "Element identity mismatch for ${cls1} vs ${cls2}."); |
| 323 Expect.equals( | 325 Expect.equals( |
| 324 node1.isDirectlyInstantiated, | 326 node1.isDirectlyInstantiated, |
| 325 node2.isDirectlyInstantiated, | 327 node2.isDirectlyInstantiated, |
| 326 "Value mismatch for 'isDirectlyInstantiated' " | 328 "Value mismatch for 'isDirectlyInstantiated' " |
| 327 "for ${node1.cls} vs ${node2.cls}."); | 329 "for ${cls1} vs ${cls2}."); |
| 328 Expect.equals( | 330 Expect.equals( |
| 329 node1.isIndirectlyInstantiated, | 331 node1.isIndirectlyInstantiated, |
| 330 node2.isIndirectlyInstantiated, | 332 node2.isIndirectlyInstantiated, |
| 331 "Value mismatch for 'isIndirectlyInstantiated' " | 333 "Value mismatch for 'isIndirectlyInstantiated' " |
| 332 "for ${node1.cls} vs ${node2.cls}."); | 334 "for ${node1.cls} vs ${node2.cls}."); |
| 333 // TODO(johnniwinther): Enforce a canonical and stable order on direct | 335 // TODO(johnniwinther): Enforce a canonical and stable order on direct |
| 334 // subclasses. | 336 // subclasses. |
| 335 for (ClassHierarchyNode child in node1.directSubclasses) { | 337 for (ClassHierarchyNode child in node1.directSubclasses) { |
| 336 bool found = false; | 338 bool found = false; |
| 337 for (ClassHierarchyNode other in node2.directSubclasses) { | 339 for (ClassHierarchyNode other in node2.directSubclasses) { |
| 338 if (areElementsEquivalent(child.cls, other.cls)) { | 340 ClassElement child1 = child.cls; |
| 341 ClassElement child2 = other.cls; |
| 342 if (areElementsEquivalent(child1, child2)) { |
| 339 checkClassHierarchyNodes(closedWorld1, closedWorld2, child, other, | 343 checkClassHierarchyNodes(closedWorld1, closedWorld2, child, other, |
| 340 verbose: verbose); | 344 verbose: verbose); |
| 341 found = true; | 345 found = true; |
| 342 break; | 346 break; |
| 343 } | 347 } |
| 344 } | 348 } |
| 345 if (!found) { | 349 if (!found) { |
| 346 if (child.isInstantiated) { | 350 if (child.isInstantiated) { |
| 347 print('Missing subclass ${child.cls} of ${node1.cls} ' | 351 print('Missing subclass ${child.cls} of ${node1.cls} ' |
| 348 'in ${node2.directSubclasses}'); | 352 'in ${node2.directSubclasses}'); |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 450 } | 454 } |
| 451 | 455 |
| 452 bool areInstancesEquivalent(Instance instance1, Instance instance2, | 456 bool areInstancesEquivalent(Instance instance1, Instance instance2, |
| 453 bool typeEquivalence(ResolutionDartType a, ResolutionDartType b)) { | 457 bool typeEquivalence(ResolutionDartType a, ResolutionDartType b)) { |
| 454 ResolutionInterfaceType type1 = instance1.type; | 458 ResolutionInterfaceType type1 = instance1.type; |
| 455 ResolutionInterfaceType type2 = instance2.type; | 459 ResolutionInterfaceType type2 = instance2.type; |
| 456 return typeEquivalence(type1, type2) && | 460 return typeEquivalence(type1, type2) && |
| 457 instance1.kind == instance2.kind && | 461 instance1.kind == instance2.kind && |
| 458 instance1.isRedirection == instance2.isRedirection; | 462 instance1.isRedirection == instance2.isRedirection; |
| 459 } | 463 } |
| OLD | NEW |