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

Unified Diff: pkg/matcher/lib/src/core_matchers.dart

Issue 332663002: pkg/matcher: add isNaN and isNotNaN matchers (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: pkg/matcher/lib/src/core_matchers.dart
diff --git a/pkg/matcher/lib/src/core_matchers.dart b/pkg/matcher/lib/src/core_matchers.dart
index 356476b24d0f33d49d373f6ef7bb4ad7a4f3cba2..e33177cf6380f6b6bb91e88e3e52aa30203a7c27 100644
--- a/pkg/matcher/lib/src/core_matchers.dart
+++ b/pkg/matcher/lib/src/core_matchers.dart
@@ -64,6 +64,24 @@ class _IsFalse extends Matcher {
Description describe(Description description) => description.add('false');
}
+/// A matcher that matches the numeric value NaN.
+const Matcher isNaN = const _IsNull();
+
+/// A matcher that matches any non-NaN value.
+const Matcher isNotNaN = const _IsNotNaN();
+
+class _IsNaN extends Matcher {
+ const _IsNaN();
+ 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.
+ Description describe(Description description) => description.add('NaN');
+}
+
+class _IsNotNaN extends Matcher {
+ const _IsNotNaN();
+ bool matches(item, Map matchState) => item != NaN;
kevmoo 2014/07/22 20:44:37 ditto
srawlins 2014/07/22 22:49:06 Done.
+ Description describe(Description description) => description.add('not NaN');
+}
+
/// Returns a matches that matches if the value is the same instance
/// as [expected], using [identical].
Matcher same(expected) => new _IsSameAs(expected);

Powered by Google App Engine
This is Rietveld 408576698