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

Side by Side 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: Created 8 years, 7 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 | « lib/json/json.dart ('k') | no next file » | 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('jsonTest'); 5 #library('jsonTest');
6 6
7 #import('dart:json'); 7 #import('dart:json');
8 8
9 main() { 9 main() {
10 testEscaping(); 10 testEscaping();
11 testParse(); 11 testParse();
12 testParseInvalid(); 12 testParseInvalid();
13 } 13 }
14 14
15 void testParse() { 15 void testParse() {
16 // Scalars. 16 // Scalars.
17 Expect.equals(5, JSON.parse(' 5 ')); 17 Expect.equals(5, JSON.parse(' 5 '));
18 Expect.equals(-42, JSON.parse(' -42 ')); 18 Expect.equals(-42, JSON.parse(' -42 '));
19 Expect.equals(3, JSON.parse(' 3e0 ')); 19 Expect.equals(3, JSON.parse(' 3e0 '));
20 Expect.equals(3.14, JSON.parse(' 3.14 ')); 20 Expect.equals(3.14, JSON.parse(' 3.14 '));
21 Expect.equals(1.0E-06, JSON.parse(' 1.0E-06 '));
Lasse Reichstein Nielsen 2012/05/02 08:54:45 More tests. How about at least: 1E0 1E+0 1E-0
Anders Johnsen 2012/05/02 09:05:46 Thank you! Added!
21 Expect.equals(true, JSON.parse(' true ')); 22 Expect.equals(true, JSON.parse(' true '));
22 Expect.equals(false, JSON.parse(' false')); 23 Expect.equals(false, JSON.parse(' false'));
23 Expect.equals(null, JSON.parse(' null ')); 24 Expect.equals(null, JSON.parse(' null '));
24 Expect.equals(null, JSON.parse('\n\rnull\t')); 25 Expect.equals(null, JSON.parse('\n\rnull\t'));
25 Expect.equals('hi there" bob', JSON.parse(' "hi there\\" bob" ')); 26 Expect.equals('hi there" bob', JSON.parse(' "hi there\\" bob" '));
26 Expect.equals('', JSON.parse(' "" ')); 27 Expect.equals('', JSON.parse(' "" '));
27 28
28 // Lists. 29 // Lists.
29 Expect.listEquals([], JSON.parse(' [] ')); 30 Expect.listEquals([], JSON.parse(' [] '));
30 Expect.listEquals(["entry"], JSON.parse(' ["entry"] ')); 31 Expect.listEquals(["entry"], JSON.parse(' ["entry"] '));
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 Expect.stringEquals('"\\u001d"', JSON.stringify('\u001d')); 99 Expect.stringEquals('"\\u001d"', JSON.stringify('\u001d'));
99 Expect.stringEquals('"\\u001e"', JSON.stringify('\u001e')); 100 Expect.stringEquals('"\\u001e"', JSON.stringify('\u001e'));
100 Expect.stringEquals('"\\u001f"', JSON.stringify('\u001f')); 101 Expect.stringEquals('"\\u001f"', JSON.stringify('\u001f'));
101 Expect.stringEquals('"\\\""', JSON.stringify('"')); 102 Expect.stringEquals('"\\\""', JSON.stringify('"'));
102 Expect.stringEquals('"\\\\"', JSON.stringify('\\')); 103 Expect.stringEquals('"\\\\"', JSON.stringify('\\'));
103 Expect.stringEquals('"Got \\b, \\f, \\n, \\r, \\t, \\u0000, \\\\, and \\"."', 104 Expect.stringEquals('"Got \\b, \\f, \\n, \\r, \\t, \\u0000, \\\\, and \\"."',
104 JSON.stringify('Got \b, \f, \n, \r, \t, \u0000, \\, and ".')); 105 JSON.stringify('Got \b, \f, \n, \r, \t, \u0000, \\, and ".'));
105 Expect.stringEquals('"Got \\b\\f\\n\\r\\t\\u0000\\\\\\"."', 106 Expect.stringEquals('"Got \\b\\f\\n\\r\\t\\u0000\\\\\\"."',
106 JSON.stringify('Got \b\f\n\r\t\u0000\\".')); 107 JSON.stringify('Got \b\f\n\r\t\u0000\\".'));
107 } 108 }
OLDNEW
« 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