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

Side by Side Diff: tests/compiler/dart2js/patch_test.dart

Issue 11238035: Make isEmpty a getter. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Update status file with co19 issue number. Created 8 years, 2 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/compiler/dart2js/parser_test.dart ('k') | tests/compiler/dart2js/resolver_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
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 import "../../../lib/compiler/implementation/dart2jslib.dart"; 5 import "../../../lib/compiler/implementation/dart2jslib.dart";
6 import "../../../lib/compiler/implementation/elements/elements.dart"; 6 import "../../../lib/compiler/implementation/elements/elements.dart";
7 import "../../../lib/compiler/implementation/tree/tree.dart"; 7 import "../../../lib/compiler/implementation/tree/tree.dart";
8 import "../../../lib/compiler/implementation/util/util.dart"; 8 import "../../../lib/compiler/implementation/util/util.dart";
9 import "mock_compiler.dart"; 9 import "mock_compiler.dart";
10 import "parser_helper.dart"; 10 import "parser_helper.dart";
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 return element; 105 return element;
106 } 106 }
107 107
108 testPatchFunction() { 108 testPatchFunction() {
109 var compiler = applyPatch( 109 var compiler = applyPatch(
110 "external test();", 110 "external test();",
111 "patch test() { return 'string'; } "); 111 "patch test() { return 'string'; } ");
112 ensure(compiler, "test", compiler.coreLibrary.find, isPatched: true); 112 ensure(compiler, "test", compiler.coreLibrary.find, isPatched: true);
113 ensure(compiler, "test", compiler.coreLibrary.patch.find, isPatch: true); 113 ensure(compiler, "test", compiler.coreLibrary.patch.find, isPatch: true);
114 114
115 Expect.isTrue(compiler.warnings.isEmpty(), 115 Expect.isTrue(compiler.warnings.isEmpty,
116 "Unexpected warnings: ${compiler.warnings}"); 116 "Unexpected warnings: ${compiler.warnings}");
117 Expect.isTrue(compiler.errors.isEmpty(), 117 Expect.isTrue(compiler.errors.isEmpty,
118 "Unexpected errors: ${compiler.errors}"); 118 "Unexpected errors: ${compiler.errors}");
119 } 119 }
120 120
121 testPatchMember() { 121 testPatchMember() {
122 var compiler = applyPatch( 122 var compiler = applyPatch(
123 """ 123 """
124 class Class { 124 class Class {
125 external String toString(); 125 external String toString();
126 } 126 }
127 """, 127 """,
128 """ 128 """
129 patch class Class { 129 patch class Class {
130 patch String toString() => 'string'; 130 patch String toString() => 'string';
131 } 131 }
132 """); 132 """);
133 var container = ensure(compiler, "Class", compiler.coreLibrary.find, 133 var container = ensure(compiler, "Class", compiler.coreLibrary.find,
134 isMethod: false, isPatched: true); 134 isMethod: false, isPatched: true);
135 container.parseNode(compiler); 135 container.parseNode(compiler);
136 ensure(compiler, "Class", compiler.coreLibrary.patch.find, 136 ensure(compiler, "Class", compiler.coreLibrary.patch.find,
137 isMethod: false, isPatch: true); 137 isMethod: false, isPatch: true);
138 138
139 ensure(compiler, "toString", container.lookupLocalMember, 139 ensure(compiler, "toString", container.lookupLocalMember,
140 isPatched: true); 140 isPatched: true);
141 ensure(compiler, "toString", container.patch.lookupLocalMember, 141 ensure(compiler, "toString", container.patch.lookupLocalMember,
142 isPatch: true); 142 isPatch: true);
143 143
144 Expect.isTrue(compiler.warnings.isEmpty(), 144 Expect.isTrue(compiler.warnings.isEmpty,
145 "Unexpected warnings: ${compiler.warnings}"); 145 "Unexpected warnings: ${compiler.warnings}");
146 Expect.isTrue(compiler.errors.isEmpty(), 146 Expect.isTrue(compiler.errors.isEmpty,
147 "Unexpected errors: ${compiler.errors}"); 147 "Unexpected errors: ${compiler.errors}");
148 } 148 }
149 149
150 testPatchGetter() { 150 testPatchGetter() {
151 var compiler = applyPatch( 151 var compiler = applyPatch(
152 """ 152 """
153 class Class { 153 class Class {
154 external int get field; 154 external int get field;
155 } 155 }
156 """, 156 """,
157 """ 157 """
158 patch class Class { 158 patch class Class {
159 patch int get field => 5; 159 patch int get field => 5;
160 } 160 }
161 """); 161 """);
162 var container = ensure(compiler, "Class", compiler.coreLibrary.find, 162 var container = ensure(compiler, "Class", compiler.coreLibrary.find,
163 isPatched: true, isMethod: false); 163 isPatched: true, isMethod: false);
164 container.parseNode(compiler); 164 container.parseNode(compiler);
165 ensure(compiler, 165 ensure(compiler,
166 "field", 166 "field",
167 container.lookupLocalMember, 167 container.lookupLocalMember,
168 isGetter: true, 168 isGetter: true,
169 isPatched: true); 169 isPatched: true);
170 ensure(compiler, 170 ensure(compiler,
171 "field", 171 "field",
172 container.patch.lookupLocalMember, 172 container.patch.lookupLocalMember,
173 isGetter: true, 173 isGetter: true,
174 isPatch: true); 174 isPatch: true);
175 175
176 Expect.isTrue(compiler.warnings.isEmpty(), 176 Expect.isTrue(compiler.warnings.isEmpty,
177 "Unexpected warnings: ${compiler.warnings}"); 177 "Unexpected warnings: ${compiler.warnings}");
178 Expect.isTrue(compiler.errors.isEmpty(), 178 Expect.isTrue(compiler.errors.isEmpty,
179 "Unexpected errors: ${compiler.errors}"); 179 "Unexpected errors: ${compiler.errors}");
180 } 180 }
181 181
182 testRegularMember() { 182 testRegularMember() {
183 var compiler = applyPatch( 183 var compiler = applyPatch(
184 """ 184 """
185 class Class { 185 class Class {
186 void regular() {} 186 void regular() {}
187 } 187 }
188 """, 188 """,
189 """ 189 """
190 patch class Class { 190 patch class Class {
191 } 191 }
192 """); 192 """);
193 var container = ensure(compiler, "Class", compiler.coreLibrary.find, 193 var container = ensure(compiler, "Class", compiler.coreLibrary.find,
194 isMethod: false, isPatched: true); 194 isMethod: false, isPatched: true);
195 container.parseNode(compiler); 195 container.parseNode(compiler);
196 ensure(compiler, "Class", compiler.coreLibrary.patch.find, 196 ensure(compiler, "Class", compiler.coreLibrary.patch.find,
197 isMethod: false, isPatch: true); 197 isMethod: false, isPatch: true);
198 198
199 ensure(compiler, "regular", container.lookupLocalMember); 199 ensure(compiler, "regular", container.lookupLocalMember);
200 ensure(compiler, "regular", container.patch.lookupLocalMember); 200 ensure(compiler, "regular", container.patch.lookupLocalMember);
201 201
202 Expect.isTrue(compiler.warnings.isEmpty(), 202 Expect.isTrue(compiler.warnings.isEmpty,
203 "Unexpected warnings: ${compiler.warnings}"); 203 "Unexpected warnings: ${compiler.warnings}");
204 Expect.isTrue(compiler.errors.isEmpty(), 204 Expect.isTrue(compiler.errors.isEmpty,
205 "Unexpected errors: ${compiler.errors}"); 205 "Unexpected errors: ${compiler.errors}");
206 } 206 }
207 207
208 testGhostMember() { 208 testGhostMember() {
209 var compiler = applyPatch( 209 var compiler = applyPatch(
210 """ 210 """
211 class Class { 211 class Class {
212 } 212 }
213 """, 213 """,
214 """ 214 """
215 patch class Class { 215 patch class Class {
216 void ghost() {} 216 void ghost() {}
217 } 217 }
218 """); 218 """);
219 var container = ensure(compiler, "Class", compiler.coreLibrary.find, 219 var container = ensure(compiler, "Class", compiler.coreLibrary.find,
220 isMethod: false, isPatched: true); 220 isMethod: false, isPatched: true);
221 container.parseNode(compiler); 221 container.parseNode(compiler);
222 ensure(compiler, "Class", compiler.coreLibrary.patch.find, 222 ensure(compiler, "Class", compiler.coreLibrary.patch.find,
223 isMethod: false, isPatch: true); 223 isMethod: false, isPatch: true);
224 224
225 ensure(compiler, "ghost", container.lookupLocalMember, isFound: false); 225 ensure(compiler, "ghost", container.lookupLocalMember, isFound: false);
226 ensure(compiler, "ghost", container.patch.lookupLocalMember); 226 ensure(compiler, "ghost", container.patch.lookupLocalMember);
227 227
228 Expect.isTrue(compiler.warnings.isEmpty(), 228 Expect.isTrue(compiler.warnings.isEmpty,
229 "Unexpected warnings: ${compiler.warnings}"); 229 "Unexpected warnings: ${compiler.warnings}");
230 Expect.isTrue(compiler.errors.isEmpty(), 230 Expect.isTrue(compiler.errors.isEmpty,
231 "Unexpected errors: ${compiler.errors}"); 231 "Unexpected errors: ${compiler.errors}");
232 } 232 }
233 233
234 testInjectFunction() { 234 testInjectFunction() {
235 var compiler = applyPatch( 235 var compiler = applyPatch(
236 "", 236 "",
237 "int _function() => 5;"); 237 "int _function() => 5;");
238 ensure(compiler, 238 ensure(compiler,
239 "_function", 239 "_function",
240 compiler.coreLibrary.find, 240 compiler.coreLibrary.find,
241 isFound: false); 241 isFound: false);
242 ensure(compiler, 242 ensure(compiler,
243 "_function", 243 "_function",
244 compiler.coreLibrary.patch.find); 244 compiler.coreLibrary.patch.find);
245 245
246 Expect.isTrue(compiler.warnings.isEmpty(), 246 Expect.isTrue(compiler.warnings.isEmpty,
247 "Unexpected warnings: ${compiler.warnings}"); 247 "Unexpected warnings: ${compiler.warnings}");
248 Expect.isTrue(compiler.errors.isEmpty(), 248 Expect.isTrue(compiler.errors.isEmpty,
249 "Unexpected errors: ${compiler.errors}"); 249 "Unexpected errors: ${compiler.errors}");
250 } 250 }
251 251
252 testPatchSignatureCheck() { 252 testPatchSignatureCheck() {
253 var compiler = applyPatch( 253 var compiler = applyPatch(
254 """ 254 """
255 class Class { 255 class Class {
256 external String method1(); 256 external String method1();
257 external void method2(String str); 257 external void method2(String str);
258 external void method3(String s1); 258 external void method3(String s1);
(...skipping 17 matching lines...) Expand all
276 } 276 }
277 """); 277 """);
278 var container = ensure(compiler, "Class", compiler.coreLibrary.find, 278 var container = ensure(compiler, "Class", compiler.coreLibrary.find,
279 isMethod: false, isPatched: true); 279 isMethod: false, isPatched: true);
280 container.ensureResolved(compiler); 280 container.ensureResolved(compiler);
281 container.parseNode(compiler); 281 container.parseNode(compiler);
282 282
283 compiler.resolver.resolveMethodElement( 283 compiler.resolver.resolveMethodElement(
284 ensure(compiler, "method1", container.lookupLocalMember, 284 ensure(compiler, "method1", container.lookupLocalMember,
285 isPatched: true)); 285 isPatched: true));
286 Expect.isTrue(compiler.warnings.isEmpty(), 286 Expect.isTrue(compiler.warnings.isEmpty,
287 "Unexpected warnings: ${compiler.warnings}"); 287 "Unexpected warnings: ${compiler.warnings}");
288 Expect.isFalse(compiler.errors.isEmpty()); 288 Expect.isFalse(compiler.errors.isEmpty);
289 print('method1:${compiler.errors}'); 289 print('method1:${compiler.errors}');
290 290
291 compiler.warnings.clear(); 291 compiler.warnings.clear();
292 compiler.errors.clear(); 292 compiler.errors.clear();
293 compiler.resolver.resolveMethodElement( 293 compiler.resolver.resolveMethodElement(
294 ensure(compiler, "method2", container.lookupLocalMember, 294 ensure(compiler, "method2", container.lookupLocalMember,
295 isPatched: true)); 295 isPatched: true));
296 Expect.isTrue(compiler.warnings.isEmpty(), 296 Expect.isTrue(compiler.warnings.isEmpty,
297 "Unexpected warnings: ${compiler.warnings}"); 297 "Unexpected warnings: ${compiler.warnings}");
298 Expect.isFalse(compiler.errors.isEmpty()); 298 Expect.isFalse(compiler.errors.isEmpty);
299 print('method2:${compiler.errors}'); 299 print('method2:${compiler.errors}');
300 300
301 compiler.warnings.clear(); 301 compiler.warnings.clear();
302 compiler.errors.clear(); 302 compiler.errors.clear();
303 compiler.resolver.resolveMethodElement( 303 compiler.resolver.resolveMethodElement(
304 ensure(compiler, "method3", container.lookupLocalMember, 304 ensure(compiler, "method3", container.lookupLocalMember,
305 isPatched: true)); 305 isPatched: true));
306 Expect.isTrue(compiler.warnings.isEmpty(), 306 Expect.isTrue(compiler.warnings.isEmpty,
307 "Unexpected warnings: ${compiler.warnings}"); 307 "Unexpected warnings: ${compiler.warnings}");
308 Expect.isFalse(compiler.errors.isEmpty()); 308 Expect.isFalse(compiler.errors.isEmpty);
309 print('method3:${compiler.errors}'); 309 print('method3:${compiler.errors}');
310 310
311 compiler.warnings.clear(); 311 compiler.warnings.clear();
312 compiler.errors.clear(); 312 compiler.errors.clear();
313 compiler.resolver.resolveMethodElement( 313 compiler.resolver.resolveMethodElement(
314 ensure(compiler, "method4", container.lookupLocalMember, 314 ensure(compiler, "method4", container.lookupLocalMember,
315 isPatched: true)); 315 isPatched: true));
316 Expect.isTrue(compiler.warnings.isEmpty(), 316 Expect.isTrue(compiler.warnings.isEmpty,
317 "Unexpected warnings: ${compiler.warnings}"); 317 "Unexpected warnings: ${compiler.warnings}");
318 Expect.isFalse(compiler.errors.isEmpty()); 318 Expect.isFalse(compiler.errors.isEmpty);
319 print('method4:${compiler.errors}'); 319 print('method4:${compiler.errors}');
320 320
321 compiler.warnings.clear(); 321 compiler.warnings.clear();
322 compiler.errors.clear(); 322 compiler.errors.clear();
323 compiler.resolver.resolveMethodElement( 323 compiler.resolver.resolveMethodElement(
324 ensure(compiler, "method5", container.lookupLocalMember, 324 ensure(compiler, "method5", container.lookupLocalMember,
325 isPatched: true)); 325 isPatched: true));
326 Expect.isTrue(compiler.warnings.isEmpty(), 326 Expect.isTrue(compiler.warnings.isEmpty,
327 "Unexpected warnings: ${compiler.warnings}"); 327 "Unexpected warnings: ${compiler.warnings}");
328 Expect.isFalse(compiler.errors.isEmpty()); 328 Expect.isFalse(compiler.errors.isEmpty);
329 print('method5:${compiler.errors}'); 329 print('method5:${compiler.errors}');
330 330
331 compiler.warnings.clear(); 331 compiler.warnings.clear();
332 compiler.errors.clear(); 332 compiler.errors.clear();
333 compiler.resolver.resolveMethodElement( 333 compiler.resolver.resolveMethodElement(
334 ensure(compiler, "method6", container.lookupLocalMember, 334 ensure(compiler, "method6", container.lookupLocalMember,
335 isPatched: true)); 335 isPatched: true));
336 Expect.isTrue(compiler.warnings.isEmpty(), 336 Expect.isTrue(compiler.warnings.isEmpty,
337 "Unexpected warnings: ${compiler.warnings}"); 337 "Unexpected warnings: ${compiler.warnings}");
338 Expect.isFalse(compiler.errors.isEmpty()); 338 Expect.isFalse(compiler.errors.isEmpty);
339 print('method6:${compiler.errors}'); 339 print('method6:${compiler.errors}');
340 340
341 compiler.warnings.clear(); 341 compiler.warnings.clear();
342 compiler.errors.clear(); 342 compiler.errors.clear();
343 compiler.resolver.resolveMethodElement( 343 compiler.resolver.resolveMethodElement(
344 ensure(compiler, "method7", container.lookupLocalMember, 344 ensure(compiler, "method7", container.lookupLocalMember,
345 isPatched: true)); 345 isPatched: true));
346 Expect.isTrue(compiler.warnings.isEmpty(), 346 Expect.isTrue(compiler.warnings.isEmpty,
347 "Unexpected warnings: ${compiler.warnings}"); 347 "Unexpected warnings: ${compiler.warnings}");
348 Expect.isFalse(compiler.errors.isEmpty()); 348 Expect.isFalse(compiler.errors.isEmpty);
349 print('method7:${compiler.errors}'); 349 print('method7:${compiler.errors}');
350 350
351 compiler.warnings.clear(); 351 compiler.warnings.clear();
352 compiler.errors.clear(); 352 compiler.errors.clear();
353 compiler.resolver.resolveMethodElement( 353 compiler.resolver.resolveMethodElement(
354 ensure(compiler, "method8", container.lookupLocalMember, 354 ensure(compiler, "method8", container.lookupLocalMember,
355 isPatched: true)); 355 isPatched: true));
356 Expect.isTrue(compiler.warnings.isEmpty(), 356 Expect.isTrue(compiler.warnings.isEmpty,
357 "Unexpected warnings: ${compiler.warnings}"); 357 "Unexpected warnings: ${compiler.warnings}");
358 Expect.isFalse(compiler.errors.isEmpty()); 358 Expect.isFalse(compiler.errors.isEmpty);
359 print('method8:${compiler.errors}'); 359 print('method8:${compiler.errors}');
360 } 360 }
361 361
362 main() { 362 main() {
363 testPatchFunction(); 363 testPatchFunction();
364 testPatchMember(); 364 testPatchMember();
365 testPatchGetter(); 365 testPatchGetter();
366 testRegularMember(); 366 testRegularMember();
367 testGhostMember(); 367 testGhostMember();
368 testInjectFunction(); 368 testInjectFunction();
369 testPatchSignatureCheck(); 369 testPatchSignatureCheck();
370 } 370 }
OLDNEW
« no previous file with comments | « tests/compiler/dart2js/parser_test.dart ('k') | tests/compiler/dart2js/resolver_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698