| OLD | NEW |
| 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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 /// General equivalence test functions. | 5 /// General equivalence test functions. |
| 6 | 6 |
| 7 library dart2js.equivalence.helpers; | 7 library dart2js.equivalence.helpers; |
| 8 | 8 |
| 9 import 'package:compiler/src/constants/expressions.dart'; | 9 import 'package:compiler/src/constants/expressions.dart'; |
| 10 import 'package:compiler/src/constants/values.dart'; | 10 import 'package:compiler/src/constants/values.dart'; |
| 11 import 'package:compiler/src/elements/elements.dart'; | |
| 12 import 'package:compiler/src/elements/entities.dart'; | 11 import 'package:compiler/src/elements/entities.dart'; |
| 13 import 'package:compiler/src/elements/resolution_types.dart'; | 12 import 'package:compiler/src/elements/resolution_types.dart'; |
| 14 import 'package:compiler/src/elements/types.dart'; | 13 import 'package:compiler/src/elements/types.dart'; |
| 15 import 'package:compiler/src/serialization/equivalence.dart'; | 14 import 'package:compiler/src/serialization/equivalence.dart'; |
| 16 import 'package:expect/expect.dart'; | 15 import 'package:expect/expect.dart'; |
| 17 | 16 |
| 18 Check currentCheck; | 17 Check currentCheck; |
| 19 | 18 |
| 20 class Check { | 19 class Check { |
| 21 final Check parent; | 20 final Check parent; |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 map2[pair[1]], sameValue); | 241 map2[pair[1]], sameValue); |
| 243 } | 242 } |
| 244 return true; | 243 return true; |
| 245 } | 244 } |
| 246 | 245 |
| 247 /// Checks the equivalence of the identity (but not properties) of [element1] | 246 /// Checks the equivalence of the identity (but not properties) of [element1] |
| 248 /// and [element2]. | 247 /// and [element2]. |
| 249 /// | 248 /// |
| 250 /// Uses [object1], [object2] and [property] to provide context for failures. | 249 /// Uses [object1], [object2] and [property] to provide context for failures. |
| 251 bool checkElementIdentities(Object object1, Object object2, String property, | 250 bool checkElementIdentities(Object object1, Object object2, String property, |
| 252 Element element1, Element element2) { | 251 Entity element1, Entity element2) { |
| 253 if (identical(element1, element2)) return true; | 252 if (identical(element1, element2)) return true; |
| 254 return check( | 253 return check( |
| 255 object1, object2, property, element1, element2, areElementsEquivalent); | 254 object1, object2, property, element1, element2, areElementsEquivalent); |
| 256 } | 255 } |
| 257 | 256 |
| 258 /// Checks the pair-wise equivalence of the identity (but not properties) of the | 257 /// Checks the pair-wise equivalence of the identity (but not properties) of the |
| 259 /// elements in [list] and [list2]. | 258 /// elements in [list] and [list2]. |
| 260 /// | 259 /// |
| 261 /// Uses [object1], [object2] and [property] to provide context for failures. | 260 /// Uses [object1], [object2] and [property] to provide context for failures. |
| 262 bool checkElementListIdentities(Object object1, Object object2, String property, | 261 bool checkElementListIdentities(Object object1, Object object2, String property, |
| 263 Iterable<Element> list1, Iterable<Element> list2) { | 262 Iterable<Entity> list1, Iterable<Entity> list2) { |
| 264 return checkListEquivalence( | 263 return checkListEquivalence( |
| 265 object1, object2, property, list1, list2, checkElementIdentities); | 264 object1, object2, property, list1, list2, checkElementIdentities); |
| 266 } | 265 } |
| 267 | 266 |
| 268 /// Checks the equivalence of [type1] and [type2]. | 267 /// Checks the equivalence of [type1] and [type2]. |
| 269 /// | 268 /// |
| 270 /// Uses [object1], [object2] and [property] to provide context for failures. | 269 /// Uses [object1], [object2] and [property] to provide context for failures. |
| 271 bool checkTypes(Object object1, Object object2, String property, | 270 bool checkTypes(Object object1, Object object2, String property, |
| 272 ResolutionDartType type1, ResolutionDartType type2) { | 271 ResolutionDartType type1, ResolutionDartType type2) { |
| 273 if (identical(type1, type2)) return true; | 272 if (identical(type1, type2)) return true; |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 478 (mismatch.isNotEmpty && failOnMismatch) || | 477 (mismatch.isNotEmpty && failOnMismatch) || |
| 479 remaining.isNotEmpty) { | 478 remaining.isNotEmpty) { |
| 480 Expect.fail(message); | 479 Expect.fail(message); |
| 481 } else { | 480 } else { |
| 482 print(message); | 481 print(message); |
| 483 } | 482 } |
| 484 } else if (verbose) { | 483 } else if (verbose) { |
| 485 print(message); | 484 print(message); |
| 486 } | 485 } |
| 487 } | 486 } |
| OLD | NEW |