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

Side by Side Diff: pkg/analyzer2dart/test/end2end_data.dart

Issue 669673006: Add SExpression test and share tests between dart2dart and analyzer2dart. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated cf. comments. Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 /// Test data for the end2end test.
6 library test.end2end.data;
7
8 import 'test_helper.dart' show Group;
9 import 'test_helper.dart' as base show TestSpec;
10
11 class TestSpec extends base.TestSpec {
12 const TestSpec(String input, [String output])
13 : super(input, output != null ? output : input);
14 }
15
16 const List<Group> TEST_DATA = const <Group>[
17 const Group('Empty main', const <TestSpec>[
18 const TestSpec('''
19 main() {}
20 '''),
21
22 const TestSpec('''
23 main() {}
24 foo() {}
25 ''', '''
26 main() {}
27 '''),
28 ]),
29 const Group('Simple call-chains', const <TestSpec>[
30 const TestSpec('''
31 foo() {}
32 main() {
33 foo();
34 }
35 '''),
36
37 const TestSpec('''
38 bar() {}
39 foo() {
40 bar();
41 }
42 main() {
43 foo();
44 }
45 '''),
46
47 const TestSpec('''
48 bar() {
49 main();
50 }
51 foo() {
52 bar();
53 }
54 main() {
55 foo();
56 }
57 '''),
58
59 ]),
60 const Group('Literals', const <TestSpec>[
61 const TestSpec('''
62 main() {
63 return 0;
64 }
65 '''),
66
67 const TestSpec('''
68 main() {
69 return 1.5;
70 }
71 '''),
72
73 const TestSpec('''
74 main() {
75 return true;
76 }
77 '''),
78
79 const TestSpec('''
80 main() {
81 return false;
82 }
83 '''),
84
85 const TestSpec('''
86 main() {
87 return "a";
88 }
89 '''),
90
91 const TestSpec('''
92 main() {
93 return "a" "b";
94 }
95 ''', '''
96 main() {
97 return "ab";
98 }
99 '''),
100 ]),
101
102 const Group('Parameters', const <TestSpec>[
103 const TestSpec('''
104 main(args) {}
105 '''),
106
107 const TestSpec('''
108 main(a, b) {}
109 '''),
110 ]),
111
112 const Group('Typed parameters', const <TestSpec>[
113 const TestSpec('''
114 void main(args) {}
115 '''),
116
117 const TestSpec('''
118 main(int a, String b) {}
119 '''),
120
121 const TestSpec('''
122 main(Comparator a, List b) {}
123 '''),
124
125 const TestSpec('''
126 main(Comparator<dynamic> a, List<dynamic> b) {}
127 ''','''
128 main(Comparator a, List b) {}
129 '''),
130
131 const TestSpec('''
132 main(Map a, Map<dynamic, List<int>> b) {}
133 '''),
134 ]),
135
136 const Group('Pass arguments', const <TestSpec>[
137 const TestSpec('''
138 foo(a) {}
139 main() {
140 foo(null);
141 }
142 '''),
143
144 const TestSpec('''
145 bar(b, c) {}
146 foo(a) {}
147 main() {
148 foo(null);
149 bar(0, "");
150 }
151 '''),
152
153 const TestSpec('''
154 bar(b) {}
155 foo(a) {
156 bar(a);
157 }
158 main() {
159 foo(null);
160 }
161 '''),
162 ]),
163
164 const Group('Top level field access', const <TestSpec>[
165 const TestSpec('''
166 main(args) {
167 return deprecated;
168 }
169 '''),
170 ]),
171
172 const Group('Local variables', const <TestSpec>[
173 const TestSpec('''
174 main() {
175 var a;
176 return a;
177 }
178 ''','''
179 main() {}
180 '''),
181
182 const TestSpec('''
183 main() {
184 var a = 0;
185 return a;
186 }
187 ''','''
188 main() {
189 return 0;
190 }
191 '''),
192 ]),
193
194 const Group('Dynamic access', const <TestSpec>[
195 const TestSpec('''
196 main(a) {
197 return a.foo;
198 }
199 '''),
200
201 const TestSpec('''
202 main() {
203 var a = "";
204 return a.foo;
205 }
206 ''','''
207 main() {
208 return "".foo;
209 }
210 '''),
211 ]),
212
213 const Group('Dynamic invocation', const <TestSpec>[
214 const TestSpec('''
215 main(a) {
216 return a.foo(0);
217 }
218 '''),
219
220 const TestSpec('''
221 main() {
222 var a = "";
223 return a.foo(0, 1);
224 }
225 ''','''
226 main() {
227 return "".foo(0, 1);
228 }
229 '''),
230 ]),
231
232 const Group('Binary expressions', const <TestSpec>[
233 const TestSpec('''
234 main(a) {
235 return a + deprecated;
236 }
237 '''),
238
239 const TestSpec('''
240 main(a) {
241 return a - deprecated;
242 }
243 '''),
244
245 const TestSpec('''
246 main(a) {
247 return a * deprecated;
248 }
249 '''),
250
251 const TestSpec('''
252 main(a) {
253 return a / deprecated;
254 }
255 '''),
256
257 const TestSpec('''
258 main(a) {
259 return a ~/ deprecated;
260 }
261 '''),
262
263 const TestSpec('''
264 main(a) {
265 return a % deprecated;
266 }
267 '''),
268
269 const TestSpec('''
270 main(a) {
271 return a < deprecated;
272 }
273 '''),
274
275 const TestSpec('''
276 main(a) {
277 return a <= deprecated;
278 }
279 '''),
280
281 const TestSpec('''
282 main(a) {
283 return a > deprecated;
284 }
285 '''),
286
287 const TestSpec('''
288 main(a) {
289 return a >= deprecated;
290 }
291 '''),
292
293 const TestSpec('''
294 main(a) {
295 return a << deprecated;
296 }
297 '''),
298
299 const TestSpec('''
300 main(a) {
301 return a >> deprecated;
302 }
303 '''),
304
305 const TestSpec('''
306 main(a) {
307 return a & deprecated;
308 }
309 '''),
310
311 const TestSpec('''
312 main(a) {
313 return a | deprecated;
314 }
315 '''),
316
317 const TestSpec('''
318 main(a) {
319 return a ^ deprecated;
320 }
321 '''),
322
323 const TestSpec('''
324 main(a) {
325 return a == deprecated;
326 }
327 '''),
328
329 const TestSpec('''
330 main(a) {
331 return a != deprecated;
332 }
333 ''','''
334 main(a) {
335 return !(a == deprecated);
336 }
337 '''),
338
339 const TestSpec('''
340 main(a) {
341 return a && deprecated;
342 }
343 '''),
344
345 const TestSpec('''
346 main(a) {
347 return a || deprecated;
348 }
349 '''),
350 ]),
351
352 const Group('If statement', const <TestSpec>[
353 const TestSpec('''
354 main(a) {
355 if (a) {
356 print(0);
357 }
358 }
359 '''),
360
361 const TestSpec('''
362 main(a) {
363 if (a) {
364 print(0);
365 } else {
366 print(1);
367 }
368 }
369 ''','''
370 main(a) {
371 a ? print(0) : print(1);
372 }
373 '''),
374
375 const TestSpec('''
376 main(a) {
377 if (a) {
378 print(0);
379 } else {
380 print(1);
381 print(2);
382 }
383 }
384 '''),
385 ]),
386
387 const Group('Conditional expression', const <TestSpec>[
388 const TestSpec('''
389 main(a) {
390 return a ? print(0) : print(1);
391 }
392 '''),
393 ]),
394 ];
OLDNEW
« no previous file with comments | « pkg/analyzer2dart/lib/src/semantic_visitor.dart ('k') | pkg/analyzer2dart/test/end2end_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698