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 json_test; | 5 library json_test; |
6 | 6 |
7 import "dart:json"; | 7 import "dart:json"; |
8 | 8 |
9 bool badFormat(e) => e is FormatException; | 9 bool badFormat(e) => e is FormatException; |
10 | 10 |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 } | 90 } |
91 } | 91 } |
92 } | 92 } |
93 } | 93 } |
94 // Doubles overflow to Infinity. | 94 // Doubles overflow to Infinity. |
95 testJson("1e+400", double.INFINITY); | 95 testJson("1e+400", double.INFINITY); |
96 // (Integers do not, but we don't have those on dart2js). | 96 // (Integers do not, but we don't have those on dart2js). |
97 | 97 |
98 // Integer part cannot be omitted: | 98 // Integer part cannot be omitted: |
99 testError(integers: ""); | 99 testError(integers: ""); |
100 // Initial zero only allowed for zero integer part. | 100 |
101 testError(integers: ["00", "01"]); | 101 // Test for "Initial zero only allowed for zero integer part" moved to |
| 102 // json_leading_zeros_test.dart because IE's JSON.parse accepts additional |
| 103 // initial zeros. |
| 104 |
102 // Only minus allowed as sign. | 105 // Only minus allowed as sign. |
103 testError(signs: "+"); | 106 testError(signs: "+"); |
104 // Requires digits after decimal point. | 107 // Requires digits after decimal point. |
105 testError(fractions: "."); | 108 testError(fractions: "."); |
106 // Requires exponent digts, and only digits. | 109 // Requires exponent digts, and only digits. |
107 testError(exponents: ["e", "e+", "e-", "e.0"]); | 110 testError(exponents: ["e", "e+", "e-", "e.0"]); |
108 | 111 |
109 // No whitespace inside numbers. | 112 // No whitespace inside numbers. |
110 testThrows("- 2.2e+2"); | 113 testThrows("- 2.2e+2"); |
111 testThrows("-2 .2e+2"); | 114 testThrows("-2 .2e+2"); |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 } | 245 } |
243 | 246 |
244 main() { | 247 main() { |
245 testNumbers(); | 248 testNumbers(); |
246 testStrings(); | 249 testStrings(); |
247 testWords(); | 250 testWords(); |
248 testObjects(); | 251 testObjects(); |
249 testArrays(); | 252 testArrays(); |
250 testWhitespace(); | 253 testWhitespace(); |
251 } | 254 } |
OLD | NEW |