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

Side by Side Diff: tests/compiler/dart2js/unparser_test.dart

Issue 2345083003: dart2js: run dartfmt on tests (Closed)
Patch Set: revert another multipart test Created 4 years, 3 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
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 import 'package:expect/expect.dart'; 5 import 'package:expect/expect.dart';
6 import 'parser_helper.dart'; 6 import 'parser_helper.dart';
7 import 'package:compiler/src/tree/tree.dart'; 7 import 'package:compiler/src/tree/tree.dart';
8 8
9 testUnparse(String statement) { 9 testUnparse(String statement) {
10 Node node = parseStatement(statement); 10 Node node = parseStatement(statement);
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 testImport() { 92 testImport() {
93 testUnparseTopLevelWithMetadata('import "søhest";'); 93 testUnparseTopLevelWithMetadata('import "søhest";');
94 testUnparseTopLevelWithMetadata('import "søhest" as fiskehest;'); 94 testUnparseTopLevelWithMetadata('import "søhest" as fiskehest;');
95 } 95 }
96 96
97 testExport() { 97 testExport() {
98 testUnparseTopLevelWithMetadata('export "søhest";'); 98 testUnparseTopLevelWithMetadata('export "søhest";');
99 } 99 }
100 100
101 testConditionalImport() { 101 testConditionalImport() {
102 testUnparseTopLevelWithMetadata( 102 testUnparseTopLevelWithMetadata('import "søhest" if(some.dotted.id)"other";');
103 'import "søhest" if(some.dotted.id)"other";'); 103 testUnparseTopLevelWithMetadata('import "søhest" if(id=="some str")"other";');
104 testUnparseTopLevelWithMetadata( 104 testUnparseTopLevelWithMetadata('import "søhest"'
105 'import "søhest" if(id=="some str")"other";');
106 testUnparseTopLevelWithMetadata(
107 'import "søhest"'
108 ' if(id=="some str")"other"' 105 ' if(id=="some str")"other"'
109 ' if(id)"other2";'); 106 ' if(id)"other2";');
110 testUnparseTopLevelWithMetadata( 107 testUnparseTopLevelWithMetadata(
111 'import "søhest" if(some.dotted.id)"other" as fiskehest;'); 108 'import "søhest" if(some.dotted.id)"other" as fiskehest;');
112 testUnparseTopLevelWithMetadata( 109 testUnparseTopLevelWithMetadata(
113 'import "søhest" if(id=="some str")"other" as fiskehest;'); 110 'import "søhest" if(id=="some str")"other" as fiskehest;');
114 testUnparseTopLevelWithMetadata( 111 testUnparseTopLevelWithMetadata('import "søhest"'
115 'import "søhest"'
116 ' if(id=="some str")"other"' 112 ' if(id=="some str")"other"'
117 ' if(id)"other2"' 113 ' if(id)"other2"'
118 ' as fiskehest;'); 114 ' as fiskehest;');
119 testUnparseTopLevelWithMetadata( 115 testUnparseTopLevelWithMetadata(
120 'import "søhest" if(some.dotted.id)"other" deferred as fiskehest;'); 116 'import "søhest" if(some.dotted.id)"other" deferred as fiskehest;');
121 testUnparseTopLevelWithMetadata( 117 testUnparseTopLevelWithMetadata(
122 'import "søhest" if(id=="some str")"other" deferred as fiskehest;'); 118 'import "søhest" if(id=="some str")"other" deferred as fiskehest;');
123 testUnparseTopLevelWithMetadata( 119 testUnparseTopLevelWithMetadata('import "søhest"'
124 'import "søhest"'
125 ' if(id=="some str")"other"' 120 ' if(id=="some str")"other"'
126 ' if(id)"other2"' 121 ' if(id)"other2"'
127 ' deferred as fiskehest;'); 122 ' deferred as fiskehest;');
128 testUnparseTopLevelWithMetadata( 123 testUnparseTopLevelWithMetadata('import "søhest"'
129 'import "søhest"'
130 ' if(id=="some str")"other"' 124 ' if(id=="some str")"other"'
131 ' if(id)"other2"' 125 ' if(id)"other2"'
132 ' deferred as fiskehest' 126 ' deferred as fiskehest'
133 ' show foo,bar;'); 127 ' show foo,bar;');
134 } 128 }
135 129
136 testConditionalExport() { 130 testConditionalExport() {
137 testUnparseTopLevelWithMetadata( 131 testUnparseTopLevelWithMetadata('export "søhest" if(some.dotted.id)"other";');
138 'export "søhest" if(some.dotted.id)"other";'); 132 testUnparseTopLevelWithMetadata('export "søhest" if(id=="some str")"other";');
139 testUnparseTopLevelWithMetadata( 133 testUnparseTopLevelWithMetadata('export "søhest"'
140 'export "søhest" if(id=="some str")"other";');
141 testUnparseTopLevelWithMetadata(
142 'export "søhest"'
143 ' if(id=="some str")"other"' 134 ' if(id=="some str")"other"'
144 ' if(id)"other2";'); 135 ' if(id)"other2";');
145 testUnparseTopLevelWithMetadata( 136 testUnparseTopLevelWithMetadata('export "søhest"'
146 'export "søhest"'
147 ' if(id=="some str")"other"' 137 ' if(id=="some str")"other"'
148 ' if(id)"other2"' 138 ' if(id)"other2"'
149 ' show foo,bar;'); 139 ' show foo,bar;');
150 } 140 }
151 141
152 testPart() { 142 testPart() {
153 testUnparseTopLevelWithMetadata('part "søhest";'); 143 testUnparseTopLevelWithMetadata('part "søhest";');
154 } 144 }
155 145
156 testPartOf() { 146 testPartOf() {
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 testUnparseMemberAndAsMemberOfFoo("factory Foo()=Bar.baz;"); 260 testUnparseMemberAndAsMemberOfFoo("factory Foo()=Bar.baz;");
271 testUnparseMemberAndAsMemberOfFoo("factory Foo()=Bar<T>;"); 261 testUnparseMemberAndAsMemberOfFoo("factory Foo()=Bar<T>;");
272 testUnparseMemberAndAsMemberOfFoo("factory Foo()=Bar<List<T>,T>;"); 262 testUnparseMemberAndAsMemberOfFoo("factory Foo()=Bar<List<T>,T>;");
273 testUnparseMemberAndAsMemberOfFoo("factory Foo()=Bar<T>.baz;"); 263 testUnparseMemberAndAsMemberOfFoo("factory Foo()=Bar<T>.baz;");
274 testUnparseMemberAndAsMemberOfFoo("factory Foo()=Bar<List<T>,T>.baz;"); 264 testUnparseMemberAndAsMemberOfFoo("factory Foo()=Bar<List<T>,T>.baz;");
275 testUnparseMemberAndAsMemberOfFoo("factory Foo()=prefix.Bar;"); 265 testUnparseMemberAndAsMemberOfFoo("factory Foo()=prefix.Bar;");
276 testUnparseMemberAndAsMemberOfFoo("factory Foo()=prefix.Bar.baz;"); 266 testUnparseMemberAndAsMemberOfFoo("factory Foo()=prefix.Bar.baz;");
277 testUnparseMemberAndAsMemberOfFoo("factory Foo()=prefix.Bar<T>;"); 267 testUnparseMemberAndAsMemberOfFoo("factory Foo()=prefix.Bar<T>;");
278 testUnparseMemberAndAsMemberOfFoo("factory Foo()=prefix.Bar<List<T>,T>;"); 268 testUnparseMemberAndAsMemberOfFoo("factory Foo()=prefix.Bar<List<T>,T>;");
279 testUnparseMemberAndAsMemberOfFoo("factory Foo()=prefix.Bar<T>.baz;"); 269 testUnparseMemberAndAsMemberOfFoo("factory Foo()=prefix.Bar<T>.baz;");
280 testUnparseMemberAndAsMemberOfFoo( 270 testUnparseMemberAndAsMemberOfFoo("factory Foo()=prefix.Bar<List<T>,T>.baz;");
281 "factory Foo()=prefix.Bar<List<T>,T>.baz;");
282 testUnparseMemberAndAsMemberOfFoo("const factory Foo()=Bar;"); 271 testUnparseMemberAndAsMemberOfFoo("const factory Foo()=Bar;");
283 testUnparseMemberAndAsMemberOfFoo("const factory Foo()=Bar.baz;"); 272 testUnparseMemberAndAsMemberOfFoo("const factory Foo()=Bar.baz;");
284 testUnparseMemberAndAsMemberOfFoo("const factory Foo()=Bar<T>;"); 273 testUnparseMemberAndAsMemberOfFoo("const factory Foo()=Bar<T>;");
285 testUnparseMemberAndAsMemberOfFoo("const factory Foo()=Bar<List<T>,T>;"); 274 testUnparseMemberAndAsMemberOfFoo("const factory Foo()=Bar<List<T>,T>;");
286 testUnparseMemberAndAsMemberOfFoo("const factory Foo()=Bar<T>.baz;"); 275 testUnparseMemberAndAsMemberOfFoo("const factory Foo()=Bar<T>.baz;");
287 testUnparseMemberAndAsMemberOfFoo( 276 testUnparseMemberAndAsMemberOfFoo("const factory Foo()=Bar<List<T>,T>.baz;");
288 "const factory Foo()=Bar<List<T>,T>.baz;");
289 testUnparseMemberAndAsMemberOfFoo("const factory Foo()=prefix.Bar;"); 277 testUnparseMemberAndAsMemberOfFoo("const factory Foo()=prefix.Bar;");
290 testUnparseMemberAndAsMemberOfFoo("const factory Foo()=prefix.Bar.baz;"); 278 testUnparseMemberAndAsMemberOfFoo("const factory Foo()=prefix.Bar.baz;");
291 testUnparseMemberAndAsMemberOfFoo("const factory Foo()=prefix.Bar<T>;"); 279 testUnparseMemberAndAsMemberOfFoo("const factory Foo()=prefix.Bar<T>;");
292 testUnparseMemberAndAsMemberOfFoo( 280 testUnparseMemberAndAsMemberOfFoo(
293 "const factory Foo()=prefix.Bar<List<T>,T>;"); 281 "const factory Foo()=prefix.Bar<List<T>,T>;");
294 testUnparseMemberAndAsMemberOfFoo("const factory Foo()=prefix.Bar<T>.baz;"); 282 testUnparseMemberAndAsMemberOfFoo("const factory Foo()=prefix.Bar<T>.baz;");
295 testUnparseMemberAndAsMemberOfFoo( 283 testUnparseMemberAndAsMemberOfFoo(
296 "const factory Foo()=prefix.Bar<List<T>,T>.baz;"); 284 "const factory Foo()=prefix.Bar<List<T>,T>.baz;");
297 testUnparseMemberAndAsMemberOfFoo("external factory Foo()=Bar;"); 285 testUnparseMemberAndAsMemberOfFoo("external factory Foo()=Bar;");
298 testUnparseMemberAndAsMemberOfFoo("external factory Foo()=Bar.baz;"); 286 testUnparseMemberAndAsMemberOfFoo("external factory Foo()=Bar.baz;");
299 testUnparseMemberAndAsMemberOfFoo("external factory Foo()=Bar<T>;"); 287 testUnparseMemberAndAsMemberOfFoo("external factory Foo()=Bar<T>;");
300 testUnparseMemberAndAsMemberOfFoo("external factory Foo()=Bar<List<T>,T>;"); 288 testUnparseMemberAndAsMemberOfFoo("external factory Foo()=Bar<List<T>,T>;");
301 testUnparseMemberAndAsMemberOfFoo("external factory Foo()=Bar<T>.baz;"); 289 testUnparseMemberAndAsMemberOfFoo("external factory Foo()=Bar<T>.baz;");
302 testUnparseMemberAndAsMemberOfFoo( 290 testUnparseMemberAndAsMemberOfFoo(
303 "external factory Foo()=Bar<List<T>,T>.baz;"); 291 "external factory Foo()=Bar<List<T>,T>.baz;");
304 testUnparseMemberAndAsMemberOfFoo("external factory Foo()=prefix.Bar;"); 292 testUnparseMemberAndAsMemberOfFoo("external factory Foo()=prefix.Bar;");
305 testUnparseMemberAndAsMemberOfFoo("external factory Foo()=prefix.Bar.baz;"); 293 testUnparseMemberAndAsMemberOfFoo("external factory Foo()=prefix.Bar.baz;");
306 testUnparseMemberAndAsMemberOfFoo("external factory Foo()=prefix.Bar<T>;"); 294 testUnparseMemberAndAsMemberOfFoo("external factory Foo()=prefix.Bar<T>;");
307 testUnparseMemberAndAsMemberOfFoo( 295 testUnparseMemberAndAsMemberOfFoo(
308 "external factory Foo()=prefix.Bar<List<T>,T>;"); 296 "external factory Foo()=prefix.Bar<List<T>,T>;");
309 testUnparseMemberAndAsMemberOfFoo( 297 testUnparseMemberAndAsMemberOfFoo(
310 "external factory Foo()=prefix.Bar<T>.baz;"); 298 "external factory Foo()=prefix.Bar<T>.baz;");
311 testUnparseMemberAndAsMemberOfFoo( 299 testUnparseMemberAndAsMemberOfFoo(
312 "external factory Foo()=prefix.Bar<List<T>,T>.baz;"); 300 "external factory Foo()=prefix.Bar<List<T>,T>.baz;");
313 testUnparseMemberAndAsMemberOfFoo("external const factory Foo()=Bar;"); 301 testUnparseMemberAndAsMemberOfFoo("external const factory Foo()=Bar;");
314 testUnparseMemberAndAsMemberOfFoo("external const factory Foo()=Bar.baz;"); 302 testUnparseMemberAndAsMemberOfFoo("external const factory Foo()=Bar.baz;");
315 testUnparseMemberAndAsMemberOfFoo("external const factory Foo()=Bar<T>;"); 303 testUnparseMemberAndAsMemberOfFoo("external const factory Foo()=Bar<T>;");
316 testUnparseMemberAndAsMemberOfFoo( 304 testUnparseMemberAndAsMemberOfFoo(
317 "external const factory Foo()=Bar<List<T>,T>;"); 305 "external const factory Foo()=Bar<List<T>,T>;");
318 testUnparseMemberAndAsMemberOfFoo( 306 testUnparseMemberAndAsMemberOfFoo("external const factory Foo()=Bar<T>.baz;");
319 "external const factory Foo()=Bar<T>.baz;");
320 testUnparseMemberAndAsMemberOfFoo( 307 testUnparseMemberAndAsMemberOfFoo(
321 "external const factory Foo()=Bar<List<T>,T>.baz;"); 308 "external const factory Foo()=Bar<List<T>,T>.baz;");
322 testUnparseMemberAndAsMemberOfFoo( 309 testUnparseMemberAndAsMemberOfFoo("external const factory Foo()=prefix.Bar;");
323 "external const factory Foo()=prefix.Bar;");
324 testUnparseMemberAndAsMemberOfFoo( 310 testUnparseMemberAndAsMemberOfFoo(
325 "external const factory Foo()=prefix.Bar.baz;"); 311 "external const factory Foo()=prefix.Bar.baz;");
326 testUnparseMemberAndAsMemberOfFoo( 312 testUnparseMemberAndAsMemberOfFoo(
327 "external const factory Foo()=prefix.Bar<T>;"); 313 "external const factory Foo()=prefix.Bar<T>;");
328 testUnparseMemberAndAsMemberOfFoo( 314 testUnparseMemberAndAsMemberOfFoo(
329 "external const factory Foo()=prefix.Bar<List<T>,T>;"); 315 "external const factory Foo()=prefix.Bar<List<T>,T>;");
330 testUnparseMemberAndAsMemberOfFoo( 316 testUnparseMemberAndAsMemberOfFoo(
331 "external const factory Foo()=prefix.Bar<T>.baz;"); 317 "external const factory Foo()=prefix.Bar<T>.baz;");
332 testUnparseMemberAndAsMemberOfFoo( 318 testUnparseMemberAndAsMemberOfFoo(
333 "external const factory Foo()=prefix.Bar<List<T>,T>.baz;"); 319 "external const factory Foo()=prefix.Bar<List<T>,T>.baz;");
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 index++; 357 index++;
372 } 358 }
373 sb.write(');'); 359 sb.write(');');
374 360
375 FunctionExpression node = parseMember(sb.toString()); 361 FunctionExpression node = parseMember(sb.toString());
376 index = 0; 362 index = 0;
377 for (VariableDefinitions parameter in node.parameters.nodes) { 363 for (VariableDefinitions parameter in node.parameters.nodes) {
378 Expect.equals(variableDeclarations[index], unparse(parameter)); 364 Expect.equals(variableDeclarations[index], unparse(parameter));
379 index++; 365 index++;
380 } 366 }
381
382 } 367 }
383 368
384 testParameters() { 369 testParameters() {
385 testUnparseParameters( 370 testUnparseParameters(["foo", "bar=0", "int baz", "int boz=0"]);
386 ["foo", "bar=0", "int baz", "int boz=0"]);
387 testUnparseParameters( 371 testUnparseParameters(
388 ["this.foo", "this.bar=0", "int this.baz", "int this.boz=0"]); 372 ["this.foo", "this.bar=0", "int this.baz", "int this.boz=0"]);
389 testUnparseParameters( 373 testUnparseParameters(
390 ["foo()", "void bar()", "int baz(a)", "int boz(int a,int b)=null"]); 374 ["foo()", "void bar()", "int baz(a)", "int boz(int a,int b)=null"]);
391 testUnparseParameters( 375 testUnparseParameters([
392 ["this.foo()", 376 "this.foo()",
393 //"void this.bar()", // Commented out due to Issue 7852 377 //"void this.bar()", // Commented out due to Issue 7852
394 //"int this.baz(a)", // Commented out due to Issue 7852 378 //"int this.baz(a)", // Commented out due to Issue 7852
395 //"int this.boz(int a,int b)=null" // Commented out due to Issue 7852 379 //"int this.boz(int a,int b)=null" // Commented out due to Issue 7852
396 ]); 380 ]);
397 testUnparseParameters( 381 testUnparseParameters(
398 ["@a foo", "@b @c bar=0", "@D(0) int baz", "@E([f],{g:h}) int boz=0"]); 382 ["@a foo", "@b @c bar=0", "@D(0) int baz", "@E([f],{g:h}) int boz=0"]);
399 } 383 }
400 384
401 testSymbolLiterals() { 385 testSymbolLiterals() {
402 testUnparse("#+;"); 386 testUnparse("#+;");
403 testUnparse("#-;"); 387 testUnparse("#-;");
404 testUnparse("#*;"); 388 testUnparse("#*;");
405 testUnparse("#/;"); 389 testUnparse("#/;");
406 testUnparse("#~/;"); 390 testUnparse("#~/;");
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 testPart(); 423 testPart();
440 testPartOf(); 424 testPartOf();
441 testCombinators(); 425 testCombinators();
442 testDeferredImport(); 426 testDeferredImport();
443 testRedirectingFactoryConstructors(); 427 testRedirectingFactoryConstructors();
444 testClassDeclarations(); 428 testClassDeclarations();
445 testMixinApplications(); 429 testMixinApplications();
446 testParameters(); 430 testParameters();
447 testSymbolLiterals(); 431 testSymbolLiterals();
448 } 432 }
OLDNEW
« no previous file with comments | « tests/compiler/dart2js/unparser2_test.dart ('k') | tests/compiler/dart2js/unused_empty_map_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698