| 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"; | 7 import "package:expect/expect.dart"; |
| 8 import "dart:convert"; | 8 import "dart:convert"; |
| 9 | 9 |
| 10 bool badFormat(e) => e is FormatException; | 10 bool badFormat(e) => e is FormatException; |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 for (var expval in ["0", "1", "200"]) { | 75 for (var expval in ["0", "1", "200"]) { |
| 76 exponentList.add("$exphead$expval"); | 76 exponentList.add("$exphead$expval"); |
| 77 } | 77 } |
| 78 } | 78 } |
| 79 | 79 |
| 80 for (var integer in integerList) { | 80 for (var integer in integerList) { |
| 81 for (var sign in signList) { | 81 for (var sign in signList) { |
| 82 for (var fraction in fractionList) { | 82 for (var fraction in fractionList) { |
| 83 for (var exp in exponentList) { | 83 for (var exp in exponentList) { |
| 84 var literal = "$sign$integer$fraction$exp"; | 84 var literal = "$sign$integer$fraction$exp"; |
| 85 var parseNumber = | 85 var expectedValue = num.parse(literal); |
| 86 ((fraction == "" && exp == "") ? (String x) => int.parse(x) | |
| 87 : (String x) => double.parse(x)); | |
| 88 var expectedValue = parseNumber(literal); | |
| 89 testJson(literal, expectedValue); | 86 testJson(literal, expectedValue); |
| 90 } | 87 } |
| 91 } | 88 } |
| 92 } | 89 } |
| 93 } | 90 } |
| 94 | 91 |
| 95 // Negative tests (syntax error). | 92 // Negative tests (syntax error). |
| 96 // testError thoroughly tests the given parts with a lot of valid | 93 // testError thoroughly tests the given parts with a lot of valid |
| 97 // values for the other parts. | 94 // values for the other parts. |
| 98 testError({signs, integers, fractions, exponents}) { | 95 testError({signs, integers, fractions, exponents}) { |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 288 } | 285 } |
| 289 | 286 |
| 290 main() { | 287 main() { |
| 291 testNumbers(); | 288 testNumbers(); |
| 292 testStrings(); | 289 testStrings(); |
| 293 testWords(); | 290 testWords(); |
| 294 testObjects(); | 291 testObjects(); |
| 295 testArrays(); | 292 testArrays(); |
| 296 testWhitespace(); | 293 testWhitespace(); |
| 297 } | 294 } |
| OLD | NEW |