| 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/dart_types.dart'; | 10 import 'package:compiler/src/dart_types.dart'; |
| (...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 429 | 429 |
| 430 testResolutionImpactEquivalence(impact1, impact2, const CheckStrategy()); | 430 testResolutionImpactEquivalence(impact1, impact2, const CheckStrategy()); |
| 431 } | 431 } |
| 432 | 432 |
| 433 void checkSets( | 433 void checkSets( |
| 434 Iterable set1, | 434 Iterable set1, |
| 435 Iterable set2, | 435 Iterable set2, |
| 436 String messagePrefix, | 436 String messagePrefix, |
| 437 bool sameElement(a, b), | 437 bool sameElement(a, b), |
| 438 {bool failOnUnfound: true, | 438 {bool failOnUnfound: true, |
| 439 bool failOnExtra: true, | |
| 440 bool verbose: false, | 439 bool verbose: false, |
| 441 void onSameElement(a, b)}) { | 440 void onSameElement(a, b)}) { |
| 442 List<List> common = <List>[]; | 441 List<List> common = <List>[]; |
| 443 List unfound = []; | 442 List unfound = []; |
| 444 Set remaining = computeSetDifference( | 443 Set remaining = computeSetDifference( |
| 445 set1, set2, common, unfound, | 444 set1, set2, common, unfound, |
| 446 sameElement: sameElement, | 445 sameElement: sameElement, |
| 447 checkElements: onSameElement); | 446 checkElements: onSameElement); |
| 448 StringBuffer sb = new StringBuffer(); | 447 StringBuffer sb = new StringBuffer(); |
| 449 sb.write("$messagePrefix:"); | 448 sb.write("$messagePrefix:"); |
| 450 if (verbose) { | 449 if (verbose) { |
| 451 sb.write("\n Common:\n ${common.join('\n ')}"); | 450 sb.write("\n Common:\n ${common.join('\n ')}"); |
| 452 } | 451 } |
| 453 if (unfound.isNotEmpty || verbose) { | 452 if (unfound.isNotEmpty || verbose) { |
| 454 sb.write("\n Unfound:\n ${unfound.join('\n ')}"); | 453 sb.write("\n Unfound:\n ${unfound.join('\n ')}"); |
| 455 } | 454 } |
| 456 if (remaining.isNotEmpty || verbose) { | 455 if (remaining.isNotEmpty || verbose) { |
| 457 sb.write("\n Extra: \n ${remaining.join('\n ')}"); | 456 sb.write("\n Extra: \n ${remaining.join('\n ')}"); |
| 458 } | 457 } |
| 459 String message = sb.toString(); | 458 String message = sb.toString(); |
| 460 if (unfound.isNotEmpty || remaining.isNotEmpty) { | 459 if (unfound.isNotEmpty || remaining.isNotEmpty) { |
| 461 | 460 |
| 462 if ((failOnUnfound && unfound.isNotEmpty) || | 461 if (failOnUnfound || remaining.isNotEmpty) { |
| 463 (failOnExtra && remaining.isNotEmpty)) { | |
| 464 Expect.fail(message); | 462 Expect.fail(message); |
| 465 } else { | 463 } else { |
| 466 print(message); | 464 print(message); |
| 467 } | 465 } |
| 468 } else if (verbose) { | 466 } else if (verbose) { |
| 469 print(message); | 467 print(message); |
| 470 } | 468 } |
| 471 } | 469 } |
| 472 | 470 |
| 473 String defaultToString(obj) => '$obj'; | 471 String defaultToString(obj) => '$obj'; |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 546 (mismatch.isNotEmpty && failOnMismatch) || | 544 (mismatch.isNotEmpty && failOnMismatch) || |
| 547 remaining.isNotEmpty) { | 545 remaining.isNotEmpty) { |
| 548 Expect.fail(message); | 546 Expect.fail(message); |
| 549 } else { | 547 } else { |
| 550 print(message); | 548 print(message); |
| 551 } | 549 } |
| 552 } else if (verbose) { | 550 } else if (verbose) { |
| 553 print(message); | 551 print(message); |
| 554 } | 552 } |
| 555 } | 553 } |
| OLD | NEW |