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

Side by Side Diff: tests/corelib/json_leading_zeros_test.dart

Issue 12314055: Use browsers JSON.parse for parsing JSON (#3) (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 10 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 | « tests/corelib/corelib.status ('k') | tests/corelib/json_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
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.
4
5 // This is a trimmed-down version of json_test to isolate a difference between
6 // IE and other runtimes.
7
8 library json_test;
9
10 import "dart:json";
11
12 bool badFormat(e) => e is FormatException;
13
14 void testThrows(json) {
15 Expect.throws(() => parse(json), badFormat);
16 }
17
18 testNumbers() {
19 // Positive tests for number formats.
20 var integerList = ["0","9","9999"];
21 var signList = ["", "-"];
22 var fractionList = ["", ".0", ".1", ".99999"];
23 var exponentList = [""];
24 for (var exphead in ["e", "E", "e-", "E-", "e+", "E+"]) {
25 for (var expval in ["0", "1", "200"]) {
26 exponentList.add("$exphead$expval");
27 }
28 }
29
30 // Negative tests (syntax error).
31 // testError thoroughly tests the given parts with a lot of valid
32 // values for the other parts.
33 testError({signs, integers, fractions, exponents}) {
34 def(value, defaultValue) {
35 if (value == null) return defaultValue;
36 if (value is List) return value;
37 return [value];
38 }
39 signs = def(signs, signList);
40 integers = def(integers, integerList);
41 fractions = def(fractions, fractionList);
42 exponents = def(exponents, exponentList);
43 for (var integer in integers) {
44 for (var sign in signs) {
45 for (var fraction in fractions) {
46 for (var exponent in exponents) {
47 var literal = "$sign$integer$fraction$exponent";
48 testThrows(literal);
49 }
50 }
51 }
52 }
53 }
54 // Initial zero only allowed for zero integer part.
55 testError(integers: ["00", "01"]);
56 }
57
58 main() {
59 testNumbers();
60 }
OLDNEW
« no previous file with comments | « tests/corelib/corelib.status ('k') | tests/corelib/json_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698