OLD | NEW |
---|---|
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 trydart.incremental_compilation_update_test; | 5 library trydart.incremental_compilation_update_test; |
6 | 6 |
7 import 'dart:html' hide | 7 import 'dart:html' hide |
8 Element; | 8 Element; |
9 | 9 |
10 import 'dart:async' show | 10 import 'dart:async' show |
(...skipping 26 matching lines...) Expand all Loading... | |
37 Element, | 37 Element, |
38 LibraryElement; | 38 LibraryElement; |
39 | 39 |
40 import 'package:compiler/src/dart2jslib.dart' show | 40 import 'package:compiler/src/dart2jslib.dart' show |
41 Compiler; | 41 Compiler; |
42 | 42 |
43 import 'program_result.dart'; | 43 import 'program_result.dart'; |
44 | 44 |
45 const int TIMEOUT = 100; | 45 const int TIMEOUT = 100; |
46 | 46 |
47 const List<List<ProgramResult>> tests = const <List<ProgramResult>>[ | 47 const List tests = const [ |
48 // Basic hello-world test. | 48 // Basic hello-world test. |
49 const <ProgramResult>[ | 49 const [ |
Johnni Winther
2014/12/16 11:39:07
I would insert a constant class at this level:
cl
ahe
2014/12/16 11:58:50
Done.
| |
50 const ProgramResult( | 50 const [ |
51 "main() { print('Hello, World!'); }", | 51 "main() { print('Hello, ", |
52 const <String> ['Hello, World!']), | 52 const ["", "Brave New "], |
53 const ProgramResult( | 53 "World!'); }", |
54 "main() { print('Hello, Brave New World!'); }", | 54 ], |
55 const <String> ['Hello, Brave New World!']), | 55 const <ProgramExpectation>[ |
56 const ProgramExpectation( | |
57 const <String>['Hello, World!']), | |
58 const ProgramExpectation( | |
59 const <String>['Hello, Brave New World!']), | |
60 ], | |
56 ], | 61 ], |
57 | 62 |
58 // Test that the test framework handles more than one update. | 63 // Test that the test framework handles more than one update. |
59 const <ProgramResult>[ | 64 const [ |
60 const ProgramResult( | 65 const [ |
61 "main() { print('Hello darkness, my old friend'); }", | 66 "main() { print('", |
62 const <String> ['Hello darkness, my old friend']), | 67 const [ |
63 const ProgramResult( | 68 "Hello darkness, my old friend", |
64 "main() { print('I\\'ve come to talk with you again'); }", | 69 "I\\'ve come to talk with you again", |
65 const <String> ['I\'ve come to talk with you again']), | 70 "Because a vision softly creeping", |
66 const ProgramResult( | 71 ], |
67 "main() { print('Because a vision softly creeping'); }", | 72 "'); }", |
68 const <String> ['Because a vision softly creeping']), | 73 ], |
74 const <ProgramExpectation>[ | |
75 const ProgramExpectation( | |
76 const <String>['Hello darkness, my old friend']), | |
77 const ProgramExpectation( | |
78 const <String>['I\'ve come to talk with you again']), | |
79 const ProgramExpectation( | |
80 const <String>['Because a vision softly creeping']), | |
81 ], | |
69 ], | 82 ], |
70 | 83 |
71 // Test that that isolate support works. | 84 // Test that that isolate support works. |
72 const <ProgramResult>[ | 85 const [ |
73 const ProgramResult( | 86 const [ |
74 "main(arguments) { print('Hello, Isolated World!'); }", | 87 "main(arguments) { print(", |
75 const <String> ['Hello, Isolated World!']), | 88 const [ |
76 const ProgramResult( | 89 "'Hello, Isolated World!'", |
77 "main(arguments) { print(arguments); }", | 90 "arguments" |
78 const <String> ['[]']), | 91 ], |
92 "); }", | |
93 ], | |
94 const <ProgramExpectation>[ | |
95 const ProgramExpectation( | |
96 const <String>['Hello, Isolated World!']), | |
97 const ProgramExpectation( | |
98 const <String>['[]']), | |
99 ], | |
79 ], | 100 ], |
80 | 101 |
81 // Test that a stored closure changes behavior when updated. | 102 const [ |
82 const <ProgramResult>[ | 103 const [ |
83 const ProgramResult( | |
84 r""" | 104 r""" |
105 // Test that a stored closure changes behavior when updated. | |
106 | |
85 var closure; | 107 var closure; |
86 | 108 |
87 foo(a, [b = 'b']) { | 109 foo(a, [b = 'b']) { |
88 print('$a $b'); | 110 """, |
111 const [ | |
112 r"print('$a $b');", | |
113 r"print('$b $a');", | |
114 ], | |
115 r""" | |
89 } | 116 } |
90 | 117 |
91 main() { | 118 main() { |
92 if (closure == null) { | |
93 print('[closure] is null.'); | |
94 closure = foo; | |
95 } | |
96 closure('a'); | |
97 closure('a', 'c'); | |
98 } | |
99 """, | |
100 const <String> ['[closure] is null.', 'a b', 'a c']), | |
101 const ProgramResult( | |
102 r""" | |
103 var closure; | |
104 | |
105 foo(a, [b = 'b']) { | |
106 print('$b $a'); | |
107 } | |
108 | |
109 main() { | |
110 if (closure == null) { | 119 if (closure == null) { |
111 print('[closure] is null.'); | 120 print('[closure] is null.'); |
112 closure = foo; | 121 closure = foo; |
113 } | 122 } |
114 closure('a'); | 123 closure('a'); |
115 closure('a', 'c'); | 124 closure('a', 'c'); |
116 } | 125 } |
117 """, | 126 """], |
118 const <String> ['b a', 'c a']), | 127 const <ProgramExpectation>[ |
128 const ProgramExpectation( | |
129 const <String>['[closure] is null.', 'a b', 'a c']), | |
130 const ProgramExpectation( | |
131 const <String>['b a', 'c a']), | |
132 ], | |
119 ], | 133 ], |
120 | 134 |
121 // Test modifying a static method works. | 135 const [ |
122 const <ProgramResult>[ | 136 const [ |
123 const ProgramResult( | |
124 """ | 137 """ |
138 // Test modifying a static method works. | |
139 | |
125 class C { | 140 class C { |
126 static m() { | 141 static m() { |
127 print('v1'); | 142 """, |
143 const [ | |
144 "print('v1');", | |
145 "print('v2');", | |
146 ], | |
147 """ | |
128 } | 148 } |
129 } | 149 } |
130 main() { | 150 main() { |
131 C.m(); | 151 C.m(); |
132 } | 152 } |
133 """, | 153 """, |
134 const <String> ['v1']), | 154 ], |
135 const ProgramResult( | 155 const <ProgramExpectation>[ |
136 """ | 156 const ProgramExpectation( |
137 class C { | 157 const <String>['v1']), |
138 static m() { | 158 const ProgramExpectation( |
139 print('v2'); | 159 const <String>['v2']), |
140 } | 160 ], |
141 } | |
142 main() { | |
143 C.m(); | |
144 } | |
145 """, | |
146 const <String> ['v2']), | |
147 ], | 161 ], |
148 | 162 |
149 // Test modifying an instance method works. | 163 const [ |
150 const <ProgramResult>[ | 164 const [ |
151 const ProgramResult( | |
152 """ | 165 """ |
166 // Test modifying an instance method works. | |
167 | |
153 class C { | 168 class C { |
154 m() { | 169 m() { |
155 print('v1'); | 170 """, |
171 const [ | |
172 "print('v1');", | |
173 "print('v2');", | |
174 ], | |
175 """ | |
156 } | 176 } |
157 } | 177 } |
158 var instance; | 178 var instance; |
159 main() { | |
160 if (instance == null) { | |
161 print('instance is null'); | |
162 instance = new C(); | |
163 } | |
164 instance.m(); | |
165 } | |
166 """, | |
167 const <String> ['instance is null', 'v1']), | |
168 const ProgramResult( | |
169 """ | |
170 class C { | |
171 m() { | |
172 print('v2'); | |
173 } | |
174 } | |
175 var instance; | |
176 main() { | 179 main() { |
177 if (instance == null) { | 180 if (instance == null) { |
178 print('instance is null'); | 181 print('instance is null'); |
179 instance = new C(); | 182 instance = new C(); |
180 } | 183 } |
181 instance.m(); | 184 instance.m(); |
182 } | 185 } |
183 """, | 186 """, |
184 const <String> ['v2']), | 187 |
188 ], | |
189 const <ProgramExpectation>[ | |
190 const ProgramExpectation( | |
191 const <String>['instance is null', 'v1']), | |
192 const ProgramExpectation( | |
193 const <String>['v2']), | |
194 ], | |
185 ], | 195 ], |
186 | 196 |
187 // Test that a stored instance tearoff changes behavior when updated. | 197 const [ |
188 const <ProgramResult>[ | 198 const [ |
189 const ProgramResult( | |
190 """ | 199 """ |
200 // Test that a stored instance tearoff changes behavior when updated. | |
201 | |
191 class C { | 202 class C { |
192 m() { | 203 m() { |
193 print('v1'); | 204 """, |
205 const [ | |
206 "print('v1');", | |
207 "print('v2');", | |
208 ], | |
209 """ | |
194 } | 210 } |
195 } | 211 } |
196 var closure; | 212 var closure; |
197 main() { | |
198 if (closure == null) { | |
199 print('closure is null'); | |
200 closure = new C().m; | |
201 } | |
202 closure(); | |
203 } | |
204 """, | |
205 const <String> ['closure is null', 'v1']), | |
206 const ProgramResult( | |
207 """ | |
208 class C { | |
209 m() { | |
210 print('v2'); | |
211 } | |
212 } | |
213 var closure; | |
214 main() { | 213 main() { |
215 if (closure == null) { | 214 if (closure == null) { |
216 print('closure is null'); | 215 print('closure is null'); |
217 closure = new C().m; | 216 closure = new C().m; |
218 } | 217 } |
219 closure(); | 218 closure(); |
220 } | 219 } |
221 """, | 220 """, |
222 const <String> ['v2']), | 221 |
222 ], | |
223 const <ProgramExpectation>[ | |
224 const ProgramExpectation( | |
225 const <String>['closure is null', 'v1']), | |
226 const ProgramExpectation( | |
227 const <String>['v2']), | |
228 ], | |
223 ], | 229 ], |
224 | 230 |
225 // Test that deleting an instance method works. | 231 const [ |
226 const <ProgramResult>[ | 232 const [ |
227 const ProgramResult( | |
228 """ | 233 """ |
234 // Test that deleting an instance method works. | |
235 | |
229 class C { | 236 class C { |
237 """, | |
238 const [ | |
239 """ | |
230 m() { | 240 m() { |
231 print('v1'); | 241 print('v1'); |
232 } | 242 } |
243 """, | |
244 """ | |
245 """, | |
246 ], | |
247 """ | |
233 } | 248 } |
234 var instance; | 249 var instance; |
235 main() { | 250 main() { |
236 if (instance == null) { | |
237 print('instance is null'); | |
238 instance = new C(); | |
239 } | |
240 try { | |
241 instance.m(); | |
242 } catch (e) { | |
243 print('threw'); | |
244 } | |
245 } | |
246 """, | |
247 const <String> ['instance is null', 'v1']), | |
248 const ProgramResult( | |
249 """ | |
250 class C { | |
251 } | |
252 var instance; | |
253 main() { | |
254 if (instance == null) { | 251 if (instance == null) { |
255 print('instance is null'); | 252 print('instance is null'); |
256 instance = new C(); | 253 instance = new C(); |
257 } | 254 } |
258 try { | 255 try { |
259 instance.m(); | 256 instance.m(); |
260 } catch (e) { | 257 } catch (e) { |
261 print('threw'); | 258 print('threw'); |
262 } | 259 } |
263 } | 260 } |
264 """, | 261 """, |
265 const <String> ['threw']), | 262 ], |
263 const <ProgramExpectation>[ | |
264 const ProgramExpectation( | |
265 const <String>['instance is null', 'v1']), | |
266 const ProgramExpectation( | |
267 const <String>['threw']), | |
268 ], | |
266 ], | 269 ], |
267 | 270 |
268 // Test that deleting an instance method works, even when accessed through | 271 const [ |
269 // super. | 272 const [ |
270 const <ProgramResult>[ | |
271 const ProgramResult( | |
272 """ | 273 """ |
274 // Test that deleting an instance method works, even when accessed through | |
275 // super. | |
276 | |
273 class A { | 277 class A { |
274 m() { | 278 m() { |
275 print('v2'); | 279 print('v2'); |
276 } | 280 } |
277 } | 281 } |
278 class B extends A { | 282 class B extends A { |
283 """, | |
284 const [ | |
285 """ | |
279 m() { | 286 m() { |
280 print('v1'); | 287 print('v1'); |
281 } | 288 } |
289 """, | |
290 """ | |
291 """, | |
292 ], | |
293 """ | |
282 } | 294 } |
283 class C extends B { | 295 class C extends B { |
284 m() { | 296 m() { |
285 super.m(); | |
286 } | |
287 } | |
288 var instance; | |
289 main() { | |
290 if (instance == null) { | |
291 print('instance is null'); | |
292 instance = new C(); | |
293 } | |
294 instance.m(); | |
295 } | |
296 """, | |
297 const <String> ['instance is null', 'v1']), | |
298 const ProgramResult( | |
299 """ | |
300 class A { | |
301 m() { | |
302 print('v2'); | |
303 } | |
304 } | |
305 class B extends A { | |
306 } | |
307 class C extends B { | |
308 m() { | |
309 super.m(); | 297 super.m(); |
310 } | 298 } |
311 } | 299 } |
312 var instance; | 300 var instance; |
313 main() { | 301 main() { |
314 if (instance == null) { | 302 if (instance == null) { |
315 print('instance is null'); | 303 print('instance is null'); |
316 instance = new C(); | 304 instance = new C(); |
317 } | 305 } |
318 instance.m(); | 306 instance.m(); |
319 } | 307 } |
320 """, | 308 """, |
321 const <String> ['v2']), | 309 |
310 ], | |
311 const <ProgramExpectation>[ | |
312 const ProgramExpectation( | |
313 const <String>['instance is null', 'v1']), | |
314 const ProgramExpectation( | |
315 const <String>['v2']), | |
316 ], | |
322 ], | 317 ], |
323 | 318 |
324 // Test that deleting a top-level method works. | 319 const [ |
325 const <ProgramResult>[ | 320 const [ |
326 const ProgramResult( | |
327 """ | 321 """ |
322 // Test that deleting a top-level method works. | |
323 | |
324 """, | |
325 const [ | |
326 """ | |
328 toplevel() { | 327 toplevel() { |
329 print('v1'); | 328 print('v1'); |
330 } | 329 } |
331 class C { | |
332 m() { | |
333 try { | |
334 toplevel(); | |
335 } catch (e) { | |
336 print('threw'); | |
337 } | |
338 } | |
339 } | |
340 var instance; | |
341 main() { | |
342 if (instance == null) { | |
343 print('instance is null'); | |
344 instance = new C(); | |
345 } | |
346 instance.m(); | |
347 } | |
348 """, | 330 """, |
349 const <String> ['instance is null', 'v1']), | 331 """ |
350 const ProgramResult( | 332 """, |
333 ], | |
351 """ | 334 """ |
352 class C { | 335 class C { |
353 m() { | 336 m() { |
354 try { | 337 try { |
355 toplevel(); | 338 toplevel(); |
356 } catch (e) { | 339 } catch (e) { |
357 print('threw'); | 340 print('threw'); |
358 } | 341 } |
359 } | 342 } |
360 } | 343 } |
361 var instance; | 344 var instance; |
362 main() { | 345 main() { |
363 if (instance == null) { | 346 if (instance == null) { |
364 print('instance is null'); | 347 print('instance is null'); |
365 instance = new C(); | 348 instance = new C(); |
366 } | 349 } |
367 instance.m(); | 350 instance.m(); |
368 } | 351 } |
369 """, | 352 """, |
370 const <String> ['threw']), | 353 ], |
354 const <ProgramExpectation>[ | |
355 const ProgramExpectation( | |
356 const <String>['instance is null', 'v1']), | |
357 const ProgramExpectation( | |
358 const <String>['threw']), | |
359 ], | |
371 ], | 360 ], |
372 | 361 |
373 // Test that deleting a static method works. | 362 const [ |
374 const <ProgramResult>[ | 363 const [ |
375 const ProgramResult( | |
376 """ | 364 """ |
365 // Test that deleting a static method works. | |
366 | |
377 class B { | 367 class B { |
368 """, | |
369 const [ | |
370 """ | |
378 static staticMethod() { | 371 static staticMethod() { |
379 print('v1'); | 372 print('v1'); |
380 } | 373 } |
374 """, | |
375 """ | |
376 """, | |
377 ], | |
378 """ | |
381 } | 379 } |
382 class C { | 380 class C { |
383 m() { | 381 m() { |
384 try { | |
385 B.staticMethod(); | |
386 } catch (e) { | |
387 print('threw'); | |
388 } | |
389 try { | |
390 // Ensure that noSuchMethod support is compiled. This test is not about | |
391 // adding new classes. | |
392 B.missingMethod(); | |
393 print('bad'); | |
394 } catch (e) { | |
395 } | |
396 } | |
397 } | |
398 var instance; | |
399 main() { | |
400 if (instance == null) { | |
401 print('instance is null'); | |
402 instance = new C(); | |
403 } | |
404 instance.m(); | |
405 } | |
406 """, | |
407 const <String> ['instance is null', 'v1']), | |
408 const ProgramResult( | |
409 """ | |
410 class B { | |
411 } | |
412 class C { | |
413 m() { | |
414 try { | 382 try { |
415 B.staticMethod(); | 383 B.staticMethod(); |
416 } catch (e) { | 384 } catch (e) { |
417 print('threw'); | 385 print('threw'); |
418 } | 386 } |
419 try { | 387 try { |
420 // Ensure that noSuchMethod support is compiled. This test is not about | 388 // Ensure that noSuchMethod support is compiled. This test is not about |
421 // adding new classes. | 389 // adding new classes. |
422 B.missingMethod(); | 390 B.missingMethod(); |
423 print('bad'); | 391 print('bad'); |
424 } catch (e) { | 392 } catch (e) { |
425 } | 393 } |
426 } | 394 } |
427 } | 395 } |
428 var instance; | 396 var instance; |
429 main() { | 397 main() { |
430 if (instance == null) { | 398 if (instance == null) { |
431 print('instance is null'); | 399 print('instance is null'); |
432 instance = new C(); | 400 instance = new C(); |
433 } | 401 } |
434 instance.m(); | 402 instance.m(); |
435 } | 403 } |
436 """, | 404 """, |
437 const <String> ['threw']), | 405 ], |
406 const <ProgramExpectation>[ | |
407 const ProgramExpectation( | |
408 const <String>['instance is null', 'v1']), | |
409 const ProgramExpectation( | |
410 const <String>['threw']), | |
411 ], | |
438 ], | 412 ], |
439 | 413 |
440 // Test that a newly instantiated class is handled. | 414 const [ |
441 const <ProgramResult>[ | 415 const [ |
442 const ProgramResult( | |
443 """ | 416 """ |
417 // Test that a newly instantiated class is handled. | |
418 | |
444 class A { | 419 class A { |
445 m() { | 420 m() { |
446 print('Called A.m'); | 421 print('Called A.m'); |
447 } | |
448 } | |
449 | |
450 class B { | |
451 m() { | |
452 print('Called B.m'); | |
453 } | |
454 } | |
455 | |
456 var instance; | |
457 main() { | |
458 if (instance == null) { | |
459 print('instance is null'); | |
460 instance = new A(); | |
461 } | |
462 instance.m(); | |
463 } | |
464 """, | |
465 const <String>['instance is null', 'Called A.m']), | |
466 const ProgramResult( | |
467 """ | |
468 class A { | |
469 m() { | |
470 print('Called A.m'); | |
471 } | 422 } |
472 } | 423 } |
473 | 424 |
474 class B { | 425 class B { |
475 m() { | 426 m() { |
476 print('Called B.m'); | 427 print('Called B.m'); |
477 } | 428 } |
478 } | 429 } |
479 | 430 |
480 var instance; | 431 var instance; |
481 main() { | 432 main() { |
482 if (instance == null) { | 433 if (instance == null) { |
483 print('instance is null'); | 434 print('instance is null'); |
484 instance = new A(); | 435 instance = new A(); |
436 """, | |
437 const [ | |
438 """ | |
439 """, | |
440 """ | |
485 } else { | 441 } else { |
486 instance = new B(); | 442 instance = new B(); |
443 """, | |
444 ], | |
445 """ | |
487 } | 446 } |
488 instance.m(); | 447 instance.m(); |
489 } | 448 } |
490 """, | 449 """, |
491 const <String>['Called B.m']), | 450 |
451 ], | |
452 const <ProgramExpectation>[ | |
453 const ProgramExpectation( | |
454 const <String>['instance is null', 'Called A.m']), | |
455 const ProgramExpectation( | |
456 const <String>['Called B.m']), | |
457 ], | |
492 ], | 458 ], |
493 | 459 |
494 // Test that source maps don't throw exceptions. | 460 const [ |
495 const <ProgramResult>[ | 461 const [ |
496 const ProgramResult( | |
497 """ | 462 """ |
463 // Test that source maps don't throw exceptions. | |
464 | |
498 main() { | 465 main() { |
499 print('a'); | 466 print('a'); |
467 """, | |
468 const [ | |
469 """ | |
470 """, | |
471 """ | |
472 print('b'); | |
473 print('c'); | |
474 """, | |
475 ], | |
476 """ | |
500 } | 477 } |
501 """, | 478 """, |
502 const <String>['a']), | 479 ], |
503 | 480 const <ProgramExpectation>[ |
504 const ProgramResult( | 481 const ProgramExpectation( |
505 """ | 482 const <String>['a']), |
506 main() { | 483 const ProgramExpectation( |
507 print('a'); | 484 const <String>['a', 'b', 'c']), |
508 print('b'); | 485 ], |
509 print('c'); | |
510 } | |
511 """, | |
512 const <String>['a', 'b', 'c']), | |
513 ], | 486 ], |
514 | 487 |
515 // Test that a newly instantiated class is handled. | 488 const [ |
516 const <ProgramResult>[ | 489 const [ |
517 const ProgramResult( | |
518 r""" | 490 r""" |
491 // Test that a newly instantiated class is handled. | |
492 | |
519 class A { | 493 class A { |
520 get name => 'A.m'; | 494 get name => 'A.m'; |
521 | 495 |
522 m() { | |
523 print('Called $name'); | |
524 } | |
525 } | |
526 | |
527 class B extends A { | |
528 get name => 'B.m'; | |
529 } | |
530 | |
531 var instance; | |
532 main() { | |
533 if (instance == null) { | |
534 print('instance is null'); | |
535 instance = new A(); | |
536 } | |
537 instance.m(); | |
538 } | |
539 """, | |
540 const <String>['instance is null', 'Called A.m']), | |
541 const ProgramResult( | |
542 r""" | |
543 class A { | |
544 get name => 'A.m'; | |
545 | |
546 m() { | 496 m() { |
547 print('Called $name'); | 497 print('Called $name'); |
548 } | 498 } |
549 } | 499 } |
550 | 500 |
551 class B extends A { | 501 class B extends A { |
552 get name => 'B.m'; | 502 get name => 'B.m'; |
553 } | 503 } |
554 | 504 |
555 var instance; | 505 var instance; |
556 main() { | 506 main() { |
557 if (instance == null) { | 507 if (instance == null) { |
558 print('instance is null'); | 508 print('instance is null'); |
559 instance = new A(); | 509 instance = new A(); |
510 """, | |
511 const [ | |
512 r""" | |
513 """, | |
514 r""" | |
560 } else { | 515 } else { |
561 instance = new B(); | 516 instance = new B(); |
517 """, | |
518 ], | |
519 r""" | |
562 } | 520 } |
563 instance.m(); | 521 instance.m(); |
564 } | 522 } |
565 """, | 523 """, |
566 const <String>['Called B.m']), | 524 ], |
525 const <ProgramExpectation>[ | |
526 const ProgramExpectation( | |
527 const <String>['instance is null', 'Called A.m']), | |
528 const ProgramExpectation( | |
529 const <String>['Called B.m']), | |
530 ], | |
567 ], | 531 ], |
568 | 532 |
569 // Test that fields of a newly instantiated class are handled. | 533 const [ |
570 const <ProgramResult>[ | 534 const [ |
571 const ProgramResult( | |
572 r""" | 535 r""" |
536 // Test that fields of a newly instantiated class are handled. | |
537 | |
573 class A { | 538 class A { |
574 var x; | 539 var x; |
575 A(this.x); | 540 A(this.x); |
576 } | 541 } |
577 var instance; | 542 var instance; |
578 foo() { | 543 foo() { |
579 if (instance != null) { | 544 if (instance != null) { |
580 print(instance.x); | 545 print(instance.x); |
581 } else { | 546 } else { |
582 print('v1'); | 547 print('v1'); |
583 } | 548 } |
584 } | 549 } |
585 main() { | 550 main() { |
551 """, | |
552 const [ | |
553 r""" | |
554 """, | |
555 r""" | |
556 instance = new A('v2'); | |
557 """, | |
558 ], | |
559 r""" | |
586 foo(); | 560 foo(); |
587 } | 561 } |
588 """, | 562 """, |
589 const <String>['v1']), | 563 ], |
590 const ProgramResult( | 564 const <ProgramExpectation>[ |
565 const ProgramExpectation( | |
566 const <String>['v1']), | |
567 const ProgramExpectation( | |
568 const <String>['v2']), | |
569 ], | |
570 ], | |
571 | |
572 const [ | |
573 const [ | |
591 r""" | 574 r""" |
592 class A { | 575 // Test that top-level functions can be added. |
593 var x; | 576 |
594 A(this.x); | 577 """, |
595 } | 578 const [ |
596 var instance; | 579 "", |
580 r""" | |
597 foo() { | 581 foo() { |
598 if (instance != null) { | 582 print('v2'); |
599 print(instance.x); | |
600 } else { | |
601 print('v1'); | |
602 } | |
603 } | |
604 main() { | |
605 instance = new A('v2'); | |
606 foo(); | |
607 } | 583 } |
608 """, | 584 """, |
609 const <String>['v2']), | 585 ], |
610 ], | |
611 | |
612 // Test that top-level functions can be added. | |
613 const <ProgramResult>[ | |
614 const ProgramResult( | |
615 r""" | 586 r""" |
616 main() { | 587 main() { |
617 try { | 588 try { |
618 foo(); | 589 foo(); |
619 } catch(e) { | |
620 print('threw'); | |
621 } | |
622 } | |
623 """, | |
624 const <String>['threw']), | |
625 const ProgramResult( | |
626 r""" | |
627 foo() { | |
628 print('v2'); | |
629 } | |
630 | |
631 main() { | |
632 try { | |
633 foo(); | |
634 } catch(e) { | 590 } catch(e) { |
635 print('threw'); | 591 print('threw'); |
636 } | 592 } |
637 } | 593 } |
638 """, | 594 """, |
639 const <String>['v2']), | 595 ], |
596 const <ProgramExpectation>[ | |
597 const ProgramExpectation( | |
598 const <String>['threw']), | |
599 const ProgramExpectation( | |
600 const <String>['v2']), | |
601 ], | |
640 ], | 602 ], |
641 | 603 |
642 // Test that static methods can be added. | 604 const [ |
643 const <ProgramResult>[ | 605 const [ |
644 const ProgramResult( | |
645 r""" | 606 r""" |
607 // Test that static methods can be added. | |
608 | |
646 class C { | 609 class C { |
610 """, | |
611 const [ | |
612 "", | |
613 r""" | |
614 static foo() { | |
615 print('v2'); | |
616 } | |
617 """, | |
618 ], | |
619 r""" | |
647 } | 620 } |
648 | 621 |
649 main() { | 622 main() { |
650 try { | |
651 C.foo(); | |
652 } catch(e) { | |
653 print('threw'); | |
654 } | |
655 } | |
656 """, | |
657 const <String>['threw']), | |
658 const ProgramResult( | |
659 r""" | |
660 class C { | |
661 static foo() { | |
662 print('v2'); | |
663 } | |
664 } | |
665 | |
666 main() { | |
667 try { | 623 try { |
668 C.foo(); | 624 C.foo(); |
669 } catch(e) { | 625 } catch(e) { |
670 print('threw'); | 626 print('threw'); |
671 } | 627 } |
672 } | 628 } |
673 """, | 629 """, |
674 const <String>['v2']), | 630 |
631 ], | |
632 const <ProgramExpectation>[ | |
633 const ProgramExpectation( | |
634 const <String>['threw']), | |
635 const ProgramExpectation( | |
636 const <String>['v2']), | |
637 ], | |
675 ], | 638 ], |
676 | 639 |
677 // Test that instance methods can be added. | 640 const [ |
678 const <ProgramResult>[ | 641 const [ |
679 const ProgramResult( | |
680 r""" | 642 r""" |
643 // Test that instance methods can be added. | |
644 | |
681 class C { | 645 class C { |
646 """, | |
647 const [ | |
648 "", | |
649 r""" | |
650 foo() { | |
651 print('v2'); | |
652 } | |
653 """, | |
654 ], | |
655 r""" | |
682 } | 656 } |
683 | 657 |
684 var instance; | 658 var instance; |
685 | |
686 main() { | |
687 if (instance == null) { | |
688 print('instance is null'); | |
689 instance = new C(); | |
690 } | |
691 | |
692 try { | |
693 instance.foo(); | |
694 } catch(e) { | |
695 print('threw'); | |
696 } | |
697 } | |
698 """, | |
699 const <String>['instance is null', 'threw']), | |
700 const ProgramResult( | |
701 r""" | |
702 class C { | |
703 foo() { | |
704 print('v2'); | |
705 } | |
706 } | |
707 | |
708 var instance; | |
709 | 659 |
710 main() { | 660 main() { |
711 if (instance == null) { | 661 if (instance == null) { |
712 print('instance is null'); | 662 print('instance is null'); |
713 instance = new C(); | 663 instance = new C(); |
714 } | 664 } |
715 | 665 |
716 try { | 666 try { |
717 instance.foo(); | 667 instance.foo(); |
718 } catch(e) { | 668 } catch(e) { |
719 print('threw'); | 669 print('threw'); |
720 } | 670 } |
721 } | 671 } |
722 """, | 672 """, |
723 const <String>['v2']), | 673 ], |
674 const <ProgramExpectation>[ | |
675 const ProgramExpectation( | |
676 const <String>['instance is null', 'threw']), | |
677 const ProgramExpectation( | |
678 const <String>['v2']), | |
679 ], | |
724 ], | 680 ], |
725 | 681 |
726 // Test that top-level functions can have signature changed. | 682 const [ |
727 const <ProgramResult>[ | 683 const [ |
728 const ProgramResult( | |
729 r""" | 684 r""" |
685 // Test that top-level functions can have signature changed. | |
686 | |
687 """, | |
688 const [ | |
689 r""" | |
730 foo() { | 690 foo() { |
731 print('v1'); | 691 print('v1'); |
692 """, | |
693 r""" | |
694 void foo() { | |
695 print('v2'); | |
696 """, | |
697 ], | |
698 r""" | |
732 } | 699 } |
733 | 700 |
734 main() { | 701 main() { |
735 foo(); | 702 foo(); |
736 } | 703 } |
737 """, | 704 """, |
738 const <String>['v1']), | 705 ], |
739 const ProgramResult( | 706 const <ProgramExpectation>[ |
740 r""" | 707 const ProgramExpectation( |
741 void foo() { | 708 const <String>['v1']), |
742 print('v2'); | 709 const ProgramExpectation( |
743 } | 710 const <String>['v2']), |
744 | 711 ], |
745 main() { | |
746 foo(); | |
747 } | |
748 """, | |
749 const <String>['v2']), | |
750 ], | 712 ], |
751 | 713 |
752 // Test that static methods can have signature changed. | 714 const [ |
753 const <ProgramResult>[ | 715 const [ |
754 const ProgramResult( | |
755 r""" | 716 r""" |
717 // Test that static methods can have signature changed. | |
718 | |
756 class C { | 719 class C { |
720 """, | |
721 const [ | |
722 r""" | |
757 static foo() { | 723 static foo() { |
758 print('v1'); | 724 print('v1'); |
725 """, | |
726 r""" | |
727 static void foo() { | |
728 print('v2'); | |
729 """, | |
730 ], | |
731 r""" | |
759 } | 732 } |
760 } | 733 } |
761 | 734 |
762 main() { | |
763 C.foo(); | |
764 } | |
765 """, | |
766 const <String>['v1']), | |
767 const ProgramResult( | |
768 r""" | |
769 class C { | |
770 static void foo() { | |
771 print('v2'); | |
772 } | |
773 } | |
774 | |
775 main() { | 735 main() { |
776 C.foo(); | 736 C.foo(); |
777 } | 737 } |
778 """, | 738 """, |
779 const <String>['v2']), | 739 ], |
740 const <ProgramExpectation>[ | |
741 const ProgramExpectation( | |
742 const <String>['v1']), | |
743 const ProgramExpectation( | |
744 const <String>['v2']), | |
745 ], | |
780 ], | 746 ], |
781 | 747 |
782 // Test that instance methods can have signature changed. | 748 const [ |
783 const <ProgramResult>[ | 749 const [ |
784 const ProgramResult( | |
785 r""" | 750 r""" |
751 // Test that instance methods can have signature changed. | |
752 | |
786 class C { | 753 class C { |
754 """, | |
755 const [ | |
756 r""" | |
787 foo() { | 757 foo() { |
788 print('v1'); | 758 print('v1'); |
759 """, | |
760 r""" | |
761 void foo() { | |
762 print('v2'); | |
763 """, | |
764 ], | |
765 r""" | |
789 } | 766 } |
790 } | 767 } |
791 | 768 |
792 var instance; | |
793 | |
794 main() { | |
795 if (instance == null) { | |
796 print('instance is null'); | |
797 instance = new C(); | |
798 } | |
799 | |
800 instance.foo(); | |
801 } | |
802 """, | |
803 const <String>['instance is null', 'v1']), | |
804 const ProgramResult( | |
805 r""" | |
806 class C { | |
807 void foo() { | |
808 print('v2'); | |
809 } | |
810 } | |
811 | |
812 var instance; | 769 var instance; |
813 | 770 |
814 main() { | 771 main() { |
815 if (instance == null) { | 772 if (instance == null) { |
816 print('instance is null'); | 773 print('instance is null'); |
817 instance = new C(); | 774 instance = new C(); |
818 } | 775 } |
819 | 776 |
820 instance.foo(); | 777 instance.foo(); |
821 } | 778 } |
822 """, | 779 """, |
823 const <String>['v2']), | 780 ], |
781 const <ProgramExpectation>[ | |
782 const ProgramExpectation( | |
783 const <String>['instance is null', 'v1']), | |
784 const ProgramExpectation( | |
785 const <String>['v2']), | |
786 ], | |
824 ], | 787 ], |
825 | 788 |
789 const [ | |
790 const [ | |
791 r""" | |
826 // Test that adding a class is supported. | 792 // Test that adding a class is supported. |
827 const <ProgramResult>[ | 793 |
828 const ProgramResult( | |
829 r""" | |
830 main() { | |
831 print('v1'); | |
832 } | |
833 """, | 794 """, |
834 const <String>['v1']), | 795 const [ |
835 const ProgramResult( | 796 "", |
836 r""" | 797 r""" |
837 class C { | 798 class C { |
838 void foo() { | 799 void foo() { |
839 print('v2'); | 800 print('v2'); |
840 } | 801 } |
841 } | 802 } |
842 | 803 """, |
804 ], | |
805 r""" | |
843 main() { | 806 main() { |
807 """, | |
808 const [ | |
809 r""" | |
810 print('v1'); | |
811 """, | |
812 r""" | |
844 new C().foo(); | 813 new C().foo(); |
814 """, | |
815 ], | |
816 r""" | |
845 } | 817 } |
846 """, | 818 """, |
847 const <String>['v2']), | 819 ], |
820 const <ProgramExpectation>[ | |
821 const ProgramExpectation( | |
822 const <String>['v1']), | |
823 const ProgramExpectation( | |
824 const <String>['v2']), | |
825 ], | |
848 ], | 826 ], |
849 | 827 |
850 // Test that removing a class is supported, using constructor. | 828 const [ |
851 const <ProgramResult>[ | 829 const [ |
852 const ProgramResult( | |
853 r""" | 830 r""" |
831 // Test that removing a class is supported, using constructor. | |
832 | |
833 """, | |
834 const [ | |
835 r""" | |
854 class C { | 836 class C { |
855 } | 837 } |
856 | |
857 main() { | |
858 try { | |
859 new C(); | |
860 print('v1'); | |
861 } catch (e) { | |
862 print('v2'); | |
863 } | |
864 } | |
865 """, | 838 """, |
866 const <String>['v1']), | 839 "" |
867 const ProgramResult( | 840 ], |
868 r""" | 841 r""" |
869 main() { | 842 main() { |
870 try { | 843 try { |
871 new C(); | 844 new C(); |
872 print('v1'); | 845 print('v1'); |
873 } catch (e) { | 846 } catch (e) { |
874 print('v2'); | 847 print('v2'); |
875 } | 848 } |
876 } | 849 } |
877 """, | 850 """, |
878 const <String>['v2']), | 851 ], |
852 const <ProgramExpectation>[ | |
853 const ProgramExpectation( | |
854 const <String>['v1']), | |
855 const ProgramExpectation( | |
856 const <String>['v2']), | |
857 ], | |
879 ], | 858 ], |
880 | 859 |
881 // Test that removing a class is supported, using a static method. | 860 const [ |
882 const <ProgramResult>[ | 861 const [ |
883 const ProgramResult( | |
884 r""" | 862 r""" |
863 // Test that removing a class is supported, using a static method. | |
864 | |
865 """, | |
866 const [ | |
867 r""" | |
885 class C { | 868 class C { |
886 static m() { | 869 static m() { |
887 print('v1'); | 870 print('v1'); |
888 } | 871 } |
889 } | 872 } |
890 | |
891 main() { | |
892 try { | |
893 C.m(); | |
894 } catch (e) { | |
895 print('v2'); | |
896 } | |
897 } | |
898 """, | 873 """, |
899 const <String>['v1']), | 874 "", |
900 const ProgramResult( | 875 ], |
901 r""" | 876 r""" |
902 main() { | 877 main() { |
903 try { | 878 try { |
904 C.m(); | 879 C.m(); |
905 } catch (e) { | 880 } catch (e) { |
906 print('v2'); | 881 print('v2'); |
907 } | 882 } |
908 } | 883 } |
909 """, | 884 """, |
910 const <String>['v2']), | 885 ], |
886 const <ProgramExpectation>[ | |
887 const ProgramExpectation( | |
888 const <String>['v1']), | |
889 const ProgramExpectation( | |
890 const <String>['v2']), | |
891 ], | |
911 ], | 892 ], |
912 | 893 |
913 // Test that changing the supertype of a class. | 894 const [ |
914 const <ProgramResult>[ | 895 const [ |
915 const ProgramResult( | |
916 r""" | 896 r""" |
897 // Test that changing the supertype of a class. | |
898 | |
917 class A { | 899 class A { |
918 m() { | 900 m() { |
919 print('v2'); | 901 print('v2'); |
920 } | 902 } |
921 } | 903 } |
922 class B extends A { | 904 class B extends A { |
923 m() { | 905 m() { |
924 print('v1'); | 906 print('v1'); |
925 } | 907 } |
926 } | 908 } |
909 """, | |
910 const [ | |
911 r""" | |
927 class C extends B { | 912 class C extends B { |
913 """, | |
914 r""" | |
915 class C extends A { | |
916 """, | |
917 ], | |
918 r""" | |
928 m() { | 919 m() { |
929 super.m(); | 920 super.m(); |
930 } | 921 } |
931 } | |
932 | |
933 var instance; | |
934 | |
935 main() { | |
936 if (instance == null) { | |
937 print('instance is null'); | |
938 instance = new C(); | |
939 } | |
940 instance.m(); | |
941 } | |
942 """, | |
943 const <String>['instance is null', 'v1']), | |
944 const ProgramResult( | |
945 r""" | |
946 class A { | |
947 m() { | |
948 print('v2'); | |
949 } | |
950 } | |
951 class B extends A { | |
952 m() { | |
953 print('v1'); | |
954 } | |
955 } | |
956 class C extends A { | |
957 m() { | |
958 super.m(); | |
959 } | |
960 } | 922 } |
961 | 923 |
962 var instance; | 924 var instance; |
963 | 925 |
964 main() { | 926 main() { |
965 if (instance == null) { | 927 if (instance == null) { |
966 print('instance is null'); | 928 print('instance is null'); |
967 instance = new C(); | 929 instance = new C(); |
968 } | 930 } |
969 instance.m(); | 931 instance.m(); |
970 } | 932 } |
971 """, | 933 """, |
972 const <String>['v2']), | 934 ], |
935 const <ProgramExpectation>[ | |
936 const ProgramExpectation( | |
937 const <String>['instance is null', 'v1']), | |
938 const ProgramExpectation( | |
939 const <String>['v2']), | |
940 ], | |
973 ], | 941 ], |
974 | 942 |
975 // Test adding a field to a class works. | 943 const [ |
976 const <ProgramResult>[ | 944 const [ |
977 const ProgramResult( | |
978 r""" | 945 r""" |
946 // Test adding a field to a class works. | |
947 | |
979 class A { | 948 class A { |
949 """, | |
950 const [ | |
951 "", | |
952 "var x;", | |
953 ], | |
954 r""" | |
980 } | 955 } |
981 | 956 |
982 var instance; | 957 var instance; |
983 | |
984 main() { | |
985 if (instance == null) { | |
986 print('instance is null'); | |
987 instance = new A(); | |
988 } | |
989 try { | |
990 instance.x = 'v2'; | |
991 } catch(e) { | |
992 print('setter threw'); | |
993 } | |
994 try { | |
995 print(instance.x); | |
996 } catch (e) { | |
997 print('getter threw'); | |
998 } | |
999 } | |
1000 """, | |
1001 const <String>['instance is null', 'setter threw', 'getter threw']), | |
1002 const ProgramResult( | |
1003 r""" | |
1004 class A { | |
1005 var x; | |
1006 } | |
1007 | |
1008 var instance; | |
1009 | 958 |
1010 main() { | 959 main() { |
1011 if (instance == null) { | 960 if (instance == null) { |
1012 print('instance is null'); | 961 print('instance is null'); |
1013 instance = new A(); | 962 instance = new A(); |
1014 } | 963 } |
1015 try { | 964 try { |
1016 instance.x = 'v2'; | 965 instance.x = 'v2'; |
1017 } catch(e) { | 966 } catch(e) { |
1018 print('setter threw'); | 967 print('setter threw'); |
1019 } | 968 } |
1020 try { | 969 try { |
1021 print(instance.x); | 970 print(instance.x); |
1022 } catch (e) { | 971 } catch (e) { |
1023 print('getter threw'); | 972 print('getter threw'); |
1024 } | 973 } |
1025 } | 974 } |
1026 """, | 975 """, |
1027 const <String>['v2']), | 976 ], |
977 const <ProgramExpectation>[ | |
978 const ProgramExpectation( | |
979 const <String>['instance is null', 'setter threw', 'getter threw ']), | |
980 const ProgramExpectation( | |
981 const <String>['v2']), | |
982 ], | |
1028 ], | 983 ], |
1029 | 984 |
1030 // Test removing a field from a class works. | 985 const [ |
1031 const <ProgramResult>[ | 986 const [ |
1032 const ProgramResult( | |
1033 r""" | 987 r""" |
988 // Test removing a field from a class works. | |
989 | |
1034 class A { | 990 class A { |
1035 var x; | 991 """, |
992 const [ | |
993 "var x;", | |
994 "", | |
995 ], | |
996 r""" | |
1036 } | 997 } |
1037 | 998 |
1038 var instance; | 999 var instance; |
1039 | |
1040 main() { | |
1041 if (instance == null) { | |
1042 print('instance is null'); | |
1043 instance = new A(); | |
1044 } | |
1045 try { | |
1046 instance.x = 'v1'; | |
1047 } catch(e) { | |
1048 print('setter threw'); | |
1049 } | |
1050 try { | |
1051 print(instance.x); | |
1052 } catch (e) { | |
1053 print('getter threw'); | |
1054 } | |
1055 } | |
1056 """, | |
1057 const <String>['instance is null', 'v1']), | |
1058 const ProgramResult( | |
1059 r""" | |
1060 class A { | |
1061 } | |
1062 | |
1063 var instance; | |
1064 | 1000 |
1065 main() { | 1001 main() { |
1066 if (instance == null) { | 1002 if (instance == null) { |
1067 print('instance is null'); | 1003 print('instance is null'); |
1068 instance = new A(); | 1004 instance = new A(); |
1069 } | 1005 } |
1070 try { | 1006 try { |
1071 instance.x = 'v1'; | 1007 instance.x = 'v1'; |
1072 } catch(e) { | 1008 } catch(e) { |
1073 print('setter threw'); | 1009 print('setter threw'); |
1074 } | 1010 } |
1075 try { | 1011 try { |
1076 print(instance.x); | 1012 print(instance.x); |
1077 } catch (e) { | 1013 } catch (e) { |
1078 print('getter threw'); | 1014 print('getter threw'); |
1079 } | 1015 } |
1080 } | 1016 } |
1081 """, | 1017 """, |
1082 const <String>['setter threw', 'getter threw']), | 1018 ], |
1019 const <ProgramExpectation>[ | |
1020 const ProgramExpectation( | |
1021 const <String>['instance is null', 'v1']), | |
1022 const ProgramExpectation( | |
1023 const <String>['setter threw', 'getter threw']), | |
1024 ], | |
1083 ], | 1025 ], |
1084 | 1026 |
1085 // Test that named arguments can be called. | 1027 const [ |
1086 const <ProgramResult>[ | 1028 const [ |
1087 const ProgramResult( | |
1088 r""" | 1029 r""" |
1030 // Test that named arguments can be called. | |
1031 | |
1089 class C { | 1032 class C { |
1090 foo({a, named: 'v1', x}) { | 1033 foo({a, named: 'v1', x}) { |
1091 print(named); | 1034 print(named); |
1092 } | 1035 } |
1093 } | 1036 } |
1094 | 1037 |
1095 var instance; | 1038 var instance; |
1096 | 1039 |
1097 main() { | 1040 main() { |
1098 if (instance == null) { | 1041 if (instance == null) { |
1099 print('instance is null'); | 1042 print('instance is null'); |
1100 instance = new C(); | 1043 instance = new C(); |
1101 } | 1044 } |
1045 """, | |
1046 const [ | |
1047 r""" | |
1102 instance.foo(); | 1048 instance.foo(); |
1049 """, | |
1050 r""" | |
1051 instance.foo(named: 'v2'); | |
1052 """, | |
1053 ], | |
1054 r""" | |
1103 } | 1055 } |
1104 """, | 1056 """, |
1105 const <String>['instance is null', 'v1']), | 1057 ], |
1106 const ProgramResult( | 1058 const <ProgramExpectation>[ |
1107 r""" | 1059 const ProgramExpectation( |
1108 class C { | 1060 const <String>['instance is null', 'v1']), |
1109 foo({a, named: 'v1', x}) { | 1061 const ProgramExpectation( |
1110 print(named); | 1062 const <String>['v2']), |
1111 } | 1063 ], |
1112 } | |
1113 | |
1114 var instance; | |
1115 | |
1116 main() { | |
1117 if (instance == null) { | |
1118 print('instance is null'); | |
1119 instance = new C(); | |
1120 } | |
1121 instance.foo(named: 'v2'); | |
1122 } | |
1123 """, | |
1124 const <String>['v2']), | |
1125 ], | 1064 ], |
1126 | 1065 |
1127 // Test than named arguments can be called. | 1066 const [ |
1128 const <ProgramResult>[ | 1067 const [ |
1129 const ProgramResult( | |
1130 r""" | 1068 r""" |
1069 // Test than named arguments can be called. | |
1070 | |
1131 class C { | 1071 class C { |
1132 foo({a, named: 'v2', x}) { | 1072 foo({a, named: 'v2', x}) { |
1133 print(named); | 1073 print(named); |
1134 } | |
1135 } | |
1136 | |
1137 var instance; | |
1138 | |
1139 main() { | |
1140 if (instance == null) { | |
1141 print('instance is null'); | |
1142 instance = new C(); | |
1143 } | |
1144 instance.foo(named: 'v1'); | |
1145 } | |
1146 """, | |
1147 const <String>['instance is null', 'v1']), | |
1148 const ProgramResult( | |
1149 r""" | |
1150 class C { | |
1151 foo({a, named: 'v2', x}) { | |
1152 print(named); | |
1153 } | 1074 } |
1154 } | 1075 } |
1155 | 1076 |
1156 var instance; | 1077 var instance; |
1157 | 1078 |
1158 main() { | 1079 main() { |
1159 if (instance == null) { | 1080 if (instance == null) { |
1160 print('instance is null'); | 1081 print('instance is null'); |
1161 instance = new C(); | 1082 instance = new C(); |
1162 } | 1083 } |
1084 """, | |
1085 const [ | |
1086 r""" | |
1087 instance.foo(named: 'v1'); | |
1088 """, | |
1089 r""" | |
1163 instance.foo(); | 1090 instance.foo(); |
1091 """, | |
1092 ], | |
1093 r""" | |
1164 } | 1094 } |
1165 """, | 1095 """, |
1166 const <String>['v2']), | 1096 ], |
1097 const <ProgramExpectation>[ | |
1098 const ProgramExpectation( | |
1099 const <String>['instance is null', 'v1']), | |
1100 const ProgramExpectation( | |
1101 const <String>['v2']), | |
1102 ], | |
1167 ], | 1103 ], |
1168 | 1104 |
1169 // Test that an instance tear-off with named parameters can be called. | 1105 const [ |
1170 const <ProgramResult>[ | 1106 const [ |
1171 const ProgramResult( | |
1172 r""" | 1107 r""" |
1108 // Test that an instance tear-off with named parameters can be called. | |
1109 | |
1173 class C { | 1110 class C { |
1174 foo({a, named: 'v1', x}) { | 1111 foo({a, named: 'v1', x}) { |
1175 print(named); | 1112 print(named); |
1176 } | |
1177 } | |
1178 | |
1179 var closure; | |
1180 | |
1181 main() { | |
1182 if (closure == null) { | |
1183 print('closure is null'); | |
1184 closure = new C().foo; | |
1185 } | |
1186 closure(); | |
1187 } | |
1188 """, | |
1189 const <String>['closure is null', 'v1']), | |
1190 const ProgramResult( | |
1191 r""" | |
1192 class C { | |
1193 foo({a, named: 'v1', x}) { | |
1194 print(named); | |
1195 } | 1113 } |
1196 } | 1114 } |
1197 | 1115 |
1198 var closure; | 1116 var closure; |
1199 | 1117 |
1200 main() { | 1118 main() { |
1201 if (closure == null) { | 1119 if (closure == null) { |
1202 print('closure is null'); | 1120 print('closure is null'); |
1203 closure = new C().foo; | 1121 closure = new C().foo; |
1204 } | 1122 } |
1123 """, | |
1124 const [ | |
1125 r""" | |
1126 closure(); | |
1127 """, | |
1128 r""" | |
1205 closure(named: 'v2'); | 1129 closure(named: 'v2'); |
1130 """, | |
1131 ], | |
1132 r""" | |
1206 } | 1133 } |
1207 """, | 1134 """, |
1208 const <String>['v2']), | 1135 ], |
1136 const <ProgramExpectation>[ | |
1137 const ProgramExpectation( | |
1138 const <String>['closure is null', 'v1']), | |
1139 const ProgramExpectation( | |
1140 const <String>['v2']), | |
1141 ], | |
1209 ], | 1142 ], |
1210 | 1143 |
1211 // Test that a lazy static is supported. | 1144 const [ |
1212 const <ProgramResult>[ | 1145 const [ |
1213 const ProgramResult( | |
1214 r""" | 1146 r""" |
1147 // Test that a lazy static is supported. | |
1148 | |
1215 var normal; | 1149 var normal; |
1216 | 1150 |
1151 """, | |
1152 const [ | |
1153 r""" | |
1217 foo() { | 1154 foo() { |
1218 print(normal); | 1155 print(normal); |
1219 } | 1156 } |
1220 | |
1221 main() { | |
1222 if (normal == null) { | |
1223 normal = 'v1'; | |
1224 } else { | |
1225 normal = ''; | |
1226 } | |
1227 foo(); | |
1228 } | |
1229 """, | 1157 """, |
1230 const <String>['v1']), | 1158 r""" |
1231 const ProgramResult( | |
1232 r""" | |
1233 var normal; | |
1234 | |
1235 var lazy = bar(); | 1159 var lazy = bar(); |
1236 | 1160 |
1237 foo() { | 1161 foo() { |
1238 print(lazy); | 1162 print(lazy); |
1239 } | 1163 } |
1240 | 1164 |
1241 bar() { | 1165 bar() { |
1242 print('v2'); | 1166 print('v2'); |
1243 return 'lazy'; | 1167 return 'lazy'; |
1244 } | 1168 } |
1245 | 1169 |
1170 """, | |
1171 ], | |
1172 r""" | |
1246 main() { | 1173 main() { |
1247 if (normal == null) { | 1174 if (normal == null) { |
1248 normal = 'v1'; | 1175 normal = 'v1'; |
1249 } else { | 1176 } else { |
1250 normal = ''; | 1177 normal = ''; |
1251 } | 1178 } |
1252 foo(); | 1179 foo(); |
1253 } | 1180 } |
1254 """, | 1181 """, |
1255 const <String>['v2', 'lazy']), | 1182 ], |
1183 const <ProgramExpectation>[ | |
1184 const ProgramExpectation( | |
1185 const <String>['v1']), | |
1186 const ProgramExpectation( | |
1187 const <String>['v2', 'lazy']), | |
1188 ], | |
1256 ], | 1189 ], |
1257 | 1190 |
1258 // Test that superclasses of directly instantiated classes are also | 1191 const [ |
1259 // emitted. | 1192 const [ |
1260 const <ProgramResult>[ | |
1261 const ProgramResult( | |
1262 r""" | 1193 r""" |
1194 // Test that superclasses of directly instantiated classes are also emitted. | |
1263 class A { | 1195 class A { |
1264 } | 1196 } |
1265 | 1197 |
1266 class B extends A { | 1198 class B extends A { |
1267 } | 1199 } |
1268 | 1200 |
1269 main() { | 1201 main() { |
1202 """, | |
1203 const [ | |
1204 r""" | |
1270 print('v1'); | 1205 print('v1'); |
1206 """, | |
1207 r""" | |
1208 new B(); | |
1209 print('v2'); | |
1210 """, | |
1211 ], | |
1212 r""" | |
1271 } | 1213 } |
1272 """, | 1214 """, |
1273 const <String>['v1']), | 1215 ], |
1274 const ProgramResult( | 1216 const <ProgramExpectation>[ |
1217 const ProgramExpectation( | |
1218 const <String>['v1']), | |
1219 const ProgramExpectation( | |
1220 const <String>['v2']), | |
1221 ], | |
1222 ], | |
1223 | |
1224 const [ | |
1225 const [ | |
1275 r""" | 1226 r""" |
1276 class A { | 1227 // Test that interceptor classes are handled correctly. |
1277 } | |
1278 | |
1279 class B extends A { | |
1280 } | |
1281 | 1228 |
1282 main() { | 1229 main() { |
1283 new B(); | 1230 """, |
1284 print('v2'); | 1231 const [ |
1232 r""" | |
1233 print('v1'); | |
1234 """, | |
1235 r""" | |
1236 ['v2'].forEach(print); | |
1237 """, | |
1238 ], | |
1239 r""" | |
1285 } | 1240 } |
1286 """, | 1241 """, |
1287 const <String>['v2']), | 1242 ], |
1243 const <ProgramExpectation>[ | |
1244 const ProgramExpectation( | |
1245 const <String>['v1']), | |
1246 const ProgramExpectation( | |
1247 const <String>['v2']), | |
1248 ], | |
1288 ], | 1249 ], |
1289 | 1250 |
1290 // Test that interceptor classes are handled correctly. | 1251 const [ |
1291 const <ProgramResult>[ | 1252 const [ |
1292 const ProgramResult( | |
1293 r""" | 1253 r""" |
1294 main() { | 1254 // Test that newly instantiated superclasses are handled correctly when there |
1295 print('v1'); | 1255 // is more than one change. |
1296 } | |
1297 """, | |
1298 const <String>['v1']), | |
1299 const ProgramResult( | |
1300 r""" | |
1301 main() { | |
1302 ['v2'].forEach(print); | |
1303 } | |
1304 """, | |
1305 const <String>['v2']), | |
1306 ], | |
1307 | 1256 |
1308 // Test that newly instantiated classes are handled correctly when there is | |
1309 // more than one change. | |
1310 const <ProgramResult>[ | |
1311 const ProgramResult( | |
1312 r""" | |
1313 class A { | 1257 class A { |
1314 foo() { | 1258 foo() { |
1315 print('Called foo'); | 1259 print('Called foo'); |
1316 } | 1260 } |
1317 | 1261 |
1318 bar() { | 1262 bar() { |
1319 print('Called bar'); | 1263 print('Called bar'); |
1320 } | 1264 } |
1321 } | 1265 } |
1322 | 1266 |
1323 class B extends A { | 1267 class B extends A { |
1324 } | 1268 } |
1325 | 1269 |
1326 main() { | 1270 main() { |
1271 """, | |
1272 const [ | |
1273 r""" | |
1327 new B().foo(); | 1274 new B().foo(); |
1275 """, | |
1276 r""" | |
1277 new B().foo(); | |
1278 """, | |
1279 r""" | |
1280 new A().bar(); | |
1281 """, | |
1282 ], | |
1283 r""" | |
1328 } | 1284 } |
1329 """, | 1285 """, |
1330 const <String>['Called foo']), | 1286 ], |
1331 const ProgramResult( | 1287 const <ProgramExpectation>[ |
1288 const ProgramExpectation( | |
1289 const <String>['Called foo']), | |
1290 const ProgramExpectation( | |
1291 const <String>['Called foo']), | |
1292 const ProgramExpectation( | |
1293 const <String>['Called bar']), | |
1294 ], | |
1295 ], | |
1296 | |
1297 const [ | |
1298 const [ | |
1332 r""" | 1299 r""" |
1300 // Test that newly instantiated subclasses are handled correctly when there is | |
1301 // more than one change. | |
1302 | |
1333 class A { | 1303 class A { |
1334 foo() { | 1304 foo() { |
1335 print('Called foo'); | 1305 print('Called foo'); |
1336 } | |
1337 | |
1338 bar() { | |
1339 print('Called bar'); | |
1340 } | |
1341 } | |
1342 | |
1343 class B extends A { | |
1344 } | |
1345 | |
1346 main() { | |
1347 new B().foo(); | |
1348 } | |
1349 """, | |
1350 const <String>['Called foo']), | |
1351 const ProgramResult( | |
1352 r""" | |
1353 class A { | |
1354 foo() { | |
1355 print('Called foo'); | |
1356 } | 1306 } |
1357 | 1307 |
1358 bar() { | 1308 bar() { |
1359 print('Called bar'); | 1309 print('Called bar'); |
1360 } | 1310 } |
1361 } | 1311 } |
1362 | 1312 |
1363 class B extends A { | 1313 class B extends A { |
1364 } | 1314 } |
1365 | 1315 |
1366 main() { | 1316 main() { |
1367 new A().bar(); | 1317 """, |
1318 const [ | |
1319 r""" | |
1320 new A().foo(); | |
1321 """, | |
1322 r""" | |
1323 new A().foo(); | |
1324 """, | |
1325 r""" | |
1326 new B().bar(); | |
1327 """, | |
1328 ], | |
1329 r""" | |
1368 } | 1330 } |
1369 """, | 1331 """, |
1370 const <String>['Called bar']), | 1332 ], |
1333 const <ProgramExpectation>[ | |
1334 const ProgramExpectation( | |
1335 const <String>['Called foo']), | |
1336 const ProgramExpectation( | |
1337 const <String>['Called foo']), | |
1338 const ProgramExpectation( | |
1339 const <String>['Called bar']), | |
1340 ], | |
1371 ], | 1341 ], |
1372 | 1342 |
1373 // Test that constants are handled correctly. | 1343 const [ |
1374 const <ProgramResult>[ | 1344 const [ |
1375 const ProgramResult( | |
1376 r""" | 1345 r""" |
1346 // Test that constants are handled correctly. | |
1347 | |
1377 class C { | 1348 class C { |
1378 final String value; | 1349 final String value; |
1379 const C(this.value); | 1350 const C(this.value); |
1380 } | 1351 } |
1381 | 1352 |
1382 main() { | 1353 main() { |
1354 """, | |
1355 const [ | |
1356 r""" | |
1383 print(const C('v1').value); | 1357 print(const C('v1').value); |
1358 """, | |
1359 r""" | |
1360 print(const C('v2').value); | |
1361 """, | |
1362 ], | |
1363 r""" | |
1384 } | 1364 } |
1385 """, | 1365 """, |
1386 const <String>['v1']), | 1366 ], |
1387 const ProgramResult( | 1367 const <ProgramExpectation>[ |
1388 r""" | 1368 const ProgramExpectation( |
1389 class C { | 1369 const <String>['v1']), |
1390 final String value; | 1370 const ProgramExpectation( |
1391 const C(this.value); | 1371 const <String>['v2']), |
1392 } | 1372 ], |
1393 | |
1394 main() { | |
1395 print(const C('v2').value); | |
1396 } | |
1397 """, | |
1398 const <String>['v2']), | |
1399 ], | 1373 ], |
1400 | 1374 |
1401 // Test that an instance field can be added to a compound declaration. | 1375 const [ |
1402 const <ProgramResult>[ | 1376 const [ |
1403 const ProgramResult( | |
1404 r""" | 1377 r""" |
1378 // Test that an instance field can be added to a compound declaration. | |
1379 | |
1405 class C { | 1380 class C { |
1381 """, | |
1382 const [ | |
1383 r""" | |
1406 int x; | 1384 int x; |
1385 """, | |
1386 r""" | |
1387 int x, y; | |
1388 """, | |
1389 ], | |
1390 r""" | |
1407 } | 1391 } |
1408 | 1392 |
1409 var instance; | 1393 var instance; |
1410 | |
1411 main() { | |
1412 if (instance == null) { | |
1413 print('[instance] is null'); | |
1414 instance = new C(); | |
1415 instance.x = 'v1'; | |
1416 } else { | |
1417 instance.y = 'v2'; | |
1418 } | |
1419 try { | |
1420 print(instance.x); | |
1421 } catch (e) { | |
1422 print('[instance.x] threw'); | |
1423 } | |
1424 try { | |
1425 print(instance.y); | |
1426 } catch (e) { | |
1427 print('[instance.y] threw'); | |
1428 } | |
1429 } | |
1430 """, | |
1431 const <String>['[instance] is null', 'v1', '[instance.y] threw']), | |
1432 | |
1433 const ProgramResult( | |
1434 r""" | |
1435 class C { | |
1436 int x, y; | |
1437 } | |
1438 | |
1439 var instance; | |
1440 | 1394 |
1441 main() { | 1395 main() { |
1442 if (instance == null) { | 1396 if (instance == null) { |
1443 print('[instance] is null'); | 1397 print('[instance] is null'); |
1444 instance = new C(); | 1398 instance = new C(); |
1445 instance.x = 'v1'; | 1399 instance.x = 'v1'; |
1446 } else { | 1400 } else { |
1447 instance.y = 'v2'; | 1401 instance.y = 'v2'; |
1448 } | 1402 } |
1449 try { | 1403 try { |
1450 print(instance.x); | 1404 print(instance.x); |
1451 } catch (e) { | 1405 } catch (e) { |
1452 print('[instance.x] threw'); | 1406 print('[instance.x] threw'); |
1453 } | 1407 } |
1454 try { | 1408 try { |
1455 print(instance.y); | 1409 print(instance.y); |
1456 } catch (e) { | 1410 } catch (e) { |
1457 print('[instance.y] threw'); | 1411 print('[instance.y] threw'); |
1458 } | 1412 } |
1459 } | 1413 } |
1460 """, | 1414 """, |
1461 const <String>['v1', 'v2'], | 1415 ], |
1462 // TODO(ahe): Shouldn't throw. | 1416 const <ProgramExpectation>[ |
1463 compileUpdatesShouldThrow: true), | 1417 const ProgramExpectation( |
1464 | 1418 const <String>[ |
1419 '[instance] is null', 'v1', '[instance.y] threw']), | |
1420 const ProgramExpectation( | |
1421 const <String>['v1', 'v2'], | |
1422 // TODO(ahe): Shouldn't throw. | |
1423 compileUpdatesShouldThrow: true), | |
1424 ], | |
1465 ], | 1425 ], |
1466 | 1426 |
1467 // Test that an instance field can be removed from a compound declaration. | 1427 const [ |
1468 const <ProgramResult>[ | 1428 const [ |
1469 const ProgramResult( | |
1470 r""" | 1429 r""" |
1430 // Test that an instance field can be removed from a compound declaration. | |
1431 | |
1471 class C { | 1432 class C { |
1433 """, | |
1434 const [ | |
1435 r""" | |
1472 int x, y; | 1436 int x, y; |
1437 """, | |
1438 r""" | |
1439 int x; | |
1440 """, | |
1441 ], | |
1442 r""" | |
1473 } | 1443 } |
1474 | 1444 |
1475 var instance; | 1445 var instance; |
1476 | |
1477 main() { | |
1478 if (instance == null) { | |
1479 print('[instance] is null'); | |
1480 instance = new C(); | |
1481 instance.x = 'v1'; | |
1482 instance.y = 'v2'; | |
1483 } | |
1484 try { | |
1485 print(instance.x); | |
1486 } catch (e) { | |
1487 print('[instance.x] threw'); | |
1488 } | |
1489 try { | |
1490 print(instance.y); | |
1491 } catch (e) { | |
1492 print('[instance.y] threw'); | |
1493 } | |
1494 } | |
1495 """, | |
1496 const <String>['[instance] is null', 'v1', 'v2']), | |
1497 | |
1498 const ProgramResult( | |
1499 r""" | |
1500 class C { | |
1501 int x; | |
1502 } | |
1503 | |
1504 var instance; | |
1505 | 1446 |
1506 main() { | 1447 main() { |
1507 if (instance == null) { | 1448 if (instance == null) { |
1508 print('[instance] is null'); | 1449 print('[instance] is null'); |
1509 instance = new C(); | 1450 instance = new C(); |
1510 instance.x = 'v1'; | 1451 instance.x = 'v1'; |
1511 instance.y = 'v2'; | 1452 instance.y = 'v2'; |
1512 } | 1453 } |
1513 try { | 1454 try { |
1514 print(instance.x); | 1455 print(instance.x); |
1515 } catch (e) { | 1456 } catch (e) { |
1516 print('[instance.x] threw'); | 1457 print('[instance.x] threw'); |
1517 } | 1458 } |
1518 try { | 1459 try { |
1519 print(instance.y); | 1460 print(instance.y); |
1520 } catch (e) { | 1461 } catch (e) { |
1521 print('[instance.y] threw'); | 1462 print('[instance.y] threw'); |
1522 } | 1463 } |
1523 } | 1464 } |
1524 """, | 1465 """, |
1525 const <String>['v1', '[instance.y] threw'], | 1466 ], |
1526 // TODO(ahe): Shouldn't throw. | 1467 const <ProgramExpectation>[ |
1527 compileUpdatesShouldThrow: true), | 1468 const ProgramExpectation( |
1469 const <String>['[instance] is null', 'v1', 'v2']), | |
1470 const ProgramExpectation( | |
1471 const <String>['v1', '[instance.y] threw'], | |
1472 // TODO(ahe): Shouldn't throw. | |
1473 compileUpdatesShouldThrow: true), | |
1474 ], | |
1528 ], | 1475 ], |
1529 | 1476 |
1530 // Test that a static field can be made an instance field. | 1477 const [ |
1531 // TODO(ahe): Test doesn't pass. | 1478 const [ |
1532 const <ProgramResult>[ | |
1533 const ProgramResult( | |
1534 r""" | 1479 r""" |
1480 // Test that a static field can be made an instance field. | |
1481 | |
1535 class C { | 1482 class C { |
1483 """, | |
1484 | |
1485 const [ | |
1486 r""" | |
1536 static int x; | 1487 static int x; |
1488 """, | |
1489 r""" | |
1490 int x; | |
1491 """, | |
1492 ], | |
1493 r""" | |
1537 } | 1494 } |
1538 | 1495 |
1539 var instance; | 1496 var instance; |
1540 | |
1541 main() { | |
1542 if (instance == null) { | |
1543 print('[instance] is null'); | |
1544 instance = new C(); | |
1545 C.x = 'v1'; | |
1546 } else { | |
1547 instance.x = 'v2'; | |
1548 } | |
1549 try { | |
1550 print(C.x); | |
1551 } catch (e) { | |
1552 print('[C.x] threw'); | |
1553 } | |
1554 try { | |
1555 print(instance.x); | |
1556 } catch (e) { | |
1557 print('[instance.x] threw'); | |
1558 } | |
1559 } | |
1560 """, | |
1561 const <String>['[instance] is null', 'v1', '[instance.x] threw']), | |
1562 | |
1563 const ProgramResult( | |
1564 r""" | |
1565 class C { | |
1566 int x; | |
1567 } | |
1568 | |
1569 var instance; | |
1570 | 1497 |
1571 main() { | 1498 main() { |
1572 if (instance == null) { | 1499 if (instance == null) { |
1573 print('[instance] is null'); | 1500 print('[instance] is null'); |
1574 instance = new C(); | 1501 instance = new C(); |
1575 C.x = 'v1'; | 1502 C.x = 'v1'; |
1576 } else { | 1503 } else { |
1577 instance.x = 'v2'; | 1504 instance.x = 'v2'; |
1578 } | 1505 } |
1579 try { | 1506 try { |
1580 print(C.x); | 1507 print(C.x); |
1581 } catch (e) { | 1508 } catch (e) { |
1582 print('[C.x] threw'); | 1509 print('[C.x] threw'); |
1583 } | 1510 } |
1584 try { | 1511 try { |
1585 print(instance.x); | 1512 print(instance.x); |
1586 } catch (e) { | 1513 } catch (e) { |
1587 print('[instance.x] threw'); | 1514 print('[instance.x] threw'); |
1588 } | 1515 } |
1589 } | 1516 } |
1590 """, | 1517 """, |
1591 const <String>['[C.x] threw', 'v2'], | 1518 ], |
1592 // TODO(ahe): Shouldn't throw. | 1519 const <ProgramExpectation>[ |
1593 compileUpdatesShouldThrow: true), | 1520 const ProgramExpectation( |
1521 const <String>['[instance] is null', 'v1', '[instance.x] threw'] ), | |
1522 const ProgramExpectation( | |
1523 const <String>['[C.x] threw', 'v2'], | |
1524 // TODO(ahe): Shouldn't throw. | |
1525 compileUpdatesShouldThrow: true), | |
1526 ], | |
1594 ], | 1527 ], |
1595 | 1528 |
1596 // Test that instance field can be made static. | 1529 const [ |
1597 const <ProgramResult>[ | 1530 const [ |
1598 const ProgramResult( | |
1599 r""" | 1531 r""" |
1532 // Test that instance field can be made static. | |
1533 | |
1600 class C { | 1534 class C { |
1535 """, | |
1536 const [ | |
1537 r""" | |
1601 int x; | 1538 int x; |
1539 """, | |
1540 r""" | |
1541 static int x; | |
1542 """, | |
1543 ], | |
1544 r""" | |
1602 } | 1545 } |
1603 | 1546 |
1604 var instance; | 1547 var instance; |
1605 | |
1606 main() { | |
1607 if (instance == null) { | |
1608 print('[instance] is null'); | |
1609 instance = new C(); | |
1610 instance.x = 'v1'; | |
1611 } else { | |
1612 C.x = 'v2'; | |
1613 } | |
1614 try { | |
1615 print(C.x); | |
1616 } catch (e) { | |
1617 print('[C.x] threw'); | |
1618 } | |
1619 try { | |
1620 print(instance.x); | |
1621 } catch (e) { | |
1622 print('[instance.x] threw'); | |
1623 } | |
1624 } | |
1625 """, | |
1626 const <String>['[instance] is null', '[C.x] threw', 'v1']), | |
1627 | |
1628 const ProgramResult( | |
1629 r""" | |
1630 class C { | |
1631 static int x; | |
1632 } | |
1633 | |
1634 var instance; | |
1635 | 1548 |
1636 main() { | 1549 main() { |
1637 if (instance == null) { | 1550 if (instance == null) { |
1638 print('[instance] is null'); | 1551 print('[instance] is null'); |
1639 instance = new C(); | 1552 instance = new C(); |
1640 instance.x = 'v1'; | 1553 instance.x = 'v1'; |
1641 } else { | 1554 } else { |
1642 C.x = 'v2'; | 1555 C.x = 'v2'; |
1643 } | 1556 } |
1644 try { | 1557 try { |
1645 print(C.x); | 1558 print(C.x); |
1646 } catch (e) { | 1559 } catch (e) { |
1647 print('[C.x] threw'); | 1560 print('[C.x] threw'); |
1648 } | 1561 } |
1649 try { | 1562 try { |
1650 print(instance.x); | 1563 print(instance.x); |
1651 } catch (e) { | 1564 } catch (e) { |
1652 print('[instance.x] threw'); | 1565 print('[instance.x] threw'); |
1653 } | 1566 } |
1654 } | 1567 } |
1655 """, | 1568 """, |
1656 const <String>['v2', '[instance.x] threw'], | 1569 ], |
1657 // TODO(ahe): Shouldn't throw. | 1570 const <ProgramExpectation>[ |
1658 compileUpdatesShouldThrow: true), | 1571 const ProgramExpectation( |
1572 const <String>['[instance] is null', '[C.x] threw', 'v1']), | |
1573 const ProgramExpectation( | |
1574 const <String>['v2', '[instance.x] threw'], | |
1575 // TODO(ahe): Shouldn't throw. | |
1576 compileUpdatesShouldThrow: true), | |
1577 ], | |
1659 ], | 1578 ], |
1660 | 1579 |
1661 // Test compound constants. | 1580 const [ |
1662 const <ProgramResult>[ | 1581 const [ |
1663 const ProgramResult( | |
1664 r""" | 1582 r""" |
1583 // Test compound constants. | |
1584 | |
1665 class A { | 1585 class A { |
1666 final value; | 1586 final value; |
1667 const A(this.value); | 1587 const A(this.value); |
1668 | 1588 |
1669 toString() => 'A($value)'; | 1589 toString() => 'A($value)'; |
1670 } | 1590 } |
1671 | 1591 |
1672 class B { | 1592 class B { |
1673 final value; | 1593 final value; |
1674 const B(this.value); | 1594 const B(this.value); |
1675 | 1595 |
1676 toString() => 'B($value)'; | 1596 toString() => 'B($value)'; |
1677 } | 1597 } |
1678 | 1598 |
1679 main() { | 1599 main() { |
1600 """, | |
1601 const [ | |
1602 r""" | |
1680 print(const A('v1')); | 1603 print(const A('v1')); |
1681 print(const B('v1')); | 1604 print(const B('v1')); |
1605 """, | |
1606 r""" | |
1607 print(const B(const A('v2'))); | |
1608 print(const A(const B('v2'))); | |
1609 """, | |
1610 ], | |
1611 r""" | |
1682 } | 1612 } |
1683 """, | 1613 """, |
1684 const <String>['A(v1)', 'B(v1)']), | 1614 ], |
1615 const <ProgramExpectation>[ | |
1616 const ProgramExpectation( | |
1617 const <String>['A(v1)', 'B(v1)']), | |
1618 const ProgramExpectation( | |
1619 const <String>['B(A(v2))', 'A(B(v2))']), | |
1620 ], | |
1621 ], | |
1685 | 1622 |
1686 const ProgramResult( | 1623 const [ |
1624 const [ | |
1687 r""" | 1625 r""" |
1626 // Test constants of new classes. | |
1627 | |
1688 class A { | 1628 class A { |
1689 final value; | 1629 final value; |
1690 const A(this.value); | 1630 const A(this.value); |
1691 | 1631 |
1692 toString() => 'A($value)'; | 1632 toString() => 'A($value)'; |
1693 } | 1633 } |
1694 | 1634 """, |
1635 const [ | |
1636 "", | |
1637 r""" | |
1695 class B { | 1638 class B { |
1696 final value; | 1639 final value; |
1697 const B(this.value); | 1640 const B(this.value); |
1698 | |
1699 toString() => 'B($value)'; | |
1700 } | |
1701 | |
1702 main() { | |
1703 print(const B(const A('v2'))); | |
1704 print(const A(const B('v2'))); | |
1705 } | |
1706 """, | |
1707 const <String>['B(A(v2))', 'A(B(v2))']), | |
1708 ], | |
1709 | |
1710 // Test constants of new classes. | |
1711 const <ProgramResult>[ | |
1712 const ProgramResult( | |
1713 r""" | |
1714 class A { | |
1715 final value; | |
1716 const A(this.value); | |
1717 | |
1718 toString() => 'A($value)'; | |
1719 } | |
1720 | |
1721 main() { | |
1722 print(const A('v1')); | |
1723 } | |
1724 """, | |
1725 const <String>['A(v1)']), | |
1726 | |
1727 const ProgramResult( | |
1728 r""" | |
1729 class A { | |
1730 final value; | |
1731 const A(this.value); | |
1732 | |
1733 toString() => 'A($value)'; | |
1734 } | |
1735 | |
1736 class B { | |
1737 final value; | |
1738 const B(this.value); | |
1739 | 1641 |
1740 toString() => 'B($value)'; | 1642 toString() => 'B($value)'; |
1741 } | 1643 } |
1742 | 1644 |
1645 """, | |
1646 ], | |
1647 r""" | |
1743 main() { | 1648 main() { |
1649 """, | |
1650 | |
1651 const [ | |
1652 r""" | |
1653 print(const A('v1')); | |
1654 """, | |
1655 r""" | |
1744 print(const A('v2')); | 1656 print(const A('v2')); |
1745 print(const B('v2')); | 1657 print(const B('v2')); |
1746 print(const B(const A('v2'))); | 1658 print(const B(const A('v2'))); |
1747 print(const A(const B('v2'))); | 1659 print(const A(const B('v2'))); |
1660 """, | |
1661 ], | |
1662 r""" | |
1748 } | 1663 } |
1749 """, | 1664 """, |
1750 const <String>['A(v2)', 'B(v2)', 'B(A(v2))', 'A(B(v2))']), | 1665 |
1666 ], | |
1667 const <ProgramExpectation>[ | |
1668 const ProgramExpectation( | |
1669 const <String>['A(v1)']), | |
1670 const ProgramExpectation( | |
1671 const <String>['A(v2)', 'B(v2)', 'B(A(v2))', 'A(B(v2))']), | |
1672 ], | |
1751 ], | 1673 ], |
1752 ]; | 1674 ]; |
1753 | 1675 |
1754 void main() { | 1676 void main() { |
1755 listener.start(); | 1677 listener.start(); |
1756 | 1678 |
1757 document.head.append(lineNumberStyle()); | 1679 document.head.append(lineNumberStyle()); |
1758 | 1680 |
1759 summary = new SpanElement(); | 1681 summary = new SpanElement(); |
1760 document.body.append(new HeadingElement.h1() | 1682 document.body.append(new HeadingElement.h1() |
(...skipping 21 matching lines...) Expand all Loading... | |
1782 SpanElement summary; | 1704 SpanElement summary; |
1783 | 1705 |
1784 int testCount = 1; | 1706 int testCount = 1; |
1785 | 1707 |
1786 bool verboseStatus = false; | 1708 bool verboseStatus = false; |
1787 | 1709 |
1788 void updateSummary(_) { | 1710 void updateSummary(_) { |
1789 summary.text = " (${testCount - 1}/${tests.length})"; | 1711 summary.text = " (${testCount - 1}/${tests.length})"; |
1790 } | 1712 } |
1791 | 1713 |
1792 Future compileAndRun(List<ProgramResult> programs) { | 1714 Future compileAndRun(List encodedResults) { |
1793 updateSummary(null); | 1715 updateSummary(null); |
1716 List<ProgramResult> programs = ProgramResult.decode(encodedResults); | |
1794 var status = new DivElement(); | 1717 var status = new DivElement(); |
1795 document.body.append(status); | 1718 document.body.append(status); |
1796 | 1719 |
1797 IFrameElement iframe = | 1720 IFrameElement iframe = |
1798 appendIFrame( | 1721 appendIFrame( |
1799 '/root_dart/tests/try/web/incremental_compilation_update.html', | 1722 '/root_dart/tests/try/web/incremental_compilation_update.html', |
1800 document.body) | 1723 document.body) |
1801 ..style.width = '100%' | 1724 ..style.width = '100%' |
1802 ..style.height = '600px'; | 1725 ..style.height = '600px'; |
1803 | 1726 |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1963 position: absolute; | 1886 position: absolute; |
1964 left: 0px; | 1887 left: 0px; |
1965 width: 3em; | 1888 width: 3em; |
1966 text-align: right; | 1889 text-align: right; |
1967 background-color: lightgoldenrodyellow; | 1890 background-color: lightgoldenrodyellow; |
1968 } | 1891 } |
1969 '''); | 1892 '''); |
1970 style.type = 'text/css'; | 1893 style.type = 'text/css'; |
1971 return style; | 1894 return style; |
1972 } | 1895 } |
OLD | NEW |