add isNaN and isNotNaN to matchers

BUG= https://code.google.com/p/dart/issues/detail?id=19302
R=kevmoo@google.com

Review URL: https://codereview.chromium.org//332663002

Patch from Sam Rawlins <srawlins@google.com>.

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/matcher@38745 260f80e4-7a28-3924-810f-c04153c831b5
diff --git a/CHANGELOG.md b/CHANGELOG.md
index e175d94..c18134d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,7 @@
+## 0.11.1
+
+* Added `isNaN` and `isNotNaN` matchers.
+
 ## 0.11.0
 
 * Removed deprecated matchers.
diff --git a/lib/src/core_matchers.dart b/lib/src/core_matchers.dart
index cb76d68..f1a724a 100644
--- a/lib/src/core_matchers.dart
+++ b/lib/src/core_matchers.dart
@@ -64,6 +64,24 @@
   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);
diff --git a/pubspec.yaml b/pubspec.yaml
index 4612c58..7cf3e9d 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -1,5 +1,5 @@
 name: matcher
-version: 0.11.0
+version: 0.11.1
 author: Dart Team <misc@dartlang.org>
 description: Support for specifying test expectations
 homepage: https://pub.dartlang.org/packages/matcher
diff --git a/test/core_matchers_test.dart b/test/core_matchers_test.dart
index 7e9b246..cfeddbe 100644
--- a/test/core_matchers_test.dart
+++ b/test/core_matchers_test.dart
@@ -33,6 +33,16 @@
     shouldFail(null, isNotNull, "Expected: not null Actual: <null>");
   });
 
+  test('isNaN', () {
+    shouldPass(double.NAN, isNaN);
+    shouldFail(3.1, isNaN, "Expected: NaN Actual: <3.1>");
+  });
+
+  test('isNotNaN', () {
+    shouldPass(3.1, isNotNaN);
+    shouldFail(double.NAN, isNotNaN, "Expected: not NaN Actual: <NaN>");
+  });
+
   test('same', () {
     var a = new Map();
     var b = new Map();