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

Unified Diff: packages/matcher/lib/src/numeric_matchers.dart

Issue 3015713002: Roll to pickup pool changes
Patch Set: Created 3 years, 3 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 | « packages/matcher/lib/src/map_matchers.dart ('k') | packages/matcher/lib/src/string_matchers.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: packages/matcher/lib/src/numeric_matchers.dart
diff --git a/packages/matcher/lib/src/numeric_matchers.dart b/packages/matcher/lib/src/numeric_matchers.dart
index e8651de0e7b44bcad0fc5aaeac92d4c3211865d1..c40539183887f1363617d3e2d4efe3ddda30d346 100644
--- a/packages/matcher/lib/src/numeric_matchers.dart
+++ b/packages/matcher/lib/src/numeric_matchers.dart
@@ -17,11 +17,13 @@ class _IsCloseTo extends Matcher {
const _IsCloseTo(this._value, this._delta);
bool matches(item, Map matchState) {
- if (item is! num) return false;
-
- var diff = item - _value;
- if (diff < 0) diff = -diff;
- return (diff <= _delta);
+ if (item is num) {
+ var diff = item - _value;
+ if (diff < 0) diff = -diff;
+ return (diff <= _delta);
+ } else {
+ return false;
+ }
}
Description describe(Description description) => description
@@ -32,12 +34,12 @@ class _IsCloseTo extends Matcher {
Description describeMismatch(
item, Description mismatchDescription, Map matchState, bool verbose) {
- if (item is! num) {
- return mismatchDescription.add(' not numeric');
- } else {
+ if (item is num) {
var diff = item - _value;
if (diff < 0) diff = -diff;
return mismatchDescription.add(' differs by ').addDescriptionOf(diff);
+ } else {
+ return mismatchDescription.add(' not numeric');
}
}
}
@@ -70,19 +72,20 @@ class _InRange extends Matcher {
this._low, this._high, this._lowMatchValue, this._highMatchValue);
bool matches(value, Map matchState) {
- if (value is! num) {
- return false;
- }
- if (value < _low || value > _high) {
+ if (value is num) {
+ if (value < _low || value > _high) {
+ return false;
+ }
+ if (value == _low) {
+ return _lowMatchValue;
+ }
+ if (value == _high) {
+ return _highMatchValue;
+ }
+ return true;
+ } else {
return false;
}
- if (value == _low) {
- return _lowMatchValue;
- }
- if (value == _high) {
- return _highMatchValue;
- }
- return true;
}
Description describe(Description description) =>
« no previous file with comments | « packages/matcher/lib/src/map_matchers.dart ('k') | packages/matcher/lib/src/string_matchers.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698