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

Side by Side Diff: tests/json/json_test.dart

Issue 12328104: Change new List(n) to return fixed length list. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Merge to head. Created 7 years, 9 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
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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_tests; 5 library json_tests;
6 import 'dart:json' as json; 6 import 'dart:json' as json;
7 import 'dart:html'; 7 import 'dart:html';
8 import '../../pkg/unittest/lib/unittest.dart'; 8 import '../../pkg/unittest/lib/unittest.dart';
9 import '../../pkg/unittest/lib/html_config.dart'; 9 import '../../pkg/unittest/lib/html_config.dart';
10 10
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 expect(json.stringify(null), equals('null')); 83 expect(json.stringify(null), equals('null'));
84 expect(json.stringify(' hi there" bob '), equals('" hi there\\" bob "')); 84 expect(json.stringify(' hi there" bob '), equals('" hi there\\" bob "'));
85 expect(json.stringify('hi\\there'), equals('"hi\\\\there"')); 85 expect(json.stringify('hi\\there'), equals('"hi\\\\there"'));
86 // TODO(devoncarew): these tests break the dartium build 86 // TODO(devoncarew): these tests break the dartium build
87 //expect(json.stringify('hi\nthere'), equals('"hi\\nthere"')); 87 //expect(json.stringify('hi\nthere'), equals('"hi\\nthere"'));
88 //expect(json.stringify('hi\r\nthere'), equals('"hi\\r\\nthere"')); 88 //expect(json.stringify('hi\r\nthere'), equals('"hi\\r\\nthere"'));
89 expect(json.stringify(''), equals('""')); 89 expect(json.stringify(''), equals('""'));
90 90
91 // Lists. 91 // Lists.
92 expect(json.stringify([]), equals('[]')); 92 expect(json.stringify([]), equals('[]'));
93 expect(json.stringify(new List.fixedLength(0)), equals('[]')); 93 expect(json.stringify(new List(0)), equals('[]'));
94 expect(json.stringify(new List.fixedLength(3)), equals('[null,null,null]')); 94 expect(json.stringify(new List(3)), equals('[null,null,null]'));
95 validateRoundTrip([3, -4.5, null, true, 'hi', false]); 95 validateRoundTrip([3, -4.5, null, true, 'hi', false]);
96 expect(json.stringify([[3], [], [null], ['hi', true]]), 96 expect(json.stringify([[3], [], [null], ['hi', true]]),
97 equals('[[3],[],[null],["hi",true]]')); 97 equals('[[3],[],[null],["hi",true]]'));
98 98
99 // Maps. 99 // Maps.
100 expect(json.stringify({}), equals('{}')); 100 expect(json.stringify({}), equals('{}'));
101 expect(json.stringify(new Map()), equals('{}')); 101 expect(json.stringify(new Map()), equals('{}'));
102 expect(json.stringify({'x':{}}), equals('{"x":{}}')); 102 expect(json.stringify({'x':{}}), equals('{"x":{}}'));
103 expect(json.stringify({'x':{'a':3}}), equals('{"x":{"a":3}}')); 103 expect(json.stringify({'x':{'a':3}}), equals('{"x":{"a":3}}'));
104 104
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 152
153 /** 153 /**
154 * Checks that the argument can be converted to a JSON string and 154 * Checks that the argument can be converted to a JSON string and
155 * back, and produce something equivalent to the argument. 155 * back, and produce something equivalent to the argument.
156 */ 156 */
157 validateRoundTrip(expected) { 157 validateRoundTrip(expected) {
158 expect(json.parse(json.stringify(expected)), equals(expected)); 158 expect(json.parse(json.stringify(expected)), equals(expected));
159 } 159 }
160 160
161 161
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698