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

Side by Side 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: Addressing comments 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pkg/intl/test/number_format_test.dart ('k') | pkg/matcher/test/core_matchers_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 == double.NaN;
kevmoo 2014/07/25 18:21:08 double.NAN Are you running tests locally before u
srawlins 2014/07/30 17:08:03 Sorry, I was _not_ running the correct set of test
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 != double.NaN;
kevmoo 2014/07/25 18:21:08 ditto
srawlins 2014/07/30 17:08:03 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 643 matching lines...) Expand 10 before | Expand all | Expand 10 after
720 addDescriptionOf(matchState['feature']); 738 addDescriptionOf(matchState['feature']);
721 var innerDescription = new StringDescription(); 739 var innerDescription = new StringDescription();
722 _matcher.describeMismatch(matchState['feature'], innerDescription, 740 _matcher.describeMismatch(matchState['feature'], innerDescription,
723 matchState['state'], verbose); 741 matchState['state'], verbose);
724 if (innerDescription.length > 0) { 742 if (innerDescription.length > 0) {
725 mismatchDescription.add(' which ').add(innerDescription.toString()); 743 mismatchDescription.add(' which ').add(innerDescription.toString());
726 } 744 }
727 return mismatchDescription; 745 return mismatchDescription;
728 } 746 }
729 } 747 }
OLDNEW
« no previous file with comments | « pkg/intl/test/number_format_test.dart ('k') | pkg/matcher/test/core_matchers_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698