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

Unified Diff: tests/utils/json_test.dart

Issue 10307003: Update locale char when moving position in number parsing in the JSON parser. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Added test cases. Created 8 years, 8 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 | « lib/json/json.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/utils/json_test.dart
diff --git a/tests/utils/json_test.dart b/tests/utils/json_test.dart
index 20138f5c8b5ff5f34fee6c3170868acf8032355e..682b67dba10927af7d64e6e02e6c670061289585 100644
--- a/tests/utils/json_test.dart
+++ b/tests/utils/json_test.dart
@@ -18,6 +18,53 @@ void testParse() {
Expect.equals(-42, JSON.parse(' -42 '));
Expect.equals(3, JSON.parse(' 3e0 '));
Expect.equals(3.14, JSON.parse(' 3.14 '));
+ Expect.equals(1.0E-06, JSON.parse(' 1.0E-06 '));
+ Expect.equals(0, JSON.parse("0"));
+ Expect.equals(1, JSON.parse("1"));
+ Expect.equals(0.1, JSON.parse("0.1"));
+ Expect.equals(1.1, JSON.parse("1.1"));
+ Expect.equals(1.1, JSON.parse("1.100000"));
+ Expect.equals(1.111111, JSON.parse("1.111111"));
+ Expect.equals(-0, JSON.parse("-0"));
+ Expect.equals(-1, JSON.parse("-1"));
+ Expect.equals(-0.1, JSON.parse("-0.1"));
+ Expect.equals(-1.1, JSON.parse("-1.1"));
+ Expect.equals(-1.1, JSON.parse("-1.100000"));
+ Expect.equals(-1.111111, JSON.parse("-1.111111"));
+ Expect.equals(11, JSON.parse("1.1e1"));
+ Expect.equals(11, JSON.parse("1.1e+1"));
+ Expect.equals(0.11, JSON.parse("1.1e-1"));
+ Expect.equals(11, JSON.parse("1.1E1"));
+ Expect.equals(11, JSON.parse("1.1E+1"));
+ Expect.equals(0.11, JSON.parse("1.1E-1"));
+ Expect.equals(1E0, JSON.parse(" 1E0"));
+ Expect.equals(1E+0, JSON.parse(" 1E+0"));
+ Expect.equals(1E-0, JSON.parse(" 1E-0"));
+ Expect.equals(1E00, JSON.parse(" 1E00"));
+ Expect.equals(1E+00, JSON.parse(" 1E+00"));
+ Expect.equals(1E-00, JSON.parse(" 1E-00"));
+ Expect.equals(1E+10, JSON.parse(" 1E+10"));
+ Expect.equals(1E+010, JSON.parse(" 1E+010"));
+ Expect.equals(1E+0010, JSON.parse(" 1E+0010"));
+ Expect.equals(1E10, JSON.parse(" 1E10"));
+ Expect.equals(1E010, JSON.parse(" 1E010"));
+ Expect.equals(1E0010, JSON.parse(" 1E0010"));
+ Expect.equals(1E-10, JSON.parse(" 1E-10"));
+ Expect.equals(1E-0010, JSON.parse(" 1E-0010"));
+ Expect.equals(1E0, JSON.parse(" 1e0"));
+ Expect.equals(1E+0, JSON.parse(" 1e+0"));
+ Expect.equals(1E-0, JSON.parse(" 1e-0"));
+ Expect.equals(1E00, JSON.parse(" 1e00"));
+ Expect.equals(1E+00, JSON.parse(" 1e+00"));
+ Expect.equals(1E-00, JSON.parse(" 1e-00"));
+ Expect.equals(1E+10, JSON.parse(" 1e+10"));
+ Expect.equals(1E+010, JSON.parse(" 1e+010"));
+ Expect.equals(1E+0010, JSON.parse(" 1e+0010"));
+ Expect.equals(1E10, JSON.parse(" 1e10"));
+ Expect.equals(1E010, JSON.parse(" 1e010"));
+ Expect.equals(1E0010, JSON.parse(" 1e0010"));
+ Expect.equals(1E-10, JSON.parse(" 1e-10"));
+ Expect.equals(1E-0010, JSON.parse(" 1e-0010"));
Expect.equals(true, JSON.parse(' true '));
Expect.equals(false, JSON.parse(' false'));
Expect.equals(null, JSON.parse(' null '));
@@ -46,12 +93,37 @@ void testParseInvalid() {
// have been updated.
Expect.throws(() => JSON.parse(s));
}
+ // Scalars
testString("");
testString("-");
testString("-.");
testString("3.a");
testString("{ key: value }");
testString("tru");
+ testString("1E--6");
+ testString("1E-+6");
+ testString("1E+-6");
+ testString("1E++6");
+ testString("1E6.6");
+ testString("1E-6.6");
+ testString("1E+6.6");
+
+ // JavaScript number literals not valid in JSON.
+ testString('[01]');
+ testString('[.1]');
+ testString('[1.]');
+ testString('[1.e1]');
+ testString('[-.1]');
+ testString('[-1.]');
+
+ // Plain invalid number literals.
+ testString('-');
+ testString('--1');
+ testString('-1e');
+ testString('1e--1]');
+ testString('1e+-1');
+ testString('1e-+1');
+ testString('1e++1');
// Lists
testString('[, ]');
« no previous file with comments | « lib/json/json.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698