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

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

Issue 639733004: Don't emit /* new backend */ comment by default. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | sdk/lib/_internal/compiler/implementation/dart_backend/backend_ast_to_frontend_ast.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 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 /// End-to-end test of the analyzer2dart compiler. 5 /// End-to-end test of the analyzer2dart compiler.
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'mock_sdk.dart'; 9 import 'mock_sdk.dart';
10 import 'package:analyzer/file_system/memory_file_system.dart'; 10 import 'package:analyzer/file_system/memory_file_system.dart';
11 import 'package:analyzer/src/generated/element.dart'; 11 import 'package:analyzer/src/generated/element.dart';
12 import 'package:analyzer/src/generated/sdk.dart'; 12 import 'package:analyzer/src/generated/sdk.dart';
13 import 'package:analyzer/src/generated/source.dart'; 13 import 'package:analyzer/src/generated/source.dart';
14 import 'package:compiler/implementation/dart_backend/backend_ast_to_frontend_ast .dart'; 14 import 'package:compiler/implementation/dart_backend/backend_ast_to_frontend_ast .dart';
15 import 'package:unittest/unittest.dart'; 15 import 'package:unittest/unittest.dart';
16 16
17 import '../lib/src/closed_world.dart'; 17 import '../lib/src/closed_world.dart';
18 import '../lib/src/driver.dart'; 18 import '../lib/src/driver.dart';
19 import '../lib/src/converted_world.dart'; 19 import '../lib/src/converted_world.dart';
20 import '../lib/src/dart_backend.dart'; 20 import '../lib/src/dart_backend.dart';
21 21
22 main() { 22 main() {
23 test('Empty main', () { 23 test('Empty main', () {
24 String expectedResult = ''' 24 String expectedResult = '''
25 main() $NEW_BACKEND_COMMENT 25 main() {}
26 {}
27
28 '''; 26 ''';
29 checkResult(''' 27 checkResult('''
30 main() {}''', 28 main() {}''',
31 expectedResult); 29 expectedResult);
32 30
33 checkResult(''' 31 checkResult('''
34 main() {} 32 main() {}
35 foo() {}''', 33 foo() {}''',
36 expectedResult); 34 expectedResult);
37 }); 35 });
38 36
39 test('Simple call-chains', () { 37 test('Simple call-chains', () {
40 checkResult(''' 38 checkResult('''
41 foo() {} 39 foo() {}
42 main() { 40 main() {
43 foo(); 41 foo();
44 } 42 }
45 ''', '''
46 foo() $NEW_BACKEND_COMMENT
47 {}
48
49 main() $NEW_BACKEND_COMMENT
50 {
51 foo();
52 }
53
54 '''); 43 ''');
55 44
56 checkResult(''' 45 checkResult('''
57 bar() {} 46 bar() {}
58 foo() { 47 foo() {
59 bar(); 48 bar();
60 } 49 }
61 main() { 50 main() {
62 foo(); 51 foo();
63 } 52 }
64 ''', '''
65 bar() $NEW_BACKEND_COMMENT
66 {}
67
68 foo() $NEW_BACKEND_COMMENT
69 {
70 bar();
71 }
72
73 main() $NEW_BACKEND_COMMENT
74 {
75 foo();
76 }
77
78 '''); 53 ''');
79 54
80 checkResult(''' 55 checkResult('''
81 bar() { 56 bar() {
82 main(); 57 main();
83 } 58 }
84 foo() { 59 foo() {
85 bar(); 60 bar();
86 } 61 }
87 main() { 62 main() {
88 foo(); 63 foo();
89 } 64 }
90 ''', '''
91 bar() $NEW_BACKEND_COMMENT
92 {
93 main();
94 }
95
96 foo() $NEW_BACKEND_COMMENT
97 {
98 bar();
99 }
100
101 main() $NEW_BACKEND_COMMENT
102 {
103 foo();
104 }
105
106 '''); 65 ''');
107 }); 66 });
108 67
109 test('Literals', () { 68 test('Literals', () {
110 checkResult(''' 69 checkResult('''
111 main() { 70 main() {
112 return 0; 71 return 0;
113 } 72 }
114 ''', '''
115 main() $NEW_BACKEND_COMMENT
116 {
117 return 0;
118 }
119
120 '''); 73 ''');
121 74
122 checkResult(''' 75 checkResult('''
123 main() { 76 main() {
124 return 1.5; 77 return 1.5;
125 } 78 }
126 ''', '''
127 main() $NEW_BACKEND_COMMENT
128 {
129 return 1.5;
130 }
131
132 '''); 79 ''');
133 80
134 checkResult(''' 81 checkResult('''
135 main() { 82 main() {
136 return true; 83 return true;
137 } 84 }
138 ''', '''
139 main() $NEW_BACKEND_COMMENT
140 {
141 return true;
142 }
143
144 '''); 85 ''');
145 86
146 checkResult(''' 87 checkResult('''
147 main() { 88 main() {
148 return false; 89 return false;
149 } 90 }
150 ''', '''
151 main() $NEW_BACKEND_COMMENT
152 {
153 return false;
154 }
155
156 '''); 91 ''');
157 92
158 checkResult(''' 93 checkResult('''
159 main() { 94 main() {
160 return "a"; 95 return "a";
161 } 96 }
162 ''', '''
163 main() $NEW_BACKEND_COMMENT
164 {
165 return "a";
166 }
167
168 '''); 97 ''');
169 98
170 checkResult(''' 99 checkResult('''
171 main() { 100 main() {
172 return "a" "b"; 101 return "a" "b";
173 } 102 }
174 ''', ''' 103 ''', '''
175 main() $NEW_BACKEND_COMMENT 104 main() {
176 { 105 return "ab";
177 return "ab"; 106 }
178 }
179
180 '''); 107 ''');
181 }); 108 });
182 109
183 test('Parameters', () { 110 test('Parameters', () {
184 checkResult(''' 111 checkResult('''
185 main(args) { 112 main(args) {}
186 }
187 ''', '''
188 main(args) $NEW_BACKEND_COMMENT
189 {}
190
191 '''); 113 ''');
192 114
193 checkResult(''' 115 checkResult('''
194 main(a, b) { 116 main(a, b) {}
195 }
196 ''', '''
197 main(a, b) $NEW_BACKEND_COMMENT
198 {}
199
200 '''); 117 ''');
201 }); 118 });
202 119
203 test('Typed parameters', () { 120 test('Typed parameters', () {
204 checkResult(''' 121 checkResult('''
205 void main(args) { 122 void main(args) {}
206 }
207 ''', '''
208 void main(args) $NEW_BACKEND_COMMENT
209 {}
210
211 '''); 123 ''');
212 124
213 checkResult(''' 125 checkResult('''
214 main(int a, String b) { 126 main(int a, String b) {}
215 }
216 ''', '''
217 main(int a, String b) $NEW_BACKEND_COMMENT
218 {}
219
220 '''); 127 ''');
221 128
222 checkResult(''' 129 checkResult('''
223 main(Comparator a, List b) { 130 main(Comparator a, List b) {}
224 }
225 ''', '''
226 main(Comparator a, List b) $NEW_BACKEND_COMMENT
227 {}
228
229 '''); 131 ''');
230 132
231 checkResult(''' 133 checkResult('''
232 main(Comparator<dynamic> a, List<dynamic> b) { 134 main(Comparator<dynamic> a, List<dynamic> b) {}
233 }
234 ''', ''' 135 ''', '''
235 main(Comparator a, List b) $NEW_BACKEND_COMMENT 136 main(Comparator a, List b) {}
236 {}
237
238 '''); 137 ''');
239 138
240 checkResult(''' 139 checkResult('''
241 main(Map a, Map<dynamic, List<int>> b) { 140 main(Map a, Map<dynamic, List<int>> b) {}
242 }
243 ''', '''
244 main(Map a, Map<dynamic, List<int>> b) $NEW_BACKEND_COMMENT
245 {}
246
247 '''); 141 ''');
248 }); 142 });
249 143
250 test('Pass arguments', () { 144 test('Pass arguments', () {
251 checkResult(''' 145 checkResult('''
252 foo(a) {} 146 foo(a) {}
253 main() { 147 main() {
254 foo(null); 148 foo(null);
255 } 149 }
256 ''', '''
257 foo(a) $NEW_BACKEND_COMMENT
258 {}
259
260 main() $NEW_BACKEND_COMMENT
261 {
262 foo(null);
263 }
264
265 '''); 150 ''');
266 151
267 checkResult(''' 152 checkResult('''
268 bar(b, c) {} 153 bar(b, c) {}
269 foo(a) {} 154 foo(a) {}
270 main() { 155 main() {
271 foo(null); 156 foo(null);
272 bar(0, ""); 157 bar(0, "");
273 } 158 }
274 ''', '''
275 bar(b, c) $NEW_BACKEND_COMMENT
276 {}
277
278 foo(a) $NEW_BACKEND_COMMENT
279 {}
280
281 main() $NEW_BACKEND_COMMENT
282 {
283 foo(null);
284 bar(0, "");
285 }
286
287 '''); 159 ''');
288 160
289 checkResult(''' 161 checkResult('''
290 bar(b) {} 162 bar(b) {}
291 foo(a) { 163 foo(a) {
292 bar(a); 164 bar(a);
293 } 165 }
294 main() { 166 main() {
295 foo(null); 167 foo(null);
296 } 168 }
297 ''', '''
298 bar(b) $NEW_BACKEND_COMMENT
299 {}
300
301 foo(a) $NEW_BACKEND_COMMENT
302 {
303 bar(a);
304 }
305
306 main() $NEW_BACKEND_COMMENT
307 {
308 foo(null);
309 }
310
311 '''); 169 ''');
312 }); 170 });
313 171
314 test('Top level field access', () { 172 test('Top level field access', () {
315 checkResult(''' 173 checkResult('''
316 main(args) { 174 main(args) {
317 return deprecated; 175 return deprecated;
318 } 176 }
319 ''', '''
320 main(args) $NEW_BACKEND_COMMENT
321 {
322 return deprecated;
323 }
324
325 '''); 177 ''');
326 }); 178 });
327 } 179 }
328 180
329 checkResult(String input, String expectedOutput) { 181 checkResult(String input, [String expectedOutput]) {
182 if (expectedOutput == null) {
183 expectedOutput = input;
184 }
185
330 CollectingOutputProvider outputProvider = new CollectingOutputProvider(); 186 CollectingOutputProvider outputProvider = new CollectingOutputProvider();
331 MemoryResourceProvider provider = new MemoryResourceProvider(); 187 MemoryResourceProvider provider = new MemoryResourceProvider();
332 DartSdk sdk = new MockSdk(); 188 DartSdk sdk = new MockSdk();
333 Driver driver = new Driver(provider, sdk, outputProvider); 189 Driver driver = new Driver(provider, sdk, outputProvider);
334 String rootFile = '/root.dart'; 190 String rootFile = '/root.dart';
335 provider.newFile(rootFile, input); 191 provider.newFile(rootFile, input);
336 Source rootSource = driver.setRoot(rootFile); 192 Source rootSource = driver.setRoot(rootFile);
337 FunctionElement entryPoint = driver.resolveEntryPoint(rootSource); 193 FunctionElement entryPoint = driver.resolveEntryPoint(rootSource);
338 ClosedWorld world = driver.computeWorld(entryPoint); 194 ClosedWorld world = driver.computeWorld(entryPoint);
339 ConvertedWorld convertedWorld = convertWorld(world); 195 ConvertedWorld convertedWorld = convertWorld(world);
(...skipping 17 matching lines...) Expand all
357 sb.write(text); 213 sb.write(text);
358 } 214 }
359 215
360 void addError(errorEvent, [StackTrace stackTrace]) {} 216 void addError(errorEvent, [StackTrace stackTrace]) {}
361 217
362 void close() {} 218 void close() {}
363 219
364 String get text => sb.toString(); 220 String get text => sb.toString();
365 } 221 }
366 222
OLDNEW
« no previous file with comments | « no previous file | sdk/lib/_internal/compiler/implementation/dart_backend/backend_ast_to_frontend_ast.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698