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 "package:expect/expect.dart"; | |
8 import "dart:json"; | 7 import "dart:json"; |
9 | 8 |
10 bool badFormat(e) => e is FormatException; | 9 bool badFormat(e) => e is FormatException; |
11 | 10 |
12 void testJson(json, expected) { | 11 void testJson(json, expected) { |
13 var value = parse(json); | 12 var value = parse(json); |
14 compare(expected, actual, path) { | 13 compare(expected, actual, path) { |
15 if (expected is List) { | 14 if (expected is List) { |
16 Expect.isTrue(actual is List); | 15 Expect.isTrue(actual is List); |
17 Expect.equals(expected.length, actual.length, "$path: List length"); | 16 Expect.equals(expected.length, actual.length, "$path: List length"); |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 } | 259 } |
261 | 260 |
262 main() { | 261 main() { |
263 testNumbers(); | 262 testNumbers(); |
264 testStrings(); | 263 testStrings(); |
265 testWords(); | 264 testWords(); |
266 testObjects(); | 265 testObjects(); |
267 testArrays(); | 266 testArrays(); |
268 testWhitespace(); | 267 testWhitespace(); |
269 } | 268 } |
OLD | NEW |