| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 test.integration.analysis; | 5 library test.integration.analysis; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:collection'; | 8 import 'dart:collection'; |
| 9 import 'dart:convert'; | 9 import 'dart:convert'; |
| 10 import 'dart:io'; | 10 import 'dart:io'; |
| (...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 449 } else { | 449 } else { |
| 450 return iterableMatcher.describeMismatch(item, mismatchDescription, | 450 return iterableMatcher.describeMismatch(item, mismatchDescription, |
| 451 matchState, verbose); | 451 matchState, verbose); |
| 452 } | 452 } |
| 453 } | 453 } |
| 454 } | 454 } |
| 455 | 455 |
| 456 Matcher isListOf(Matcher elementMatcher) => new _ListOf(elementMatcher); | 456 Matcher isListOf(Matcher elementMatcher) => new _ListOf(elementMatcher); |
| 457 | 457 |
| 458 /** | 458 /** |
| 459 * Matcher that matches a union of different types, each of which is described |
| 460 * by a matcher. |
| 461 */ |
| 462 class _OneOf extends Matcher { |
| 463 /** |
| 464 * Matchers for the individual choices. |
| 465 */ |
| 466 final List<Matcher> choiceMatchers; |
| 467 |
| 468 _OneOf(this.choiceMatchers); |
| 469 |
| 470 @override |
| 471 bool matches(item, Map matchState) { |
| 472 for (Matcher choiceMatcher in choiceMatchers) { |
| 473 Map subState = {}; |
| 474 if (choiceMatcher.matches(item, subState)) { |
| 475 return true; |
| 476 } |
| 477 } |
| 478 return false; |
| 479 } |
| 480 |
| 481 @override |
| 482 Description describe(Description description) { |
| 483 for (int i = 0; i < choiceMatchers.length; i++) { |
| 484 if (i != 0) { |
| 485 if (choiceMatchers.length == 2) { |
| 486 description = description.add(' or '); |
| 487 } else { |
| 488 description = description.add(', '); |
| 489 if (i == choiceMatchers.length - 1) { |
| 490 description = description.add('or '); |
| 491 } |
| 492 } |
| 493 } |
| 494 description = description.addDescriptionOf(choiceMatchers[i]); |
| 495 } |
| 496 return description; |
| 497 } |
| 498 } |
| 499 |
| 500 Matcher isOneOf(List<Matcher> choiceMatchers) => new _OneOf(choiceMatchers); |
| 501 |
| 502 /** |
| 459 * Matcher that matches a map of objects, where each key/value pair in the | 503 * Matcher that matches a map of objects, where each key/value pair in the |
| 460 * map satisies the given key and value matchers. | 504 * map satisies the given key and value matchers. |
| 461 */ | 505 */ |
| 462 class _MapOf extends _RecursiveMatcher { | 506 class _MapOf extends _RecursiveMatcher { |
| 463 /** | 507 /** |
| 464 * Matcher which every key in the map must satisfy. | 508 * Matcher which every key in the map must satisfy. |
| 465 */ | 509 */ |
| 466 final Matcher keyMatcher; | 510 final Matcher keyMatcher; |
| 467 | 511 |
| 468 /** | 512 /** |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 732 */ | 776 */ |
| 733 void _recordStdio(String line) { | 777 void _recordStdio(String line) { |
| 734 double elapsedTime = _time.elapsedTicks / _time.frequency; | 778 double elapsedTime = _time.elapsedTicks / _time.frequency; |
| 735 line = "$elapsedTime: $line"; | 779 line = "$elapsedTime: $line"; |
| 736 if (_debuggingStdio) { | 780 if (_debuggingStdio) { |
| 737 print(line); | 781 print(line); |
| 738 } | 782 } |
| 739 _recordedStdio.add(line); | 783 _recordedStdio.add(line); |
| 740 } | 784 } |
| 741 } | 785 } |
| OLD | NEW |