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

Side by Side Diff: test/dart_codegen/expect/collection/maps.dart

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, 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
OLDNEW
1 part of dart.collection; 1 part of dart.collection;
2 2 abstract class MapBase<K, V> = Object with MapMixin<K, V>;
3 abstract class MapBase<K, V> = Object with MapMixin<K, V>; 3 abstract class MapMixin<K, V> implements Map<K, V> {Iterable<K> get keys;
4 abstract class MapMixin<K, V> implements Map<K, V> { 4 V operator [](Object key);
5 Iterable<K> get keys; 5 operator []=(K key, V value);
6 V operator [](Object key); 6 V remove(Object key);
7 operator []=(K key, V value); 7 void clear();
8 V remove(Object key); 8 void forEach(void action(K key, V value)) {
9 void clear(); 9 for (K key in keys) {
10 void forEach(void action(K key, V value)) { 10 action(key, this[key]);
11 for (K key in keys) {
12 action(key, this[key]);
13 } 11 }
14 } 12 }
15 void addAll(Map<K, V> other) { 13 void addAll(Map<K, V> other) {
16 for (K key in other.keys) { 14 for (K key in other.keys) {
17 this[key] = other[key]; 15 this[key] = other[key];
18 } 16 }
19 } 17 }
20 bool containsValue(V value) { 18 bool containsValue(V value) {
21 for (K key in keys) { 19 for (K key in keys) {
22 if (this[key] == value) return true; 20 if (this[key] == value) return true;
23 } 21 }
24 return false; 22 return false;
25 } 23 }
26 V putIfAbsent(K key, V ifAbsent()) { 24 V putIfAbsent(K key, V ifAbsent()) {
27 if (keys.contains(key)) { 25 if (keys.contains(key)) {
28 return this[key]; 26 return this[key];
29 } 27 }
30 return this[key] = ifAbsent(); 28 return this[key] = ifAbsent();
31 } 29 }
32 bool containsKey(Object key) => keys.contains(key); 30 bool containsKey(Object key) => keys.contains(key);
33 int get length => keys.length; 31 int get length => keys.length;
34 bool get isEmpty => keys.isEmpty; 32 bool get isEmpty => keys.isEmpty;
35 bool get isNotEmpty => keys.isNotEmpty; 33 bool get isNotEmpty => keys.isNotEmpty;
36 Iterable<V> get values => new _MapBaseValueIterable<V>(this); 34 Iterable<V> get values => new _MapBaseValueIterable<V>(this);
37 String toString() => Maps.mapToString(this); 35 String toString() => Maps.mapToString(this);
38 } 36 }
39 abstract class UnmodifiableMapBase<K, V> = MapBase<K, V> 37 abstract class UnmodifiableMapBase<K, V> = MapBase<K, V> with _UnmodifiableMapM ixin<K, V>;
40 with _UnmodifiableMapMixin<K, V>; 38 class _MapBaseValueIterable<V> extends IterableBase<V> implements EfficientLeng th {final Map _map;
41 class _MapBaseValueIterable<V> extends IterableBase<V> 39 _MapBaseValueIterable(this._map);
42 implements EfficientLength { 40 int get length => _map.length;
43 final Map _map; 41 bool get isEmpty => _map.isEmpty;
44 _MapBaseValueIterable(this._map); 42 bool get isNotEmpty => _map.isNotEmpty;
45 int get length => _map.length; 43 V get first => ((__x26) => DDC$RT.cast(__x26, dynamic, V, "CastGeneral", """lin e 122, column 18 of dart:collection/maps.dart: """, __x26 is V, false))(_map[_ma p.keys.first]);
46 bool get isEmpty => _map.isEmpty; 44 V get single => ((__x27) => DDC$RT.cast(__x27, dynamic, V, "CastGeneral", """li ne 123, column 19 of dart:collection/maps.dart: """, __x27 is V, false))(_map[_m ap.keys.single]);
47 bool get isNotEmpty => _map.isNotEmpty; 45 V get last => ((__x28) => DDC$RT.cast(__x28, dynamic, V, "CastGeneral", """line 124, column 17 of dart:collection/maps.dart: """, __x28 is V, false))(_map[_map .keys.last]);
48 V get first => ((__x26) => DDC$RT.cast(__x26, dynamic, V, "CastGeneral", 46 Iterator<V> get iterator => new _MapBaseValueIterator<V>(_map);
49 """line 122, column 18 of dart:collection/maps.dart: """, __x26 is V,
50 false))(_map[_map.keys.first]);
51 V get single => ((__x27) => DDC$RT.cast(__x27, dynamic, V, "CastGeneral",
52 """line 123, column 19 of dart:collection/maps.dart: """, __x27 is V,
53 false))(_map[_map.keys.single]);
54 V get last => ((__x28) => DDC$RT.cast(__x28, dynamic, V, "CastGeneral",
55 """line 124, column 17 of dart:collection/maps.dart: """, __x28 is V,
56 false))(_map[_map.keys.last]);
57 Iterator<V> get iterator => new _MapBaseValueIterator<V>(_map);
58 } 47 }
59 class _MapBaseValueIterator<V> implements Iterator<V> { 48 class _MapBaseValueIterator<V> implements Iterator<V> {final Iterator _keys;
60 final Iterator _keys; 49 final Map _map;
61 final Map _map; 50 V _current = ((__x29) => DDC$RT.cast(__x29, Null, V, "CastLiteral", """line 138 , column 16 of dart:collection/maps.dart: """, __x29 is V, false))(null);
62 V _current = ((__x29) => DDC$RT.cast(__x29, Null, V, "CastLiteral", 51 _MapBaseValueIterator(Map map) : _map = map, _keys = map.keys.iterator;
63 """line 138, column 16 of dart:collection/maps.dart: """, __x29 is V, 52 bool moveNext() {
64 false))(null); 53 if (_keys.moveNext()) {
65 _MapBaseValueIterator(Map map) 54 _current = ((__x30) => DDC$RT.cast(__x30, dynamic, V, "CastGeneral", """line 144 , column 18 of dart:collection/maps.dart: """, __x30 is V, false))(_map[_keys.cu rrent]);
66 : _map = map, 55 return true;
67 _keys = map.keys.iterator;
68 bool moveNext() {
69 if (_keys.moveNext()) {
70 _current = ((__x30) => DDC$RT.cast(__x30, dynamic, V, "CastGeneral",
71 """line 144, column 18 of dart:collection/maps.dart: """, __x30 is V,
72 false))(_map[_keys.current]);
73 return true;
74 }
75 _current = ((__x31) => DDC$RT.cast(__x31, Null, V, "CastLiteral",
76 """line 147, column 16 of dart:collection/maps.dart: """, __x31 is V,
77 false))(null);
78 return false;
79 }
80 V get current => _current;
81 } 56 }
82 abstract class _UnmodifiableMapMixin<K, V> implements Map<K, V> { 57 _current = ((__x31) => DDC$RT.cast(__x31, Null, V, "CastLiteral", """line 147, column 16 of dart:collection/maps.dart: """, __x31 is V, false))(null);
83 void operator []=(K key, V value) { 58 return false;
84 throw new UnsupportedError("Cannot modify unmodifiable map");
85 }
86 void addAll(Map<K, V> other) {
87 throw new UnsupportedError("Cannot modify unmodifiable map");
88 }
89 void clear() {
90 throw new UnsupportedError("Cannot modify unmodifiable map");
91 }
92 V remove(Object key) {
93 throw new UnsupportedError("Cannot modify unmodifiable map");
94 }
95 V putIfAbsent(K key, V ifAbsent()) {
96 throw new UnsupportedError("Cannot modify unmodifiable map");
97 }
98 } 59 }
99 class MapView<K, V> implements Map<K, V> { 60 V get current => _current;
100 final Map<K, V> _map;
101 const MapView(Map<K, V> map) : _map = map;
102 V operator [](Object key) => _map[key];
103 void operator []=(K key, V value) {
104 _map[key] = value;
105 }
106 void addAll(Map<K, V> other) {
107 _map.addAll(other);
108 }
109 void clear() {
110 _map.clear();
111 }
112 V putIfAbsent(K key, V ifAbsent()) => _map.putIfAbsent(key, ifAbsent);
113 bool containsKey(Object key) => _map.containsKey(key);
114 bool containsValue(Object value) => _map.containsValue(value);
115 void forEach(void action(K key, V value)) {
116 _map.forEach(action);
117 }
118 bool get isEmpty => _map.isEmpty;
119 bool get isNotEmpty => _map.isNotEmpty;
120 int get length => _map.length;
121 Iterable<K> get keys => _map.keys;
122 V remove(Object key) => _map.remove(key);
123 String toString() => _map.toString();
124 Iterable<V> get values => _map.values;
125 } 61 }
126 class UnmodifiableMapView<K, V> = MapView<K, V> 62 abstract class _UnmodifiableMapMixin<K, V> implements Map<K, V> {void operator []=(K key, V value) {
127 with _UnmodifiableMapMixin<K, V>; 63 throw new UnsupportedError("Cannot modify unmodifiable map");
128 class Maps {
129 static bool containsValue(Map map, value) {
130 for (final v in map.values) {
131 if (value == v) {
132 return true;
133 }
134 }
135 return false;
136 }
137 static bool containsKey(Map map, key) {
138 for (final k in map.keys) {
139 if (key == k) {
140 return true;
141 }
142 }
143 return false;
144 }
145 static putIfAbsent(Map map, key, ifAbsent()) {
146 if (map.containsKey(key)) {
147 return map[key];
148 }
149 final v = ifAbsent();
150 map[key] = v;
151 return v;
152 }
153 static clear(Map map) {
154 for (final k in map.keys.toList()) {
155 map.remove(k);
156 }
157 }
158 static forEach(Map map, void f(key, value)) {
159 for (final k in map.keys) {
160 f(k, map[k]);
161 }
162 }
163 static Iterable getValues(Map map) {
164 return map.keys.map((key) => map[key]);
165 }
166 static int length(Map map) => map.keys.length;
167 static bool isEmpty(Map map) => map.keys.isEmpty;
168 static bool isNotEmpty(Map map) => map.keys.isNotEmpty;
169 static String mapToString(Map m) {
170 if (IterableBase._isToStringVisiting(m)) {
171 return '{...}';
172 }
173 var result = new StringBuffer();
174 try {
175 IterableBase._toStringVisiting.add(m);
176 result.write('{');
177 bool first = true;
178 m.forEach((k, v) {
179 if (!first) {
180 result.write(', ');
181 }
182 first = false;
183 result.write(k);
184 result.write(': ');
185 result.write(v);
186 });
187 result.write('}');
188 } finally {
189 assert(identical(IterableBase._toStringVisiting.last, m));
190 IterableBase._toStringVisiting.removeLast();
191 }
192 return result.toString();
193 }
194 static _id(x) => x;
195 static void _fillMapWithMappedIterable(
196 Map map, Iterable iterable, key(element), value(element)) {
197 if (key == null) key = _id;
198 if (value == null) value = _id;
199 for (var element in iterable) {
200 map[key(element)] = value(element);
201 }
202 }
203 static void _fillMapWithIterables(Map map, Iterable keys, Iterable values) {
204 Iterator keyIterator = keys.iterator;
205 Iterator valueIterator = values.iterator;
206 bool hasNextKey = keyIterator.moveNext();
207 bool hasNextValue = valueIterator.moveNext();
208 while (hasNextKey && hasNextValue) {
209 map[keyIterator.current] = valueIterator.current;
210 hasNextKey = keyIterator.moveNext();
211 hasNextValue = valueIterator.moveNext();
212 }
213 if (hasNextKey || hasNextValue) {
214 throw new ArgumentError("Iterables do not have same length.");
215 }
216 }
217 } 64 }
65 void addAll(Map<K, V> other) {
66 throw new UnsupportedError("Cannot modify unmodifiable map");
67 }
68 void clear() {
69 throw new UnsupportedError("Cannot modify unmodifiable map");
70 }
71 V remove(Object key) {
72 throw new UnsupportedError("Cannot modify unmodifiable map");
73 }
74 V putIfAbsent(K key, V ifAbsent()) {
75 throw new UnsupportedError("Cannot modify unmodifiable map");
76 }
77 }
78 class MapView<K, V> implements Map<K, V> {final Map<K, V> _map;
79 const MapView(Map<K, V> map) : _map = map;
80 V operator [](Object key) => _map[key];
81 void operator []=(K key, V value) {
82 _map[key] = value;
83 }
84 void addAll(Map<K, V> other) {
85 _map.addAll(other);
86 }
87 void clear() {
88 _map.clear();
89 }
90 V putIfAbsent(K key, V ifAbsent()) => _map.putIfAbsent(key, ifAbsent);
91 bool containsKey(Object key) => _map.containsKey(key);
92 bool containsValue(Object value) => _map.containsValue(value);
93 void forEach(void action(K key, V value)) {
94 _map.forEach(action);
95 }
96 bool get isEmpty => _map.isEmpty;
97 bool get isNotEmpty => _map.isNotEmpty;
98 int get length => _map.length;
99 Iterable<K> get keys => _map.keys;
100 V remove(Object key) => _map.remove(key);
101 String toString() => _map.toString();
102 Iterable<V> get values => _map.values;
103 }
104 class UnmodifiableMapView<K, V> = MapView<K, V> with _UnmodifiableMapMixin<K, V >;
105 class Maps {static bool containsValue(Map map, value) {
106 for (final v in map.values) {
107 if (value == v) {
108 return true;
109 }
110 }
111 return false;
112 }
113 static bool containsKey(Map map, key) {
114 for (final k in map.keys) {
115 if (key == k) {
116 return true;
117 }
118 }
119 return false;
120 }
121 static putIfAbsent(Map map, key, ifAbsent()) {
122 if (map.containsKey(key)) {
123 return map[key];
124 }
125 final v = ifAbsent();
126 map[key] = v;
127 return v;
128 }
129 static clear(Map map) {
130 for (final k in map.keys.toList()) {
131 map.remove(k);
132 }
133 }
134 static forEach(Map map, void f(key, value)) {
135 for (final k in map.keys) {
136 f(k, map[k]);
137 }
138 }
139 static Iterable getValues(Map map) {
140 return map.keys.map((key) => map[key]);
141 }
142 static int length(Map map) => map.keys.length;
143 static bool isEmpty(Map map) => map.keys.isEmpty;
144 static bool isNotEmpty(Map map) => map.keys.isNotEmpty;
145 static String mapToString(Map m) {
146 if (IterableBase._isToStringVisiting(m)) {
147 return '{...}';
148 }
149 var result = new StringBuffer();
150 try {
151 IterableBase._toStringVisiting.add(m);
152 result.write('{');
153 bool first = true;
154 m.forEach((k, v) {
155 if (!first) {
156 result.write(', ');
157 }
158 first = false;
159 result.write(k);
160 result.write(': ');
161 result.write(v);
162 }
163 );
164 result.write('}');
165 }
166 finally {
167 assert (identical(IterableBase._toStringVisiting.last, m)); IterableBase._toStri ngVisiting.removeLast();
168 }
169 return result.toString();
170 }
171 static _id(x) => x;
172 static void _fillMapWithMappedIterable(Map map, Iterable iterable, key(element) , value(element)) {
173 if (key == null) key = _id;
174 if (value == null) value = _id;
175 for (var element in iterable) {
176 map[key(element)] = value(element);
177 }
178 }
179 static void _fillMapWithIterables(Map map, Iterable keys, Iterable values) {
180 Iterator keyIterator = keys.iterator;
181 Iterator valueIterator = values.iterator;
182 bool hasNextKey = keyIterator.moveNext();
183 bool hasNextValue = valueIterator.moveNext();
184 while (hasNextKey && hasNextValue) {
185 map[keyIterator.current] = valueIterator.current;
186 hasNextKey = keyIterator.moveNext();
187 hasNextValue = valueIterator.moveNext();
188 }
189 if (hasNextKey || hasNextValue) {
190 throw new ArgumentError("Iterables do not have same length.");
191 }
192 }
193 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698