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

Side by Side Diff: test/dart_codegen/expect/convert/convert

Issue 963593002: Disable formatting and add new-lines to make tests faster. (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 5 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
OLDNEW
1 library dart.convert; 1 library dart.convert;
2
3 import 'dart:async' as DDC$async$; 2 import 'dart:async' as DDC$async$;
4 import 'package:dev_compiler/runtime/dart_logging_runtime.dart' as DDC$RT; 3 import 'package:dev_compiler/runtime/dart_logging_runtime.dart' as DDC$RT;
5 import 'dart:async'; 4 import 'dart:async';
6 import 'dart:typed_data'; 5 import 'dart:typed_data';
7 import 'dart:_internal' show MappedIterable, ListIterable; 6 import 'dart:_internal' show MappedIterable, ListIterable;
8 import 'dart:collection' show Maps, LinkedHashMap; 7 import 'dart:collection' show Maps, LinkedHashMap;
9 part 'ascii.dart'; 8 part 'ascii.dart';
10 part 'byte_conversion.dart'; 9 part 'byte_conversion.dart';
11 part 'chunked_conversion.dart'; 10 part 'chunked_conversion.dart';
12 part 'codec.dart'; 11 part 'codec.dart';
13 part 'converter.dart'; 12 part 'converter.dart';
14 part 'encoding.dart'; 13 part 'encoding.dart';
15 part 'html_escape.dart'; 14 part 'html_escape.dart';
16 part 'json.dart'; 15 part 'json.dart';
17 part 'latin1.dart'; 16 part 'latin1.dart';
18 part 'line_splitter.dart'; 17 part 'line_splitter.dart';
19 part 'string_conversion.dart'; 18 part 'string_conversion.dart';
20 part 'utf.dart'; 19 part 'utf.dart';
21 20 _convertJsonToDart(json, reviver(key, value)) {
22 _convertJsonToDart(json, reviver(key, value)) { 21 assert (reviver != null); walk(e) {
23 assert(reviver != null);
24 walk(e) {
25 if (JS('bool', '# == null', e) || JS('bool', 'typeof # != "object"', e)) { 22 if (JS('bool', '# == null', e) || JS('bool', 'typeof # != "object"', e)) {
26 return e; 23 return e;
27 } 24 }
28 if (JS('bool', 'Object.getPrototypeOf(#) === Array.prototype', e)) { 25 if (JS('bool', 'Object.getPrototypeOf(#) === Array.prototype', e)) {
29 for (int i = 0; i < JS('int', '#.length', e); i++) { 26 for (int i = 0;
27 i < JS('int', '#.length', e);
28 i++) {
30 var item = JS('', '#[#]', e, i); 29 var item = JS('', '#[#]', e, i);
31 JS('', '#[#]=#', e, i, reviver(i, walk(item))); 30 JS('', '#[#]=#', e, i, reviver(i, walk(item)));
32 } 31 }
33 return e; 32 return e;
34 } 33 }
35 _JsonMap map = new _JsonMap(e); 34 _JsonMap map = new _JsonMap(e);
36 var processed = map._processed; 35 var processed = map._processed;
37 List<String> keys = map._computeKeys(); 36 List<String> keys = map._computeKeys();
38 for (int i = 0; i < keys.length; i++) { 37 for (int i = 0;
38 i < keys.length;
39 i++) {
39 String key = keys[i]; 40 String key = keys[i];
40 var revived = reviver(key, walk(JS('', '#[#]', e, key))); 41 var revived = reviver(key, walk(JS('', '#[#]', e, key)));
41 JS('', '#[#]=#', processed, key, revived); 42 JS('', '#[#]=#', processed, key, revived);
42 } 43 }
43 map._original = processed; 44 map._original = processed;
44 return map; 45 return map;
45 } 46 }
46 return reviver(null, walk(json)); 47 return reviver(null, walk(json));
47 } 48 }
48 _convertJsonToDartLazy(object) { 49 _convertJsonToDartLazy(object) {
49 if (object == null) return null; 50 if (object == null) return null;
50 if (JS('bool', 'typeof # != "object"', object)) { 51 if (JS('bool', 'typeof # != "object"', object)) {
51 return object; 52 return object;
52 } 53 }
53 if (JS('bool', 'Object.getPrototypeOf(#) !== Array.prototype', object)) { 54 if (JS('bool', 'Object.getPrototypeOf(#) !== Array.prototype', object)) {
54 return new _JsonMap(object); 55 return new _JsonMap(object);
55 } 56 }
56 for (int i = 0; i < JS('int', '#.length', object); i++) { 57 for (int i = 0;
58 i < JS('int', '#.length', object);
59 i++) {
57 var item = JS('', '#[#]', object, i); 60 var item = JS('', '#[#]', object, i);
58 JS('', '#[#]=#', object, i, _convertJsonToDartLazy(item)); 61 JS('', '#[#]=#', object, i, _convertJsonToDartLazy(item));
59 } 62 }
60 return object; 63 return object;
61 } 64 }
62 class _JsonMap implements LinkedHashMap { 65 class _JsonMap implements LinkedHashMap {var _original;
63 var _original; 66 var _processed = _newJavaScriptObject();
64 var _processed = _newJavaScriptObject(); 67 var _data = null;
65 var _data = null; 68 _JsonMap(this._original);
66 _JsonMap(this._original); 69 operator [](key) {
67 operator [](key) { 70 if (_isUpgraded) {
68 if (_isUpgraded) { 71 return _upgradedMap[key];
69 return _upgradedMap[key]; 72 }
70 } else if (key is! String) { 73 else if (key is! String) {
71 return null; 74 return null;
72 } else { 75 }
73 var result = _getProperty(_processed, DDC$RT.cast(key, dynamic, String, 76 else {
74 "CastGeneral", """line 173, column 45 of dart:convert: """, 77 var result = _getProperty(_processed, DDC$RT.cast(key, dynamic, String, "Cas tGeneral", """line 173, column 45 of dart:convert: """, key is String, true));
75 key is String, true)); 78 if (_isUnprocessed(result)) result = _process(DDC$RT.cast(key, dynamic, Str ing, "CastGeneral", """line 174, column 53 of dart:convert: """, key is String, true));
76 if (_isUnprocessed(result)) result = _process(DDC$RT.cast(key, dynamic, 79 return result;
77 String, "CastGeneral", """line 174, column 53 of dart:convert: """, 80 }
78 key is String, true)); 81 }
79 return result; 82 int get length => _isUpgraded ? _upgradedMap.length : _computeKeys().length;
80 } 83 bool get isEmpty => length == 0;
81 } 84 bool get isNotEmpty => length > 0;
82 int get length => _isUpgraded ? _upgradedMap.length : _computeKeys().length; 85 Iterable get keys {
83 bool get isEmpty => length == 0; 86 if (_isUpgraded) return _upgradedMap.keys;
84 bool get isNotEmpty => length > 0; 87 return new _JsonMapKeyIterable(this);
85 Iterable get keys { 88 }
86 if (_isUpgraded) return _upgradedMap.keys; 89 Iterable get values {
87 return new _JsonMapKeyIterable(this); 90 if (_isUpgraded) return _upgradedMap.values;
88 } 91 return new MappedIterable(_computeKeys(), (each) => this[each]);
89 Iterable get values { 92 }
90 if (_isUpgraded) return _upgradedMap.values; 93 operator []=(key, value) {
91 return new MappedIterable(_computeKeys(), (each) => this[each]); 94 if (_isUpgraded) {
92 } 95 _upgradedMap[key] = value;
93 operator []=(key, value) { 96 }
94 if (_isUpgraded) { 97 else if (containsKey(key)) {
95 _upgradedMap[key] = value; 98 var processed = _processed;
96 } else if (containsKey(key)) { 99 _setProperty(processed, DDC$RT.cast(key, dynamic, String, "CastGeneral", "" "line 201, column 31 of dart:convert: """, key is String, true), value);
97 var processed = _processed; 100 var original = _original;
98 _setProperty(processed, DDC$RT.cast(key, dynamic, String, "CastGeneral", 101 if (!identical(original, processed)) {
99 """line 201, column 31 of dart:convert: """, key is String, true), 102 _setProperty(original, DDC$RT.cast(key, dynamic, String, "CastGeneral", "" "line 204, column 32 of dart:convert: """, key is String, true), null);
100 value); 103 }
101 var original = _original; 104 }
102 if (!identical(original, processed)) { 105 else {
103 _setProperty(original, DDC$RT.cast(key, dynamic, String, "CastGeneral", 106 _upgrade()[key] = value;
104 """line 204, column 32 of dart:convert: """, key is String, 107 }
105 true), null); 108 }
106 } 109 void addAll(Map other) {
107 } else { 110 other.forEach((key, value) {
108 _upgrade()[key] = value;
109 }
110 }
111 void addAll(Map other) {
112 other.forEach((key, value) {
113 this[key] = value;
114 });
115 }
116 bool containsValue(value) {
117 if (_isUpgraded) return _upgradedMap.containsValue(value);
118 List<String> keys = _computeKeys();
119 for (int i = 0; i < keys.length; i++) {
120 String key = keys[i];
121 if (this[key] == value) return true;
122 }
123 return false;
124 }
125 bool containsKey(key) {
126 if (_isUpgraded) return _upgradedMap.containsKey(key);
127 if (key is! String) return false;
128 return _hasProperty(_original, DDC$RT.cast(key, dynamic, String,
129 "CastGeneral", """line 230, column 36 of dart:convert: """,
130 key is String, true));
131 }
132 putIfAbsent(key, ifAbsent()) {
133 if (containsKey(key)) return this[key];
134 var value = ifAbsent();
135 this[key] = value; 111 this[key] = value;
136 return value; 112 }
137 } 113 );
138 remove(Object key) { 114 }
139 if (!_isUpgraded && !containsKey(key)) return null; 115 bool containsValue(value) {
140 return _upgrade().remove(key); 116 if (_isUpgraded) return _upgradedMap.containsValue(value);
141 } 117 List<String> keys = _computeKeys();
142 void clear() { 118 for (int i = 0;
143 if (_isUpgraded) { 119 i < keys.length;
144 _upgradedMap.clear(); 120 i++) {
145 } else { 121 String key = keys[i];
146 if (_data != null) { 122 if (this[key] == value) return true;
147 _data.clear(); 123 }
148 } 124 return false;
149 _original = _processed = null; 125 }
150 _data = {}; 126 bool containsKey(key) {
151 } 127 if (_isUpgraded) return _upgradedMap.containsKey(key);
152 } 128 if (key is! String) return false;
153 void forEach(void f(key, value)) { 129 return _hasProperty(_original, DDC$RT.cast(key, dynamic, String, "CastGeneral ", """line 230, column 36 of dart:convert: """, key is String, true));
154 if (_isUpgraded) return _upgradedMap.forEach(f); 130 }
155 List<String> keys = _computeKeys(); 131 putIfAbsent(key, ifAbsent()) {
156 for (int i = 0; i < keys.length; i++) { 132 if (containsKey(key)) return this[key];
157 String key = keys[i]; 133 var value = ifAbsent();
158 var value = _getProperty(_processed, key); 134 this[key] = value;
159 if (_isUnprocessed(value)) { 135 return value;
160 value = _convertJsonToDartLazy(_getProperty(_original, key)); 136 }
161 _setProperty(_processed, key, value); 137 remove(Object key) {
162 } 138 if (!_isUpgraded && !containsKey(key)) return null;
163 f(key, value); 139 return _upgrade().remove(key);
164 if (!identical(keys, _data)) { 140 }
165 throw new ConcurrentModificationError(this); 141 void clear() {
166 } 142 if (_isUpgraded) {
167 } 143 _upgradedMap.clear();
168 } 144 }
169 String toString() => Maps.mapToString(this); 145 else {
170 bool get _isUpgraded => _processed == null; 146 if (_data != null) {
171 Map get _upgradedMap { 147 _data.clear();
172 assert(_isUpgraded); 148 }
173 return ((__x32) => DDC$RT.cast(__x32, dynamic, 149 _original = _processed = null;
174 DDC$RT.type((Map<dynamic, dynamic> _) {}), "CastGeneral", 150 _data = {
175 """line 299, column 12 of dart:convert: """, 151 }
176 __x32 is Map<dynamic, dynamic>, true))(JS('LinkedHashMap', '#', _data)); 152 ;
177 } 153 }
178 List<String> _computeKeys() { 154 }
179 assert(!_isUpgraded); 155 void forEach(void f(key, value)) {
180 List keys = DDC$RT.cast(_data, dynamic, DDC$RT.type((List<dynamic> _) {}), 156 if (_isUpgraded) return _upgradedMap.forEach(f);
181 "CastGeneral", """line 304, column 17 of dart:convert: """, 157 List<String> keys = _computeKeys();
182 _data is List<dynamic>, true); 158 for (int i = 0;
183 if (keys == null) { 159 i < keys.length;
184 keys = _data = _getPropertyNames(_original); 160 i++) {
185 } 161 String key = keys[i];
186 return ((__x33) => DDC$RT.cast(__x33, dynamic, 162 var value = _getProperty(_processed, key);
187 DDC$RT.type((List<String> _) {}), "CastGeneral", 163 if (_isUnprocessed(value)) {
188 """line 308, column 12 of dart:convert: """, __x33 is List<String>, 164 value = _convertJsonToDartLazy(_getProperty(_original, key));
189 false))(JS('JSExtendableArray', '#', keys)); 165 _setProperty(_processed, key, value);
190 } 166 }
191 Map _upgrade() { 167 f(key, value);
192 if (_isUpgraded) return _upgradedMap; 168 if (!identical(keys, _data)) {
193 Map result = {}; 169 throw new ConcurrentModificationError(this);
194 List<String> keys = _computeKeys(); 170 }
195 for (int i = 0; i < keys.length; i++) { 171 }
196 String key = keys[i]; 172 }
197 result[key] = this[key]; 173 String toString() => Maps.mapToString(this);
198 } 174 bool get _isUpgraded => _processed == null;
199 if (keys.isEmpty) { 175 Map get _upgradedMap {
200 keys.add(null); 176 assert (_isUpgraded); return ((__x32) => DDC$RT.cast(__x32, dynamic, DDC$RT.ty pe((Map<dynamic, dynamic> _) {
201 } else { 177 }
202 keys.clear(); 178 ), "CastGeneral", """line 299, column 12 of dart:convert: """, __x32 is Map<dy namic, dynamic>, true))(JS('LinkedHashMap', '#', _data));
203 } 179 }
204 _original = _processed = null; 180 List<String> _computeKeys() {
205 _data = result; 181 assert (!_isUpgraded); List keys = DDC$RT.cast(_data, dynamic, DDC$RT.type((Li st<dynamic> _) {
206 assert(_isUpgraded); 182 }
207 return result; 183 ), "CastGeneral", """line 304, column 17 of dart:convert: """, _data is List<d ynamic>, true);
208 } 184 if (keys == null) {
209 _process(String key) { 185 keys = _data = _getPropertyNames(_original);
210 if (!_hasProperty(_original, key)) return null; 186 }
211 var result = _convertJsonToDartLazy(_getProperty(_original, key)); 187 return ((__x33) => DDC$RT.cast(__x33, dynamic, DDC$RT.type((List<String> _) {
212 return _setProperty(_processed, key, result); 188 }
213 } 189 ), "CastGeneral", """line 308, column 12 of dart:convert: """, __x33 is List<S tring>, false))(JS('JSExtendableArray', '#', keys));
214 static bool _hasProperty(object, String key) => ((__x34) => DDC$RT.cast(__x34, 190 }
215 dynamic, bool, "CastGeneral", 191 Map _upgrade() {
216 """line 352, column 10 of dart:convert: """, __x34 is bool, true))( 192 if (_isUpgraded) return _upgradedMap;
217 JS('bool', 'Object.prototype.hasOwnProperty.call(#,#)', object, key)); 193 Map result = {
218 static _getProperty(object, String key) => JS('', '#[#]', object, key); 194 }
219 static _setProperty(object, String key, value) => 195 ;
220 JS('', '#[#]=#', object, key, value); 196 List<String> keys = _computeKeys();
221 static List _getPropertyNames(object) => ((__x35) => DDC$RT.cast(__x35, 197 for (int i = 0;
222 dynamic, DDC$RT.type((List<dynamic> _) {}), "CastGeneral", 198 i < keys.length;
223 """line 358, column 10 of dart:convert: """, __x35 is List<dynamic>, 199 i++) {
224 true))(JS('JSExtendableArray', 'Object.keys(#)', object)); 200 String key = keys[i];
225 static bool _isUnprocessed(object) => ((__x36) => DDC$RT.cast(__x36, dynamic, 201 result[key] = this[key];
226 bool, "CastGeneral", """line 360, column 10 of dart:convert: """, 202 }
227 __x36 is bool, true))(JS('bool', 'typeof(#)=="undefined"', object)); 203 if (keys.isEmpty) {
228 static _newJavaScriptObject() => JS('=Object', 'Object.create(null)'); 204 keys.add(null);
229 } 205 }
230 class _JsonMapKeyIterable extends ListIterable { 206 else {
231 final _JsonMap _parent; 207 keys.clear();
232 _JsonMapKeyIterable(this._parent); 208 }
233 int get length => _parent.length; 209 _original = _processed = null;
234 String elementAt(int index) { 210 _data = result;
235 return ((__x37) => DDC$RT.cast(__x37, dynamic, String, "CastGeneral", 211 assert (_isUpgraded); return result;
236 """line 372, column 12 of dart:convert: """, __x37 is String, 212 }
237 true))(_parent._isUpgraded 213 _process(String key) {
238 ? _parent.keys.elementAt(index) 214 if (!_hasProperty(_original, key)) return null;
239 : _parent._computeKeys()[index]); 215 var result = _convertJsonToDartLazy(_getProperty(_original, key));
240 } 216 return _setProperty(_processed, key, result);
241 Iterator get iterator { 217 }
242 return ((__x38) => DDC$RT.cast(__x38, Object, 218 static bool _hasProperty(object, String key) => ((__x34) => DDC$RT.cast(__x34, dynamic, bool, "CastGeneral", """line 352, column 10 of dart:convert: """, __x34 is bool, true))(JS('bool', 'Object.prototype.hasOwnProperty.call(#,#)', object, key));
243 DDC$RT.type((Iterator<dynamic> _) {}), "CastGeneral", 219 static _getProperty(object, String key) => JS('', '#[#]', object, key);
244 """line 380, column 12 of dart:convert: """, 220 static _setProperty(object, String key, value) => JS('', '#[#]=#', object, key, value);
245 __x38 is Iterator<dynamic>, true))(_parent._isUpgraded 221 static List _getPropertyNames(object) => ((__x35) => DDC$RT.cast(__x35, dynamic , DDC$RT.type((List<dynamic> _) {
246 ? _parent.keys.iterator 222 }
247 : _parent._computeKeys().iterator); 223 ), "CastGeneral", """line 358, column 10 of dart:convert: """, __x35 is List<dyn amic>, true))(JS('JSExtendableArray', 'Object.keys(#)', object));
248 } 224 static bool _isUnprocessed(object) => ((__x36) => DDC$RT.cast(__x36, dynamic, b ool, "CastGeneral", """line 360, column 10 of dart:convert: """, __x36 is bool, true))(JS('bool', 'typeof(#)=="undefined"', object));
249 bool contains(Object key) => _parent.containsKey(key); 225 static _newJavaScriptObject() => JS('=Object', 'Object.create(null)');
250 } 226 }
251 class _JsonDecoderSink extends _StringSinkConversionSink { 227 class _JsonMapKeyIterable extends ListIterable {final _JsonMap _parent;
252 final _Reviver _reviver; 228 _JsonMapKeyIterable(this._parent);
253 final Sink<Object> _sink; 229 int get length => _parent.length;
254 _JsonDecoderSink(this._reviver, this._sink) : super(new StringBuffer()); 230 String elementAt(int index) {
255 void close() { 231 return ((__x37) => DDC$RT.cast(__x37, dynamic, String, "CastGeneral", """line 37 2, column 12 of dart:convert: """, __x37 is String, true))(_parent._isUpgraded ? _parent.keys.elementAt(index) : _parent._computeKeys()[index]);
256 super.close(); 232 }
257 StringBuffer buffer = DDC$RT.cast(_stringSink, StringSink, StringBuffer, 233 Iterator get iterator {
258 "CastGeneral", """line 404, column 27 of dart:convert: """, 234 return ((__x38) => DDC$RT.cast(__x38, Object, DDC$RT.type((Iterator<dynamic> _) {
259 _stringSink is StringBuffer, true); 235 }
260 String accumulated = buffer.toString(); 236 ), "CastGeneral", """line 380, column 12 of dart:convert: """, __x38 is Iterator <dynamic>, true))(_parent._isUpgraded ? _parent.keys.iterator : _parent._compute Keys().iterator);
261 buffer.clear(); 237 }
262 Object decoded = _parseJson(accumulated, _reviver); 238 bool contains(Object key) => _parent.containsKey(key);
263 _sink.add(decoded); 239 }
264 _sink.close(); 240 class _JsonDecoderSink extends _StringSinkConversionSink {final _Reviver _reviv er;
265 } 241 final Sink<Object> _sink;
266 } 242 _JsonDecoderSink(this._reviver, this._sink) : super(new StringBuffer());
243 void close() {
244 super.close();
245 StringBuffer buffer = DDC$RT.cast(_stringSink, StringSink, StringBuffer, "CastG eneral", """line 404, column 27 of dart:convert: """, _stringSink is StringBuffe r, true);
246 String accumulated = buffer.toString();
247 buffer.clear();
248 Object decoded = _parseJson(accumulated, _reviver);
249 _sink.add(decoded);
250 _sink.close();
251 }
252 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698