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

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

Issue 2873113004: Add equivalence check of NativeData and InterceptorData (Closed)
Patch Set: Created 3 years, 7 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) 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 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 throw message; 221 throw message;
222 } 222 }
223 return true; 223 return true;
224 } 224 }
225 225
226 /// Check equivalence of the two iterables, [set1] and [set1], as sets using 226 /// Check equivalence of the two iterables, [set1] and [set1], as sets using
227 /// [elementEquivalence] to compute the pair-wise equivalence. 227 /// [elementEquivalence] to compute the pair-wise equivalence.
228 /// 228 ///
229 /// Uses [object1], [object2] and [property] to provide context for failures. 229 /// Uses [object1], [object2] and [property] to provide context for failures.
230 bool checkMapEquivalence(var object1, var object2, String property, Map map1, 230 bool checkMapEquivalence(var object1, var object2, String property, Map map1,
231 Map map2, bool sameKey(a, b), bool sameValue(a, b)) { 231 Map map2, bool sameKey(a, b), bool sameValue(a, b),
232 {bool allowExtra: false}) {
232 List<List> common = <List>[]; 233 List<List> common = <List>[];
233 List unfound = []; 234 List unfound = [];
234 Set remaining = computeSetDifference(map1.keys, map2.keys, common, unfound, 235 Set extra = computeSetDifference(map1.keys, map2.keys, common, unfound,
235 sameElement: sameKey); 236 sameElement: sameKey);
236 if (unfound.isNotEmpty || remaining.isNotEmpty) { 237 if (unfound.isNotEmpty || (!allowExtra && extra.isNotEmpty)) {
237 String message = 238 String message =
238 "Map key mismatch for `$property` on $object1 vs $object2: \n" 239 "Map key mismatch for `$property` on $object1 vs $object2: \n"
239 "Common:\n ${common.join('\n ')}\n" 240 "Common:\n ${common.join('\n ')}\n"
240 "Unfound:\n ${unfound.join('\n ')}\n" 241 "Unfound:\n ${unfound.join('\n ')}\n"
241 "Extra: \n ${remaining.join('\n ')}"; 242 "Extra: \n ${extra.join('\n ')}";
242 throw message; 243 throw message;
243 } 244 }
244 for (List pair in common) { 245 for (List pair in common) {
245 check(pair[0], pair[1], 'Map value for `$property`', map1[pair[0]], 246 check(pair[0], pair[1], 'Map value for `$property`', map1[pair[0]],
246 map2[pair[1]], sameValue); 247 map2[pair[1]], sameValue);
247 } 248 }
248 return true; 249 return true;
249 } 250 }
250 251
251 /// Checks the equivalence of the identity (but not properties) of [element1] 252 /// Checks the equivalence of the identity (but not properties) of [element1]
(...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after
809 strategy.testTypeLists(a, b, 'namedParameterTypes', 810 strategy.testTypeLists(a, b, 'namedParameterTypes',
810 aType.namedParameterTypes, b.namedParameterTypes); 811 aType.namedParameterTypes, b.namedParameterTypes);
811 } 812 }
812 return false; 813 return false;
813 default: 814 default:
814 throw new UnsupportedError('Unsupported equivalence: ' 815 throw new UnsupportedError('Unsupported equivalence: '
815 '$a (${a.runtimeType}) vs $b (${b.runtimeType})'); 816 '$a (${a.runtimeType}) vs $b (${b.runtimeType})');
816 } 817 }
817 } 818 }
818 } 819 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698