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

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: Removing parens Created 6 years, 5 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
« no previous file with comments | « pkg/matcher/CHANGELOG.md ('k') | pkg/matcher/pubspec.yaml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 cb76d6843de7ee97f4ba1df16964a777ec6c707b..f1a724a72719a7ea4839439bd492a86cda64238f 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 _IsNaN();
+
+/// A matcher that matches any non-NaN value.
+const Matcher isNotNaN = const _IsNotNaN();
+
+class _IsNaN extends Matcher {
+ const _IsNaN();
+ bool matches(item, Map matchState) => double.NAN.compareTo(item) == 0;
+ Description describe(Description description) => description.add('NaN');
+}
+
+class _IsNotNaN extends Matcher {
+ const _IsNotNaN();
+ bool matches(item, Map matchState) => double.NAN.compareTo(item) != 0;
+ 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);
« no previous file with comments | « pkg/matcher/CHANGELOG.md ('k') | pkg/matcher/pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698