| OLD | NEW |
| 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 29 matching lines...) Expand all Loading... |
| 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 // TODO(ajohnsen): Require JSONParseException exception once all JSON libs | 45 // TODO(ajohnsen): Require JSONParseException exception once all JSON libs |
| 46 // have been updated. | 46 // have been updated. |
| 47 Expect.throws(() => JSON.parse(s)); | 47 Expect.throws(() => JSON.parse(s)); |
| 48 } | 48 } |
| 49 testString(""); | 49 testString(""); |
| 50 testString("-"); |
| 51 testString("-."); |
| 50 testString("3.a"); | 52 testString("3.a"); |
| 51 testString("{ key: value }"); | 53 testString("{ key: value }"); |
| 52 testString("tru"); | 54 testString("tru"); |
| 53 | 55 |
| 54 // Lists | 56 // Lists |
| 55 testString('[, ]'); | 57 testString('[, ]'); |
| 56 testString('["", ]'); | 58 testString('["", ]'); |
| 57 testString('["", "]'); | 59 testString('["", "]'); |
| 58 testString('["" ""]'); | 60 testString('["" ""]'); |
| 59 | 61 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 Expect.stringEquals('"\\u001d"', JSON.stringify('\u001d')); | 98 Expect.stringEquals('"\\u001d"', JSON.stringify('\u001d')); |
| 97 Expect.stringEquals('"\\u001e"', JSON.stringify('\u001e')); | 99 Expect.stringEquals('"\\u001e"', JSON.stringify('\u001e')); |
| 98 Expect.stringEquals('"\\u001f"', JSON.stringify('\u001f')); | 100 Expect.stringEquals('"\\u001f"', JSON.stringify('\u001f')); |
| 99 Expect.stringEquals('"\\\""', JSON.stringify('"')); | 101 Expect.stringEquals('"\\\""', JSON.stringify('"')); |
| 100 Expect.stringEquals('"\\\\"', JSON.stringify('\\')); | 102 Expect.stringEquals('"\\\\"', JSON.stringify('\\')); |
| 101 Expect.stringEquals('"Got \\b, \\f, \\n, \\r, \\t, \\u0000, \\\\, and \\"."', | 103 Expect.stringEquals('"Got \\b, \\f, \\n, \\r, \\t, \\u0000, \\\\, and \\"."', |
| 102 JSON.stringify('Got \b, \f, \n, \r, \t, \u0000, \\, and ".')); | 104 JSON.stringify('Got \b, \f, \n, \r, \t, \u0000, \\, and ".')); |
| 103 Expect.stringEquals('"Got \\b\\f\\n\\r\\t\\u0000\\\\\\"."', | 105 Expect.stringEquals('"Got \\b\\f\\n\\r\\t\\u0000\\\\\\"."', |
| 104 JSON.stringify('Got \b\f\n\r\t\u0000\\".')); | 106 JSON.stringify('Got \b\f\n\r\t\u0000\\".')); |
| 105 } | 107 } |
| OLD | NEW |