OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 dart2js.serialization_test_data; | 5 library dart2js.serialization_test_data; |
6 | 6 |
7 const List<Test> TESTS = const <Test>[ | 7 const List<Test> TESTS = const <Test>[ |
8 // These tests are very long-running and put here first to compile them on | 8 // These tests are very long-running and put here first to compile them on |
9 // their own tests. | 9 // their own tests. |
10 const Test('Disable tree shaking through reflection', const { | 10 const Test( |
11 'main.dart': ''' | 11 'Disable tree shaking through reflection', |
| 12 const { |
| 13 'main.dart': ''' |
12 import 'dart:mirrors'; | 14 import 'dart:mirrors'; |
13 | 15 |
14 main() { | 16 main() { |
15 reflect(null).invoke(#toString, []).reflectee; | 17 reflect(null).invoke(#toString, []).reflectee; |
16 } | 18 } |
17 ''', | 19 ''', |
18 }, expectedWarningCount: 1), | 20 }, |
| 21 expectedWarningCount: 1), |
19 | 22 |
20 const Test('Use of dart:indexed_db', const { | 23 const Test('Use of dart:indexed_db', const { |
21 'main.dart': ''' | 24 'main.dart': ''' |
22 import 'a.dart'; | 25 import 'a.dart'; |
23 | 26 |
24 main() {} | 27 main() {} |
25 ''', | 28 ''', |
26 }, preserializedSourceFiles: const { | 29 }, preserializedSourceFiles: const { |
27 'a.dart': ''' | 30 'a.dart': ''' |
28 import 'dart:indexed_db'; | 31 import 'dart:indexed_db'; |
29 ''', | 32 ''', |
30 }), | 33 }), |
31 | 34 |
32 // These tests | 35 // These tests |
33 const Test('Empty program', const { | 36 const Test('Empty program', const {'main.dart': 'main() {}'}), |
34 'main.dart': 'main() {}' | |
35 }), | |
36 | 37 |
37 const Test('Hello World', const { | 38 const Test( |
38 'main.dart': 'main() => print("Hello World");' | 39 'Hello World', const {'main.dart': 'main() => print("Hello World");'}), |
39 }), | |
40 | 40 |
41 const Test('Too many arguments to print', const { | 41 const Test('Too many arguments to print', |
42 'main.dart': 'main() => print("Hello World", 0);' | 42 const {'main.dart': 'main() => print("Hello World", 0);'}, |
43 }, | 43 expectedWarningCount: 1, expectedInfoCount: 1), |
44 expectedWarningCount: 1, | |
45 expectedInfoCount: 1), | |
46 | 44 |
47 const Test('Hello World with string interpolation', const { | 45 const Test('Hello World with string interpolation', const { |
48 'main.dart': r''' | 46 'main.dart': r''' |
49 main() { | 47 main() { |
50 String text = "Hello World"; | 48 String text = "Hello World"; |
51 print('$text'); | 49 print('$text'); |
52 }''' | 50 }''' |
53 }), | 51 }), |
54 | 52 |
55 const Test('Too many arguments to print with string interpolation', const { | 53 const Test( |
56 'main.dart': r''' | 54 'Too many arguments to print with string interpolation', |
| 55 const { |
| 56 'main.dart': r''' |
57 main() { | 57 main() { |
58 String text = "Hello World"; | 58 String text = "Hello World"; |
59 print('$text', text); | 59 print('$text', text); |
60 }''' | 60 }''' |
61 }, | 61 }, |
62 expectedWarningCount: 1, | 62 expectedWarningCount: 1, |
63 expectedInfoCount: 1), | 63 expectedInfoCount: 1), |
64 | 64 |
65 const Test('Print main arguments', const { | 65 const Test('Print main arguments', const { |
66 'main.dart': r''' | 66 'main.dart': r''' |
67 main(List<String> arguments) { | 67 main(List<String> arguments) { |
68 print(arguments); | 68 print(arguments); |
69 }''' | 69 }''' |
70 }), | 70 }), |
71 | 71 |
72 const Test('For loop on main arguments', const { | 72 const Test('For loop on main arguments', const { |
73 'main.dart': r''' | 73 'main.dart': r''' |
74 main(List<String> arguments) { | 74 main(List<String> arguments) { |
75 for (int i = 0; i < arguments.length; i++) { | 75 for (int i = 0; i < arguments.length; i++) { |
76 print(arguments[i]); | 76 print(arguments[i]); |
77 } | 77 } |
78 }''' | 78 }''' |
79 }), | 79 }), |
80 | 80 |
81 const Test('For-in loop on main arguments', const { | 81 const Test('For-in loop on main arguments', const { |
82 'main.dart': r''' | 82 'main.dart': r''' |
83 main(List<String> arguments) { | 83 main(List<String> arguments) { |
84 for (String argument in arguments) { | 84 for (String argument in arguments) { |
85 print(argument); | 85 print(argument); |
86 } | 86 } |
87 }''' | 87 }''' |
88 }), | 88 }), |
89 | 89 |
90 const Test('Simple class', const { | 90 const Test('Simple class', const { |
91 'main.dart': r''' | 91 'main.dart': r''' |
92 class Class {} | 92 class Class {} |
93 main() { | 93 main() { |
94 print(new Class()); | 94 print(new Class()); |
95 }''' | 95 }''' |
96 }), | 96 }), |
97 | 97 |
98 const Test('Simple class implements Function without call method', const { | 98 const Test( |
99 'main.dart': r''' | 99 'Simple class implements Function without call method', |
| 100 const { |
| 101 'main.dart': r''' |
100 class Class implements Function {} | 102 class Class implements Function {} |
101 main() { | 103 main() { |
102 print(new Class()); | 104 print(new Class()); |
103 }''' | 105 }''' |
104 }, | 106 }, |
105 expectedWarningCount: 1), | 107 expectedWarningCount: 1), |
106 | 108 |
107 const Test('Simple class implements Function with call method', const { | 109 const Test('Simple class implements Function with call method', const { |
108 'main.dart': r''' | 110 'main.dart': r''' |
109 class Class implements Function { | 111 class Class implements Function { |
110 call() {} | 112 call() {} |
111 } | 113 } |
112 main() { | 114 main() { |
113 print(new Class()()); | 115 print(new Class()()); |
114 }''' | 116 }''' |
115 }), | 117 }), |
116 | 118 |
117 const Test('Implement Comparable', const { | 119 const Test('Implement Comparable', const { |
118 'main.dart': r''' | 120 'main.dart': r''' |
119 class Class implements Comparable<Class> { | 121 class Class implements Comparable<Class> { |
120 int compareTo(Class other) => 0; | 122 int compareTo(Class other) => 0; |
121 } | 123 } |
122 main() { | 124 main() { |
123 print(new Class()); | 125 print(new Class()); |
124 }''' | 126 }''' |
125 }), | 127 }), |
126 | 128 |
127 const Test('Implement Comparable with two many type arguments', const { | 129 const Test( |
128 'main.dart': r''' | 130 'Implement Comparable with two many type arguments', |
| 131 const { |
| 132 'main.dart': r''' |
129 class Class implements Comparable<Class, Class> { | 133 class Class implements Comparable<Class, Class> { |
130 int compareTo(other) => 0; | 134 int compareTo(other) => 0; |
131 } | 135 } |
132 main() { | 136 main() { |
133 print(new Class()); | 137 print(new Class()); |
134 }''' | 138 }''' |
135 }, | 139 }, |
136 expectedWarningCount: 1), | 140 expectedWarningCount: 1), |
137 | 141 |
138 const Test('Implement Comparable with incompatible parameter types', const { | 142 const Test( |
139 'main.dart': r''' | 143 'Implement Comparable with incompatible parameter types', |
| 144 const { |
| 145 'main.dart': r''' |
140 class Class implements Comparable<Class> { | 146 class Class implements Comparable<Class> { |
141 int compareTo(String other) => 0; | 147 int compareTo(String other) => 0; |
142 } | 148 } |
143 main() { | 149 main() { |
144 print(new Class().compareTo(null)); | 150 print(new Class().compareTo(null)); |
145 }''' | 151 }''' |
146 }, | 152 }, |
147 expectedWarningCount: 1, | 153 expectedWarningCount: 1, |
148 expectedInfoCount: 1), | 154 expectedInfoCount: 1), |
149 | 155 |
150 const Test('Implement Comparable with incompatible parameter count', const { | 156 const Test( |
151 'main.dart': r''' | 157 'Implement Comparable with incompatible parameter count', |
| 158 const { |
| 159 'main.dart': r''' |
152 class Class implements Comparable { | 160 class Class implements Comparable { |
153 bool compareTo(a, b) => true; | 161 bool compareTo(a, b) => true; |
154 } | 162 } |
155 main() { | 163 main() { |
156 print(new Class().compareTo(null, null)); | 164 print(new Class().compareTo(null, null)); |
157 }''' | 165 }''' |
158 }, | 166 }, |
159 expectedWarningCount: 1, | 167 expectedWarningCount: 1, |
160 expectedInfoCount: 1), | 168 expectedInfoCount: 1), |
161 | 169 |
162 const Test('Implement Random and call nextInt directly', const { | 170 const Test( |
163 'main.dart': r''' | 171 'Implement Random and call nextInt directly', |
| 172 const { |
| 173 'main.dart': r''' |
164 import 'dart:math'; | 174 import 'dart:math'; |
165 | 175 |
166 class MyRandom implements Random { | 176 class MyRandom implements Random { |
167 int nextInt(int max) { | 177 int nextInt(int max) { |
168 return max.length; | 178 return max.length; |
169 } | 179 } |
170 bool nextBool() => true; | 180 bool nextBool() => true; |
171 double nextDouble() => 0.0; | 181 double nextDouble() => 0.0; |
172 } | 182 } |
173 main() { | 183 main() { |
174 new MyRandom().nextInt(0); | 184 new MyRandom().nextInt(0); |
175 }''' | 185 }''' |
176 }, | 186 }, |
177 expectedWarningCount: 1, | 187 expectedWarningCount: 1, |
178 expectedInfoCount: 0), | 188 expectedInfoCount: 0), |
179 | 189 |
180 const Test('Implement Random and do not call nextInt', const { | 190 const Test('Implement Random and do not call nextInt', const { |
181 'main.dart': r''' | 191 'main.dart': r''' |
182 import 'dart:math'; | 192 import 'dart:math'; |
183 | 193 |
184 class MyRandom implements Random { | 194 class MyRandom implements Random { |
185 int nextInt(int max) { | 195 int nextInt(int max) { |
186 return max.length; | 196 return max.length; |
187 } | 197 } |
188 bool nextBool() => true; | 198 bool nextBool() => true; |
189 double nextDouble() => 0.0; | 199 double nextDouble() => 0.0; |
190 } | 200 } |
191 main() { | 201 main() { |
192 new MyRandom(); | 202 new MyRandom(); |
193 }''' | 203 }''' |
194 }), | 204 }), |
195 | 205 |
196 const Test('Implement Random and call nextInt through native code', const { | 206 const Test( |
197 'main.dart': r''' | 207 'Implement Random and call nextInt through native code', |
| 208 const { |
| 209 'main.dart': r''' |
198 import 'dart:math'; | 210 import 'dart:math'; |
199 | 211 |
200 class MyRandom implements Random { | 212 class MyRandom implements Random { |
201 int nextInt(int max) { | 213 int nextInt(int max) { |
202 return max.length; | 214 return max.length; |
203 } | 215 } |
204 bool nextBool() => true; | 216 bool nextBool() => true; |
205 double nextDouble() => 0.0; | 217 double nextDouble() => 0.0; |
206 } | 218 } |
207 main() { | 219 main() { |
208 // Invocation of `MyRandom.nextInt` is only detected knowing the actual | 220 // Invocation of `MyRandom.nextInt` is only detected knowing the actual |
209 // implementation class for `List` and the world impact of its `shuffle` | 221 // implementation class for `List` and the world impact of its `shuffle` |
210 // method. | 222 // method. |
211 [].shuffle(new MyRandom()); | 223 [].shuffle(new MyRandom()); |
212 }''' | 224 }''' |
213 }, | 225 }, |
214 expectedWarningCount: 1, | 226 expectedWarningCount: 1, |
215 expectedInfoCount: 0), | 227 expectedInfoCount: 0), |
216 | 228 |
217 const Test('Handle break and continue', const { | 229 const Test('Handle break and continue', const { |
218 'main.dart': ''' | 230 'main.dart': ''' |
219 main() { | 231 main() { |
220 loop: for (var a in []) { | 232 loop: for (var a in []) { |
221 for (var b in []) { | 233 for (var b in []) { |
222 continue loop; | 234 continue loop; |
223 } | 235 } |
224 break; | 236 break; |
225 } | 237 } |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 } | 283 } |
272 main() => new C();''' | 284 main() => new C();''' |
273 }), | 285 }), |
274 | 286 |
275 const Test('Constructed constant using its default values.', const { | 287 const Test('Constructed constant using its default values.', const { |
276 'main.dart': ''' | 288 'main.dart': ''' |
277 main() => const Duration(); | 289 main() => const Duration(); |
278 ''', | 290 ''', |
279 }), | 291 }), |
280 | 292 |
281 const Test('Call forwarding constructor on named mixin application', | 293 const Test('Call forwarding constructor on named mixin application', const { |
282 const { | 294 'main.dart': ''' |
283 'main.dart': ''' | |
284 import 'dart:collection'; | 295 import 'dart:collection'; |
285 main() => new UnmodifiableListView(null); | 296 main() => new UnmodifiableListView(null); |
286 ''', | 297 ''', |
287 }), | 298 }), |
288 | 299 |
289 const Test('Function reference constant', const { | 300 const Test('Function reference constant', const { |
290 'main.dart': ''' | 301 'main.dart': ''' |
291 var myIdentical = identical; | 302 var myIdentical = identical; |
292 main() => myIdentical; | 303 main() => myIdentical; |
293 ''', | 304 ''', |
294 }), | 305 }), |
295 | 306 |
296 const Test('Super method call', const { | 307 const Test('Super method call', const { |
297 'main.dart': ''' | 308 'main.dart': ''' |
298 class Foo { | 309 class Foo { |
299 String toString() => super.toString(); | 310 String toString() => super.toString(); |
300 } | 311 } |
301 main() { | 312 main() { |
302 print(new Foo()); | 313 print(new Foo()); |
303 } | 314 } |
304 ''', | 315 ''', |
305 }), | 316 }), |
306 | 317 |
307 const Test('Call forwarding constructor on named mixin application, no args.', | 318 const Test( |
| 319 'Call forwarding constructor on named mixin application, no args.', |
308 const { | 320 const { |
309 'main.dart': ''' | 321 'main.dart': ''' |
310 import 'lib.dart'; | 322 import 'lib.dart'; |
311 main() => new C(); | 323 main() => new C(); |
312 ''', | 324 ''', |
313 }, preserializedSourceFiles: const { | 325 }, |
| 326 preserializedSourceFiles: const { |
314 'lib.dart': ''' | 327 'lib.dart': ''' |
315 class M {} | 328 class M {} |
316 class S {} | 329 class S {} |
317 class C = S with M; | 330 class C = S with M; |
318 ''', | 331 ''', |
319 }), | 332 }), |
320 | 333 |
321 const Test('Call forwarding constructor on named mixin application, one arg.', | 334 const Test( |
| 335 'Call forwarding constructor on named mixin application, one arg.', |
322 const { | 336 const { |
323 'main.dart': ''' | 337 'main.dart': ''' |
324 import 'lib.dart'; | 338 import 'lib.dart'; |
325 main() => new C(0); | 339 main() => new C(0); |
326 ''', | 340 ''', |
327 }, preserializedSourceFiles: const { | 341 }, |
| 342 preserializedSourceFiles: const { |
328 'lib.dart': ''' | 343 'lib.dart': ''' |
329 class M {} | 344 class M {} |
330 class S { | 345 class S { |
331 S(a); | 346 S(a); |
332 } | 347 } |
333 class C = S with M; | 348 class C = S with M; |
334 ''', | 349 ''', |
335 }), | 350 }), |
336 | 351 |
337 const Test('Import mirrors, thus checking import paths', const { | 352 const Test( |
338 'main.dart': ''' | 353 'Import mirrors, thus checking import paths', |
| 354 const { |
| 355 'main.dart': ''' |
339 import 'dart:mirrors'; | 356 import 'dart:mirrors'; |
340 main() {} | 357 main() {} |
341 ''', | 358 ''', |
342 }, | 359 }, |
343 expectedWarningCount: 1), | 360 expectedWarningCount: 1), |
344 | 361 |
345 const Test('Serialized symbol literal', const { | 362 const Test('Serialized symbol literal', const { |
346 'main.dart': ''' | 363 'main.dart': ''' |
347 import 'lib.dart'; | 364 import 'lib.dart'; |
348 main() => m(); | 365 main() => m(); |
349 ''', | 366 ''', |
350 }, preserializedSourceFiles: const { | 367 }, preserializedSourceFiles: const { |
351 'lib.dart': ''' | 368 'lib.dart': ''' |
352 m() => print(#main); | 369 m() => print(#main); |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
507 ''', | 524 ''', |
508 }, preserializedSourceFiles: const { | 525 }, preserializedSourceFiles: const { |
509 'a.dart': ''' | 526 'a.dart': ''' |
510 class A {} | 527 class A {} |
511 class B {} | 528 class B {} |
512 class C {} | 529 class C {} |
513 class D = A with B, C; | 530 class D = A with B, C; |
514 ''', | 531 ''', |
515 'b.dart': ''' | 532 'b.dart': ''' |
516 ''', | 533 ''', |
517 }), | 534 }), |
518 | 535 |
519 const Test('Deferred prefix loadLibrary', const { | 536 const Test('Deferred prefix loadLibrary', const { |
520 'main.dart': ''' | 537 'main.dart': ''' |
521 import 'a.dart'; | 538 import 'a.dart'; |
522 | 539 |
523 main() { | 540 main() { |
524 test(); | 541 test(); |
525 } | 542 } |
526 ''', | 543 ''', |
527 }, preserializedSourceFiles: const { | 544 }, preserializedSourceFiles: const { |
528 'a.dart': ''' | 545 'a.dart': ''' |
529 import 'b.dart' deferred as pre; | 546 import 'b.dart' deferred as pre; |
530 test() { | 547 test() { |
531 pre.loadLibrary(); | 548 pre.loadLibrary(); |
532 } | 549 } |
533 ''', | 550 ''', |
534 'b.dart': ''' | 551 'b.dart': ''' |
535 ''', | 552 ''', |
536 }), | 553 }), |
537 | 554 |
538 const Test('Deferred without prefix', const { | 555 const Test( |
539 'main.dart': ''' | 556 'Deferred without prefix', |
| 557 const { |
| 558 'main.dart': ''' |
540 import 'a.dart'; | 559 import 'a.dart'; |
541 | 560 |
542 main() { | 561 main() { |
543 test(); | 562 test(); |
544 } | 563 } |
545 ''', | 564 ''', |
546 }, preserializedSourceFiles: const { | 565 }, |
547 'a.dart': ''' | 566 preserializedSourceFiles: const { |
| 567 'a.dart': ''' |
548 import 'b.dart' deferred; | 568 import 'b.dart' deferred; |
549 test() {} | 569 test() {} |
550 ''', | 570 ''', |
551 'b.dart': ''' | 571 'b.dart': ''' |
552 ''', | 572 ''', |
553 }, expectedErrorCount: 1), | 573 }, |
| 574 expectedErrorCount: 1), |
554 | 575 |
555 const Test('Deferred with duplicate prefix', const { | 576 const Test( |
556 'main.dart': ''' | 577 'Deferred with duplicate prefix', |
| 578 const { |
| 579 'main.dart': ''' |
557 import 'a.dart'; | 580 import 'a.dart'; |
558 | 581 |
559 main() { | 582 main() { |
560 test(); | 583 test(); |
561 } | 584 } |
562 ''', | 585 ''', |
563 }, preserializedSourceFiles: const { | 586 }, |
564 'a.dart': ''' | 587 preserializedSourceFiles: const { |
| 588 'a.dart': ''' |
565 import 'b.dart' deferred as pre; | 589 import 'b.dart' deferred as pre; |
566 import 'c.dart' deferred as pre; | 590 import 'c.dart' deferred as pre; |
567 test() {} | 591 test() {} |
568 ''', | 592 ''', |
569 'b.dart': ''' | 593 'b.dart': ''' |
570 ''', | 594 ''', |
571 'c.dart': ''' | 595 'c.dart': ''' |
572 ''', | 596 ''', |
573 }, expectedErrorCount: 1), | 597 }, |
| 598 expectedErrorCount: 1), |
574 | 599 |
575 const Test('Closure in operator function', const { | 600 const Test('Closure in operator function', const { |
576 'main.dart': ''' | 601 'main.dart': ''' |
577 import 'a.dart'; | 602 import 'a.dart'; |
578 | 603 |
579 main() { | 604 main() { |
580 test(); | 605 test(); |
581 } | 606 } |
582 ''', | 607 ''', |
583 }, preserializedSourceFiles: const { | 608 }, preserializedSourceFiles: const { |
584 'a.dart': ''' | 609 'a.dart': ''' |
585 class C { | 610 class C { |
586 operator ==(other) => () {}; | 611 operator ==(other) => () {}; |
587 } | 612 } |
588 | 613 |
589 test() => new C() == null; | 614 test() => new C() == null; |
590 ''', | 615 ''', |
591 }), | 616 }), |
592 | 617 |
593 const Test('Checked setter', const { | 618 const Test( |
594 'main.dart': ''' | 619 'Checked setter', |
| 620 const { |
| 621 'main.dart': ''' |
595 import 'a.dart'; | 622 import 'a.dart'; |
596 | 623 |
597 main() { | 624 main() { |
598 test(); | 625 test(); |
599 } | 626 } |
600 ''', | 627 ''', |
601 }, preserializedSourceFiles: const { | 628 }, |
602 'a.dart': ''' | 629 preserializedSourceFiles: const { |
| 630 'a.dart': ''' |
603 class C { | 631 class C { |
604 set foo(int i) {} | 632 set foo(int i) {} |
605 } | 633 } |
606 | 634 |
607 test() => new C().foo = 0; | 635 test() => new C().foo = 0; |
608 ''', | 636 ''', |
609 }, checkedMode: true), | 637 }, |
| 638 checkedMode: true), |
610 | 639 |
611 const Test('Deferred access', const { | 640 const Test('Deferred access', const { |
612 'main.dart': ''' | 641 'main.dart': ''' |
613 import 'a.dart'; | 642 import 'a.dart'; |
614 | 643 |
615 main() { | 644 main() { |
616 test(); | 645 test(); |
617 } | 646 } |
618 ''', | 647 ''', |
619 }, preserializedSourceFiles: const { | 648 }, preserializedSourceFiles: const { |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
652 main() {} | 681 main() {} |
653 ''', | 682 ''', |
654 }, preserializedSourceFiles: const { | 683 }, preserializedSourceFiles: const { |
655 'a.dart': ''' | 684 'a.dart': ''' |
656 import 'dart:indexed_db'; | 685 import 'dart:indexed_db'; |
657 ''', | 686 ''', |
658 }), | 687 }), |
659 | 688 |
660 const Test('Deferred static access', const {}, | 689 const Test('Deferred static access', const {}, |
661 preserializedSourceFiles: const { | 690 preserializedSourceFiles: const { |
662 'main.dart': ''' | 691 'main.dart': ''' |
663 import 'b.dart' deferred as prefix; | 692 import 'b.dart' deferred as prefix; |
664 | 693 |
665 main() => prefix.loadLibrary().then((_) => prefix.test2()); | 694 main() => prefix.loadLibrary().then((_) => prefix.test2()); |
666 ''', | 695 ''', |
667 'b.dart': ''' | 696 'b.dart': ''' |
668 test2() => x; | 697 test2() => x; |
669 var x = const ConstClass(const ConstClass(1)); | 698 var x = const ConstClass(const ConstClass(1)); |
670 class ConstClass { | 699 class ConstClass { |
671 final x; | 700 final x; |
672 const ConstClass(this.x); | 701 const ConstClass(this.x); |
673 } | 702 } |
674 ''', | 703 ''', |
675 }), | 704 }), |
676 | 705 |
677 const Test('Multi variable declaration', const { | 706 const Test('Multi variable declaration', const { |
678 'main.dart': ''' | 707 'main.dart': ''' |
679 import 'a.dart'; | 708 import 'a.dart'; |
680 | 709 |
681 main() => y; | 710 main() => y; |
682 ''', | 711 ''', |
683 }, preserializedSourceFiles: const { | 712 }, preserializedSourceFiles: const { |
684 'a.dart': ''' | 713 'a.dart': ''' |
685 var x, y = 2; | 714 var x, y = 2; |
686 ''', | 715 ''', |
687 }), | 716 }), |
688 | 717 |
689 const Test('Double values', const {}, | 718 const Test('Double values', const {}, preserializedSourceFiles: const { |
690 preserializedSourceFiles: const { | 719 'main.dart': ''' |
691 'main.dart': ''' | |
692 const a = 1e+400; | 720 const a = 1e+400; |
693 main() => a; | 721 main() => a; |
694 ''', | 722 ''', |
695 }), | 723 }), |
696 | 724 |
697 const Test('Erroneous constructor', const {}, | 725 const Test('Erroneous constructor', const {}, |
698 preserializedSourceFiles: const { | 726 preserializedSourceFiles: const { |
| 727 'main.dart': ''' |
| 728 main() => new Null(); |
| 729 ''' |
| 730 }), |
| 731 |
| 732 const Test('Metadata on imports', const {}, preserializedSourceFiles: const { |
699 'main.dart': ''' | 733 'main.dart': ''' |
700 main() => new Null(); | |
701 '''}), | |
702 | |
703 const Test('Metadata on imports', const {}, | |
704 preserializedSourceFiles: const { | |
705 'main.dart': ''' | |
706 @deprecated | 734 @deprecated |
707 import 'main.dart'; | 735 import 'main.dart'; |
708 | 736 |
709 main() {} | 737 main() {} |
710 '''}), | 738 ''' |
| 739 }), |
711 | 740 |
712 const Test('Metadata on exports', const {}, | 741 const Test('Metadata on exports', const {}, preserializedSourceFiles: const { |
713 preserializedSourceFiles: const { | 742 'main.dart': ''' |
714 'main.dart': ''' | |
715 @deprecated | 743 @deprecated |
716 export 'main.dart'; | 744 export 'main.dart'; |
717 | 745 |
718 main() {} | 746 main() {} |
719 '''}), | 747 ''' |
| 748 }), |
720 | 749 |
721 const Test('Metadata on part tags', const {}, | 750 const Test('Metadata on part tags', const {}, |
722 preserializedSourceFiles: const { | 751 preserializedSourceFiles: const { |
723 'main.dart': ''' | 752 'main.dart': ''' |
724 library main; | 753 library main; |
725 | 754 |
726 @deprecated | 755 @deprecated |
727 part 'a.dart'; | 756 part 'a.dart'; |
728 | 757 |
729 main() {} | 758 main() {} |
730 '''}, | 759 ''' |
| 760 }, |
731 unserializedSourceFiles: const { | 761 unserializedSourceFiles: const { |
732 'a.dart': ''' | 762 'a.dart': ''' |
733 part of main; | 763 part of main; |
734 '''}), | 764 ''' |
| 765 }), |
735 | 766 |
736 const Test('Metadata on part-of tags', const {}, | 767 const Test('Metadata on part-of tags', const {}, |
737 preserializedSourceFiles: const { | 768 preserializedSourceFiles: const { |
738 'main.dart': ''' | 769 'main.dart': ''' |
739 library main; | 770 library main; |
740 | 771 |
741 part 'a.dart'; | 772 part 'a.dart'; |
742 | 773 |
743 main() {} | 774 main() {} |
744 '''}, | 775 ''' |
| 776 }, |
745 unserializedSourceFiles: const { | 777 unserializedSourceFiles: const { |
746 'a.dart': ''' | 778 'a.dart': ''' |
747 @deprecated | 779 @deprecated |
748 part of main; | 780 part of main; |
749 '''}), | 781 ''' |
| 782 }), |
750 | 783 |
751 const Test('Ambiguous elements', const {}, | 784 const Test('Ambiguous elements', const {}, preserializedSourceFiles: const { |
752 preserializedSourceFiles: const { | 785 'main.dart': ''' |
753 'main.dart': ''' | |
754 import 'a.dart'; | 786 import 'a.dart'; |
755 import 'b.dart'; | 787 import 'b.dart'; |
756 | 788 |
757 main() => new foo(); | 789 main() => new foo(); |
758 ''', | 790 ''', |
759 'a.dart': ''' | 791 'a.dart': ''' |
760 var foo; | 792 var foo; |
761 ''', | 793 ''', |
762 'b.dart': ''' | 794 'b.dart': ''' |
763 var foo; | 795 var foo; |
764 ''',}), | 796 ''', |
| 797 }), |
765 | 798 |
766 const Test('html and mirrors', const {}, | 799 const Test('html and mirrors', const {}, |
767 preserializedSourceFiles: const { | 800 preserializedSourceFiles: const { |
768 'main.dart': ''' | 801 'main.dart': ''' |
769 import 'dart:html'; | 802 import 'dart:html'; |
770 import 'dart:mirrors'; | 803 import 'dart:mirrors'; |
771 main() {} | 804 main() {} |
772 '''}, | 805 ''' |
| 806 }, |
773 expectedWarningCount: 1), | 807 expectedWarningCount: 1), |
774 ]; | 808 ]; |
775 | 809 |
776 class Test { | 810 class Test { |
777 final String name; | 811 final String name; |
778 final Map sourceFiles; | 812 final Map sourceFiles; |
779 final Map preserializedSourceFiles; | 813 final Map preserializedSourceFiles; |
780 final Map unserializedSourceFiles; | 814 final Map unserializedSourceFiles; |
781 final int expectedErrorCount; | 815 final int expectedErrorCount; |
782 final int expectedWarningCount; | 816 final int expectedWarningCount; |
783 final int expectedHintCount; | 817 final int expectedHintCount; |
784 final int expectedInfoCount; | 818 final int expectedInfoCount; |
785 final bool checkedMode; | 819 final bool checkedMode; |
786 | 820 |
787 const Test( | 821 const Test(this.name, this.sourceFiles, |
788 this.name, | |
789 this.sourceFiles, | |
790 {this.preserializedSourceFiles, | 822 {this.preserializedSourceFiles, |
791 this.unserializedSourceFiles, | 823 this.unserializedSourceFiles, |
792 this.expectedErrorCount: 0, | 824 this.expectedErrorCount: 0, |
793 this.expectedWarningCount: 0, | 825 this.expectedWarningCount: 0, |
794 this.expectedHintCount: 0, | 826 this.expectedHintCount: 0, |
795 this.expectedInfoCount: 0, | 827 this.expectedInfoCount: 0, |
796 this.checkedMode: false}); | 828 this.checkedMode: false}); |
797 } | 829 } |
OLD | NEW |