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

Unified Diff: tests/corelib/src/MathTest.dart

Issue 9595013: parseInt fixes. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Update status file. Created 8 years, 10 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 | « tests/corelib/src/MathParseDoubleTest.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/corelib/src/MathTest.dart
diff --git a/tests/corelib/src/MathTest.dart b/tests/corelib/src/MathTest.dart
index f74850e02f69a14056cd2be09bb3f92672384707..b7b204aa078318643833fb9b464b79af401f443b 100644
--- a/tests/corelib/src/MathTest.dart
+++ b/tests/corelib/src/MathTest.dart
@@ -203,6 +203,9 @@ class MathTest {
Expect.equals(-10, Math.parseInt("-010"));
Expect.equals(10, Math.parseInt(" 010 "));
Expect.equals(-10, Math.parseInt(" -010 "));
+ Expect.equals(9, Math.parseInt("09"));
+ Expect.equals(9, Math.parseInt(" 09 "));
+ Expect.equals(-9, Math.parseInt("-09"));
Expect.equals(true, parseIntThrowsBadNumberFormatException("1b"));
Expect.equals(true, parseIntThrowsBadNumberFormatException(" 1b "));
Expect.equals(true, parseIntThrowsBadNumberFormatException(" 1 b "));
@@ -232,123 +235,6 @@ class MathTest {
Expect.equals(true, parseIntThrowsBadNumberFormatException(" "));
}
- static bool parseDoubleThrowsBadNumberFormatException(str) {
- try {
- Math.parseDouble(str);
- return false;
- } catch (BadNumberFormatException e) {
- return true;
- }
- }
-
- static void testParseDouble() {
- Expect.equals(499.0, Math.parseDouble("499"));
- Expect.equals(499.0, Math.parseDouble("499.0"));
- Expect.equals(499.0, Math.parseDouble("499.0"));
- Expect.equals(499.0, Math.parseDouble("+499"));
- Expect.equals(-499.0, Math.parseDouble("-499"));
- Expect.equals(499.0, Math.parseDouble(" 499 "));
- Expect.equals(499.0, Math.parseDouble(" +499 "));
- Expect.equals(-499.0, Math.parseDouble(" -499 "));
- Expect.equals(0.0, Math.parseDouble("0"));
- Expect.equals(0.0, Math.parseDouble("+0"));
- Expect.equals(-0.0, Math.parseDouble("-0"));
- Expect.equals(true, Math.parseDouble("-0").isNegative());
- Expect.equals(0.0, Math.parseDouble(" 0 "));
- Expect.equals(0.0, Math.parseDouble(" +0 "));
- Expect.equals(-0.0, Math.parseDouble(" -0 "));
- Expect.equals(true, Math.parseDouble(" -0 ").isNegative());
- Expect.equals(1.0 * 0x1234567890, Math.parseDouble("0x1234567890"));
- Expect.equals(1.0 * 0x1234567890, Math.parseDouble("+0x1234567890"));
- Expect.equals(1.0 * -0x1234567890, Math.parseDouble("-0x1234567890"));
- Expect.equals(1.0 * 0x1234567890, Math.parseDouble(" 0x1234567890 "));
- Expect.equals(1.0 * 0x1234567890, Math.parseDouble(" +0x1234567890 "));
- Expect.equals(1.0 * -0x1234567890, Math.parseDouble(" -0x1234567890 "));
- Expect.equals(256.0, Math.parseDouble("0x100"));
- Expect.equals(256.0, Math.parseDouble("+0x100"));
- Expect.equals(-256.0, Math.parseDouble("-0x100"));
- Expect.equals(256.0, Math.parseDouble(" 0x100 "));
- Expect.equals(256.0, Math.parseDouble(" +0x100 "));
- Expect.equals(-256.0, Math.parseDouble(" -0x100 "));
- Expect.equals(1.0 * 0xabcdef, Math.parseDouble("0xabcdef"));
- Expect.equals(1.0 * 0xABCDEF, Math.parseDouble("0xABCDEF"));
- Expect.equals(1.0 * 0xabcdef, Math.parseDouble("0xabCDEf"));
- Expect.equals(1.0 * -0xabcdef, Math.parseDouble("-0xabcdef"));
- Expect.equals(1.0 * -0xABCDEF, Math.parseDouble("-0xABCDEF"));
- Expect.equals(1.0 * 0xabcdef, Math.parseDouble(" 0xabcdef "));
- Expect.equals(1.0 * 0xABCDEF, Math.parseDouble(" 0xABCDEF "));
- Expect.equals(1.0 * -0xabcdef, Math.parseDouble(" -0xabcdef "));
- Expect.equals(1.0 * -0xABCDEF, Math.parseDouble(" -0xABCDEF "));
- Expect.equals(1.0 * 0xabcdef, Math.parseDouble("0x00000abcdef"));
- Expect.equals(1.0 * 0xABCDEF, Math.parseDouble("0x00000ABCDEF"));
- Expect.equals(1.0 * -0xabcdef, Math.parseDouble("-0x00000abcdef"));
- Expect.equals(1.0 * -0xABCDEF, Math.parseDouble("-0x00000ABCDEF"));
- Expect.equals(1.0 * 0xabcdef, Math.parseDouble(" 0x00000abcdef "));
- Expect.equals(1.0 * 0xABCDEF, Math.parseDouble(" 0x00000ABCDEF "));
- Expect.equals(1.0 * -0xabcdef, Math.parseDouble(" -0x00000abcdef "));
- Expect.equals(1.0 * -0xABCDEF, Math.parseDouble(" -0x00000ABCDEF "));
- Expect.equals(10.0, Math.parseDouble("010"));
- Expect.equals(-10.0, Math.parseDouble("-010"));
- Expect.equals(10.0, Math.parseDouble(" 010 "));
- Expect.equals(-10.0, Math.parseDouble(" -010 "));
- Expect.equals(0.1, Math.parseDouble("0.1"));
- Expect.equals(0.1, Math.parseDouble(" 0.1 "));
- Expect.equals(0.1, Math.parseDouble(" +0.1 "));
- Expect.equals(-0.1, Math.parseDouble(" -0.1 "));
- Expect.equals(0.1, Math.parseDouble(".1"));
- Expect.equals(0.1, Math.parseDouble(" .1 "));
- Expect.equals(0.1, Math.parseDouble(" +.1 "));
- Expect.equals(-0.1, Math.parseDouble(" -.1 "));
- Expect.equals(1234567.89, Math.parseDouble("1234567.89"));
- Expect.equals(1234567.89, Math.parseDouble(" 1234567.89 "));
- Expect.equals(1234567.89, Math.parseDouble(" +1234567.89 "));
- Expect.equals(-1234567.89, Math.parseDouble(" -1234567.89 "));
- Expect.equals(1234567e89, Math.parseDouble("1234567e89"));
- Expect.equals(1234567e89, Math.parseDouble(" 1234567e89 "));
- Expect.equals(1234567e89, Math.parseDouble(" +1234567e89 "));
- Expect.equals(-1234567e89, Math.parseDouble(" -1234567e89 "));
- Expect.equals(1234567.89e2, Math.parseDouble("1234567.89e2"));
- Expect.equals(1234567.89e2, Math.parseDouble(" 1234567.89e2 "));
- Expect.equals(1234567.89e2, Math.parseDouble(" +1234567.89e2 "));
- Expect.equals(-1234567.89e2, Math.parseDouble(" -1234567.89e2 "));
- Expect.equals(1234567.89e2, Math.parseDouble("1234567.89E2"));
- Expect.equals(1234567.89e2, Math.parseDouble(" 1234567.89E2 "));
- Expect.equals(1234567.89e2, Math.parseDouble(" +1234567.89E2 "));
- Expect.equals(-1234567.89e2, Math.parseDouble(" -1234567.89E2 "));
- Expect.equals(1234567.89e-2, Math.parseDouble("1234567.89e-2"));
- Expect.equals(1234567.89e-2, Math.parseDouble(" 1234567.89e-2 "));
- Expect.equals(1234567.89e-2, Math.parseDouble(" +1234567.89e-2 "));
- Expect.equals(-1234567.89e-2, Math.parseDouble(" -1234567.89e-2 "));
- // TODO(floitsch): add tests for NaN and Infinity.
- Expect.equals(false, parseDoubleThrowsBadNumberFormatException("1.5"));
- Expect.equals(true, parseDoubleThrowsBadNumberFormatException("1b"));
- Expect.equals(true, parseDoubleThrowsBadNumberFormatException(" 1b "));
- Expect.equals(true, parseDoubleThrowsBadNumberFormatException(" 1 b "));
- Expect.equals(true, parseDoubleThrowsBadNumberFormatException(" e3 "));
- Expect.equals(true, parseDoubleThrowsBadNumberFormatException(" .e3 "));
- Expect.equals(true, parseDoubleThrowsBadNumberFormatException("00x12"));
- Expect.equals(true, parseDoubleThrowsBadNumberFormatException(" 00x12 "));
- Expect.equals(true, parseDoubleThrowsBadNumberFormatException("-1b"));
- Expect.equals(true, parseDoubleThrowsBadNumberFormatException(" -1b "));
- Expect.equals(true, parseDoubleThrowsBadNumberFormatException(" -1 b "));
- Expect.equals(true, parseDoubleThrowsBadNumberFormatException("-00x12"));
- Expect.equals(true, parseDoubleThrowsBadNumberFormatException(" -00x12 "));
- Expect.equals(true, parseDoubleThrowsBadNumberFormatException(" -00x12 "));
- Expect.equals(true, parseDoubleThrowsBadNumberFormatException("0x0x12"));
- Expect.equals(true, parseDoubleThrowsBadNumberFormatException("+ 1.5"));
- Expect.equals(true, parseDoubleThrowsBadNumberFormatException("- 1.5"));
- Expect.equals(true, parseDoubleThrowsBadNumberFormatException(""));
- Expect.equals(true, parseDoubleThrowsBadNumberFormatException(" "));
- Expect.equals(true, parseDoubleThrowsBadNumberFormatException("5."));
- Expect.equals(true, parseDoubleThrowsBadNumberFormatException(" 5. "));
- Expect.equals(true, parseDoubleThrowsBadNumberFormatException(" +5. "));
- Expect.equals(true, parseDoubleThrowsBadNumberFormatException(" -5. "));
- Expect.equals(true, parseDoubleThrowsBadNumberFormatException("1234567.e2"));
- Expect.equals(true, parseDoubleThrowsBadNumberFormatException(" 1234567.e2 "));
- Expect.equals(true, parseDoubleThrowsBadNumberFormatException(" +1234567.e2 "));
- Expect.equals(true, parseDoubleThrowsBadNumberFormatException(" -1234567.e2 "));
- }
-
static testMain() {
testConstants();
testSin();
@@ -363,7 +249,6 @@ class MathTest {
testExp();
testPow();
testParseInt();
- testParseDouble();
}
}
« no previous file with comments | « tests/corelib/src/MathParseDoubleTest.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698