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

Side by Side Diff: tests/compiler/dart2js/serialization/test_data.dart

Issue 2013763002: Add names and support for preserialized data to serialization tests (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Updated cf. comments. Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tests/compiler/dart2js/serialization/resolved_ast_test.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 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 const Test(const { 8 const Test('Empty program', const {
9 'main.dart': 'main() {}' 9 'main.dart': 'main() {}'
10 }), 10 }),
11 11
12 const Test(const { 12 const Test('Hello World', const {
13 'main.dart': 'main() => print("Hello World");' 13 'main.dart': 'main() => print("Hello World");'
14 }), 14 }),
15 15
16 const Test(const { 16 const Test('Too many arguments to print', const {
17 'main.dart': 'main() => print("Hello World", 0);' 17 'main.dart': 'main() => print("Hello World", 0);'
18 }, 18 },
19 expectedWarningCount: 1, 19 expectedWarningCount: 1,
20 expectedInfoCount: 1), 20 expectedInfoCount: 1),
21 21
22 const Test(const { 22 const Test('Hello World with string interpolation', const {
23 'main.dart': r''' 23 'main.dart': r'''
24 main() { 24 main() {
25 String text = "Hello World"; 25 String text = "Hello World";
26 print('$text'); 26 print('$text');
27 }''' 27 }'''
28 }), 28 }),
29 29
30 const Test(const { 30 const Test('Too many arguments to print with string interpolation', const {
31 'main.dart': r''' 31 'main.dart': r'''
32 main() { 32 main() {
33 String text = "Hello World"; 33 String text = "Hello World";
34 print('$text', text); 34 print('$text', text);
35 }''' 35 }'''
36 }, 36 },
37 expectedWarningCount: 1, 37 expectedWarningCount: 1,
38 expectedInfoCount: 1), 38 expectedInfoCount: 1),
39 39
40 const Test(const { 40 const Test('Print main arguments', const {
41 'main.dart': r''' 41 'main.dart': r'''
42 main(List<String> arguments) { 42 main(List<String> arguments) {
43 print(arguments); 43 print(arguments);
44 }''' 44 }'''
45 }), 45 }),
46 46
47 const Test(const { 47 const Test('For loop on main arguments', const {
48 'main.dart': r''' 48 'main.dart': r'''
49 main(List<String> arguments) { 49 main(List<String> arguments) {
50 for (int i = 0; i < arguments.length; i++) { 50 for (int i = 0; i < arguments.length; i++) {
51 print(arguments[i]); 51 print(arguments[i]);
52 } 52 }
53 }''' 53 }'''
54 }), 54 }),
55 55
56 const Test(const { 56 const Test('For-in loop on main arguments', const {
57 'main.dart': r''' 57 'main.dart': r'''
58 main(List<String> arguments) { 58 main(List<String> arguments) {
59 for (String argument in arguments) { 59 for (String argument in arguments) {
60 print(argument); 60 print(argument);
61 } 61 }
62 }''' 62 }'''
63 }), 63 }),
64 64
65 const Test(const { 65 const Test('Simple class', const {
66 'main.dart': r''' 66 'main.dart': r'''
67 class Class {} 67 class Class {}
68 main() { 68 main() {
69 print(new Class()); 69 print(new Class());
70 }''' 70 }'''
71 }), 71 }),
72 72
73 const Test(const { 73 const Test('Simple class implements Function without call method', const {
74 'main.dart': r''' 74 'main.dart': r'''
75 class Class implements Function {} 75 class Class implements Function {}
76 main() { 76 main() {
77 print(new Class()); 77 print(new Class());
78 }''' 78 }'''
79 }, 79 },
80 expectedWarningCount: 1), 80 expectedWarningCount: 1),
81 81
82 const Test(const { 82 const Test('Simple class implements Function with call method', const {
83 'main.dart': r''' 83 'main.dart': r'''
84 class Class implements Function { 84 class Class implements Function {
85 call() {} 85 call() {}
86 } 86 }
87 main() { 87 main() {
88 print(new Class()()); 88 print(new Class()());
89 }''' 89 }'''
90 }), 90 }),
91 91
92 const Test(const { 92 const Test('Implement Comparable', const {
93 'main.dart': r''' 93 'main.dart': r'''
94 class Class implements Comparable<Class> { 94 class Class implements Comparable<Class> {
95 int compareTo(Class other) => 0; 95 int compareTo(Class other) => 0;
96 } 96 }
97 main() { 97 main() {
98 print(new Class()); 98 print(new Class());
99 }''' 99 }'''
100 }), 100 }),
101 101
102 const Test(const { 102 const Test('Implement Comparable with two many type arguments', const {
103 'main.dart': r''' 103 'main.dart': r'''
104 class Class implements Comparable<Class, Class> { 104 class Class implements Comparable<Class, Class> {
105 int compareTo(other) => 0; 105 int compareTo(other) => 0;
106 } 106 }
107 main() { 107 main() {
108 print(new Class()); 108 print(new Class());
109 }''' 109 }'''
110 }, 110 },
111 expectedWarningCount: 1), 111 expectedWarningCount: 1),
112 112
113 const Test(const { 113 const Test('Impliment Comparable with incompatible parameter types', const {
114 'main.dart': r''' 114 'main.dart': r'''
115 class Class implements Comparable<Class> { 115 class Class implements Comparable<Class> {
116 int compareTo(String other) => 0; 116 int compareTo(String other) => 0;
117 } 117 }
118 main() { 118 main() {
119 print(new Class().compareTo(null)); 119 print(new Class().compareTo(null));
120 }''' 120 }'''
121 }, 121 },
122 expectedWarningCount: 1, 122 expectedWarningCount: 1,
123 expectedInfoCount: 1), 123 expectedInfoCount: 1),
124 124
125 const Test(const { 125 const Test('Impliment Comparable with incompatible parameter count', const {
126 'main.dart': r''' 126 'main.dart': r'''
127 class Class implements Comparable { 127 class Class implements Comparable {
128 bool compareTo(a, b) => true; 128 bool compareTo(a, b) => true;
129 } 129 }
130 main() { 130 main() {
131 print(new Class().compareTo(null, null)); 131 print(new Class().compareTo(null, null));
132 }''' 132 }'''
133 }, 133 },
134 expectedWarningCount: 1, 134 expectedWarningCount: 1,
135 expectedInfoCount: 1), 135 expectedInfoCount: 1),
136 136
137 const Test(const { 137 const Test('Implement Random and call nextInt directly', const {
138 'main.dart': r''' 138 'main.dart': r'''
139 import 'dart:math'; 139 import 'dart:math';
140 140
141 class MyRandom implements Random { 141 class MyRandom implements Random {
142 int nextInt(int max) { 142 int nextInt(int max) {
143 return max.length; 143 return max.length;
144 } 144 }
145 bool nextBool() => true; 145 bool nextBool() => true;
146 double nextDouble() => 0.0; 146 double nextDouble() => 0.0;
147 } 147 }
148 main() { 148 main() {
149 new MyRandom().nextInt(0); 149 new MyRandom().nextInt(0);
150 }''' 150 }'''
151 }, 151 },
152 expectedWarningCount: 1, 152 expectedWarningCount: 1,
153 expectedInfoCount: 0), 153 expectedInfoCount: 0),
154 154
155 const Test(const { 155 const Test('Implement Random and do not call nextInt', const {
156 'main.dart': r''' 156 'main.dart': r'''
157 import 'dart:math'; 157 import 'dart:math';
158 158
159 class MyRandom implements Random { 159 class MyRandom implements Random {
160 int nextInt(int max) { 160 int nextInt(int max) {
161 return max.length; 161 return max.length;
162 } 162 }
163 bool nextBool() => true; 163 bool nextBool() => true;
164 double nextDouble() => 0.0; 164 double nextDouble() => 0.0;
165 } 165 }
166 main() { 166 main() {
167 new MyRandom(); 167 new MyRandom();
168 }''' 168 }'''
169 }), 169 }),
170 170
171 const Test(const { 171 const Test('Implement Random and call nextInt through native code', const {
172 'main.dart': r''' 172 'main.dart': r'''
173 import 'dart:math'; 173 import 'dart:math';
174 174
175 class MyRandom implements Random { 175 class MyRandom implements Random {
176 int nextInt(int max) { 176 int nextInt(int max) {
177 return max.length; 177 return max.length;
178 } 178 }
179 bool nextBool() => true; 179 bool nextBool() => true;
180 double nextDouble() => 0.0; 180 double nextDouble() => 0.0;
181 } 181 }
182 main() { 182 main() {
183 // Invocation of `MyRandom.nextInt` is only detected knowing the actual 183 // Invocation of `MyRandom.nextInt` is only detected knowing the actual
184 // implementation class for `List` and the world impact of its `shuffle` 184 // implementation class for `List` and the world impact of its `shuffle`
185 // method. 185 // method.
186 [].shuffle(new MyRandom()); 186 [].shuffle(new MyRandom());
187 }''' 187 }'''
188 }, 188 },
189 expectedWarningCount: 1, 189 expectedWarningCount: 1,
190 expectedInfoCount: 0), 190 expectedInfoCount: 0),
191 191
192 const Test(const { 192 const Test('Handle break and continue', const {
193 'main.dart': ''' 193 'main.dart': '''
194 main() { 194 main() {
195 loop: for (var a in []) { 195 loop: for (var a in []) {
196 for (var b in []) { 196 for (var b in []) {
197 continue loop; 197 continue loop;
198 } 198 }
199 break; 199 break;
200 } 200 }
201 }''' 201 }'''
202 }), 202 }),
203 203
204 const Test(const { 204 const Test('Explicit default constructor', const {
205 'main.dart': ''' 205 'main.dart': '''
206 class A { 206 class A {
207 A(); 207 A();
208 } 208 }
209 main() => new A(); 209 main() => new A();
210 ''', 210 ''',
211 }), 211 }),
212 212
213 const Test(const { 213 const Test('Explicit default constructor, preserialized', const {
214 'main.dart': '''
215 import 'lib.dart';
216 main() => new A();
217 ''',
218 }, preserializedSourceFiles: const {
219 'lib.dart': '''
220 class A {
221 A();
222 }
223 ''',
224 }),
225
226 const Test('Const constructor', const {
214 'main.dart': ''' 227 'main.dart': '''
215 class C { 228 class C {
216 const C(); 229 const C();
217 } 230 }
218 main() => const C();''' 231 main() => const C();'''
219 }), 232 }),
220 233
221 const Test(const { 234 const Test('Redirecting factory', const {
222 'main.dart': ''' 235 'main.dart': '''
223 class C { 236 class C {
224 factory C() = Object; 237 factory C() = Object;
225 } 238 }
226 main() => new C();''' 239 main() => new C();'''
227 }), 240 }),
228 241
229 const Test(const { 242 const Test('Redirecting factory with optional arguments', const {
230 'main.dart': ''' 243 'main.dart': '''
231 abstract class C implements List { 244 abstract class C implements List {
232 factory C([_]) = List; 245 factory C([_]) = List;
233 } 246 }
234 main() => new C();''' 247 main() => new C();'''
235 }), 248 }),
236 249
237 const Test(const { 250 const Test('Constructed constant using its default values.', const {
238 'main.dart': ''' 251 'main.dart': '''
239 main() => const Duration(); 252 main() => const Duration();
240 ''', 253 ''',
241 }), 254 }),
242 255
243 const Test(const { 256 const Test('Call forwarding constructor on named mixin application',
244 'main.dart': ''' 257 const {
258 'main.dart': '''
245 import 'dart:collection'; 259 import 'dart:collection';
246 main() => new UnmodifiableListView(null); 260 main() => new UnmodifiableListView(null);
247 ''', 261 ''',
248 }), 262 }),
249 263
250 const Test(const { 264 const Test('Function reference constant', const {
251 'main.dart': ''' 265 'main.dart': '''
252 var myIdentical = identical; 266 var myIdentical = identical;
253 main() => myIdentical; 267 main() => myIdentical;
254 ''', 268 ''',
255 }), 269 }),
256 270
257 const Test(const { 271 const Test('Super method call', const {
258 'main.dart': ''' 272 'main.dart': '''
259 class Foo { 273 class Foo {
260 String toString() => super.toString(); 274 String toString() => super.toString();
261 } 275 }
262 main() { 276 main() {
263 print(new Foo()); 277 print(new Foo());
264 } 278 }
265 ''', 279 ''',
266 }), 280 }),
281
282 const Test('Call forwarding constructor on named mixin application, no args.',
283 const {
284 'main.dart': '''
285 import 'lib.dart';
286 main() => new C();
287 ''',
288 }, preserializedSourceFiles: const {
289 'lib.dart': '''
290 class M {}
291 class S {}
292 class C = S with M;
293 ''',
294 }),
295
296 const Test('Call forwarding constructor on named mixin application, one arg.',
297 const {
298 'main.dart': '''
299 import 'lib.dart';
300 main() => new C(0);
301 ''',
302 }, preserializedSourceFiles: const {
303 'lib.dart': '''
304 class M {}
305 class S {
306 S(a);
307 }
308 class C = S with M;
309 ''',
310 }),
267 ]; 311 ];
268 312
269 class Test { 313 class Test {
314 final String name;
270 final Map sourceFiles; 315 final Map sourceFiles;
316 final Map preserializedSourceFiles;
271 final int expectedErrorCount; 317 final int expectedErrorCount;
272 final int expectedWarningCount; 318 final int expectedWarningCount;
273 final int expectedHintCount; 319 final int expectedHintCount;
274 final int expectedInfoCount; 320 final int expectedInfoCount;
275 321
276 const Test(this.sourceFiles, { 322 const Test(
277 this.expectedErrorCount: 0, 323 this.name,
278 this.expectedWarningCount: 0, 324 this.sourceFiles,
279 this.expectedHintCount: 0, 325 {this.preserializedSourceFiles,
280 this.expectedInfoCount: 0}); 326 this.expectedErrorCount: 0,
327 this.expectedWarningCount: 0,
328 this.expectedHintCount: 0,
329 this.expectedInfoCount: 0});
281 } 330 }
OLDNEW
« no previous file with comments | « tests/compiler/dart2js/serialization/resolved_ast_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698