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 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 /// | 233 /// |
234 /// Uses [object1], [object2] and [property] to provide context for failures. | 234 /// Uses [object1], [object2] and [property] to provide context for failures. |
235 bool checkSetEquivalence(var object1, var object2, String property, | 235 bool checkSetEquivalence(var object1, var object2, String property, |
236 Iterable set1, Iterable set2, bool sameElement(a, b), | 236 Iterable set1, Iterable set2, bool sameElement(a, b), |
237 {void onSameElement(a, b)}) { | 237 {void onSameElement(a, b)}) { |
238 List<List> common = <List>[]; | 238 List<List> common = <List>[]; |
239 List unfound = []; | 239 List unfound = []; |
240 Set remaining = computeSetDifference(set1, set2, common, unfound, | 240 Set remaining = computeSetDifference(set1, set2, common, unfound, |
241 sameElement: sameElement, checkElements: onSameElement); | 241 sameElement: sameElement, checkElements: onSameElement); |
242 if (unfound.isNotEmpty || remaining.isNotEmpty) { | 242 if (unfound.isNotEmpty || remaining.isNotEmpty) { |
243 String message = "Set mismatch for `$property` on $object1 vs $object2: \n" | 243 String message = "Set mismatch for `$property` on\n" |
| 244 "$object1\n vs\n$object2:\n" |
244 "Common:\n ${common.join('\n ')}\n" | 245 "Common:\n ${common.join('\n ')}\n" |
245 "Unfound:\n ${unfound.join('\n ')}\n" | 246 "Unfound:\n ${unfound.join('\n ')}\n" |
246 "Extra: \n ${remaining.join('\n ')}"; | 247 "Extra: \n ${remaining.join('\n ')}"; |
247 throw message; | 248 throw message; |
248 } | 249 } |
249 return true; | 250 return true; |
250 } | 251 } |
251 | 252 |
252 /// Check equivalence of the two iterables, [set1] and [set1], as sets using | 253 /// Check equivalence of the two iterables, [set1] and [set1], as sets using |
253 /// [elementEquivalence] to compute the pair-wise equivalence. | 254 /// [elementEquivalence] to compute the pair-wise equivalence. |
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
641 } | 642 } |
642 | 643 |
643 if (index == 1 && skip != 0) { | 644 if (index == 1 && skip != 0) { |
644 return ['${skip}', segmentNumber(index)]; | 645 return ['${skip}', segmentNumber(index)]; |
645 } else if (index == count) { | 646 } else if (index == count) { |
646 return [segmentNumber(index - 1)]; | 647 return [segmentNumber(index - 1)]; |
647 } else { | 648 } else { |
648 return [segmentNumber(index - 1), segmentNumber(index)]; | 649 return [segmentNumber(index - 1), segmentNumber(index)]; |
649 } | 650 } |
650 } | 651 } |
OLD | NEW |