| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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_helper; | 5 library dart2js.serialization_test_helper; |
| 6 | 6 |
| 7 import 'dart:collection'; | 7 import 'dart:collection'; |
| 8 import 'package:compiler/src/common/resolution.dart'; | 8 import 'package:compiler/src/common/resolution.dart'; |
| 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'; |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 | 96 |
| 97 @override | 97 @override |
| 98 bool testElements(Object object1, Object object2, String property, | 98 bool testElements(Object object1, Object object2, String property, |
| 99 Element element1, Element element2) { | 99 Element element1, Element element2) { |
| 100 return checkElementIdentities( | 100 return checkElementIdentities( |
| 101 object1, object2, property, element1, element2); | 101 object1, object2, property, element1, element2); |
| 102 } | 102 } |
| 103 | 103 |
| 104 @override | 104 @override |
| 105 bool testTypes(Object object1, Object object2, String property, | 105 bool testTypes(Object object1, Object object2, String property, |
| 106 DartType type1, DartType type2) { | 106 ResolutionDartType type1, ResolutionDartType type2) { |
| 107 return checkTypes(object1, object2, property, type1, type2); | 107 return checkTypes(object1, object2, property, type1, type2); |
| 108 } | 108 } |
| 109 | 109 |
| 110 @override | 110 @override |
| 111 bool testConstants(Object object1, Object object2, String property, | 111 bool testConstants(Object object1, Object object2, String property, |
| 112 ConstantExpression exp1, ConstantExpression exp2) { | 112 ConstantExpression exp1, ConstantExpression exp2) { |
| 113 return checkConstants(object1, object2, property, exp1, exp2); | 113 return checkConstants(object1, object2, property, exp1, exp2); |
| 114 } | 114 } |
| 115 | 115 |
| 116 @override | 116 @override |
| 117 bool testConstantValues(Object object1, Object object2, String property, | 117 bool testConstantValues(Object object1, Object object2, String property, |
| 118 ConstantValue value1, ConstantValue value2) { | 118 ConstantValue value1, ConstantValue value2) { |
| 119 return areConstantValuesEquivalent(value1, value2); | 119 return areConstantValuesEquivalent(value1, value2); |
| 120 } | 120 } |
| 121 | 121 |
| 122 @override | 122 @override |
| 123 bool testTypeLists(Object object1, Object object2, String property, | 123 bool testTypeLists(Object object1, Object object2, String property, |
| 124 List<DartType> list1, List<DartType> list2) { | 124 List<ResolutionDartType> list1, List<ResolutionDartType> list2) { |
| 125 return checkTypeLists(object1, object2, property, list1, list2); | 125 return checkTypeLists(object1, object2, property, list1, list2); |
| 126 } | 126 } |
| 127 | 127 |
| 128 @override | 128 @override |
| 129 bool testConstantLists(Object object1, Object object2, String property, | 129 bool testConstantLists(Object object1, Object object2, String property, |
| 130 List<ConstantExpression> list1, List<ConstantExpression> list2) { | 130 List<ConstantExpression> list1, List<ConstantExpression> list2) { |
| 131 return checkConstantLists(object1, object2, property, list1, list2); | 131 return checkConstantLists(object1, object2, property, list1, list2); |
| 132 } | 132 } |
| 133 | 133 |
| 134 @override | 134 @override |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 /// Uses [object1], [object2] and [property] to provide context for failures. | 294 /// Uses [object1], [object2] and [property] to provide context for failures. |
| 295 bool checkElementListIdentities(Object object1, Object object2, String property, | 295 bool checkElementListIdentities(Object object1, Object object2, String property, |
| 296 Iterable<Element> list1, Iterable<Element> list2) { | 296 Iterable<Element> list1, Iterable<Element> list2) { |
| 297 return checkListEquivalence( | 297 return checkListEquivalence( |
| 298 object1, object2, property, list1, list2, checkElementIdentities); | 298 object1, object2, property, list1, list2, checkElementIdentities); |
| 299 } | 299 } |
| 300 | 300 |
| 301 /// Checks the equivalence of [type1] and [type2]. | 301 /// Checks the equivalence of [type1] and [type2]. |
| 302 /// | 302 /// |
| 303 /// Uses [object1], [object2] and [property] to provide context for failures. | 303 /// Uses [object1], [object2] and [property] to provide context for failures. |
| 304 bool checkTypes(Object object1, Object object2, String property, DartType type1, | 304 bool checkTypes(Object object1, Object object2, String property, |
| 305 DartType type2) { | 305 ResolutionDartType type1, ResolutionDartType type2) { |
| 306 if (identical(type1, type2)) return true; | 306 if (identical(type1, type2)) return true; |
| 307 if (type1 == null || type2 == null) { | 307 if (type1 == null || type2 == null) { |
| 308 return check(object1, object2, property, type1, type2); | 308 return check(object1, object2, property, type1, type2); |
| 309 } else { | 309 } else { |
| 310 return check(object1, object2, property, type1, type2, | 310 return check(object1, object2, property, type1, type2, |
| 311 (a, b) => const TypeEquivalence(const CheckStrategy()).visit(a, b)); | 311 (a, b) => const TypeEquivalence(const CheckStrategy()).visit(a, b)); |
| 312 } | 312 } |
| 313 } | 313 } |
| 314 | 314 |
| 315 /// Checks the pair-wise equivalence of the types in [list1] and [list2]. | 315 /// Checks the pair-wise equivalence of the types in [list1] and [list2]. |
| 316 /// | 316 /// |
| 317 /// Uses [object1], [object2] and [property] to provide context for failures. | 317 /// Uses [object1], [object2] and [property] to provide context for failures. |
| 318 bool checkTypeLists(Object object1, Object object2, String property, | 318 bool checkTypeLists(Object object1, Object object2, String property, |
| 319 List<DartType> list1, List<DartType> list2) { | 319 List<ResolutionDartType> list1, List<ResolutionDartType> list2) { |
| 320 return checkListEquivalence( | 320 return checkListEquivalence( |
| 321 object1, object2, property, list1, list2, checkTypes); | 321 object1, object2, property, list1, list2, checkTypes); |
| 322 } | 322 } |
| 323 | 323 |
| 324 /// Checks the equivalence of [exp1] and [exp2]. | 324 /// Checks the equivalence of [exp1] and [exp2]. |
| 325 /// | 325 /// |
| 326 /// Uses [object1], [object2] and [property] to provide context for failures. | 326 /// Uses [object1], [object2] and [property] to provide context for failures. |
| 327 bool checkConstants(Object object1, Object object2, String property, | 327 bool checkConstants(Object object1, Object object2, String property, |
| 328 ConstantExpression exp1, ConstantExpression exp2) { | 328 ConstantExpression exp1, ConstantExpression exp2) { |
| 329 if (identical(exp1, exp2)) return true; | 329 if (identical(exp1, exp2)) return true; |
| (...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 654 } | 654 } |
| 655 | 655 |
| 656 if (index == 1 && skip != 0) { | 656 if (index == 1 && skip != 0) { |
| 657 return ['${skip}', segmentNumber(index)]; | 657 return ['${skip}', segmentNumber(index)]; |
| 658 } else if (index == count) { | 658 } else if (index == count) { |
| 659 return [segmentNumber(index - 1)]; | 659 return [segmentNumber(index - 1)]; |
| 660 } else { | 660 } else { |
| 661 return [segmentNumber(index - 1), segmentNumber(index)]; | 661 return [segmentNumber(index - 1), segmentNumber(index)]; |
| 662 } | 662 } |
| 663 } | 663 } |
| OLD | NEW |