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 library matcher.core_matchers; | 5 library matcher.core_matchers; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 | 8 |
9 import 'description.dart'; | 9 import 'description.dart'; |
10 import 'expect.dart'; | 10 import 'expect.dart'; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
57 bool matches(item, Map matchState) => item == true; | 57 bool matches(item, Map matchState) => item == true; |
58 Description describe(Description description) => description.add('true'); | 58 Description describe(Description description) => description.add('true'); |
59 } | 59 } |
60 | 60 |
61 class _IsFalse extends Matcher { | 61 class _IsFalse extends Matcher { |
62 const _IsFalse(); | 62 const _IsFalse(); |
63 bool matches(item, Map matchState) => item == false; | 63 bool matches(item, Map matchState) => item == false; |
64 Description describe(Description description) => description.add('false'); | 64 Description describe(Description description) => description.add('false'); |
65 } | 65 } |
66 | 66 |
67 /// A matcher that matches the numeric value NaN. | |
68 const Matcher isNaN = const _IsNull(); | |
69 | |
70 /// A matcher that matches any non-NaN value. | |
71 const Matcher isNotNaN = const _IsNotNaN(); | |
72 | |
73 class _IsNaN extends Matcher { | |
74 const _IsNaN(); | |
75 bool matches(item, Map matchState) => item == NaN; | |
kevmoo
2014/07/22 20:44:37
Where is NaN coming from here? Do you mean double.
srawlins
2014/07/22 22:49:06
Done.
| |
76 Description describe(Description description) => description.add('NaN'); | |
77 } | |
78 | |
79 class _IsNotNaN extends Matcher { | |
80 const _IsNotNaN(); | |
81 bool matches(item, Map matchState) => item != NaN; | |
kevmoo
2014/07/22 20:44:37
ditto
srawlins
2014/07/22 22:49:06
Done.
| |
82 Description describe(Description description) => description.add('not NaN'); | |
83 } | |
84 | |
67 /// Returns a matches that matches if the value is the same instance | 85 /// Returns a matches that matches if the value is the same instance |
68 /// as [expected], using [identical]. | 86 /// as [expected], using [identical]. |
69 Matcher same(expected) => new _IsSameAs(expected); | 87 Matcher same(expected) => new _IsSameAs(expected); |
70 | 88 |
71 class _IsSameAs extends Matcher { | 89 class _IsSameAs extends Matcher { |
72 final _expected; | 90 final _expected; |
73 const _IsSameAs(this._expected); | 91 const _IsSameAs(this._expected); |
74 bool matches(item, Map matchState) => identical(item, _expected); | 92 bool matches(item, Map matchState) => identical(item, _expected); |
75 // If all types were hashable we could show a hash here. | 93 // If all types were hashable we could show a hash here. |
76 Description describe(Description description) => | 94 Description describe(Description description) => |
(...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
699 addDescriptionOf(matchState['feature']); | 717 addDescriptionOf(matchState['feature']); |
700 var innerDescription = new StringDescription(); | 718 var innerDescription = new StringDescription(); |
701 _matcher.describeMismatch(matchState['feature'], innerDescription, | 719 _matcher.describeMismatch(matchState['feature'], innerDescription, |
702 matchState['state'], verbose); | 720 matchState['state'], verbose); |
703 if (innerDescription.length > 0) { | 721 if (innerDescription.length > 0) { |
704 mismatchDescription.add(' which ').add(innerDescription.toString()); | 722 mismatchDescription.add(' which ').add(innerDescription.toString()); |
705 } | 723 } |
706 return mismatchDescription; | 724 return mismatchDescription; |
707 } | 725 } |
708 } | 726 } |
OLD | NEW |