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

Unified Diff: tests/corelib/num_parse_test.dart

Issue 87953002: Change Expect.identical(NaN, x) to not assume NaNs are identical. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 1 month 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 | « runtime/lib/double_patch.dart ('k') | tests/lib/math/double_pow_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/corelib/num_parse_test.dart
diff --git a/tests/corelib/num_parse_test.dart b/tests/corelib/num_parse_test.dart
index 1c0b8386d589fe990583d4b15436016720f3d034..e35bd94d80a524584603d16075a21a6028cfb604 100644
--- a/tests/corelib/num_parse_test.dart
+++ b/tests/corelib/num_parse_test.dart
@@ -34,17 +34,25 @@ const whiteSpace = const [
"\uFEFF"
];
+void expectNumEquals(num expect, num actual, String message) {
+ if (expect is double && expect.isNaN) {
+ Expect.isTrue(actual is double && actual.isNaN, "isNaN: $message");
+ } else {
+ Expect.identical(expect, actual, message);
+ }
+}
+
void testParse(String source, num result) {
for (String ws1 in whiteSpace) {
for (String ws2 in whiteSpace) {
String padded = "$ws1$source$ws2";
// Use Expect.identical because it also handles NaN and 0.0/-0.0.
// Except on dart2js: http://dartbug.com/11551
- Expect.identical(result, num.parse(padded), "parse '$padded'");
+ expectNumEquals(result, num.parse(padded), "parse '$padded'");
padded = "$ws1$ws2$source";
- Expect.identical(result, num.parse(padded), "parse '$padded'");
+ expectNumEquals(result, num.parse(padded), "parse '$padded'");
padded = "$source$ws1$ws2";
- Expect.identical(result, num.parse(padded), "parse '$padded'");
+ expectNumEquals(result, num.parse(padded), "parse '$padded'");
}
}
}
« no previous file with comments | « runtime/lib/double_patch.dart ('k') | tests/lib/math/double_pow_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698