| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 part of matcher; | 5 part of matcher; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * Returns a matcher that matches empty strings, maps or collections. | 8 * Returns a matcher that matches empty strings, maps or collections. |
| 9 */ | 9 */ |
| 10 const Matcher isEmpty = const _Empty(); | 10 const Matcher isEmpty = const _Empty(); |
| (...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 458 | 458 |
| 459 /** A matcher for functions that throw RangeError. */ | 459 /** A matcher for functions that throw RangeError. */ |
| 460 const Matcher throwsRangeError = | 460 const Matcher throwsRangeError = |
| 461 const Throws(isRangeError); | 461 const Throws(isRangeError); |
| 462 | 462 |
| 463 class _RangeError extends TypeMatcher { | 463 class _RangeError extends TypeMatcher { |
| 464 const _RangeError() : super("RangeError"); | 464 const _RangeError() : super("RangeError"); |
| 465 bool matches(item, MatchState matchState) => item is RangeError; | 465 bool matches(item, MatchState matchState) => item is RangeError; |
| 466 } | 466 } |
| 467 | 467 |
| 468 // Temporary matcher for deprecated IndexOutOfRangeException. | |
| 469 /** A matcher for IndexOutOfRangeExceptions. */ | |
| 470 const isIndexOutOfRangeException = const _IndexOutOfRangeException(); | |
| 471 | |
| 472 /** A matcher for functions that throw IndexOutOfRangeException. */ | |
| 473 const Matcher throwsIndexOutOfRangeException = | |
| 474 const Throws(isIndexOutOfRangeException); | |
| 475 | |
| 476 class _IndexOutOfRangeException extends TypeMatcher { | |
| 477 const _IndexOutOfRangeException() : super("IndexOutOfRangeException"); | |
| 478 bool matches(item, MatchState matchState) => item is IndexOutOfRangeException; | |
| 479 } | |
| 480 | |
| 481 /** A matcher for NoSuchMethodErrors. */ | 468 /** A matcher for NoSuchMethodErrors. */ |
| 482 const isNoSuchMethodError = const _NoSuchMethodError(); | 469 const isNoSuchMethodError = const _NoSuchMethodError(); |
| 483 | 470 |
| 484 /** A matcher for functions that throw NoSuchMethodError. */ | 471 /** A matcher for functions that throw NoSuchMethodError. */ |
| 485 const Matcher throwsNoSuchMethodError = | 472 const Matcher throwsNoSuchMethodError = |
| 486 const Throws(isNoSuchMethodError); | 473 const Throws(isNoSuchMethodError); |
| 487 | 474 |
| 488 class _NoSuchMethodError extends TypeMatcher { | 475 class _NoSuchMethodError extends TypeMatcher { |
| 489 const _NoSuchMethodError() : super("NoSuchMethodError"); | 476 const _NoSuchMethodError() : super("NoSuchMethodError"); |
| 490 bool matches(item, MatchState matchState) => item is NoSuchMethodError; | 477 bool matches(item, MatchState matchState) => item is NoSuchMethodError; |
| 491 } | 478 } |
| 492 | 479 |
| 493 /** A matcher for UnimplementedErrors. */ | 480 /** A matcher for UnimplementedErrors. */ |
| 494 const isUnimplementedError = const _UnimplementedError(); | 481 const isUnimplementedError = const _UnimplementedError(); |
| 495 | 482 |
| 496 /** A matcher for functions that throw Exception. */ | 483 /** A matcher for functions that throw Exception. */ |
| 497 const Matcher throwsUnimplementedError = | 484 const Matcher throwsUnimplementedError = |
| 498 const Throws(isUnimplementedError); | 485 const Throws(isUnimplementedError); |
| 499 | 486 |
| 500 class _UnimplementedError extends TypeMatcher { | 487 class _UnimplementedError extends TypeMatcher { |
| 501 const _UnimplementedError() : super("UnimplementedError"); | 488 const _UnimplementedError() : super("UnimplementedError"); |
| 502 bool matches(item, MatchState matchState) => item is UnimplementedError; | 489 bool matches(item, MatchState matchState) => item is UnimplementedError; |
| 503 } | 490 } |
| 504 | 491 |
| 505 // Temporary matcher until NotImplementedException is removed. | |
| 506 /** A matcher for NotImplementedExceptions. */ | |
| 507 const isNotImplementedException = isUnimplementedError; | |
| 508 | |
| 509 /** A matcher for functions that throw Exception. */ | |
| 510 const Matcher throwsNotImplementedException = | |
| 511 const Throws(isUnimplementedError); | |
| 512 | |
| 513 | |
| 514 /** A matcher for NullPointerExceptions. */ | 492 /** A matcher for NullPointerExceptions. */ |
| 515 const isNullPointerException = const _NullPointerException(); | 493 const isNullPointerException = const _NullPointerException(); |
| 516 | 494 |
| 517 /** A matcher for functions that throw NotNullPointerException. */ | 495 /** A matcher for functions that throw NotNullPointerException. */ |
| 518 const Matcher throwsNullPointerException = | 496 const Matcher throwsNullPointerException = |
| 519 const Throws(isNullPointerException); | 497 const Throws(isNullPointerException); |
| 520 | 498 |
| 521 class _NullPointerException extends TypeMatcher { | 499 class _NullPointerException extends TypeMatcher { |
| 522 const _NullPointerException() : super("NullPointerException"); | 500 const _NullPointerException() : super("NullPointerException"); |
| 523 bool matches(item, MatchState matchState) => item is NullPointerException; | 501 bool matches(item, MatchState matchState) => item is NullPointerException; |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 711 description.add(_featureDescription).add(' ').addDescriptionOf(_matcher); | 689 description.add(_featureDescription).add(' ').addDescriptionOf(_matcher); |
| 712 | 690 |
| 713 Description describeMismatch(item, Description mismatchDescription, | 691 Description describeMismatch(item, Description mismatchDescription, |
| 714 MatchState matchState, bool verbose) { | 692 MatchState matchState, bool verbose) { |
| 715 mismatchDescription.add(_featureName).add(' '); | 693 mismatchDescription.add(_featureName).add(' '); |
| 716 _matcher.describeMismatch(matchState.state['feature'], mismatchDescription, | 694 _matcher.describeMismatch(matchState.state['feature'], mismatchDescription, |
| 717 matchState.state['innerState'], verbose); | 695 matchState.state['innerState'], verbose); |
| 718 return mismatchDescription; | 696 return mismatchDescription; |
| 719 } | 697 } |
| 720 } | 698 } |
| OLD | NEW |