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

Side by Side Diff: tests/utils/src/JsonTest.dart

Issue 10243002: Relax JSON test to support other targets then the VM. (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 | « no previous file | 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();
(...skipping 24 matching lines...) Expand all
35 Expect.mapEquals({}, JSON.parse(' {} ')); 35 Expect.mapEquals({}, JSON.parse(' {} '));
36 Expect.mapEquals({"key": "value"}, JSON.parse(' {"key": "value" } ')); 36 Expect.mapEquals({"key": "value"}, JSON.parse(' {"key": "value" } '));
37 Expect.mapEquals({"key1": 1, "key2": 2}, 37 Expect.mapEquals({"key1": 1, "key2": 2},
38 JSON.parse(' {"key1": 1, "key2": 2} ')); 38 JSON.parse(' {"key1": 1, "key2": 2} '));
39 Expect.mapEquals({"key1": 1}, 39 Expect.mapEquals({"key1": 1},
40 JSON.parse(' { "key1" : 1 } ')); 40 JSON.parse(' { "key1" : 1 } '));
41 } 41 }
42 42
43 void testParseInvalid() { 43 void testParseInvalid() {
44 void testString(String s) { 44 void testString(String s) {
45 Expect.throws(() => JSON.parse(s), (e) => e is JSONParseException); 45 // TODO(ajohnsen): Require JSONParseException exception once all JSON libs
46 // have been updated.
47 Expect.throws(() => JSON.parse(s));
46 } 48 }
47 testString(""); 49 testString("");
48 testString("3.a"); 50 testString("3.a");
49 testString("{ key: value }"); 51 testString("{ key: value }");
50 testString("tru"); 52 testString("tru");
51 53
52 // Lists 54 // Lists
53 testString('[, ]'); 55 testString('[, ]');
54 testString('["", ]'); 56 testString('["", ]');
55 testString('["", "]'); 57 testString('["", "]');
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 Expect.stringEquals('"\\u001d"', JSON.stringify('\u001d')); 96 Expect.stringEquals('"\\u001d"', JSON.stringify('\u001d'));
95 Expect.stringEquals('"\\u001e"', JSON.stringify('\u001e')); 97 Expect.stringEquals('"\\u001e"', JSON.stringify('\u001e'));
96 Expect.stringEquals('"\\u001f"', JSON.stringify('\u001f')); 98 Expect.stringEquals('"\\u001f"', JSON.stringify('\u001f'));
97 Expect.stringEquals('"\\\""', JSON.stringify('"')); 99 Expect.stringEquals('"\\\""', JSON.stringify('"'));
98 Expect.stringEquals('"\\\\"', JSON.stringify('\\')); 100 Expect.stringEquals('"\\\\"', JSON.stringify('\\'));
99 Expect.stringEquals('"Got \\b, \\f, \\n, \\r, \\t, \\u0000, \\\\, and \\"."', 101 Expect.stringEquals('"Got \\b, \\f, \\n, \\r, \\t, \\u0000, \\\\, and \\"."',
100 JSON.stringify('Got \b, \f, \n, \r, \t, \u0000, \\, and ".')); 102 JSON.stringify('Got \b, \f, \n, \r, \t, \u0000, \\, and ".'));
101 Expect.stringEquals('"Got \\b\\f\\n\\r\\t\\u0000\\\\\\"."', 103 Expect.stringEquals('"Got \\b\\f\\n\\r\\t\\u0000\\\\\\"."',
102 JSON.stringify('Got \b\f\n\r\t\u0000\\".')); 104 JSON.stringify('Got \b\f\n\r\t\u0000\\".'));
103 } 105 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698