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

Side by Side Diff: pkg/analyzer/test/generated/ast_test.dart

Issue 1269393002: Fix ToStringVisitor to handle external functions (issue 23968) (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 4 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) 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 // This code was auto-generated, is not intended to be edited, and is subject to 5 // This code was auto-generated, is not intended to be edited, and is subject to
6 // significant change. Please see the README file for more information. 6 // significant change. Please see the README file for more information.
7 7
8 library engine.ast_test; 8 library engine.ast_test;
9 9
10 import 'package:analyzer/src/generated/ast.dart'; 10 import 'package:analyzer/src/generated/ast.dart';
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 visitor.visitAllNodes(unit); 125 visitor.visitAllNodes(unit);
126 expect(nodes, hasLength(59)); 126 expect(nodes, hasLength(59));
127 EngineTestCase.assertInstanceOf( 127 EngineTestCase.assertInstanceOf(
128 (obj) => obj is CompilationUnit, CompilationUnit, nodes[0]); 128 (obj) => obj is CompilationUnit, CompilationUnit, nodes[0]);
129 EngineTestCase.assertInstanceOf( 129 EngineTestCase.assertInstanceOf(
130 (obj) => obj is ClassDeclaration, ClassDeclaration, nodes[2]); 130 (obj) => obj is ClassDeclaration, ClassDeclaration, nodes[2]);
131 EngineTestCase.assertInstanceOf( 131 EngineTestCase.assertInstanceOf(
132 (obj) => obj is FunctionDeclaration, FunctionDeclaration, nodes[3]); 132 (obj) => obj is FunctionDeclaration, FunctionDeclaration, nodes[3]);
133 EngineTestCase.assertInstanceOf( 133 EngineTestCase.assertInstanceOf(
134 (obj) => obj is FunctionDeclarationStatement, 134 (obj) => obj is FunctionDeclarationStatement,
135 FunctionDeclarationStatement, nodes[27]); 135 FunctionDeclarationStatement,
136 nodes[27]);
136 EngineTestCase.assertInstanceOf( 137 EngineTestCase.assertInstanceOf(
137 (obj) => obj is IntegerLiteral, IntegerLiteral, nodes[58]); 138 (obj) => obj is IntegerLiteral, IntegerLiteral, nodes[58]);
138 //3 139 //3
139 } 140 }
140 } 141 }
141 142
142 @reflectiveTest 143 @reflectiveTest
143 class ClassDeclarationTest extends ParserTestCase { 144 class ClassDeclarationTest extends ParserTestCase {
144 void test_getConstructor() { 145 void test_getConstructor() {
145 List<ConstructorInitializer> initializers = 146 List<ConstructorInitializer> initializers =
146 new List<ConstructorInitializer>(); 147 new List<ConstructorInitializer>();
147 ConstructorDeclaration defaultConstructor = AstFactory 148 ConstructorDeclaration defaultConstructor = AstFactory
148 .constructorDeclaration(AstFactory.identifier3("Test"), null, 149 .constructorDeclaration(AstFactory.identifier3("Test"), null,
149 AstFactory.formalParameterList(), initializers); 150 AstFactory.formalParameterList(), initializers);
150 ConstructorDeclaration aConstructor = AstFactory.constructorDeclaration( 151 ConstructorDeclaration aConstructor = AstFactory.constructorDeclaration(
151 AstFactory.identifier3("Test"), "a", AstFactory.formalParameterList(), 152 AstFactory.identifier3("Test"),
153 "a",
154 AstFactory.formalParameterList(),
152 initializers); 155 initializers);
153 ConstructorDeclaration bConstructor = AstFactory.constructorDeclaration( 156 ConstructorDeclaration bConstructor = AstFactory.constructorDeclaration(
154 AstFactory.identifier3("Test"), "b", AstFactory.formalParameterList(), 157 AstFactory.identifier3("Test"),
158 "b",
159 AstFactory.formalParameterList(),
155 initializers); 160 initializers);
156 ClassDeclaration clazz = AstFactory.classDeclaration(null, "Test", null, 161 ClassDeclaration clazz = AstFactory.classDeclaration(null, "Test", null,
157 null, null, null, [defaultConstructor, aConstructor, bConstructor]); 162 null, null, null, [defaultConstructor, aConstructor, bConstructor]);
158 expect(clazz.getConstructor(null), same(defaultConstructor)); 163 expect(clazz.getConstructor(null), same(defaultConstructor));
159 expect(clazz.getConstructor("a"), same(aConstructor)); 164 expect(clazz.getConstructor("a"), same(aConstructor));
160 expect(clazz.getConstructor("b"), same(bConstructor)); 165 expect(clazz.getConstructor("b"), same(bConstructor));
161 expect(clazz.getConstructor("noSuchConstructor"), same(null)); 166 expect(clazz.getConstructor("noSuchConstructor"), same(null));
162 } 167 }
163 168
164 void test_getField() { 169 void test_getField() {
165 VariableDeclaration aVar = AstFactory.variableDeclaration("a"); 170 VariableDeclaration aVar = AstFactory.variableDeclaration("a");
166 VariableDeclaration bVar = AstFactory.variableDeclaration("b"); 171 VariableDeclaration bVar = AstFactory.variableDeclaration("b");
167 VariableDeclaration cVar = AstFactory.variableDeclaration("c"); 172 VariableDeclaration cVar = AstFactory.variableDeclaration("c");
168 ClassDeclaration clazz = AstFactory.classDeclaration(null, "Test", null, 173 ClassDeclaration clazz =
169 null, null, null, [ 174 AstFactory.classDeclaration(null, "Test", null, null, null, null, [
170 AstFactory.fieldDeclaration2(false, null, [aVar]), 175 AstFactory.fieldDeclaration2(false, null, [aVar]),
171 AstFactory.fieldDeclaration2(false, null, [bVar, cVar]) 176 AstFactory.fieldDeclaration2(false, null, [bVar, cVar])
172 ]); 177 ]);
173 expect(clazz.getField("a"), same(aVar)); 178 expect(clazz.getField("a"), same(aVar));
174 expect(clazz.getField("b"), same(bVar)); 179 expect(clazz.getField("b"), same(bVar));
175 expect(clazz.getField("c"), same(cVar)); 180 expect(clazz.getField("c"), same(cVar));
176 expect(clazz.getField("noSuchField"), same(null)); 181 expect(clazz.getField("noSuchField"), same(null));
177 } 182 }
178 183
179 void test_getMethod() { 184 void test_getMethod() {
180 MethodDeclaration aMethod = AstFactory.methodDeclaration(null, null, null, 185 MethodDeclaration aMethod = AstFactory.methodDeclaration(null, null, null,
181 null, AstFactory.identifier3("a"), AstFactory.formalParameterList()); 186 null, AstFactory.identifier3("a"), AstFactory.formalParameterList());
182 MethodDeclaration bMethod = AstFactory.methodDeclaration(null, null, null, 187 MethodDeclaration bMethod = AstFactory.methodDeclaration(null, null, null,
183 null, AstFactory.identifier3("b"), AstFactory.formalParameterList()); 188 null, AstFactory.identifier3("b"), AstFactory.formalParameterList());
184 ClassDeclaration clazz = AstFactory.classDeclaration( 189 ClassDeclaration clazz = AstFactory.classDeclaration(
185 null, "Test", null, null, null, null, [aMethod, bMethod]); 190 null, "Test", null, null, null, null, [aMethod, bMethod]);
186 expect(clazz.getMethod("a"), same(aMethod)); 191 expect(clazz.getMethod("a"), same(aMethod));
187 expect(clazz.getMethod("b"), same(bMethod)); 192 expect(clazz.getMethod("b"), same(bMethod));
188 expect(clazz.getMethod("noSuchMethod"), same(null)); 193 expect(clazz.getMethod("noSuchMethod"), same(null));
189 } 194 }
190 195
191 void test_isAbstract() { 196 void test_isAbstract() {
192 expect(AstFactory.classDeclaration( 197 expect(
193 null, "A", null, null, null, null).isAbstract, isFalse); 198 AstFactory
194 expect(AstFactory.classDeclaration( 199 .classDeclaration(null, "A", null, null, null, null)
195 Keyword.ABSTRACT, "B", null, null, null, null).isAbstract, isTrue); 200 .isAbstract,
201 isFalse);
202 expect(
203 AstFactory
204 .classDeclaration(Keyword.ABSTRACT, "B", null, null, null, null)
205 .isAbstract,
206 isTrue);
196 } 207 }
197 } 208 }
198 209
199 @reflectiveTest 210 @reflectiveTest
200 class ClassTypeAliasTest extends ParserTestCase { 211 class ClassTypeAliasTest extends ParserTestCase {
201 void test_isAbstract() { 212 void test_isAbstract() {
202 expect( 213 expect(
203 AstFactory.classTypeAlias("A", null, null, null, null, null).isAbstract, 214 AstFactory.classTypeAlias("A", null, null, null, null, null).isAbstract,
204 isFalse); 215 isFalse);
205 expect(AstFactory.classTypeAlias( 216 expect(
206 "B", null, Keyword.ABSTRACT, null, null, null).isAbstract, isTrue); 217 AstFactory
218 .classTypeAlias("B", null, Keyword.ABSTRACT, null, null, null)
219 .isAbstract,
220 isTrue);
207 } 221 }
208 } 222 }
209 223
210 @reflectiveTest 224 @reflectiveTest
211 class ConstantEvaluatorTest extends ParserTestCase { 225 class ConstantEvaluatorTest extends ParserTestCase {
212 void fail_constructor() { 226 void fail_constructor() {
213 Object value = _getConstantValue("?"); 227 Object value = _getConstantValue("?");
214 expect(value, null); 228 expect(value, null);
215 } 229 }
216 230
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
510 Object _getConstantValue(String source) => 524 Object _getConstantValue(String source) =>
511 parseExpression(source).accept(new ConstantEvaluator()); 525 parseExpression(source).accept(new ConstantEvaluator());
512 } 526 }
513 527
514 @reflectiveTest 528 @reflectiveTest
515 class ConstructorDeclarationTest extends EngineTestCase { 529 class ConstructorDeclarationTest extends EngineTestCase {
516 void test_firstTokenAfterCommentAndMetadata_all_inverted() { 530 void test_firstTokenAfterCommentAndMetadata_all_inverted() {
517 Token externalKeyword = TokenFactory.tokenFromKeyword(Keyword.EXTERNAL); 531 Token externalKeyword = TokenFactory.tokenFromKeyword(Keyword.EXTERNAL);
518 externalKeyword.offset = 14; 532 externalKeyword.offset = 14;
519 ConstructorDeclaration declaration = AstFactory.constructorDeclaration2( 533 ConstructorDeclaration declaration = AstFactory.constructorDeclaration2(
520 Keyword.CONST, Keyword.FACTORY, AstFactory.identifier3('int'), null, 534 Keyword.CONST,
521 null, null, null); 535 Keyword.FACTORY,
536 AstFactory.identifier3('int'),
537 null,
538 null,
539 null,
540 null);
522 declaration.externalKeyword = externalKeyword; 541 declaration.externalKeyword = externalKeyword;
523 declaration.constKeyword.offset = 8; 542 declaration.constKeyword.offset = 8;
524 Token factoryKeyword = declaration.factoryKeyword; 543 Token factoryKeyword = declaration.factoryKeyword;
525 factoryKeyword.offset = 0; 544 factoryKeyword.offset = 0;
526 expect(declaration.firstTokenAfterCommentAndMetadata, factoryKeyword); 545 expect(declaration.firstTokenAfterCommentAndMetadata, factoryKeyword);
527 } 546 }
528 547
529 void test_firstTokenAfterCommentAndMetadata_all_normal() { 548 void test_firstTokenAfterCommentAndMetadata_all_normal() {
530 Token token = TokenFactory.tokenFromKeyword(Keyword.EXTERNAL); 549 Token token = TokenFactory.tokenFromKeyword(Keyword.EXTERNAL);
531 token.offset = 0; 550 token.offset = 0;
532 ConstructorDeclaration declaration = AstFactory.constructorDeclaration2( 551 ConstructorDeclaration declaration = AstFactory.constructorDeclaration2(
533 Keyword.CONST, Keyword.FACTORY, AstFactory.identifier3('int'), null, 552 Keyword.CONST,
534 null, null, null); 553 Keyword.FACTORY,
554 AstFactory.identifier3('int'),
555 null,
556 null,
557 null,
558 null);
535 declaration.externalKeyword = token; 559 declaration.externalKeyword = token;
536 declaration.constKeyword.offset = 9; 560 declaration.constKeyword.offset = 9;
537 declaration.factoryKeyword.offset = 15; 561 declaration.factoryKeyword.offset = 15;
538 expect(declaration.firstTokenAfterCommentAndMetadata, token); 562 expect(declaration.firstTokenAfterCommentAndMetadata, token);
539 } 563 }
540 564
541 void test_firstTokenAfterCommentAndMetadata_constOnly() { 565 void test_firstTokenAfterCommentAndMetadata_constOnly() {
542 ConstructorDeclaration declaration = AstFactory.constructorDeclaration2( 566 ConstructorDeclaration declaration = AstFactory.constructorDeclaration2(
543 Keyword.CONST, null, AstFactory.identifier3('int'), null, null, null, 567 Keyword.CONST,
568 null,
569 AstFactory.identifier3('int'),
570 null,
571 null,
572 null,
544 null); 573 null);
545 expect(declaration.firstTokenAfterCommentAndMetadata, 574 expect(declaration.firstTokenAfterCommentAndMetadata,
546 declaration.constKeyword); 575 declaration.constKeyword);
547 } 576 }
548 577
549 void test_firstTokenAfterCommentAndMetadata_externalOnly() { 578 void test_firstTokenAfterCommentAndMetadata_externalOnly() {
550 Token externalKeyword = TokenFactory.tokenFromKeyword(Keyword.EXTERNAL); 579 Token externalKeyword = TokenFactory.tokenFromKeyword(Keyword.EXTERNAL);
551 ConstructorDeclaration declaration = AstFactory.constructorDeclaration2( 580 ConstructorDeclaration declaration = AstFactory.constructorDeclaration2(
552 null, null, AstFactory.identifier3('int'), null, null, null, null); 581 null, null, AstFactory.identifier3('int'), null, null, null, null);
553 declaration.externalKeyword = externalKeyword; 582 declaration.externalKeyword = externalKeyword;
554 expect(declaration.firstTokenAfterCommentAndMetadata, externalKeyword); 583 expect(declaration.firstTokenAfterCommentAndMetadata, externalKeyword);
555 } 584 }
556 585
557 void test_firstTokenAfterCommentAndMetadata_factoryOnly() { 586 void test_firstTokenAfterCommentAndMetadata_factoryOnly() {
558 ConstructorDeclaration declaration = AstFactory.constructorDeclaration2( 587 ConstructorDeclaration declaration = AstFactory.constructorDeclaration2(
559 null, Keyword.FACTORY, AstFactory.identifier3('int'), null, null, null, 588 null,
589 Keyword.FACTORY,
590 AstFactory.identifier3('int'),
591 null,
592 null,
593 null,
560 null); 594 null);
561 expect(declaration.firstTokenAfterCommentAndMetadata, 595 expect(declaration.firstTokenAfterCommentAndMetadata,
562 declaration.factoryKeyword); 596 declaration.factoryKeyword);
563 } 597 }
564 } 598 }
565 599
566 @reflectiveTest 600 @reflectiveTest
567 class FieldFormalParameterTest extends EngineTestCase { 601 class FieldFormalParameterTest extends EngineTestCase {
568 void test_endToken_noParameters() { 602 void test_endToken_noParameters() {
569 FieldFormalParameter parameter = AstFactory.fieldFormalParameter2('field'); 603 FieldFormalParameter parameter = AstFactory.fieldFormalParameter2('field');
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after
984 expect(identifier.inDeclarationContext(), isTrue); 1018 expect(identifier.inDeclarationContext(), isTrue);
985 } 1019 }
986 1020
987 void test_inDeclarationContext_classTypeAlias() { 1021 void test_inDeclarationContext_classTypeAlias() {
988 SimpleIdentifier identifier = 1022 SimpleIdentifier identifier =
989 AstFactory.classTypeAlias("C", null, null, null, null, null).name; 1023 AstFactory.classTypeAlias("C", null, null, null, null, null).name;
990 expect(identifier.inDeclarationContext(), isTrue); 1024 expect(identifier.inDeclarationContext(), isTrue);
991 } 1025 }
992 1026
993 void test_inDeclarationContext_constructorDeclaration() { 1027 void test_inDeclarationContext_constructorDeclaration() {
994 SimpleIdentifier identifier = AstFactory.constructorDeclaration( 1028 SimpleIdentifier identifier = AstFactory
995 AstFactory.identifier3("C"), "c", null, null).name; 1029 .constructorDeclaration(AstFactory.identifier3("C"), "c", null, null)
1030 .name;
996 expect(identifier.inDeclarationContext(), isTrue); 1031 expect(identifier.inDeclarationContext(), isTrue);
997 } 1032 }
998 1033
999 void test_inDeclarationContext_declaredIdentifier() { 1034 void test_inDeclarationContext_declaredIdentifier() {
1000 DeclaredIdentifier declaredIdentifier = AstFactory.declaredIdentifier3("v"); 1035 DeclaredIdentifier declaredIdentifier = AstFactory.declaredIdentifier3("v");
1001 SimpleIdentifier identifier = declaredIdentifier.identifier; 1036 SimpleIdentifier identifier = declaredIdentifier.identifier;
1002 expect(identifier.inDeclarationContext(), isTrue); 1037 expect(identifier.inDeclarationContext(), isTrue);
1003 } 1038 }
1004 1039
1005 void test_inDeclarationContext_enumConstantDeclaration() { 1040 void test_inDeclarationContext_enumConstantDeclaration() {
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
1151 1186
1152 void test_isQualified_inMethodInvocation_noTarget() { 1187 void test_isQualified_inMethodInvocation_noTarget() {
1153 MethodInvocation invocation = 1188 MethodInvocation invocation =
1154 AstFactory.methodInvocation2("test", [AstFactory.identifier3("arg0")]); 1189 AstFactory.methodInvocation2("test", [AstFactory.identifier3("arg0")]);
1155 SimpleIdentifier identifier = invocation.methodName; 1190 SimpleIdentifier identifier = invocation.methodName;
1156 expect(identifier.isQualified, isFalse); 1191 expect(identifier.isQualified, isFalse);
1157 } 1192 }
1158 1193
1159 void test_isQualified_inMethodInvocation_withTarget() { 1194 void test_isQualified_inMethodInvocation_withTarget() {
1160 MethodInvocation invocation = AstFactory.methodInvocation( 1195 MethodInvocation invocation = AstFactory.methodInvocation(
1161 AstFactory.identifier3("target"), "test", 1196 AstFactory.identifier3("target"),
1197 "test",
1162 [AstFactory.identifier3("arg0")]); 1198 [AstFactory.identifier3("arg0")]);
1163 SimpleIdentifier identifier = invocation.methodName; 1199 SimpleIdentifier identifier = invocation.methodName;
1164 expect(identifier.isQualified, isTrue); 1200 expect(identifier.isQualified, isTrue);
1165 } 1201 }
1166 1202
1167 void test_isQualified_inPrefixedIdentifier_name() { 1203 void test_isQualified_inPrefixedIdentifier_name() {
1168 SimpleIdentifier identifier = AstFactory.identifier3("test"); 1204 SimpleIdentifier identifier = AstFactory.identifier3("test");
1169 AstFactory.identifier4("prefix", identifier); 1205 AstFactory.identifier4("prefix", identifier);
1170 expect(identifier.isQualified, isTrue); 1206 expect(identifier.isQualified, isTrue);
1171 } 1207 }
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
1256 child = parent; 1292 child = parent;
1257 parent = parent.parent; 1293 parent = parent.parent;
1258 } 1294 }
1259 return child; 1295 return child;
1260 } 1296 }
1261 } 1297 }
1262 1298
1263 @reflectiveTest 1299 @reflectiveTest
1264 class SimpleStringLiteralTest extends ParserTestCase { 1300 class SimpleStringLiteralTest extends ParserTestCase {
1265 void test_contentsEnd() { 1301 void test_contentsEnd() {
1266 expect(new SimpleStringLiteral( 1302 expect(
1267 TokenFactory.tokenFromString("'X'"), "X").contentsEnd, 2); 1303 new SimpleStringLiteral(TokenFactory.tokenFromString("'X'"), "X")
1268 expect(new SimpleStringLiteral( 1304 .contentsEnd,
1269 TokenFactory.tokenFromString('"X"'), "X").contentsEnd, 2); 1305 2);
1306 expect(
1307 new SimpleStringLiteral(TokenFactory.tokenFromString('"X"'), "X")
1308 .contentsEnd,
1309 2);
1270 1310
1271 expect(new SimpleStringLiteral( 1311 expect(
1272 TokenFactory.tokenFromString('"""X"""'), "X").contentsEnd, 4); 1312 new SimpleStringLiteral(TokenFactory.tokenFromString('"""X"""'), "X")
1273 expect(new SimpleStringLiteral( 1313 .contentsEnd,
1274 TokenFactory.tokenFromString("'''X'''"), "X").contentsEnd, 4); 1314 4);
1275 expect(new SimpleStringLiteral( 1315 expect(
1276 TokenFactory.tokenFromString("''' \nX'''"), "X").contentsEnd, 7); 1316 new SimpleStringLiteral(TokenFactory.tokenFromString("'''X'''"), "X")
1317 .contentsEnd,
1318 4);
1319 expect(
1320 new SimpleStringLiteral(
1321 TokenFactory.tokenFromString("''' \nX'''"), "X").contentsEnd,
1322 7);
1277 1323
1278 expect(new SimpleStringLiteral( 1324 expect(
1279 TokenFactory.tokenFromString("r'X'"), "X").contentsEnd, 3); 1325 new SimpleStringLiteral(TokenFactory.tokenFromString("r'X'"), "X")
1280 expect(new SimpleStringLiteral( 1326 .contentsEnd,
1281 TokenFactory.tokenFromString('r"X"'), "X").contentsEnd, 3); 1327 3);
1328 expect(
1329 new SimpleStringLiteral(TokenFactory.tokenFromString('r"X"'), "X")
1330 .contentsEnd,
1331 3);
1282 1332
1283 expect(new SimpleStringLiteral( 1333 expect(
1284 TokenFactory.tokenFromString('r"""X"""'), "X").contentsEnd, 5); 1334 new SimpleStringLiteral(TokenFactory.tokenFromString('r"""X"""'), "X")
1285 expect(new SimpleStringLiteral( 1335 .contentsEnd,
1286 TokenFactory.tokenFromString("r'''X'''"), "X").contentsEnd, 5); 1336 5);
1287 expect(new SimpleStringLiteral( 1337 expect(
1288 TokenFactory.tokenFromString("r''' \nX'''"), "X").contentsEnd, 8); 1338 new SimpleStringLiteral(TokenFactory.tokenFromString("r'''X'''"), "X")
1339 .contentsEnd,
1340 5);
1341 expect(
1342 new SimpleStringLiteral(
1343 TokenFactory.tokenFromString("r''' \nX'''"), "X").contentsEnd,
1344 8);
1289 } 1345 }
1290 1346
1291 void test_contentsOffset() { 1347 void test_contentsOffset() {
1292 expect(new SimpleStringLiteral( 1348 expect(
1293 TokenFactory.tokenFromString("'X'"), "X").contentsOffset, 1); 1349 new SimpleStringLiteral(TokenFactory.tokenFromString("'X'"), "X")
1294 expect(new SimpleStringLiteral( 1350 .contentsOffset,
1295 TokenFactory.tokenFromString("\"X\""), "X").contentsOffset, 1); 1351 1);
1296 expect(new SimpleStringLiteral( 1352 expect(
1297 TokenFactory.tokenFromString("\"\"\"X\"\"\""), "X").contentsOffset, 3); 1353 new SimpleStringLiteral(TokenFactory.tokenFromString("\"X\""), "X")
1298 expect(new SimpleStringLiteral( 1354 .contentsOffset,
1299 TokenFactory.tokenFromString("'''X'''"), "X").contentsOffset, 3); 1355 1);
1300 expect(new SimpleStringLiteral( 1356 expect(
1301 TokenFactory.tokenFromString("r'X'"), "X").contentsOffset, 2); 1357 new SimpleStringLiteral(
1302 expect(new SimpleStringLiteral( 1358 TokenFactory.tokenFromString("\"\"\"X\"\"\""), "X").contentsOffset,
1303 TokenFactory.tokenFromString("r\"X\""), "X").contentsOffset, 2); 1359 3);
1304 expect(new SimpleStringLiteral( 1360 expect(
1305 TokenFactory.tokenFromString("r\"\"\"X\"\"\""), "X").contentsOffset, 4); 1361 new SimpleStringLiteral(TokenFactory.tokenFromString("'''X'''"), "X")
1306 expect(new SimpleStringLiteral( 1362 .contentsOffset,
1307 TokenFactory.tokenFromString("r'''X'''"), "X").contentsOffset, 4); 1363 3);
1364 expect(
1365 new SimpleStringLiteral(TokenFactory.tokenFromString("r'X'"), "X")
1366 .contentsOffset,
1367 2);
1368 expect(
1369 new SimpleStringLiteral(TokenFactory.tokenFromString("r\"X\""), "X")
1370 .contentsOffset,
1371 2);
1372 expect(
1373 new SimpleStringLiteral(
1374 TokenFactory.tokenFromString("r\"\"\"X\"\"\""), "X").contentsOffset,
1375 4);
1376 expect(
1377 new SimpleStringLiteral(TokenFactory.tokenFromString("r'''X'''"), "X")
1378 .contentsOffset,
1379 4);
1308 // leading whitespace 1380 // leading whitespace
1309 expect(new SimpleStringLiteral( 1381 expect(
1310 TokenFactory.tokenFromString("''' \ \nX''"), "X").contentsOffset, 6); 1382 new SimpleStringLiteral(
1311 expect(new SimpleStringLiteral( 1383 TokenFactory.tokenFromString("''' \ \nX''"), "X").contentsOffset,
1312 TokenFactory.tokenFromString('r""" \ \nX"""'), "X").contentsOffset, 7); 1384 6);
1385 expect(
1386 new SimpleStringLiteral(
1387 TokenFactory.tokenFromString('r""" \ \nX"""'), "X").contentsOffset,
1388 7);
1313 } 1389 }
1314 1390
1315 void test_isMultiline() { 1391 void test_isMultiline() {
1316 expect(new SimpleStringLiteral( 1392 expect(
1317 TokenFactory.tokenFromString("'X'"), "X").isMultiline, isFalse); 1393 new SimpleStringLiteral(TokenFactory.tokenFromString("'X'"), "X")
1318 expect(new SimpleStringLiteral( 1394 .isMultiline,
1319 TokenFactory.tokenFromString("r'X'"), "X").isMultiline, isFalse); 1395 isFalse);
1320 expect(new SimpleStringLiteral( 1396 expect(
1321 TokenFactory.tokenFromString("\"X\""), "X").isMultiline, isFalse); 1397 new SimpleStringLiteral(TokenFactory.tokenFromString("r'X'"), "X")
1322 expect(new SimpleStringLiteral( 1398 .isMultiline,
1323 TokenFactory.tokenFromString("r\"X\""), "X").isMultiline, isFalse); 1399 isFalse);
1324 expect(new SimpleStringLiteral( 1400 expect(
1325 TokenFactory.tokenFromString("'''X'''"), "X").isMultiline, isTrue); 1401 new SimpleStringLiteral(TokenFactory.tokenFromString("\"X\""), "X")
1326 expect(new SimpleStringLiteral( 1402 .isMultiline,
1327 TokenFactory.tokenFromString("r'''X'''"), "X").isMultiline, isTrue); 1403 isFalse);
1328 expect(new SimpleStringLiteral( 1404 expect(
1405 new SimpleStringLiteral(TokenFactory.tokenFromString("r\"X\""), "X")
1406 .isMultiline,
1407 isFalse);
1408 expect(
1409 new SimpleStringLiteral(TokenFactory.tokenFromString("'''X'''"), "X")
1410 .isMultiline,
1411 isTrue);
1412 expect(
1413 new SimpleStringLiteral(TokenFactory.tokenFromString("r'''X'''"), "X")
1414 .isMultiline,
1415 isTrue);
1416 expect(
1417 new SimpleStringLiteral(
1329 TokenFactory.tokenFromString("\"\"\"X\"\"\""), "X").isMultiline, 1418 TokenFactory.tokenFromString("\"\"\"X\"\"\""), "X").isMultiline,
1330 isTrue); 1419 isTrue);
1331 expect(new SimpleStringLiteral( 1420 expect(
1421 new SimpleStringLiteral(
1332 TokenFactory.tokenFromString("r\"\"\"X\"\"\""), "X").isMultiline, 1422 TokenFactory.tokenFromString("r\"\"\"X\"\"\""), "X").isMultiline,
1333 isTrue); 1423 isTrue);
1334 } 1424 }
1335 1425
1336 void test_isRaw() { 1426 void test_isRaw() {
1337 expect( 1427 expect(
1338 new SimpleStringLiteral(TokenFactory.tokenFromString("'X'"), "X").isRaw, 1428 new SimpleStringLiteral(TokenFactory.tokenFromString("'X'"), "X").isRaw,
1339 isFalse); 1429 isFalse);
1340 expect(new SimpleStringLiteral( 1430 expect(
1341 TokenFactory.tokenFromString("\"X\""), "X").isRaw, isFalse); 1431 new SimpleStringLiteral(TokenFactory.tokenFromString("\"X\""), "X")
1342 expect(new SimpleStringLiteral( 1432 .isRaw,
1343 TokenFactory.tokenFromString("\"\"\"X\"\"\""), "X").isRaw, isFalse); 1433 isFalse);
1344 expect(new SimpleStringLiteral( 1434 expect(
1345 TokenFactory.tokenFromString("'''X'''"), "X").isRaw, isFalse); 1435 new SimpleStringLiteral(
1346 expect(new SimpleStringLiteral( 1436 TokenFactory.tokenFromString("\"\"\"X\"\"\""), "X").isRaw,
1347 TokenFactory.tokenFromString("r'X'"), "X").isRaw, isTrue); 1437 isFalse);
1348 expect(new SimpleStringLiteral( 1438 expect(
1349 TokenFactory.tokenFromString("r\"X\""), "X").isRaw, isTrue); 1439 new SimpleStringLiteral(TokenFactory.tokenFromString("'''X'''"), "X")
1350 expect(new SimpleStringLiteral( 1440 .isRaw,
1351 TokenFactory.tokenFromString("r\"\"\"X\"\"\""), "X").isRaw, isTrue); 1441 isFalse);
1352 expect(new SimpleStringLiteral( 1442 expect(
1353 TokenFactory.tokenFromString("r'''X'''"), "X").isRaw, isTrue); 1443 new SimpleStringLiteral(TokenFactory.tokenFromString("r'X'"), "X")
1444 .isRaw,
1445 isTrue);
1446 expect(
1447 new SimpleStringLiteral(TokenFactory.tokenFromString("r\"X\""), "X")
1448 .isRaw,
1449 isTrue);
1450 expect(
1451 new SimpleStringLiteral(
1452 TokenFactory.tokenFromString("r\"\"\"X\"\"\""), "X").isRaw,
1453 isTrue);
1454 expect(
1455 new SimpleStringLiteral(TokenFactory.tokenFromString("r'''X'''"), "X")
1456 .isRaw,
1457 isTrue);
1354 } 1458 }
1355 1459
1356 void test_isSingleQuoted() { 1460 void test_isSingleQuoted() {
1357 // ' 1461 // '
1358 { 1462 {
1359 var token = TokenFactory.tokenFromString("'X'"); 1463 var token = TokenFactory.tokenFromString("'X'");
1360 var node = new SimpleStringLiteral(token, null); 1464 var node = new SimpleStringLiteral(token, null);
1361 expect(node.isSingleQuoted, isTrue); 1465 expect(node.isSingleQuoted, isTrue);
1362 } 1466 }
1363 // ''' 1467 // '''
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
1543 var c = AstFactory.interpolationString("ccc'''", "ccc"); 1647 var c = AstFactory.interpolationString("ccc'''", "ccc");
1544 StringInterpolation node = AstFactory.string([a, b, c]); 1648 StringInterpolation node = AstFactory.string([a, b, c]);
1545 expect(node.isSingleQuoted, isTrue); 1649 expect(node.isSingleQuoted, isTrue);
1546 } 1650 }
1547 } 1651 }
1548 } 1652 }
1549 1653
1550 @reflectiveTest 1654 @reflectiveTest
1551 class ToSourceVisitorTest extends EngineTestCase { 1655 class ToSourceVisitorTest extends EngineTestCase {
1552 void test_visitAdjacentStrings() { 1656 void test_visitAdjacentStrings() {
1553 _assertSource("'a' 'b'", AstFactory 1657 _assertSource(
1554 .adjacentStrings([AstFactory.string2("a"), AstFactory.string2("b")])); 1658 "'a' 'b'",
1659 AstFactory.adjacentStrings(
1660 [AstFactory.string2("a"), AstFactory.string2("b")]));
1555 } 1661 }
1556 1662
1557 void test_visitAnnotation_constant() { 1663 void test_visitAnnotation_constant() {
1558 _assertSource("@A", AstFactory.annotation(AstFactory.identifier3("A"))); 1664 _assertSource("@A", AstFactory.annotation(AstFactory.identifier3("A")));
1559 } 1665 }
1560 1666
1561 void test_visitAnnotation_constructor() { 1667 void test_visitAnnotation_constructor() {
1562 _assertSource("@A.c()", AstFactory.annotation2(AstFactory.identifier3("A"), 1668 _assertSource(
1563 AstFactory.identifier3("c"), AstFactory.argumentList())); 1669 "@A.c()",
1670 AstFactory.annotation2(AstFactory.identifier3("A"),
1671 AstFactory.identifier3("c"), AstFactory.argumentList()));
1564 } 1672 }
1565 1673
1566 void test_visitArgumentList() { 1674 void test_visitArgumentList() {
1567 _assertSource("(a, b)", AstFactory.argumentList( 1675 _assertSource(
1568 [AstFactory.identifier3("a"), AstFactory.identifier3("b")])); 1676 "(a, b)",
1677 AstFactory.argumentList(
1678 [AstFactory.identifier3("a"), AstFactory.identifier3("b")]));
1569 } 1679 }
1570 1680
1571 void test_visitAsExpression() { 1681 void test_visitAsExpression() {
1572 _assertSource("e as T", AstFactory.asExpression( 1682 _assertSource(
1573 AstFactory.identifier3("e"), AstFactory.typeName4("T"))); 1683 "e as T",
1684 AstFactory.asExpression(
1685 AstFactory.identifier3("e"), AstFactory.typeName4("T")));
1574 } 1686 }
1575 1687
1576 void test_visitAssertStatement() { 1688 void test_visitAssertStatement() {
1577 _assertSource( 1689 _assertSource(
1578 "assert (a);", AstFactory.assertStatement(AstFactory.identifier3("a"))); 1690 "assert (a);", AstFactory.assertStatement(AstFactory.identifier3("a")));
1579 } 1691 }
1580 1692
1581 void test_visitAssignmentExpression() { 1693 void test_visitAssignmentExpression() {
1582 _assertSource("a = b", AstFactory.assignmentExpression( 1694 _assertSource(
1583 AstFactory.identifier3("a"), TokenType.EQ, 1695 "a = b",
1584 AstFactory.identifier3("b"))); 1696 AstFactory.assignmentExpression(AstFactory.identifier3("a"),
1697 TokenType.EQ, AstFactory.identifier3("b")));
1585 } 1698 }
1586 1699
1587 void test_visitAwaitExpression() { 1700 void test_visitAwaitExpression() {
1588 _assertSource( 1701 _assertSource(
1589 "await e;", AstFactory.awaitExpression(AstFactory.identifier3("e"))); 1702 "await e;", AstFactory.awaitExpression(AstFactory.identifier3("e")));
1590 } 1703 }
1591 1704
1592 void test_visitBinaryExpression() { 1705 void test_visitBinaryExpression() {
1593 _assertSource("a + b", AstFactory.binaryExpression( 1706 _assertSource(
1594 AstFactory.identifier3("a"), TokenType.PLUS, 1707 "a + b",
1595 AstFactory.identifier3("b"))); 1708 AstFactory.binaryExpression(AstFactory.identifier3("a"), TokenType.PLUS,
1709 AstFactory.identifier3("b")));
1596 } 1710 }
1597 1711
1598 void test_visitBlock_empty() { 1712 void test_visitBlock_empty() {
1599 _assertSource("{}", AstFactory.block()); 1713 _assertSource("{}", AstFactory.block());
1600 } 1714 }
1601 1715
1602 void test_visitBlock_nonEmpty() { 1716 void test_visitBlock_nonEmpty() {
1603 _assertSource("{break; break;}", AstFactory 1717 _assertSource(
1604 .block([AstFactory.breakStatement(), AstFactory.breakStatement()])); 1718 "{break; break;}",
1719 AstFactory
1720 .block([AstFactory.breakStatement(), AstFactory.breakStatement()]));
1605 } 1721 }
1606 1722
1607 void test_visitBlockFunctionBody_async() { 1723 void test_visitBlockFunctionBody_async() {
1608 _assertSource("async {}", AstFactory.asyncBlockFunctionBody()); 1724 _assertSource("async {}", AstFactory.asyncBlockFunctionBody());
1609 } 1725 }
1610 1726
1611 void test_visitBlockFunctionBody_async_star() { 1727 void test_visitBlockFunctionBody_async_star() {
1612 _assertSource("async* {}", AstFactory.asyncGeneratorBlockFunctionBody()); 1728 _assertSource("async* {}", AstFactory.asyncGeneratorBlockFunctionBody());
1613 } 1729 }
1614 1730
(...skipping 19 matching lines...) Expand all
1634 1750
1635 void test_visitBreakStatement_label() { 1751 void test_visitBreakStatement_label() {
1636 _assertSource("break l;", AstFactory.breakStatement2("l")); 1752 _assertSource("break l;", AstFactory.breakStatement2("l"));
1637 } 1753 }
1638 1754
1639 void test_visitBreakStatement_noLabel() { 1755 void test_visitBreakStatement_noLabel() {
1640 _assertSource("break;", AstFactory.breakStatement()); 1756 _assertSource("break;", AstFactory.breakStatement());
1641 } 1757 }
1642 1758
1643 void test_visitCascadeExpression_field() { 1759 void test_visitCascadeExpression_field() {
1644 _assertSource("a..b..c", AstFactory.cascadeExpression( 1760 _assertSource(
1645 AstFactory.identifier3("a"), [ 1761 "a..b..c",
1646 AstFactory.cascadedPropertyAccess("b"), 1762 AstFactory.cascadeExpression(AstFactory.identifier3("a"), [
1647 AstFactory.cascadedPropertyAccess("c") 1763 AstFactory.cascadedPropertyAccess("b"),
1648 ])); 1764 AstFactory.cascadedPropertyAccess("c")
1765 ]));
1649 } 1766 }
1650 1767
1651 void test_visitCascadeExpression_index() { 1768 void test_visitCascadeExpression_index() {
1652 _assertSource("a..[0]..[1]", AstFactory.cascadeExpression( 1769 _assertSource(
1653 AstFactory.identifier3("a"), [ 1770 "a..[0]..[1]",
1654 AstFactory.cascadedIndexExpression(AstFactory.integer(0)), 1771 AstFactory.cascadeExpression(AstFactory.identifier3("a"), [
1655 AstFactory.cascadedIndexExpression(AstFactory.integer(1)) 1772 AstFactory.cascadedIndexExpression(AstFactory.integer(0)),
1656 ])); 1773 AstFactory.cascadedIndexExpression(AstFactory.integer(1))
1774 ]));
1657 } 1775 }
1658 1776
1659 void test_visitCascadeExpression_method() { 1777 void test_visitCascadeExpression_method() {
1660 _assertSource("a..b()..c()", AstFactory.cascadeExpression( 1778 _assertSource(
1661 AstFactory.identifier3("a"), [ 1779 "a..b()..c()",
1662 AstFactory.cascadedMethodInvocation("b"), 1780 AstFactory.cascadeExpression(AstFactory.identifier3("a"), [
1663 AstFactory.cascadedMethodInvocation("c") 1781 AstFactory.cascadedMethodInvocation("b"),
1664 ])); 1782 AstFactory.cascadedMethodInvocation("c")
1783 ]));
1665 } 1784 }
1666 1785
1667 void test_visitCatchClause_catch_noStack() { 1786 void test_visitCatchClause_catch_noStack() {
1668 _assertSource("catch (e) {}", AstFactory.catchClause("e")); 1787 _assertSource("catch (e) {}", AstFactory.catchClause("e"));
1669 } 1788 }
1670 1789
1671 void test_visitCatchClause_catch_stack() { 1790 void test_visitCatchClause_catch_stack() {
1672 _assertSource("catch (e, s) {}", AstFactory.catchClause2("e", "s")); 1791 _assertSource("catch (e, s) {}", AstFactory.catchClause2("e", "s"));
1673 } 1792 }
1674 1793
1675 void test_visitCatchClause_on() { 1794 void test_visitCatchClause_on() {
1676 _assertSource( 1795 _assertSource(
1677 "on E {}", AstFactory.catchClause3(AstFactory.typeName4("E"))); 1796 "on E {}", AstFactory.catchClause3(AstFactory.typeName4("E")));
1678 } 1797 }
1679 1798
1680 void test_visitCatchClause_on_catch() { 1799 void test_visitCatchClause_on_catch() {
1681 _assertSource("on E catch (e) {}", 1800 _assertSource("on E catch (e) {}",
1682 AstFactory.catchClause4(AstFactory.typeName4("E"), "e")); 1801 AstFactory.catchClause4(AstFactory.typeName4("E"), "e"));
1683 } 1802 }
1684 1803
1685 void test_visitClassDeclaration_abstract() { 1804 void test_visitClassDeclaration_abstract() {
1686 _assertSource("abstract class C {}", AstFactory.classDeclaration( 1805 _assertSource(
1687 Keyword.ABSTRACT, "C", null, null, null, null)); 1806 "abstract class C {}",
1807 AstFactory.classDeclaration(
1808 Keyword.ABSTRACT, "C", null, null, null, null));
1688 } 1809 }
1689 1810
1690 void test_visitClassDeclaration_empty() { 1811 void test_visitClassDeclaration_empty() {
1691 _assertSource("class C {}", 1812 _assertSource("class C {}",
1692 AstFactory.classDeclaration(null, "C", null, null, null, null)); 1813 AstFactory.classDeclaration(null, "C", null, null, null, null));
1693 } 1814 }
1694 1815
1695 void test_visitClassDeclaration_extends() { 1816 void test_visitClassDeclaration_extends() {
1696 _assertSource("class C extends A {}", AstFactory.classDeclaration(null, "C", 1817 _assertSource(
1697 null, AstFactory.extendsClause(AstFactory.typeName4("A")), null, null)); 1818 "class C extends A {}",
1819 AstFactory.classDeclaration(null, "C", null,
1820 AstFactory.extendsClause(AstFactory.typeName4("A")), null, null));
1698 } 1821 }
1699 1822
1700 void test_visitClassDeclaration_extends_implements() { 1823 void test_visitClassDeclaration_extends_implements() {
1701 _assertSource("class C extends A implements B {}", AstFactory 1824 _assertSource(
1702 .classDeclaration(null, "C", null, 1825 "class C extends A implements B {}",
1703 AstFactory.extendsClause(AstFactory.typeName4("A")), null, 1826 AstFactory.classDeclaration(
1827 null,
1828 "C",
1829 null,
1830 AstFactory.extendsClause(AstFactory.typeName4("A")),
1831 null,
1704 AstFactory.implementsClause([AstFactory.typeName4("B")]))); 1832 AstFactory.implementsClause([AstFactory.typeName4("B")])));
1705 } 1833 }
1706 1834
1707 void test_visitClassDeclaration_extends_with() { 1835 void test_visitClassDeclaration_extends_with() {
1708 _assertSource("class C extends A with M {}", AstFactory.classDeclaration( 1836 _assertSource(
1709 null, "C", null, AstFactory.extendsClause(AstFactory.typeName4("A")), 1837 "class C extends A with M {}",
1710 AstFactory.withClause([AstFactory.typeName4("M")]), null)); 1838 AstFactory.classDeclaration(
1839 null,
1840 "C",
1841 null,
1842 AstFactory.extendsClause(AstFactory.typeName4("A")),
1843 AstFactory.withClause([AstFactory.typeName4("M")]),
1844 null));
1711 } 1845 }
1712 1846
1713 void test_visitClassDeclaration_extends_with_implements() { 1847 void test_visitClassDeclaration_extends_with_implements() {
1714 _assertSource("class C extends A with M implements B {}", AstFactory 1848 _assertSource(
1715 .classDeclaration(null, "C", null, 1849 "class C extends A with M implements B {}",
1850 AstFactory.classDeclaration(
1851 null,
1852 "C",
1853 null,
1716 AstFactory.extendsClause(AstFactory.typeName4("A")), 1854 AstFactory.extendsClause(AstFactory.typeName4("A")),
1717 AstFactory.withClause([AstFactory.typeName4("M")]), 1855 AstFactory.withClause([AstFactory.typeName4("M")]),
1718 AstFactory.implementsClause([AstFactory.typeName4("B")]))); 1856 AstFactory.implementsClause([AstFactory.typeName4("B")])));
1719 } 1857 }
1720 1858
1721 void test_visitClassDeclaration_implements() { 1859 void test_visitClassDeclaration_implements() {
1722 _assertSource("class C implements B {}", AstFactory.classDeclaration(null, 1860 _assertSource(
1723 "C", null, null, null, 1861 "class C implements B {}",
1724 AstFactory.implementsClause([AstFactory.typeName4("B")]))); 1862 AstFactory.classDeclaration(null, "C", null, null, null,
1863 AstFactory.implementsClause([AstFactory.typeName4("B")])));
1725 } 1864 }
1726 1865
1727 void test_visitClassDeclaration_multipleMember() { 1866 void test_visitClassDeclaration_multipleMember() {
1728 _assertSource("class C {var a; var b;}", AstFactory.classDeclaration(null, 1867 _assertSource(
1729 "C", null, null, null, null, [ 1868 "class C {var a; var b;}",
1730 AstFactory.fieldDeclaration2( 1869 AstFactory.classDeclaration(null, "C", null, null, null, null, [
1731 false, Keyword.VAR, [AstFactory.variableDeclaration("a")]), 1870 AstFactory.fieldDeclaration2(
1732 AstFactory.fieldDeclaration2( 1871 false, Keyword.VAR, [AstFactory.variableDeclaration("a")]),
1733 false, Keyword.VAR, [AstFactory.variableDeclaration("b")]) 1872 AstFactory.fieldDeclaration2(
1734 ])); 1873 false, Keyword.VAR, [AstFactory.variableDeclaration("b")])
1874 ]));
1735 } 1875 }
1736 1876
1737 void test_visitClassDeclaration_parameters() { 1877 void test_visitClassDeclaration_parameters() {
1738 _assertSource("class C<E> {}", AstFactory.classDeclaration( 1878 _assertSource(
1739 null, "C", AstFactory.typeParameterList(["E"]), null, null, null)); 1879 "class C<E> {}",
1880 AstFactory.classDeclaration(
1881 null, "C", AstFactory.typeParameterList(["E"]), null, null, null));
1740 } 1882 }
1741 1883
1742 void test_visitClassDeclaration_parameters_extends() { 1884 void test_visitClassDeclaration_parameters_extends() {
1743 _assertSource("class C<E> extends A {}", AstFactory.classDeclaration(null, 1885 _assertSource(
1744 "C", AstFactory.typeParameterList(["E"]), 1886 "class C<E> extends A {}",
1745 AstFactory.extendsClause(AstFactory.typeName4("A")), null, null)); 1887 AstFactory.classDeclaration(
1888 null,
1889 "C",
1890 AstFactory.typeParameterList(["E"]),
1891 AstFactory.extendsClause(AstFactory.typeName4("A")),
1892 null,
1893 null));
1746 } 1894 }
1747 1895
1748 void test_visitClassDeclaration_parameters_extends_implements() { 1896 void test_visitClassDeclaration_parameters_extends_implements() {
1749 _assertSource("class C<E> extends A implements B {}", AstFactory 1897 _assertSource(
1750 .classDeclaration(null, "C", AstFactory.typeParameterList(["E"]), 1898 "class C<E> extends A implements B {}",
1751 AstFactory.extendsClause(AstFactory.typeName4("A")), null, 1899 AstFactory.classDeclaration(
1900 null,
1901 "C",
1902 AstFactory.typeParameterList(["E"]),
1903 AstFactory.extendsClause(AstFactory.typeName4("A")),
1904 null,
1752 AstFactory.implementsClause([AstFactory.typeName4("B")]))); 1905 AstFactory.implementsClause([AstFactory.typeName4("B")])));
1753 } 1906 }
1754 1907
1755 void test_visitClassDeclaration_parameters_extends_with() { 1908 void test_visitClassDeclaration_parameters_extends_with() {
1756 _assertSource("class C<E> extends A with M {}", AstFactory.classDeclaration( 1909 _assertSource(
1757 null, "C", AstFactory.typeParameterList(["E"]), 1910 "class C<E> extends A with M {}",
1758 AstFactory.extendsClause(AstFactory.typeName4("A")), 1911 AstFactory.classDeclaration(
1759 AstFactory.withClause([AstFactory.typeName4("M")]), null)); 1912 null,
1913 "C",
1914 AstFactory.typeParameterList(["E"]),
1915 AstFactory.extendsClause(AstFactory.typeName4("A")),
1916 AstFactory.withClause([AstFactory.typeName4("M")]),
1917 null));
1760 } 1918 }
1761 1919
1762 void test_visitClassDeclaration_parameters_extends_with_implements() { 1920 void test_visitClassDeclaration_parameters_extends_with_implements() {
1763 _assertSource("class C<E> extends A with M implements B {}", AstFactory 1921 _assertSource(
1764 .classDeclaration(null, "C", AstFactory.typeParameterList(["E"]), 1922 "class C<E> extends A with M implements B {}",
1923 AstFactory.classDeclaration(
1924 null,
1925 "C",
1926 AstFactory.typeParameterList(["E"]),
1765 AstFactory.extendsClause(AstFactory.typeName4("A")), 1927 AstFactory.extendsClause(AstFactory.typeName4("A")),
1766 AstFactory.withClause([AstFactory.typeName4("M")]), 1928 AstFactory.withClause([AstFactory.typeName4("M")]),
1767 AstFactory.implementsClause([AstFactory.typeName4("B")]))); 1929 AstFactory.implementsClause([AstFactory.typeName4("B")])));
1768 } 1930 }
1769 1931
1770 void test_visitClassDeclaration_parameters_implements() { 1932 void test_visitClassDeclaration_parameters_implements() {
1771 _assertSource("class C<E> implements B {}", AstFactory.classDeclaration( 1933 _assertSource(
1772 null, "C", AstFactory.typeParameterList(["E"]), null, null, 1934 "class C<E> implements B {}",
1773 AstFactory.implementsClause([AstFactory.typeName4("B")]))); 1935 AstFactory.classDeclaration(
1936 null,
1937 "C",
1938 AstFactory.typeParameterList(["E"]),
1939 null,
1940 null,
1941 AstFactory.implementsClause([AstFactory.typeName4("B")])));
1774 } 1942 }
1775 1943
1776 void test_visitClassDeclaration_singleMember() { 1944 void test_visitClassDeclaration_singleMember() {
1777 _assertSource("class C {var a;}", AstFactory.classDeclaration(null, "C", 1945 _assertSource(
1778 null, null, null, null, [ 1946 "class C {var a;}",
1779 AstFactory.fieldDeclaration2( 1947 AstFactory.classDeclaration(null, "C", null, null, null, null, [
1780 false, Keyword.VAR, [AstFactory.variableDeclaration("a")]) 1948 AstFactory.fieldDeclaration2(
1781 ])); 1949 false, Keyword.VAR, [AstFactory.variableDeclaration("a")])
1950 ]));
1782 } 1951 }
1783 1952
1784 void test_visitClassDeclaration_withMetadata() { 1953 void test_visitClassDeclaration_withMetadata() {
1785 ClassDeclaration declaration = 1954 ClassDeclaration declaration =
1786 AstFactory.classDeclaration(null, "C", null, null, null, null); 1955 AstFactory.classDeclaration(null, "C", null, null, null, null);
1787 declaration.metadata 1956 declaration.metadata
1788 .add(AstFactory.annotation(AstFactory.identifier3("deprecated"))); 1957 .add(AstFactory.annotation(AstFactory.identifier3("deprecated")));
1789 _assertSource("@deprecated class C {}", declaration); 1958 _assertSource("@deprecated class C {}", declaration);
1790 } 1959 }
1791 1960
1792 void test_visitClassTypeAlias_abstract() { 1961 void test_visitClassTypeAlias_abstract() {
1793 _assertSource("abstract class C = S with M1;", AstFactory.classTypeAlias( 1962 _assertSource(
1794 "C", null, Keyword.ABSTRACT, AstFactory.typeName4("S"), 1963 "abstract class C = S with M1;",
1795 AstFactory.withClause([AstFactory.typeName4("M1")]), null)); 1964 AstFactory.classTypeAlias(
1965 "C",
1966 null,
1967 Keyword.ABSTRACT,
1968 AstFactory.typeName4("S"),
1969 AstFactory.withClause([AstFactory.typeName4("M1")]),
1970 null));
1796 } 1971 }
1797 1972
1798 void test_visitClassTypeAlias_abstract_implements() { 1973 void test_visitClassTypeAlias_abstract_implements() {
1799 _assertSource("abstract class C = S with M1 implements I;", AstFactory 1974 _assertSource(
1800 .classTypeAlias("C", null, Keyword.ABSTRACT, AstFactory.typeName4("S"), 1975 "abstract class C = S with M1 implements I;",
1976 AstFactory.classTypeAlias(
1977 "C",
1978 null,
1979 Keyword.ABSTRACT,
1980 AstFactory.typeName4("S"),
1801 AstFactory.withClause([AstFactory.typeName4("M1")]), 1981 AstFactory.withClause([AstFactory.typeName4("M1")]),
1802 AstFactory.implementsClause([AstFactory.typeName4("I")]))); 1982 AstFactory.implementsClause([AstFactory.typeName4("I")])));
1803 } 1983 }
1804 1984
1805 void test_visitClassTypeAlias_generic() { 1985 void test_visitClassTypeAlias_generic() {
1806 _assertSource("class C<E> = S<E> with M1<E>;", AstFactory.classTypeAlias( 1986 _assertSource(
1807 "C", AstFactory.typeParameterList(["E"]), null, 1987 "class C<E> = S<E> with M1<E>;",
1808 AstFactory.typeName4("S", [AstFactory.typeName4("E")]), 1988 AstFactory.classTypeAlias(
1809 AstFactory.withClause( 1989 "C",
1810 [AstFactory.typeName4("M1", [AstFactory.typeName4("E")])]), null)); 1990 AstFactory.typeParameterList(["E"]),
1991 null,
1992 AstFactory.typeName4("S", [AstFactory.typeName4("E")]),
1993 AstFactory.withClause([
1994 AstFactory.typeName4("M1", [AstFactory.typeName4("E")])
1995 ]),
1996 null));
1811 } 1997 }
1812 1998
1813 void test_visitClassTypeAlias_implements() { 1999 void test_visitClassTypeAlias_implements() {
1814 _assertSource("class C = S with M1 implements I;", AstFactory 2000 _assertSource(
1815 .classTypeAlias("C", null, null, AstFactory.typeName4("S"), 2001 "class C = S with M1 implements I;",
2002 AstFactory.classTypeAlias(
2003 "C",
2004 null,
2005 null,
2006 AstFactory.typeName4("S"),
1816 AstFactory.withClause([AstFactory.typeName4("M1")]), 2007 AstFactory.withClause([AstFactory.typeName4("M1")]),
1817 AstFactory.implementsClause([AstFactory.typeName4("I")]))); 2008 AstFactory.implementsClause([AstFactory.typeName4("I")])));
1818 } 2009 }
1819 2010
1820 void test_visitClassTypeAlias_minimal() { 2011 void test_visitClassTypeAlias_minimal() {
1821 _assertSource("class C = S with M1;", AstFactory.classTypeAlias("C", null, 2012 _assertSource(
1822 null, AstFactory.typeName4("S"), 2013 "class C = S with M1;",
1823 AstFactory.withClause([AstFactory.typeName4("M1")]), null)); 2014 AstFactory.classTypeAlias("C", null, null, AstFactory.typeName4("S"),
2015 AstFactory.withClause([AstFactory.typeName4("M1")]), null));
1824 } 2016 }
1825 2017
1826 void test_visitClassTypeAlias_parameters_abstract() { 2018 void test_visitClassTypeAlias_parameters_abstract() {
1827 _assertSource("abstract class C<E> = S with M1;", AstFactory.classTypeAlias( 2019 _assertSource(
1828 "C", AstFactory.typeParameterList(["E"]), Keyword.ABSTRACT, 2020 "abstract class C<E> = S with M1;",
1829 AstFactory.typeName4("S"), 2021 AstFactory.classTypeAlias(
1830 AstFactory.withClause([AstFactory.typeName4("M1")]), null)); 2022 "C",
2023 AstFactory.typeParameterList(["E"]),
2024 Keyword.ABSTRACT,
2025 AstFactory.typeName4("S"),
2026 AstFactory.withClause([AstFactory.typeName4("M1")]),
2027 null));
1831 } 2028 }
1832 2029
1833 void test_visitClassTypeAlias_parameters_abstract_implements() { 2030 void test_visitClassTypeAlias_parameters_abstract_implements() {
1834 _assertSource("abstract class C<E> = S with M1 implements I;", AstFactory 2031 _assertSource(
1835 .classTypeAlias("C", AstFactory.typeParameterList(["E"]), 2032 "abstract class C<E> = S with M1 implements I;",
1836 Keyword.ABSTRACT, AstFactory.typeName4("S"), 2033 AstFactory.classTypeAlias(
2034 "C",
2035 AstFactory.typeParameterList(["E"]),
2036 Keyword.ABSTRACT,
2037 AstFactory.typeName4("S"),
1837 AstFactory.withClause([AstFactory.typeName4("M1")]), 2038 AstFactory.withClause([AstFactory.typeName4("M1")]),
1838 AstFactory.implementsClause([AstFactory.typeName4("I")]))); 2039 AstFactory.implementsClause([AstFactory.typeName4("I")])));
1839 } 2040 }
1840 2041
1841 void test_visitClassTypeAlias_parameters_implements() { 2042 void test_visitClassTypeAlias_parameters_implements() {
1842 _assertSource("class C<E> = S with M1 implements I;", AstFactory 2043 _assertSource(
1843 .classTypeAlias("C", AstFactory.typeParameterList(["E"]), null, 2044 "class C<E> = S with M1 implements I;",
2045 AstFactory.classTypeAlias(
2046 "C",
2047 AstFactory.typeParameterList(["E"]),
2048 null,
1844 AstFactory.typeName4("S"), 2049 AstFactory.typeName4("S"),
1845 AstFactory.withClause([AstFactory.typeName4("M1")]), 2050 AstFactory.withClause([AstFactory.typeName4("M1")]),
1846 AstFactory.implementsClause([AstFactory.typeName4("I")]))); 2051 AstFactory.implementsClause([AstFactory.typeName4("I")])));
1847 } 2052 }
1848 2053
1849 void test_visitClassTypeAlias_withMetadata() { 2054 void test_visitClassTypeAlias_withMetadata() {
1850 ClassTypeAlias declaration = AstFactory.classTypeAlias("C", null, null, 2055 ClassTypeAlias declaration = AstFactory.classTypeAlias(
2056 "C",
2057 null,
2058 null,
1851 AstFactory.typeName4("S"), 2059 AstFactory.typeName4("S"),
1852 AstFactory.withClause([AstFactory.typeName4("M1")]), null); 2060 AstFactory.withClause([AstFactory.typeName4("M1")]),
2061 null);
1853 declaration.metadata 2062 declaration.metadata
1854 .add(AstFactory.annotation(AstFactory.identifier3("deprecated"))); 2063 .add(AstFactory.annotation(AstFactory.identifier3("deprecated")));
1855 _assertSource("@deprecated class C = S with M1;", declaration); 2064 _assertSource("@deprecated class C = S with M1;", declaration);
1856 } 2065 }
1857 2066
1858 void test_visitComment() { 2067 void test_visitComment() {
1859 _assertSource("", Comment.createBlockComment( 2068 _assertSource(
1860 <Token>[TokenFactory.tokenFromString("/* comment */")])); 2069 "",
2070 Comment.createBlockComment(
2071 <Token>[TokenFactory.tokenFromString("/* comment */")]));
1861 } 2072 }
1862 2073
1863 void test_visitCommentReference() { 2074 void test_visitCommentReference() {
1864 _assertSource("", new CommentReference(null, AstFactory.identifier3("a"))); 2075 _assertSource("", new CommentReference(null, AstFactory.identifier3("a")));
1865 } 2076 }
1866 2077
1867 void test_visitCompilationUnit_declaration() { 2078 void test_visitCompilationUnit_declaration() {
1868 _assertSource("var a;", AstFactory.compilationUnit2([ 2079 _assertSource(
1869 AstFactory.topLevelVariableDeclaration2( 2080 "var a;",
1870 Keyword.VAR, [AstFactory.variableDeclaration("a")]) 2081 AstFactory.compilationUnit2([
1871 ])); 2082 AstFactory.topLevelVariableDeclaration2(
2083 Keyword.VAR, [AstFactory.variableDeclaration("a")])
2084 ]));
1872 } 2085 }
1873 2086
1874 void test_visitCompilationUnit_directive() { 2087 void test_visitCompilationUnit_directive() {
1875 _assertSource("library l;", 2088 _assertSource("library l;",
1876 AstFactory.compilationUnit3([AstFactory.libraryDirective2("l")])); 2089 AstFactory.compilationUnit3([AstFactory.libraryDirective2("l")]));
1877 } 2090 }
1878 2091
1879 void test_visitCompilationUnit_directive_declaration() { 2092 void test_visitCompilationUnit_directive_declaration() {
1880 _assertSource("library l; var a;", AstFactory.compilationUnit4( 2093 _assertSource(
1881 [AstFactory.libraryDirective2("l")], [ 2094 "library l; var a;",
1882 AstFactory.topLevelVariableDeclaration2( 2095 AstFactory.compilationUnit4([
1883 Keyword.VAR, [AstFactory.variableDeclaration("a")]) 2096 AstFactory.libraryDirective2("l")
1884 ])); 2097 ], [
2098 AstFactory.topLevelVariableDeclaration2(
2099 Keyword.VAR, [AstFactory.variableDeclaration("a")])
2100 ]));
1885 } 2101 }
1886 2102
1887 void test_visitCompilationUnit_empty() { 2103 void test_visitCompilationUnit_empty() {
1888 _assertSource("", AstFactory.compilationUnit()); 2104 _assertSource("", AstFactory.compilationUnit());
1889 } 2105 }
1890 2106
1891 void test_visitCompilationUnit_script() { 2107 void test_visitCompilationUnit_script() {
1892 _assertSource( 2108 _assertSource(
1893 "!#/bin/dartvm", AstFactory.compilationUnit5("!#/bin/dartvm")); 2109 "!#/bin/dartvm", AstFactory.compilationUnit5("!#/bin/dartvm"));
1894 } 2110 }
1895 2111
1896 void test_visitCompilationUnit_script_declaration() { 2112 void test_visitCompilationUnit_script_declaration() {
1897 _assertSource("!#/bin/dartvm var a;", AstFactory.compilationUnit6( 2113 _assertSource(
1898 "!#/bin/dartvm", [ 2114 "!#/bin/dartvm var a;",
1899 AstFactory.topLevelVariableDeclaration2( 2115 AstFactory.compilationUnit6("!#/bin/dartvm", [
1900 Keyword.VAR, [AstFactory.variableDeclaration("a")]) 2116 AstFactory.topLevelVariableDeclaration2(
1901 ])); 2117 Keyword.VAR, [AstFactory.variableDeclaration("a")])
2118 ]));
1902 } 2119 }
1903 2120
1904 void test_visitCompilationUnit_script_directive() { 2121 void test_visitCompilationUnit_script_directive() {
1905 _assertSource("!#/bin/dartvm library l;", AstFactory.compilationUnit7( 2122 _assertSource(
1906 "!#/bin/dartvm", [AstFactory.libraryDirective2("l")])); 2123 "!#/bin/dartvm library l;",
2124 AstFactory.compilationUnit7(
2125 "!#/bin/dartvm", [AstFactory.libraryDirective2("l")]));
1907 } 2126 }
1908 2127
1909 void test_visitCompilationUnit_script_directives_declarations() { 2128 void test_visitCompilationUnit_script_directives_declarations() {
1910 _assertSource("!#/bin/dartvm library l; var a;", AstFactory 2129 _assertSource(
1911 .compilationUnit8("!#/bin/dartvm", [AstFactory.libraryDirective2("l")], 2130 "!#/bin/dartvm library l; var a;",
1912 [ 2131 AstFactory.compilationUnit8("!#/bin/dartvm", [
1913 AstFactory.topLevelVariableDeclaration2( 2132 AstFactory.libraryDirective2("l")
1914 Keyword.VAR, [AstFactory.variableDeclaration("a")]) 2133 ], [
1915 ])); 2134 AstFactory.topLevelVariableDeclaration2(
2135 Keyword.VAR, [AstFactory.variableDeclaration("a")])
2136 ]));
1916 } 2137 }
1917 2138
1918 void test_visitConditionalExpression() { 2139 void test_visitConditionalExpression() {
1919 _assertSource("a ? b : c", AstFactory.conditionalExpression( 2140 _assertSource(
1920 AstFactory.identifier3("a"), AstFactory.identifier3("b"), 2141 "a ? b : c",
1921 AstFactory.identifier3("c"))); 2142 AstFactory.conditionalExpression(AstFactory.identifier3("a"),
2143 AstFactory.identifier3("b"), AstFactory.identifier3("c")));
1922 } 2144 }
1923 2145
1924 void test_visitConstructorDeclaration_const() { 2146 void test_visitConstructorDeclaration_const() {
1925 _assertSource("const C() {}", AstFactory.constructorDeclaration2( 2147 _assertSource(
1926 Keyword.CONST, null, AstFactory.identifier3("C"), null, 2148 "const C() {}",
1927 AstFactory.formalParameterList(), null, 2149 AstFactory.constructorDeclaration2(
1928 AstFactory.blockFunctionBody2())); 2150 Keyword.CONST,
2151 null,
2152 AstFactory.identifier3("C"),
2153 null,
2154 AstFactory.formalParameterList(),
2155 null,
2156 AstFactory.blockFunctionBody2()));
1929 } 2157 }
1930 2158
1931 void test_visitConstructorDeclaration_external() { 2159 void test_visitConstructorDeclaration_external() {
1932 _assertSource("external C();", AstFactory.constructorDeclaration( 2160 _assertSource(
1933 AstFactory.identifier3("C"), null, AstFactory.formalParameterList(), 2161 "external C();",
1934 null)); 2162 AstFactory.constructorDeclaration(AstFactory.identifier3("C"), null,
2163 AstFactory.formalParameterList(), null));
1935 } 2164 }
1936 2165
1937 void test_visitConstructorDeclaration_minimal() { 2166 void test_visitConstructorDeclaration_minimal() {
1938 _assertSource("C() {}", AstFactory.constructorDeclaration2(null, null, 2167 _assertSource(
1939 AstFactory.identifier3("C"), null, AstFactory.formalParameterList(), 2168 "C() {}",
1940 null, AstFactory.blockFunctionBody2())); 2169 AstFactory.constructorDeclaration2(
2170 null,
2171 null,
2172 AstFactory.identifier3("C"),
2173 null,
2174 AstFactory.formalParameterList(),
2175 null,
2176 AstFactory.blockFunctionBody2()));
1941 } 2177 }
1942 2178
1943 void test_visitConstructorDeclaration_multipleInitializers() { 2179 void test_visitConstructorDeclaration_multipleInitializers() {
1944 _assertSource("C() : a = b, c = d {}", AstFactory.constructorDeclaration2( 2180 _assertSource(
1945 null, null, AstFactory.identifier3("C"), null, 2181 "C() : a = b, c = d {}",
1946 AstFactory.formalParameterList(), [ 2182 AstFactory.constructorDeclaration2(
1947 AstFactory.constructorFieldInitializer( 2183 null,
1948 false, "a", AstFactory.identifier3("b")), 2184 null,
1949 AstFactory.constructorFieldInitializer( 2185 AstFactory.identifier3("C"),
1950 false, "c", AstFactory.identifier3("d")) 2186 null,
1951 ], AstFactory.blockFunctionBody2())); 2187 AstFactory.formalParameterList(),
2188 [
2189 AstFactory.constructorFieldInitializer(
2190 false, "a", AstFactory.identifier3("b")),
2191 AstFactory.constructorFieldInitializer(
2192 false, "c", AstFactory.identifier3("d"))
2193 ],
2194 AstFactory.blockFunctionBody2()));
1952 } 2195 }
1953 2196
1954 void test_visitConstructorDeclaration_multipleParameters() { 2197 void test_visitConstructorDeclaration_multipleParameters() {
1955 _assertSource("C(var a, var b) {}", AstFactory.constructorDeclaration2(null, 2198 _assertSource(
1956 null, AstFactory.identifier3("C"), null, AstFactory.formalParameterList( 2199 "C(var a, var b) {}",
1957 [ 2200 AstFactory.constructorDeclaration2(
1958 AstFactory.simpleFormalParameter(Keyword.VAR, "a"), 2201 null,
1959 AstFactory.simpleFormalParameter(Keyword.VAR, "b") 2202 null,
1960 ]), null, AstFactory.blockFunctionBody2())); 2203 AstFactory.identifier3("C"),
2204 null,
2205 AstFactory.formalParameterList([
2206 AstFactory.simpleFormalParameter(Keyword.VAR, "a"),
2207 AstFactory.simpleFormalParameter(Keyword.VAR, "b")
2208 ]),
2209 null,
2210 AstFactory.blockFunctionBody2()));
1961 } 2211 }
1962 2212
1963 void test_visitConstructorDeclaration_named() { 2213 void test_visitConstructorDeclaration_named() {
1964 _assertSource("C.m() {}", AstFactory.constructorDeclaration2(null, null, 2214 _assertSource(
1965 AstFactory.identifier3("C"), "m", AstFactory.formalParameterList(), 2215 "C.m() {}",
1966 null, AstFactory.blockFunctionBody2())); 2216 AstFactory.constructorDeclaration2(
2217 null,
2218 null,
2219 AstFactory.identifier3("C"),
2220 "m",
2221 AstFactory.formalParameterList(),
2222 null,
2223 AstFactory.blockFunctionBody2()));
1967 } 2224 }
1968 2225
1969 void test_visitConstructorDeclaration_singleInitializer() { 2226 void test_visitConstructorDeclaration_singleInitializer() {
1970 _assertSource("C() : a = b {}", AstFactory.constructorDeclaration2(null, 2227 _assertSource(
1971 null, AstFactory.identifier3("C"), null, 2228 "C() : a = b {}",
1972 AstFactory.formalParameterList(), [ 2229 AstFactory.constructorDeclaration2(
1973 AstFactory.constructorFieldInitializer( 2230 null,
1974 false, "a", AstFactory.identifier3("b")) 2231 null,
1975 ], AstFactory.blockFunctionBody2())); 2232 AstFactory.identifier3("C"),
2233 null,
2234 AstFactory.formalParameterList(),
2235 [
2236 AstFactory.constructorFieldInitializer(
2237 false, "a", AstFactory.identifier3("b"))
2238 ],
2239 AstFactory.blockFunctionBody2()));
1976 } 2240 }
1977 2241
1978 void test_visitConstructorDeclaration_withMetadata() { 2242 void test_visitConstructorDeclaration_withMetadata() {
1979 ConstructorDeclaration declaration = AstFactory.constructorDeclaration2( 2243 ConstructorDeclaration declaration = AstFactory.constructorDeclaration2(
1980 null, null, AstFactory.identifier3("C"), null, 2244 null,
1981 AstFactory.formalParameterList(), null, 2245 null,
2246 AstFactory.identifier3("C"),
2247 null,
2248 AstFactory.formalParameterList(),
2249 null,
1982 AstFactory.blockFunctionBody2()); 2250 AstFactory.blockFunctionBody2());
1983 declaration.metadata 2251 declaration.metadata
1984 .add(AstFactory.annotation(AstFactory.identifier3("deprecated"))); 2252 .add(AstFactory.annotation(AstFactory.identifier3("deprecated")));
1985 _assertSource("@deprecated C() {}", declaration); 2253 _assertSource("@deprecated C() {}", declaration);
1986 } 2254 }
1987 2255
1988 void test_visitConstructorFieldInitializer_withoutThis() { 2256 void test_visitConstructorFieldInitializer_withoutThis() {
1989 _assertSource("a = b", AstFactory.constructorFieldInitializer( 2257 _assertSource(
1990 false, "a", AstFactory.identifier3("b"))); 2258 "a = b",
2259 AstFactory.constructorFieldInitializer(
2260 false, "a", AstFactory.identifier3("b")));
1991 } 2261 }
1992 2262
1993 void test_visitConstructorFieldInitializer_withThis() { 2263 void test_visitConstructorFieldInitializer_withThis() {
1994 _assertSource("this.a = b", AstFactory.constructorFieldInitializer( 2264 _assertSource(
1995 true, "a", AstFactory.identifier3("b"))); 2265 "this.a = b",
2266 AstFactory.constructorFieldInitializer(
2267 true, "a", AstFactory.identifier3("b")));
1996 } 2268 }
1997 2269
1998 void test_visitConstructorName_named_prefix() { 2270 void test_visitConstructorName_named_prefix() {
1999 _assertSource("p.C.n", 2271 _assertSource("p.C.n",
2000 AstFactory.constructorName(AstFactory.typeName4("p.C.n"), null)); 2272 AstFactory.constructorName(AstFactory.typeName4("p.C.n"), null));
2001 } 2273 }
2002 2274
2003 void test_visitConstructorName_unnamed_noPrefix() { 2275 void test_visitConstructorName_unnamed_noPrefix() {
2004 _assertSource( 2276 _assertSource(
2005 "C", AstFactory.constructorName(AstFactory.typeName4("C"), null)); 2277 "C", AstFactory.constructorName(AstFactory.typeName4("C"), null));
2006 } 2278 }
2007 2279
2008 void test_visitConstructorName_unnamed_prefix() { 2280 void test_visitConstructorName_unnamed_prefix() {
2009 _assertSource("p.C", AstFactory.constructorName( 2281 _assertSource(
2010 AstFactory.typeName3(AstFactory.identifier5("p", "C")), null)); 2282 "p.C",
2283 AstFactory.constructorName(
2284 AstFactory.typeName3(AstFactory.identifier5("p", "C")), null));
2011 } 2285 }
2012 2286
2013 void test_visitContinueStatement_label() { 2287 void test_visitContinueStatement_label() {
2014 _assertSource("continue l;", AstFactory.continueStatement("l")); 2288 _assertSource("continue l;", AstFactory.continueStatement("l"));
2015 } 2289 }
2016 2290
2017 void test_visitContinueStatement_noLabel() { 2291 void test_visitContinueStatement_noLabel() {
2018 _assertSource("continue;", AstFactory.continueStatement()); 2292 _assertSource("continue;", AstFactory.continueStatement());
2019 } 2293 }
2020 2294
2021 void test_visitDefaultFormalParameter_named_noValue() { 2295 void test_visitDefaultFormalParameter_named_noValue() {
2022 _assertSource("p", AstFactory.namedFormalParameter( 2296 _assertSource(
2023 AstFactory.simpleFormalParameter3("p"), null)); 2297 "p",
2298 AstFactory.namedFormalParameter(
2299 AstFactory.simpleFormalParameter3("p"), null));
2024 } 2300 }
2025 2301
2026 void test_visitDefaultFormalParameter_named_value() { 2302 void test_visitDefaultFormalParameter_named_value() {
2027 _assertSource("p : 0", AstFactory.namedFormalParameter( 2303 _assertSource(
2028 AstFactory.simpleFormalParameter3("p"), AstFactory.integer(0))); 2304 "p : 0",
2305 AstFactory.namedFormalParameter(
2306 AstFactory.simpleFormalParameter3("p"), AstFactory.integer(0)));
2029 } 2307 }
2030 2308
2031 void test_visitDefaultFormalParameter_positional_noValue() { 2309 void test_visitDefaultFormalParameter_positional_noValue() {
2032 _assertSource("p", AstFactory.positionalFormalParameter( 2310 _assertSource(
2033 AstFactory.simpleFormalParameter3("p"), null)); 2311 "p",
2312 AstFactory.positionalFormalParameter(
2313 AstFactory.simpleFormalParameter3("p"), null));
2034 } 2314 }
2035 2315
2036 void test_visitDefaultFormalParameter_positional_value() { 2316 void test_visitDefaultFormalParameter_positional_value() {
2037 _assertSource("p = 0", AstFactory.positionalFormalParameter( 2317 _assertSource(
2038 AstFactory.simpleFormalParameter3("p"), AstFactory.integer(0))); 2318 "p = 0",
2319 AstFactory.positionalFormalParameter(
2320 AstFactory.simpleFormalParameter3("p"), AstFactory.integer(0)));
2039 } 2321 }
2040 2322
2041 void test_visitDoStatement() { 2323 void test_visitDoStatement() {
2042 _assertSource("do {} while (c);", AstFactory.doStatement( 2324 _assertSource(
2043 AstFactory.block(), AstFactory.identifier3("c"))); 2325 "do {} while (c);",
2326 AstFactory.doStatement(
2327 AstFactory.block(), AstFactory.identifier3("c")));
2044 } 2328 }
2045 2329
2046 void test_visitDoubleLiteral() { 2330 void test_visitDoubleLiteral() {
2047 _assertSource("4.2", AstFactory.doubleLiteral(4.2)); 2331 _assertSource("4.2", AstFactory.doubleLiteral(4.2));
2048 } 2332 }
2049 2333
2050 void test_visitEmptyFunctionBody() { 2334 void test_visitEmptyFunctionBody() {
2051 _assertSource(";", AstFactory.emptyFunctionBody()); 2335 _assertSource(";", AstFactory.emptyFunctionBody());
2052 } 2336 }
2053 2337
2054 void test_visitEmptyStatement() { 2338 void test_visitEmptyStatement() {
2055 _assertSource(";", AstFactory.emptyStatement()); 2339 _assertSource(";", AstFactory.emptyStatement());
2056 } 2340 }
2057 2341
2058 void test_visitEnumDeclaration_multiple() { 2342 void test_visitEnumDeclaration_multiple() {
2059 _assertSource( 2343 _assertSource(
2060 "enum E {ONE, TWO}", AstFactory.enumDeclaration2("E", ["ONE", "TWO"])); 2344 "enum E {ONE, TWO}", AstFactory.enumDeclaration2("E", ["ONE", "TWO"]));
2061 } 2345 }
2062 2346
2063 void test_visitEnumDeclaration_single() { 2347 void test_visitEnumDeclaration_single() {
2064 _assertSource("enum E {ONE}", AstFactory.enumDeclaration2("E", ["ONE"])); 2348 _assertSource("enum E {ONE}", AstFactory.enumDeclaration2("E", ["ONE"]));
2065 } 2349 }
2066 2350
2067 void test_visitExportDirective_combinator() { 2351 void test_visitExportDirective_combinator() {
2068 _assertSource("export 'a.dart' show A;", AstFactory.exportDirective2( 2352 _assertSource(
2069 "a.dart", [AstFactory.showCombinator([AstFactory.identifier3("A")])])); 2353 "export 'a.dart' show A;",
2354 AstFactory.exportDirective2("a.dart", [
2355 AstFactory.showCombinator([AstFactory.identifier3("A")])
2356 ]));
2070 } 2357 }
2071 2358
2072 void test_visitExportDirective_combinators() { 2359 void test_visitExportDirective_combinators() {
2073 _assertSource("export 'a.dart' show A hide B;", AstFactory.exportDirective2( 2360 _assertSource(
2074 "a.dart", [ 2361 "export 'a.dart' show A hide B;",
2075 AstFactory.showCombinator([AstFactory.identifier3("A")]), 2362 AstFactory.exportDirective2("a.dart", [
2076 AstFactory.hideCombinator([AstFactory.identifier3("B")]) 2363 AstFactory.showCombinator([AstFactory.identifier3("A")]),
2077 ])); 2364 AstFactory.hideCombinator([AstFactory.identifier3("B")])
2365 ]));
2078 } 2366 }
2079 2367
2080 void test_visitExportDirective_minimal() { 2368 void test_visitExportDirective_minimal() {
2081 _assertSource("export 'a.dart';", AstFactory.exportDirective2("a.dart")); 2369 _assertSource("export 'a.dart';", AstFactory.exportDirective2("a.dart"));
2082 } 2370 }
2083 2371
2084 void test_visitExportDirective_withMetadata() { 2372 void test_visitExportDirective_withMetadata() {
2085 ExportDirective directive = AstFactory.exportDirective2("a.dart"); 2373 ExportDirective directive = AstFactory.exportDirective2("a.dart");
2086 directive.metadata 2374 directive.metadata
2087 .add(AstFactory.annotation(AstFactory.identifier3("deprecated"))); 2375 .add(AstFactory.annotation(AstFactory.identifier3("deprecated")));
(...skipping 14 matching lines...) Expand all
2102 _assertSource( 2390 _assertSource(
2103 "a;", AstFactory.expressionStatement(AstFactory.identifier3("a"))); 2391 "a;", AstFactory.expressionStatement(AstFactory.identifier3("a")));
2104 } 2392 }
2105 2393
2106 void test_visitExtendsClause() { 2394 void test_visitExtendsClause() {
2107 _assertSource( 2395 _assertSource(
2108 "extends C", AstFactory.extendsClause(AstFactory.typeName4("C"))); 2396 "extends C", AstFactory.extendsClause(AstFactory.typeName4("C")));
2109 } 2397 }
2110 2398
2111 void test_visitFieldDeclaration_instance() { 2399 void test_visitFieldDeclaration_instance() {
2112 _assertSource("var a;", AstFactory.fieldDeclaration2( 2400 _assertSource(
2113 false, Keyword.VAR, [AstFactory.variableDeclaration("a")])); 2401 "var a;",
2402 AstFactory.fieldDeclaration2(
2403 false, Keyword.VAR, [AstFactory.variableDeclaration("a")]));
2114 } 2404 }
2115 2405
2116 void test_visitFieldDeclaration_static() { 2406 void test_visitFieldDeclaration_static() {
2117 _assertSource("static var a;", AstFactory.fieldDeclaration2( 2407 _assertSource(
2118 true, Keyword.VAR, [AstFactory.variableDeclaration("a")])); 2408 "static var a;",
2409 AstFactory.fieldDeclaration2(
2410 true, Keyword.VAR, [AstFactory.variableDeclaration("a")]));
2119 } 2411 }
2120 2412
2121 void test_visitFieldDeclaration_withMetadata() { 2413 void test_visitFieldDeclaration_withMetadata() {
2122 FieldDeclaration declaration = AstFactory.fieldDeclaration2( 2414 FieldDeclaration declaration = AstFactory.fieldDeclaration2(
2123 false, Keyword.VAR, [AstFactory.variableDeclaration("a")]); 2415 false, Keyword.VAR, [AstFactory.variableDeclaration("a")]);
2124 declaration.metadata 2416 declaration.metadata
2125 .add(AstFactory.annotation(AstFactory.identifier3("deprecated"))); 2417 .add(AstFactory.annotation(AstFactory.identifier3("deprecated")));
2126 _assertSource("@deprecated var a;", declaration); 2418 _assertSource("@deprecated var a;", declaration);
2127 } 2419 }
2128 2420
2129 void test_visitFieldFormalParameter_functionTyped() { 2421 void test_visitFieldFormalParameter_functionTyped() {
2130 _assertSource("A this.a(b)", AstFactory.fieldFormalParameter(null, 2422 _assertSource(
2131 AstFactory.typeName4("A"), "a", AstFactory 2423 "A this.a(b)",
2132 .formalParameterList([AstFactory.simpleFormalParameter3("b")]))); 2424 AstFactory.fieldFormalParameter(
2425 null,
2426 AstFactory.typeName4("A"),
2427 "a",
2428 AstFactory.formalParameterList(
2429 [AstFactory.simpleFormalParameter3("b")])));
2133 } 2430 }
2134 2431
2135 void test_visitFieldFormalParameter_functionTyped_typeParameters() { 2432 void test_visitFieldFormalParameter_functionTyped_typeParameters() {
2136 _assertSource("A this.a<E, F>(b)", new FieldFormalParameter(null, null, 2433 _assertSource(
2137 null, AstFactory.typeName4('A'), 2434 "A this.a<E, F>(b)",
2138 TokenFactory.tokenFromKeyword(Keyword.THIS), 2435 new FieldFormalParameter(
2139 TokenFactory.tokenFromType(TokenType.PERIOD), 2436 null,
2140 AstFactory.identifier3('a'), AstFactory.typeParameterList(['E', 'F']), 2437 null,
2141 AstFactory 2438 null,
2142 .formalParameterList([AstFactory.simpleFormalParameter3("b")]))); 2439 AstFactory.typeName4('A'),
2440 TokenFactory.tokenFromKeyword(Keyword.THIS),
2441 TokenFactory.tokenFromType(TokenType.PERIOD),
2442 AstFactory.identifier3('a'),
2443 AstFactory.typeParameterList(['E', 'F']),
2444 AstFactory.formalParameterList(
2445 [AstFactory.simpleFormalParameter3("b")])));
2143 } 2446 }
2144 2447
2145 void test_visitFieldFormalParameter_keyword() { 2448 void test_visitFieldFormalParameter_keyword() {
2146 _assertSource( 2449 _assertSource(
2147 "var this.a", AstFactory.fieldFormalParameter(Keyword.VAR, null, "a")); 2450 "var this.a", AstFactory.fieldFormalParameter(Keyword.VAR, null, "a"));
2148 } 2451 }
2149 2452
2150 void test_visitFieldFormalParameter_keywordAndType() { 2453 void test_visitFieldFormalParameter_keywordAndType() {
2151 _assertSource("final A this.a", AstFactory.fieldFormalParameter( 2454 _assertSource(
2152 Keyword.FINAL, AstFactory.typeName4("A"), "a")); 2455 "final A this.a",
2456 AstFactory.fieldFormalParameter(
2457 Keyword.FINAL, AstFactory.typeName4("A"), "a"));
2153 } 2458 }
2154 2459
2155 void test_visitFieldFormalParameter_type() { 2460 void test_visitFieldFormalParameter_type() {
2156 _assertSource("A this.a", 2461 _assertSource("A this.a",
2157 AstFactory.fieldFormalParameter(null, AstFactory.typeName4("A"), "a")); 2462 AstFactory.fieldFormalParameter(null, AstFactory.typeName4("A"), "a"));
2158 } 2463 }
2159 2464
2160 void test_visitForEachStatement_declared() { 2465 void test_visitForEachStatement_declared() {
2161 _assertSource("for (a in b) {}", AstFactory.forEachStatement( 2466 _assertSource(
2162 AstFactory.declaredIdentifier3("a"), AstFactory.identifier3("b"), 2467 "for (a in b) {}",
2163 AstFactory.block())); 2468 AstFactory.forEachStatement(AstFactory.declaredIdentifier3("a"),
2469 AstFactory.identifier3("b"), AstFactory.block()));
2164 } 2470 }
2165 2471
2166 void test_visitForEachStatement_variable() { 2472 void test_visitForEachStatement_variable() {
2167 _assertSource("for (a in b) {}", new ForEachStatement.withReference(null, 2473 _assertSource(
2168 TokenFactory.tokenFromKeyword(Keyword.FOR), 2474 "for (a in b) {}",
2169 TokenFactory.tokenFromType(TokenType.OPEN_PAREN), 2475 new ForEachStatement.withReference(
2170 AstFactory.identifier3("a"), TokenFactory.tokenFromKeyword(Keyword.IN), 2476 null,
2171 AstFactory.identifier3("b"), 2477 TokenFactory.tokenFromKeyword(Keyword.FOR),
2172 TokenFactory.tokenFromType(TokenType.CLOSE_PAREN), AstFactory.block())); 2478 TokenFactory.tokenFromType(TokenType.OPEN_PAREN),
2479 AstFactory.identifier3("a"),
2480 TokenFactory.tokenFromKeyword(Keyword.IN),
2481 AstFactory.identifier3("b"),
2482 TokenFactory.tokenFromType(TokenType.CLOSE_PAREN),
2483 AstFactory.block()));
2173 } 2484 }
2174 2485
2175 void test_visitForEachStatement_variable_await() { 2486 void test_visitForEachStatement_variable_await() {
2176 _assertSource("await for (a in b) {}", new ForEachStatement.withReference( 2487 _assertSource(
2177 TokenFactory.tokenFromString("await"), 2488 "await for (a in b) {}",
2178 TokenFactory.tokenFromKeyword(Keyword.FOR), 2489 new ForEachStatement.withReference(
2179 TokenFactory.tokenFromType(TokenType.OPEN_PAREN), 2490 TokenFactory.tokenFromString("await"),
2180 AstFactory.identifier3("a"), TokenFactory.tokenFromKeyword(Keyword.IN), 2491 TokenFactory.tokenFromKeyword(Keyword.FOR),
2181 AstFactory.identifier3("b"), 2492 TokenFactory.tokenFromType(TokenType.OPEN_PAREN),
2182 TokenFactory.tokenFromType(TokenType.CLOSE_PAREN), AstFactory.block())); 2493 AstFactory.identifier3("a"),
2494 TokenFactory.tokenFromKeyword(Keyword.IN),
2495 AstFactory.identifier3("b"),
2496 TokenFactory.tokenFromType(TokenType.CLOSE_PAREN),
2497 AstFactory.block()));
2183 } 2498 }
2184 2499
2185 void test_visitFormalParameterList_empty() { 2500 void test_visitFormalParameterList_empty() {
2186 _assertSource("()", AstFactory.formalParameterList()); 2501 _assertSource("()", AstFactory.formalParameterList());
2187 } 2502 }
2188 2503
2189 void test_visitFormalParameterList_n() { 2504 void test_visitFormalParameterList_n() {
2190 _assertSource("({a : 0})", AstFactory.formalParameterList([ 2505 _assertSource(
2191 AstFactory.namedFormalParameter( 2506 "({a : 0})",
2192 AstFactory.simpleFormalParameter3("a"), AstFactory.integer(0)) 2507 AstFactory.formalParameterList([
2193 ])); 2508 AstFactory.namedFormalParameter(
2509 AstFactory.simpleFormalParameter3("a"), AstFactory.integer(0))
2510 ]));
2194 } 2511 }
2195 2512
2196 void test_visitFormalParameterList_nn() { 2513 void test_visitFormalParameterList_nn() {
2197 _assertSource("({a : 0, b : 1})", AstFactory.formalParameterList([ 2514 _assertSource(
2198 AstFactory.namedFormalParameter( 2515 "({a : 0, b : 1})",
2199 AstFactory.simpleFormalParameter3("a"), AstFactory.integer(0)), 2516 AstFactory.formalParameterList([
2200 AstFactory.namedFormalParameter( 2517 AstFactory.namedFormalParameter(
2201 AstFactory.simpleFormalParameter3("b"), AstFactory.integer(1)) 2518 AstFactory.simpleFormalParameter3("a"), AstFactory.integer(0)),
2202 ])); 2519 AstFactory.namedFormalParameter(
2520 AstFactory.simpleFormalParameter3("b"), AstFactory.integer(1))
2521 ]));
2203 } 2522 }
2204 2523
2205 void test_visitFormalParameterList_p() { 2524 void test_visitFormalParameterList_p() {
2206 _assertSource("([a = 0])", AstFactory.formalParameterList([ 2525 _assertSource(
2207 AstFactory.positionalFormalParameter( 2526 "([a = 0])",
2208 AstFactory.simpleFormalParameter3("a"), AstFactory.integer(0)) 2527 AstFactory.formalParameterList([
2209 ])); 2528 AstFactory.positionalFormalParameter(
2529 AstFactory.simpleFormalParameter3("a"), AstFactory.integer(0))
2530 ]));
2210 } 2531 }
2211 2532
2212 void test_visitFormalParameterList_pp() { 2533 void test_visitFormalParameterList_pp() {
2213 _assertSource("([a = 0, b = 1])", AstFactory.formalParameterList([ 2534 _assertSource(
2214 AstFactory.positionalFormalParameter( 2535 "([a = 0, b = 1])",
2215 AstFactory.simpleFormalParameter3("a"), AstFactory.integer(0)), 2536 AstFactory.formalParameterList([
2216 AstFactory.positionalFormalParameter( 2537 AstFactory.positionalFormalParameter(
2217 AstFactory.simpleFormalParameter3("b"), AstFactory.integer(1)) 2538 AstFactory.simpleFormalParameter3("a"), AstFactory.integer(0)),
2218 ])); 2539 AstFactory.positionalFormalParameter(
2540 AstFactory.simpleFormalParameter3("b"), AstFactory.integer(1))
2541 ]));
2219 } 2542 }
2220 2543
2221 void test_visitFormalParameterList_r() { 2544 void test_visitFormalParameterList_r() {
2222 _assertSource("(a)", AstFactory 2545 _assertSource(
2223 .formalParameterList([AstFactory.simpleFormalParameter3("a")])); 2546 "(a)",
2547 AstFactory
2548 .formalParameterList([AstFactory.simpleFormalParameter3("a")]));
2224 } 2549 }
2225 2550
2226 void test_visitFormalParameterList_rn() { 2551 void test_visitFormalParameterList_rn() {
2227 _assertSource("(a, {b : 1})", AstFactory.formalParameterList([ 2552 _assertSource(
2228 AstFactory.simpleFormalParameter3("a"), 2553 "(a, {b : 1})",
2229 AstFactory.namedFormalParameter( 2554 AstFactory.formalParameterList([
2230 AstFactory.simpleFormalParameter3("b"), AstFactory.integer(1)) 2555 AstFactory.simpleFormalParameter3("a"),
2231 ])); 2556 AstFactory.namedFormalParameter(
2557 AstFactory.simpleFormalParameter3("b"), AstFactory.integer(1))
2558 ]));
2232 } 2559 }
2233 2560
2234 void test_visitFormalParameterList_rnn() { 2561 void test_visitFormalParameterList_rnn() {
2235 _assertSource("(a, {b : 1, c : 2})", AstFactory.formalParameterList([ 2562 _assertSource(
2236 AstFactory.simpleFormalParameter3("a"), 2563 "(a, {b : 1, c : 2})",
2237 AstFactory.namedFormalParameter( 2564 AstFactory.formalParameterList([
2238 AstFactory.simpleFormalParameter3("b"), AstFactory.integer(1)), 2565 AstFactory.simpleFormalParameter3("a"),
2239 AstFactory.namedFormalParameter( 2566 AstFactory.namedFormalParameter(
2240 AstFactory.simpleFormalParameter3("c"), AstFactory.integer(2)) 2567 AstFactory.simpleFormalParameter3("b"), AstFactory.integer(1)),
2241 ])); 2568 AstFactory.namedFormalParameter(
2569 AstFactory.simpleFormalParameter3("c"), AstFactory.integer(2))
2570 ]));
2242 } 2571 }
2243 2572
2244 void test_visitFormalParameterList_rp() { 2573 void test_visitFormalParameterList_rp() {
2245 _assertSource("(a, [b = 1])", AstFactory.formalParameterList([ 2574 _assertSource(
2246 AstFactory.simpleFormalParameter3("a"), 2575 "(a, [b = 1])",
2247 AstFactory.positionalFormalParameter( 2576 AstFactory.formalParameterList([
2248 AstFactory.simpleFormalParameter3("b"), AstFactory.integer(1)) 2577 AstFactory.simpleFormalParameter3("a"),
2249 ])); 2578 AstFactory.positionalFormalParameter(
2579 AstFactory.simpleFormalParameter3("b"), AstFactory.integer(1))
2580 ]));
2250 } 2581 }
2251 2582
2252 void test_visitFormalParameterList_rpp() { 2583 void test_visitFormalParameterList_rpp() {
2253 _assertSource("(a, [b = 1, c = 2])", AstFactory.formalParameterList([ 2584 _assertSource(
2254 AstFactory.simpleFormalParameter3("a"), 2585 "(a, [b = 1, c = 2])",
2255 AstFactory.positionalFormalParameter( 2586 AstFactory.formalParameterList([
2256 AstFactory.simpleFormalParameter3("b"), AstFactory.integer(1)), 2587 AstFactory.simpleFormalParameter3("a"),
2257 AstFactory.positionalFormalParameter( 2588 AstFactory.positionalFormalParameter(
2258 AstFactory.simpleFormalParameter3("c"), AstFactory.integer(2)) 2589 AstFactory.simpleFormalParameter3("b"), AstFactory.integer(1)),
2259 ])); 2590 AstFactory.positionalFormalParameter(
2591 AstFactory.simpleFormalParameter3("c"), AstFactory.integer(2))
2592 ]));
2260 } 2593 }
2261 2594
2262 void test_visitFormalParameterList_rr() { 2595 void test_visitFormalParameterList_rr() {
2263 _assertSource("(a, b)", AstFactory.formalParameterList([ 2596 _assertSource(
2264 AstFactory.simpleFormalParameter3("a"), 2597 "(a, b)",
2265 AstFactory.simpleFormalParameter3("b") 2598 AstFactory.formalParameterList([
2266 ])); 2599 AstFactory.simpleFormalParameter3("a"),
2600 AstFactory.simpleFormalParameter3("b")
2601 ]));
2267 } 2602 }
2268 2603
2269 void test_visitFormalParameterList_rrn() { 2604 void test_visitFormalParameterList_rrn() {
2270 _assertSource("(a, b, {c : 3})", AstFactory.formalParameterList([ 2605 _assertSource(
2271 AstFactory.simpleFormalParameter3("a"), 2606 "(a, b, {c : 3})",
2272 AstFactory.simpleFormalParameter3("b"), 2607 AstFactory.formalParameterList([
2273 AstFactory.namedFormalParameter( 2608 AstFactory.simpleFormalParameter3("a"),
2274 AstFactory.simpleFormalParameter3("c"), AstFactory.integer(3)) 2609 AstFactory.simpleFormalParameter3("b"),
2275 ])); 2610 AstFactory.namedFormalParameter(
2611 AstFactory.simpleFormalParameter3("c"), AstFactory.integer(3))
2612 ]));
2276 } 2613 }
2277 2614
2278 void test_visitFormalParameterList_rrnn() { 2615 void test_visitFormalParameterList_rrnn() {
2279 _assertSource("(a, b, {c : 3, d : 4})", AstFactory.formalParameterList([ 2616 _assertSource(
2280 AstFactory.simpleFormalParameter3("a"), 2617 "(a, b, {c : 3, d : 4})",
2281 AstFactory.simpleFormalParameter3("b"), 2618 AstFactory.formalParameterList([
2282 AstFactory.namedFormalParameter( 2619 AstFactory.simpleFormalParameter3("a"),
2283 AstFactory.simpleFormalParameter3("c"), AstFactory.integer(3)), 2620 AstFactory.simpleFormalParameter3("b"),
2284 AstFactory.namedFormalParameter( 2621 AstFactory.namedFormalParameter(
2285 AstFactory.simpleFormalParameter3("d"), AstFactory.integer(4)) 2622 AstFactory.simpleFormalParameter3("c"), AstFactory.integer(3)),
2286 ])); 2623 AstFactory.namedFormalParameter(
2624 AstFactory.simpleFormalParameter3("d"), AstFactory.integer(4))
2625 ]));
2287 } 2626 }
2288 2627
2289 void test_visitFormalParameterList_rrp() { 2628 void test_visitFormalParameterList_rrp() {
2290 _assertSource("(a, b, [c = 3])", AstFactory.formalParameterList([ 2629 _assertSource(
2291 AstFactory.simpleFormalParameter3("a"), 2630 "(a, b, [c = 3])",
2292 AstFactory.simpleFormalParameter3("b"), 2631 AstFactory.formalParameterList([
2293 AstFactory.positionalFormalParameter( 2632 AstFactory.simpleFormalParameter3("a"),
2294 AstFactory.simpleFormalParameter3("c"), AstFactory.integer(3)) 2633 AstFactory.simpleFormalParameter3("b"),
2295 ])); 2634 AstFactory.positionalFormalParameter(
2635 AstFactory.simpleFormalParameter3("c"), AstFactory.integer(3))
2636 ]));
2296 } 2637 }
2297 2638
2298 void test_visitFormalParameterList_rrpp() { 2639 void test_visitFormalParameterList_rrpp() {
2299 _assertSource("(a, b, [c = 3, d = 4])", AstFactory.formalParameterList([ 2640 _assertSource(
2300 AstFactory.simpleFormalParameter3("a"), 2641 "(a, b, [c = 3, d = 4])",
2301 AstFactory.simpleFormalParameter3("b"), 2642 AstFactory.formalParameterList([
2302 AstFactory.positionalFormalParameter( 2643 AstFactory.simpleFormalParameter3("a"),
2303 AstFactory.simpleFormalParameter3("c"), AstFactory.integer(3)), 2644 AstFactory.simpleFormalParameter3("b"),
2304 AstFactory.positionalFormalParameter( 2645 AstFactory.positionalFormalParameter(
2305 AstFactory.simpleFormalParameter3("d"), AstFactory.integer(4)) 2646 AstFactory.simpleFormalParameter3("c"), AstFactory.integer(3)),
2306 ])); 2647 AstFactory.positionalFormalParameter(
2648 AstFactory.simpleFormalParameter3("d"), AstFactory.integer(4))
2649 ]));
2307 } 2650 }
2308 2651
2309 void test_visitForStatement_c() { 2652 void test_visitForStatement_c() {
2310 _assertSource("for (; c;) {}", AstFactory.forStatement( 2653 _assertSource(
2311 null, AstFactory.identifier3("c"), null, AstFactory.block())); 2654 "for (; c;) {}",
2655 AstFactory.forStatement(
2656 null, AstFactory.identifier3("c"), null, AstFactory.block()));
2312 } 2657 }
2313 2658
2314 void test_visitForStatement_cu() { 2659 void test_visitForStatement_cu() {
2315 _assertSource("for (; c; u) {}", AstFactory.forStatement(null, 2660 _assertSource(
2316 AstFactory.identifier3("c"), [AstFactory.identifier3("u")], 2661 "for (; c; u) {}",
2317 AstFactory.block())); 2662 AstFactory.forStatement(null, AstFactory.identifier3("c"),
2663 [AstFactory.identifier3("u")], AstFactory.block()));
2318 } 2664 }
2319 2665
2320 void test_visitForStatement_e() { 2666 void test_visitForStatement_e() {
2321 _assertSource("for (e;;) {}", AstFactory.forStatement( 2667 _assertSource(
2322 AstFactory.identifier3("e"), null, null, AstFactory.block())); 2668 "for (e;;) {}",
2669 AstFactory.forStatement(
2670 AstFactory.identifier3("e"), null, null, AstFactory.block()));
2323 } 2671 }
2324 2672
2325 void test_visitForStatement_ec() { 2673 void test_visitForStatement_ec() {
2326 _assertSource("for (e; c;) {}", AstFactory.forStatement( 2674 _assertSource(
2327 AstFactory.identifier3("e"), AstFactory.identifier3("c"), null, 2675 "for (e; c;) {}",
2328 AstFactory.block())); 2676 AstFactory.forStatement(AstFactory.identifier3("e"),
2677 AstFactory.identifier3("c"), null, AstFactory.block()));
2329 } 2678 }
2330 2679
2331 void test_visitForStatement_ecu() { 2680 void test_visitForStatement_ecu() {
2332 _assertSource("for (e; c; u) {}", AstFactory.forStatement( 2681 _assertSource(
2333 AstFactory.identifier3("e"), AstFactory.identifier3("c"), 2682 "for (e; c; u) {}",
2334 [AstFactory.identifier3("u")], AstFactory.block())); 2683 AstFactory.forStatement(
2684 AstFactory.identifier3("e"),
2685 AstFactory.identifier3("c"),
2686 [AstFactory.identifier3("u")],
2687 AstFactory.block()));
2335 } 2688 }
2336 2689
2337 void test_visitForStatement_eu() { 2690 void test_visitForStatement_eu() {
2338 _assertSource("for (e;; u) {}", AstFactory.forStatement( 2691 _assertSource(
2339 AstFactory.identifier3("e"), null, [AstFactory.identifier3("u")], 2692 "for (e;; u) {}",
2340 AstFactory.block())); 2693 AstFactory.forStatement(AstFactory.identifier3("e"), null,
2694 [AstFactory.identifier3("u")], AstFactory.block()));
2341 } 2695 }
2342 2696
2343 void test_visitForStatement_i() { 2697 void test_visitForStatement_i() {
2344 _assertSource("for (var i;;) {}", AstFactory.forStatement2(AstFactory 2698 _assertSource(
2345 .variableDeclarationList2( 2699 "for (var i;;) {}",
2346 Keyword.VAR, [AstFactory.variableDeclaration("i")]), null, null, 2700 AstFactory.forStatement2(
2347 AstFactory.block())); 2701 AstFactory.variableDeclarationList2(
2702 Keyword.VAR, [AstFactory.variableDeclaration("i")]),
2703 null,
2704 null,
2705 AstFactory.block()));
2348 } 2706 }
2349 2707
2350 void test_visitForStatement_ic() { 2708 void test_visitForStatement_ic() {
2351 _assertSource("for (var i; c;) {}", AstFactory.forStatement2(AstFactory 2709 _assertSource(
2352 .variableDeclarationList2( 2710 "for (var i; c;) {}",
2353 Keyword.VAR, [AstFactory.variableDeclaration("i")]), 2711 AstFactory.forStatement2(
2354 AstFactory.identifier3("c"), null, AstFactory.block())); 2712 AstFactory.variableDeclarationList2(
2713 Keyword.VAR, [AstFactory.variableDeclaration("i")]),
2714 AstFactory.identifier3("c"),
2715 null,
2716 AstFactory.block()));
2355 } 2717 }
2356 2718
2357 void test_visitForStatement_icu() { 2719 void test_visitForStatement_icu() {
2358 _assertSource("for (var i; c; u) {}", AstFactory.forStatement2(AstFactory 2720 _assertSource(
2359 .variableDeclarationList2( 2721 "for (var i; c; u) {}",
2360 Keyword.VAR, [AstFactory.variableDeclaration("i")]), 2722 AstFactory.forStatement2(
2361 AstFactory.identifier3("c"), [AstFactory.identifier3("u")], 2723 AstFactory.variableDeclarationList2(
2362 AstFactory.block())); 2724 Keyword.VAR, [AstFactory.variableDeclaration("i")]),
2725 AstFactory.identifier3("c"),
2726 [AstFactory.identifier3("u")],
2727 AstFactory.block()));
2363 } 2728 }
2364 2729
2365 void test_visitForStatement_iu() { 2730 void test_visitForStatement_iu() {
2366 _assertSource("for (var i;; u) {}", AstFactory.forStatement2(AstFactory 2731 _assertSource(
2367 .variableDeclarationList2( 2732 "for (var i;; u) {}",
2368 Keyword.VAR, [AstFactory.variableDeclaration("i")]), null, 2733 AstFactory.forStatement2(
2369 [AstFactory.identifier3("u")], AstFactory.block())); 2734 AstFactory.variableDeclarationList2(
2735 Keyword.VAR, [AstFactory.variableDeclaration("i")]),
2736 null,
2737 [AstFactory.identifier3("u")],
2738 AstFactory.block()));
2370 } 2739 }
2371 2740
2372 void test_visitForStatement_u() { 2741 void test_visitForStatement_u() {
2373 _assertSource("for (;; u) {}", AstFactory.forStatement( 2742 _assertSource(
2374 null, null, [AstFactory.identifier3("u")], AstFactory.block())); 2743 "for (;; u) {}",
2744 AstFactory.forStatement(
2745 null, null, [AstFactory.identifier3("u")], AstFactory.block()));
2746 }
2747
2748 void test_visitFunctionDeclaration_external() {
2749 FunctionDeclaration functionDeclaration = AstFactory.functionDeclaration(
2750 null,
2751 null,
2752 "f",
2753 AstFactory.functionExpression2(
2754 AstFactory.formalParameterList(), AstFactory.emptyFunctionBody()));
2755 functionDeclaration.externalKeyword =
2756 TokenFactory.tokenFromKeyword(Keyword.EXTERNAL);
2757 _assertSource("external f();", functionDeclaration);
2375 } 2758 }
2376 2759
2377 void test_visitFunctionDeclaration_getter() { 2760 void test_visitFunctionDeclaration_getter() {
2378 _assertSource("get f() {}", AstFactory.functionDeclaration( 2761 _assertSource(
2379 null, Keyword.GET, "f", AstFactory.functionExpression())); 2762 "get f() {}",
2763 AstFactory.functionDeclaration(
2764 null, Keyword.GET, "f", AstFactory.functionExpression()));
2380 } 2765 }
2381 2766
2382 void test_visitFunctionDeclaration_local_blockBody() { 2767 void test_visitFunctionDeclaration_local_blockBody() {
2383 FunctionDeclaration f = AstFactory.functionDeclaration( 2768 FunctionDeclaration f = AstFactory.functionDeclaration(
2384 null, null, "f", AstFactory.functionExpression()); 2769 null, null, "f", AstFactory.functionExpression());
2385 FunctionDeclarationStatement fStatement = 2770 FunctionDeclarationStatement fStatement =
2386 new FunctionDeclarationStatement(f); 2771 new FunctionDeclarationStatement(f);
2387 _assertSource("main() {f() {} 42;}", AstFactory.functionDeclaration(null, 2772 _assertSource(
2388 null, "main", AstFactory.functionExpression2( 2773 "main() {f() {} 42;}",
2389 AstFactory.formalParameterList(), AstFactory.blockFunctionBody2([ 2774 AstFactory.functionDeclaration(
2390 fStatement, 2775 null,
2391 AstFactory.expressionStatement(AstFactory.integer(42)) 2776 null,
2392 ])))); 2777 "main",
2778 AstFactory.functionExpression2(
2779 AstFactory.formalParameterList(),
2780 AstFactory.blockFunctionBody2([
2781 fStatement,
2782 AstFactory.expressionStatement(AstFactory.integer(42))
2783 ]))));
2393 } 2784 }
2394 2785
2395 void test_visitFunctionDeclaration_local_expressionBody() { 2786 void test_visitFunctionDeclaration_local_expressionBody() {
2396 FunctionDeclaration f = AstFactory.functionDeclaration(null, null, "f", 2787 FunctionDeclaration f = AstFactory.functionDeclaration(
2788 null,
2789 null,
2790 "f",
2397 AstFactory.functionExpression2(AstFactory.formalParameterList(), 2791 AstFactory.functionExpression2(AstFactory.formalParameterList(),
2398 AstFactory.expressionFunctionBody(AstFactory.integer(1)))); 2792 AstFactory.expressionFunctionBody(AstFactory.integer(1))));
2399 FunctionDeclarationStatement fStatement = 2793 FunctionDeclarationStatement fStatement =
2400 new FunctionDeclarationStatement(f); 2794 new FunctionDeclarationStatement(f);
2401 _assertSource("main() {f() => 1; 2;}", AstFactory.functionDeclaration(null, 2795 _assertSource(
2402 null, "main", AstFactory.functionExpression2( 2796 "main() {f() => 1; 2;}",
2403 AstFactory.formalParameterList(), AstFactory.blockFunctionBody2([ 2797 AstFactory.functionDeclaration(
2404 fStatement, 2798 null,
2405 AstFactory.expressionStatement(AstFactory.integer(2)) 2799 null,
2406 ])))); 2800 "main",
2801 AstFactory.functionExpression2(
2802 AstFactory.formalParameterList(),
2803 AstFactory.blockFunctionBody2([
2804 fStatement,
2805 AstFactory.expressionStatement(AstFactory.integer(2))
2806 ]))));
2407 } 2807 }
2408 2808
2409 void test_visitFunctionDeclaration_normal() { 2809 void test_visitFunctionDeclaration_normal() {
2410 _assertSource("f() {}", AstFactory.functionDeclaration( 2810 _assertSource(
2411 null, null, "f", AstFactory.functionExpression())); 2811 "f() {}",
2812 AstFactory.functionDeclaration(
2813 null, null, "f", AstFactory.functionExpression()));
2412 } 2814 }
2413 2815
2414 void test_visitFunctionDeclaration_setter() { 2816 void test_visitFunctionDeclaration_setter() {
2415 _assertSource("set f() {}", AstFactory.functionDeclaration( 2817 _assertSource(
2416 null, Keyword.SET, "f", AstFactory.functionExpression())); 2818 "set f() {}",
2819 AstFactory.functionDeclaration(
2820 null, Keyword.SET, "f", AstFactory.functionExpression()));
2417 } 2821 }
2418 2822
2419 void test_visitFunctionDeclaration_typeParameters() { 2823 void test_visitFunctionDeclaration_typeParameters() {
2420 _assertSource("f<E>() {}", AstFactory.functionDeclaration(null, null, "f", 2824 _assertSource(
2421 AstFactory.functionExpression3(AstFactory.typeParameterList(['E']), 2825 "f<E>() {}",
2422 AstFactory.formalParameterList(), 2826 AstFactory.functionDeclaration(
2423 AstFactory.blockFunctionBody2()))); 2827 null,
2828 null,
2829 "f",
2830 AstFactory.functionExpression3(
2831 AstFactory.typeParameterList(['E']),
2832 AstFactory.formalParameterList(),
2833 AstFactory.blockFunctionBody2())));
2424 } 2834 }
2425 2835
2426 void test_visitFunctionDeclaration_withMetadata() { 2836 void test_visitFunctionDeclaration_withMetadata() {
2427 FunctionDeclaration declaration = AstFactory.functionDeclaration( 2837 FunctionDeclaration declaration = AstFactory.functionDeclaration(
2428 null, null, "f", AstFactory.functionExpression()); 2838 null, null, "f", AstFactory.functionExpression());
2429 declaration.metadata 2839 declaration.metadata
2430 .add(AstFactory.annotation(AstFactory.identifier3("deprecated"))); 2840 .add(AstFactory.annotation(AstFactory.identifier3("deprecated")));
2431 _assertSource("@deprecated f() {}", declaration); 2841 _assertSource("@deprecated f() {}", declaration);
2432 } 2842 }
2433 2843
2434 void test_visitFunctionDeclarationStatement() { 2844 void test_visitFunctionDeclarationStatement() {
2435 _assertSource("f() {}", AstFactory.functionDeclarationStatement( 2845 _assertSource(
2436 null, null, "f", AstFactory.functionExpression())); 2846 "f() {}",
2847 AstFactory.functionDeclarationStatement(
2848 null, null, "f", AstFactory.functionExpression()));
2437 } 2849 }
2438 2850
2439 void test_visitFunctionExpression() { 2851 void test_visitFunctionExpression() {
2440 _assertSource("() {}", AstFactory.functionExpression()); 2852 _assertSource("() {}", AstFactory.functionExpression());
2441 } 2853 }
2442 2854
2443 void test_visitFunctionExpression_typeParameters() { 2855 void test_visitFunctionExpression_typeParameters() {
2444 _assertSource("<E>() {}", AstFactory.functionExpression3( 2856 _assertSource(
2445 AstFactory.typeParameterList(['E']), AstFactory.formalParameterList(), 2857 "<E>() {}",
2446 AstFactory.blockFunctionBody2())); 2858 AstFactory.functionExpression3(AstFactory.typeParameterList(['E']),
2859 AstFactory.formalParameterList(), AstFactory.blockFunctionBody2()));
2447 } 2860 }
2448 2861
2449 void test_visitFunctionExpressionInvocation_minimal() { 2862 void test_visitFunctionExpressionInvocation_minimal() {
2450 _assertSource("f()", 2863 _assertSource("f()",
2451 AstFactory.functionExpressionInvocation(AstFactory.identifier3("f"))); 2864 AstFactory.functionExpressionInvocation(AstFactory.identifier3("f")));
2452 } 2865 }
2453 2866
2454 void test_visitFunctionExpressionInvocation_typeArguments() { 2867 void test_visitFunctionExpressionInvocation_typeArguments() {
2455 _assertSource("f<A>()", AstFactory.functionExpressionInvocation2( 2868 _assertSource(
2456 AstFactory.identifier3("f"), 2869 "f<A>()",
2457 AstFactory.typeArgumentList([AstFactory.typeName4('A')]))); 2870 AstFactory.functionExpressionInvocation2(AstFactory.identifier3("f"),
2871 AstFactory.typeArgumentList([AstFactory.typeName4('A')])));
2458 } 2872 }
2459 2873
2460 void test_visitFunctionTypeAlias_generic() { 2874 void test_visitFunctionTypeAlias_generic() {
2461 _assertSource("typedef A F<B>();", AstFactory.typeAlias( 2875 _assertSource(
2462 AstFactory.typeName4("A"), "F", AstFactory.typeParameterList(["B"]), 2876 "typedef A F<B>();",
2463 AstFactory.formalParameterList())); 2877 AstFactory.typeAlias(
2878 AstFactory.typeName4("A"),
2879 "F",
2880 AstFactory.typeParameterList(["B"]),
2881 AstFactory.formalParameterList()));
2464 } 2882 }
2465 2883
2466 void test_visitFunctionTypeAlias_nonGeneric() { 2884 void test_visitFunctionTypeAlias_nonGeneric() {
2467 _assertSource("typedef A F();", AstFactory.typeAlias( 2885 _assertSource(
2468 AstFactory.typeName4("A"), "F", null, 2886 "typedef A F();",
2469 AstFactory.formalParameterList())); 2887 AstFactory.typeAlias(AstFactory.typeName4("A"), "F", null,
2888 AstFactory.formalParameterList()));
2470 } 2889 }
2471 2890
2472 void test_visitFunctionTypeAlias_withMetadata() { 2891 void test_visitFunctionTypeAlias_withMetadata() {
2473 FunctionTypeAlias declaration = AstFactory.typeAlias( 2892 FunctionTypeAlias declaration = AstFactory.typeAlias(
2474 AstFactory.typeName4("A"), "F", null, AstFactory.formalParameterList()); 2893 AstFactory.typeName4("A"), "F", null, AstFactory.formalParameterList());
2475 declaration.metadata 2894 declaration.metadata
2476 .add(AstFactory.annotation(AstFactory.identifier3("deprecated"))); 2895 .add(AstFactory.annotation(AstFactory.identifier3("deprecated")));
2477 _assertSource("@deprecated typedef A F();", declaration); 2896 _assertSource("@deprecated typedef A F();", declaration);
2478 } 2897 }
2479 2898
2480 void test_visitFunctionTypedFormalParameter_noType() { 2899 void test_visitFunctionTypedFormalParameter_noType() {
2481 _assertSource("f()", AstFactory.functionTypedFormalParameter(null, "f")); 2900 _assertSource("f()", AstFactory.functionTypedFormalParameter(null, "f"));
2482 } 2901 }
2483 2902
2484 void test_visitFunctionTypedFormalParameter_type() { 2903 void test_visitFunctionTypedFormalParameter_type() {
2485 _assertSource("T f()", AstFactory.functionTypedFormalParameter( 2904 _assertSource(
2486 AstFactory.typeName4("T"), "f")); 2905 "T f()",
2906 AstFactory.functionTypedFormalParameter(
2907 AstFactory.typeName4("T"), "f"));
2487 } 2908 }
2488 2909
2489 void test_visitFunctionTypedFormalParameter_typeParameters() { 2910 void test_visitFunctionTypedFormalParameter_typeParameters() {
2490 _assertSource("T f<E>()", new FunctionTypedFormalParameter(null, null, 2911 _assertSource(
2491 AstFactory.typeName4("T"), AstFactory.identifier3('f'), 2912 "T f<E>()",
2492 AstFactory.typeParameterList(['E']), 2913 new FunctionTypedFormalParameter(
2493 AstFactory.formalParameterList([]))); 2914 null,
2915 null,
2916 AstFactory.typeName4("T"),
2917 AstFactory.identifier3('f'),
2918 AstFactory.typeParameterList(['E']),
2919 AstFactory.formalParameterList([])));
2494 } 2920 }
2495 2921
2496 void test_visitIfStatement_withElse() { 2922 void test_visitIfStatement_withElse() {
2497 _assertSource("if (c) {} else {}", AstFactory.ifStatement2( 2923 _assertSource(
2498 AstFactory.identifier3("c"), AstFactory.block(), AstFactory.block())); 2924 "if (c) {} else {}",
2925 AstFactory.ifStatement2(AstFactory.identifier3("c"), AstFactory.block(),
2926 AstFactory.block()));
2499 } 2927 }
2500 2928
2501 void test_visitIfStatement_withoutElse() { 2929 void test_visitIfStatement_withoutElse() {
2502 _assertSource("if (c) {}", AstFactory.ifStatement( 2930 _assertSource(
2503 AstFactory.identifier3("c"), AstFactory.block())); 2931 "if (c) {}",
2932 AstFactory.ifStatement(
2933 AstFactory.identifier3("c"), AstFactory.block()));
2504 } 2934 }
2505 2935
2506 void test_visitImplementsClause_multiple() { 2936 void test_visitImplementsClause_multiple() {
2507 _assertSource("implements A, B", AstFactory.implementsClause( 2937 _assertSource(
2508 [AstFactory.typeName4("A"), AstFactory.typeName4("B")])); 2938 "implements A, B",
2939 AstFactory.implementsClause(
2940 [AstFactory.typeName4("A"), AstFactory.typeName4("B")]));
2509 } 2941 }
2510 2942
2511 void test_visitImplementsClause_single() { 2943 void test_visitImplementsClause_single() {
2512 _assertSource("implements A", 2944 _assertSource("implements A",
2513 AstFactory.implementsClause([AstFactory.typeName4("A")])); 2945 AstFactory.implementsClause([AstFactory.typeName4("A")]));
2514 } 2946 }
2515 2947
2516 void test_visitImportDirective_combinator() { 2948 void test_visitImportDirective_combinator() {
2517 _assertSource("import 'a.dart' show A;", AstFactory.importDirective3( 2949 _assertSource(
2518 "a.dart", null, 2950 "import 'a.dart' show A;",
2519 [AstFactory.showCombinator([AstFactory.identifier3("A")])])); 2951 AstFactory.importDirective3("a.dart", null, [
2952 AstFactory.showCombinator([AstFactory.identifier3("A")])
2953 ]));
2520 } 2954 }
2521 2955
2522 void test_visitImportDirective_combinators() { 2956 void test_visitImportDirective_combinators() {
2523 _assertSource("import 'a.dart' show A hide B;", AstFactory.importDirective3( 2957 _assertSource(
2524 "a.dart", null, [ 2958 "import 'a.dart' show A hide B;",
2525 AstFactory.showCombinator([AstFactory.identifier3("A")]), 2959 AstFactory.importDirective3("a.dart", null, [
2526 AstFactory.hideCombinator([AstFactory.identifier3("B")]) 2960 AstFactory.showCombinator([AstFactory.identifier3("A")]),
2527 ])); 2961 AstFactory.hideCombinator([AstFactory.identifier3("B")])
2962 ]));
2528 } 2963 }
2529 2964
2530 void test_visitImportDirective_deferred() { 2965 void test_visitImportDirective_deferred() {
2531 _assertSource("import 'a.dart' deferred as p;", 2966 _assertSource("import 'a.dart' deferred as p;",
2532 AstFactory.importDirective2("a.dart", true, "p")); 2967 AstFactory.importDirective2("a.dart", true, "p"));
2533 } 2968 }
2534 2969
2535 void test_visitImportDirective_minimal() { 2970 void test_visitImportDirective_minimal() {
2536 _assertSource( 2971 _assertSource(
2537 "import 'a.dart';", AstFactory.importDirective3("a.dart", null)); 2972 "import 'a.dart';", AstFactory.importDirective3("a.dart", null));
2538 } 2973 }
2539 2974
2540 void test_visitImportDirective_prefix() { 2975 void test_visitImportDirective_prefix() {
2541 _assertSource( 2976 _assertSource(
2542 "import 'a.dart' as p;", AstFactory.importDirective3("a.dart", "p")); 2977 "import 'a.dart' as p;", AstFactory.importDirective3("a.dart", "p"));
2543 } 2978 }
2544 2979
2545 void test_visitImportDirective_prefix_combinator() { 2980 void test_visitImportDirective_prefix_combinator() {
2546 _assertSource("import 'a.dart' as p show A;", AstFactory.importDirective3( 2981 _assertSource(
2547 "a.dart", "p", 2982 "import 'a.dart' as p show A;",
2548 [AstFactory.showCombinator([AstFactory.identifier3("A")])])); 2983 AstFactory.importDirective3("a.dart", "p", [
2984 AstFactory.showCombinator([AstFactory.identifier3("A")])
2985 ]));
2549 } 2986 }
2550 2987
2551 void test_visitImportDirective_prefix_combinators() { 2988 void test_visitImportDirective_prefix_combinators() {
2552 _assertSource("import 'a.dart' as p show A hide B;", AstFactory 2989 _assertSource(
2553 .importDirective3("a.dart", "p", [ 2990 "import 'a.dart' as p show A hide B;",
2554 AstFactory.showCombinator([AstFactory.identifier3("A")]), 2991 AstFactory.importDirective3("a.dart", "p", [
2555 AstFactory.hideCombinator([AstFactory.identifier3("B")]) 2992 AstFactory.showCombinator([AstFactory.identifier3("A")]),
2556 ])); 2993 AstFactory.hideCombinator([AstFactory.identifier3("B")])
2994 ]));
2557 } 2995 }
2558 2996
2559 void test_visitImportDirective_withMetadata() { 2997 void test_visitImportDirective_withMetadata() {
2560 ImportDirective directive = AstFactory.importDirective3("a.dart", null); 2998 ImportDirective directive = AstFactory.importDirective3("a.dart", null);
2561 directive.metadata 2999 directive.metadata
2562 .add(AstFactory.annotation(AstFactory.identifier3("deprecated"))); 3000 .add(AstFactory.annotation(AstFactory.identifier3("deprecated")));
2563 _assertSource("@deprecated import 'a.dart';", directive); 3001 _assertSource("@deprecated import 'a.dart';", directive);
2564 } 3002 }
2565 3003
2566 void test_visitImportHideCombinator_multiple() { 3004 void test_visitImportHideCombinator_multiple() {
2567 _assertSource("hide a, b", AstFactory.hideCombinator( 3005 _assertSource(
2568 [AstFactory.identifier3("a"), AstFactory.identifier3("b")])); 3006 "hide a, b",
3007 AstFactory.hideCombinator(
3008 [AstFactory.identifier3("a"), AstFactory.identifier3("b")]));
2569 } 3009 }
2570 3010
2571 void test_visitImportHideCombinator_single() { 3011 void test_visitImportHideCombinator_single() {
2572 _assertSource( 3012 _assertSource(
2573 "hide a", AstFactory.hideCombinator([AstFactory.identifier3("a")])); 3013 "hide a", AstFactory.hideCombinator([AstFactory.identifier3("a")]));
2574 } 3014 }
2575 3015
2576 void test_visitImportShowCombinator_multiple() { 3016 void test_visitImportShowCombinator_multiple() {
2577 _assertSource("show a, b", AstFactory.showCombinator( 3017 _assertSource(
2578 [AstFactory.identifier3("a"), AstFactory.identifier3("b")])); 3018 "show a, b",
3019 AstFactory.showCombinator(
3020 [AstFactory.identifier3("a"), AstFactory.identifier3("b")]));
2579 } 3021 }
2580 3022
2581 void test_visitImportShowCombinator_single() { 3023 void test_visitImportShowCombinator_single() {
2582 _assertSource( 3024 _assertSource(
2583 "show a", AstFactory.showCombinator([AstFactory.identifier3("a")])); 3025 "show a", AstFactory.showCombinator([AstFactory.identifier3("a")]));
2584 } 3026 }
2585 3027
2586 void test_visitIndexExpression() { 3028 void test_visitIndexExpression() {
2587 _assertSource("a[i]", AstFactory.indexExpression( 3029 _assertSource(
2588 AstFactory.identifier3("a"), AstFactory.identifier3("i"))); 3030 "a[i]",
3031 AstFactory.indexExpression(
3032 AstFactory.identifier3("a"), AstFactory.identifier3("i")));
2589 } 3033 }
2590 3034
2591 void test_visitInstanceCreationExpression_const() { 3035 void test_visitInstanceCreationExpression_const() {
2592 _assertSource("const C()", AstFactory.instanceCreationExpression2( 3036 _assertSource(
2593 Keyword.CONST, AstFactory.typeName4("C"))); 3037 "const C()",
3038 AstFactory.instanceCreationExpression2(
3039 Keyword.CONST, AstFactory.typeName4("C")));
2594 } 3040 }
2595 3041
2596 void test_visitInstanceCreationExpression_named() { 3042 void test_visitInstanceCreationExpression_named() {
2597 _assertSource("new C.c()", AstFactory.instanceCreationExpression3( 3043 _assertSource(
2598 Keyword.NEW, AstFactory.typeName4("C"), "c")); 3044 "new C.c()",
3045 AstFactory.instanceCreationExpression3(
3046 Keyword.NEW, AstFactory.typeName4("C"), "c"));
2599 } 3047 }
2600 3048
2601 void test_visitInstanceCreationExpression_unnamed() { 3049 void test_visitInstanceCreationExpression_unnamed() {
2602 _assertSource("new C()", AstFactory.instanceCreationExpression2( 3050 _assertSource(
2603 Keyword.NEW, AstFactory.typeName4("C"))); 3051 "new C()",
3052 AstFactory.instanceCreationExpression2(
3053 Keyword.NEW, AstFactory.typeName4("C")));
2604 } 3054 }
2605 3055
2606 void test_visitIntegerLiteral() { 3056 void test_visitIntegerLiteral() {
2607 _assertSource("42", AstFactory.integer(42)); 3057 _assertSource("42", AstFactory.integer(42));
2608 } 3058 }
2609 3059
2610 void test_visitInterpolationExpression_expression() { 3060 void test_visitInterpolationExpression_expression() {
2611 _assertSource("\${a}", 3061 _assertSource("\${a}",
2612 AstFactory.interpolationExpression(AstFactory.identifier3("a"))); 3062 AstFactory.interpolationExpression(AstFactory.identifier3("a")));
2613 } 3063 }
2614 3064
2615 void test_visitInterpolationExpression_identifier() { 3065 void test_visitInterpolationExpression_identifier() {
2616 _assertSource("\$a", AstFactory.interpolationExpression2("a")); 3066 _assertSource("\$a", AstFactory.interpolationExpression2("a"));
2617 } 3067 }
2618 3068
2619 void test_visitInterpolationString() { 3069 void test_visitInterpolationString() {
2620 _assertSource("'x", AstFactory.interpolationString("'x", "x")); 3070 _assertSource("'x", AstFactory.interpolationString("'x", "x"));
2621 } 3071 }
2622 3072
2623 void test_visitIsExpression_negated() { 3073 void test_visitIsExpression_negated() {
2624 _assertSource("a is! C", AstFactory.isExpression( 3074 _assertSource(
2625 AstFactory.identifier3("a"), true, AstFactory.typeName4("C"))); 3075 "a is! C",
3076 AstFactory.isExpression(
3077 AstFactory.identifier3("a"), true, AstFactory.typeName4("C")));
2626 } 3078 }
2627 3079
2628 void test_visitIsExpression_normal() { 3080 void test_visitIsExpression_normal() {
2629 _assertSource("a is C", AstFactory.isExpression( 3081 _assertSource(
2630 AstFactory.identifier3("a"), false, AstFactory.typeName4("C"))); 3082 "a is C",
3083 AstFactory.isExpression(
3084 AstFactory.identifier3("a"), false, AstFactory.typeName4("C")));
2631 } 3085 }
2632 3086
2633 void test_visitLabel() { 3087 void test_visitLabel() {
2634 _assertSource("a:", AstFactory.label2("a")); 3088 _assertSource("a:", AstFactory.label2("a"));
2635 } 3089 }
2636 3090
2637 void test_visitLabeledStatement_multiple() { 3091 void test_visitLabeledStatement_multiple() {
2638 _assertSource("a: b: return;", AstFactory.labeledStatement([ 3092 _assertSource(
2639 AstFactory.label2("a"), 3093 "a: b: return;",
2640 AstFactory.label2("b") 3094 AstFactory.labeledStatement(
2641 ], AstFactory.returnStatement())); 3095 [AstFactory.label2("a"), AstFactory.label2("b")],
3096 AstFactory.returnStatement()));
2642 } 3097 }
2643 3098
2644 void test_visitLabeledStatement_single() { 3099 void test_visitLabeledStatement_single() {
2645 _assertSource("a: return;", AstFactory.labeledStatement( 3100 _assertSource(
2646 [AstFactory.label2("a")], AstFactory.returnStatement())); 3101 "a: return;",
3102 AstFactory.labeledStatement(
3103 [AstFactory.label2("a")], AstFactory.returnStatement()));
2647 } 3104 }
2648 3105
2649 void test_visitLibraryDirective() { 3106 void test_visitLibraryDirective() {
2650 _assertSource("library l;", AstFactory.libraryDirective2("l")); 3107 _assertSource("library l;", AstFactory.libraryDirective2("l"));
2651 } 3108 }
2652 3109
2653 void test_visitLibraryDirective_withMetadata() { 3110 void test_visitLibraryDirective_withMetadata() {
2654 LibraryDirective directive = AstFactory.libraryDirective2("l"); 3111 LibraryDirective directive = AstFactory.libraryDirective2("l");
2655 directive.metadata 3112 directive.metadata
2656 .add(AstFactory.annotation(AstFactory.identifier3("deprecated"))); 3113 .add(AstFactory.annotation(AstFactory.identifier3("deprecated")));
2657 _assertSource("@deprecated library l;", directive); 3114 _assertSource("@deprecated library l;", directive);
2658 } 3115 }
2659 3116
2660 void test_visitLibraryIdentifier_multiple() { 3117 void test_visitLibraryIdentifier_multiple() {
2661 _assertSource("a.b.c", AstFactory.libraryIdentifier([ 3118 _assertSource(
2662 AstFactory.identifier3("a"), 3119 "a.b.c",
2663 AstFactory.identifier3("b"), 3120 AstFactory.libraryIdentifier([
2664 AstFactory.identifier3("c") 3121 AstFactory.identifier3("a"),
2665 ])); 3122 AstFactory.identifier3("b"),
3123 AstFactory.identifier3("c")
3124 ]));
2666 } 3125 }
2667 3126
2668 void test_visitLibraryIdentifier_single() { 3127 void test_visitLibraryIdentifier_single() {
2669 _assertSource( 3128 _assertSource(
2670 "a", AstFactory.libraryIdentifier([AstFactory.identifier3("a")])); 3129 "a", AstFactory.libraryIdentifier([AstFactory.identifier3("a")]));
2671 } 3130 }
2672 3131
2673 void test_visitListLiteral_const() { 3132 void test_visitListLiteral_const() {
2674 _assertSource("const []", AstFactory.listLiteral2(Keyword.CONST, null)); 3133 _assertSource("const []", AstFactory.listLiteral2(Keyword.CONST, null));
2675 } 3134 }
2676 3135
2677 void test_visitListLiteral_empty() { 3136 void test_visitListLiteral_empty() {
2678 _assertSource("[]", AstFactory.listLiteral()); 3137 _assertSource("[]", AstFactory.listLiteral());
2679 } 3138 }
2680 3139
2681 void test_visitListLiteral_nonEmpty() { 3140 void test_visitListLiteral_nonEmpty() {
2682 _assertSource("[a, b, c]", AstFactory.listLiteral([ 3141 _assertSource(
2683 AstFactory.identifier3("a"), 3142 "[a, b, c]",
2684 AstFactory.identifier3("b"), 3143 AstFactory.listLiteral([
2685 AstFactory.identifier3("c") 3144 AstFactory.identifier3("a"),
2686 ])); 3145 AstFactory.identifier3("b"),
3146 AstFactory.identifier3("c")
3147 ]));
2687 } 3148 }
2688 3149
2689 void test_visitMapLiteral_const() { 3150 void test_visitMapLiteral_const() {
2690 _assertSource("const {}", AstFactory.mapLiteral(Keyword.CONST, null)); 3151 _assertSource("const {}", AstFactory.mapLiteral(Keyword.CONST, null));
2691 } 3152 }
2692 3153
2693 void test_visitMapLiteral_empty() { 3154 void test_visitMapLiteral_empty() {
2694 _assertSource("{}", AstFactory.mapLiteral2()); 3155 _assertSource("{}", AstFactory.mapLiteral2());
2695 } 3156 }
2696 3157
2697 void test_visitMapLiteral_nonEmpty() { 3158 void test_visitMapLiteral_nonEmpty() {
2698 _assertSource("{'a' : a, 'b' : b, 'c' : c}", AstFactory.mapLiteral2([ 3159 _assertSource(
2699 AstFactory.mapLiteralEntry("a", AstFactory.identifier3("a")), 3160 "{'a' : a, 'b' : b, 'c' : c}",
2700 AstFactory.mapLiteralEntry("b", AstFactory.identifier3("b")), 3161 AstFactory.mapLiteral2([
2701 AstFactory.mapLiteralEntry("c", AstFactory.identifier3("c")) 3162 AstFactory.mapLiteralEntry("a", AstFactory.identifier3("a")),
2702 ])); 3163 AstFactory.mapLiteralEntry("b", AstFactory.identifier3("b")),
3164 AstFactory.mapLiteralEntry("c", AstFactory.identifier3("c"))
3165 ]));
2703 } 3166 }
2704 3167
2705 void test_visitMapLiteralEntry() { 3168 void test_visitMapLiteralEntry() {
2706 _assertSource("'a' : b", 3169 _assertSource("'a' : b",
2707 AstFactory.mapLiteralEntry("a", AstFactory.identifier3("b"))); 3170 AstFactory.mapLiteralEntry("a", AstFactory.identifier3("b")));
2708 } 3171 }
2709 3172
2710 void test_visitMethodDeclaration_external() { 3173 void test_visitMethodDeclaration_external() {
2711 _assertSource("external m();", AstFactory.methodDeclaration(null, null, 3174 _assertSource(
2712 null, null, AstFactory.identifier3("m"), 3175 "external m();",
2713 AstFactory.formalParameterList())); 3176 AstFactory.methodDeclaration(null, null, null, null,
3177 AstFactory.identifier3("m"), AstFactory.formalParameterList()));
2714 } 3178 }
2715 3179
2716 void test_visitMethodDeclaration_external_returnType() { 3180 void test_visitMethodDeclaration_external_returnType() {
2717 _assertSource("external T m();", AstFactory.methodDeclaration(null, 3181 _assertSource(
2718 AstFactory.typeName4("T"), null, null, AstFactory.identifier3("m"), 3182 "external T m();",
2719 AstFactory.formalParameterList())); 3183 AstFactory.methodDeclaration(
3184 null,
3185 AstFactory.typeName4("T"),
3186 null,
3187 null,
3188 AstFactory.identifier3("m"),
3189 AstFactory.formalParameterList()));
2720 } 3190 }
2721 3191
2722 void test_visitMethodDeclaration_getter() { 3192 void test_visitMethodDeclaration_getter() {
2723 _assertSource("get m {}", AstFactory.methodDeclaration2(null, null, 3193 _assertSource(
2724 Keyword.GET, null, AstFactory.identifier3("m"), null, 3194 "get m {}",
2725 AstFactory.blockFunctionBody2())); 3195 AstFactory.methodDeclaration2(
3196 null,
3197 null,
3198 Keyword.GET,
3199 null,
3200 AstFactory.identifier3("m"),
3201 null,
3202 AstFactory.blockFunctionBody2()));
2726 } 3203 }
2727 3204
2728 void test_visitMethodDeclaration_getter_returnType() { 3205 void test_visitMethodDeclaration_getter_returnType() {
2729 _assertSource("T get m {}", AstFactory.methodDeclaration2(null, 3206 _assertSource(
2730 AstFactory.typeName4("T"), Keyword.GET, null, 3207 "T get m {}",
2731 AstFactory.identifier3("m"), null, AstFactory.blockFunctionBody2())); 3208 AstFactory.methodDeclaration2(
3209 null,
3210 AstFactory.typeName4("T"),
3211 Keyword.GET,
3212 null,
3213 AstFactory.identifier3("m"),
3214 null,
3215 AstFactory.blockFunctionBody2()));
2732 } 3216 }
2733 3217
2734 void test_visitMethodDeclaration_getter_seturnType() { 3218 void test_visitMethodDeclaration_getter_seturnType() {
2735 _assertSource("T set m(var v) {}", AstFactory.methodDeclaration2(null, 3219 _assertSource(
2736 AstFactory.typeName4("T"), Keyword.SET, null, 3220 "T set m(var v) {}",
2737 AstFactory.identifier3("m"), AstFactory.formalParameterList( 3221 AstFactory.methodDeclaration2(
2738 [AstFactory.simpleFormalParameter(Keyword.VAR, "v")]), 3222 null,
2739 AstFactory.blockFunctionBody2())); 3223 AstFactory.typeName4("T"),
3224 Keyword.SET,
3225 null,
3226 AstFactory.identifier3("m"),
3227 AstFactory.formalParameterList(
3228 [AstFactory.simpleFormalParameter(Keyword.VAR, "v")]),
3229 AstFactory.blockFunctionBody2()));
2740 } 3230 }
2741 3231
2742 void test_visitMethodDeclaration_minimal() { 3232 void test_visitMethodDeclaration_minimal() {
2743 _assertSource("m() {}", AstFactory.methodDeclaration2(null, null, null, 3233 _assertSource(
2744 null, AstFactory.identifier3("m"), AstFactory.formalParameterList(), 3234 "m() {}",
2745 AstFactory.blockFunctionBody2())); 3235 AstFactory.methodDeclaration2(
3236 null,
3237 null,
3238 null,
3239 null,
3240 AstFactory.identifier3("m"),
3241 AstFactory.formalParameterList(),
3242 AstFactory.blockFunctionBody2()));
2746 } 3243 }
2747 3244
2748 void test_visitMethodDeclaration_multipleParameters() { 3245 void test_visitMethodDeclaration_multipleParameters() {
2749 _assertSource("m(var a, var b) {}", AstFactory.methodDeclaration2(null, 3246 _assertSource(
2750 null, null, null, AstFactory.identifier3("m"), AstFactory 3247 "m(var a, var b) {}",
2751 .formalParameterList([ 3248 AstFactory.methodDeclaration2(
2752 AstFactory.simpleFormalParameter(Keyword.VAR, "a"), 3249 null,
2753 AstFactory.simpleFormalParameter(Keyword.VAR, "b") 3250 null,
2754 ]), AstFactory.blockFunctionBody2())); 3251 null,
3252 null,
3253 AstFactory.identifier3("m"),
3254 AstFactory.formalParameterList([
3255 AstFactory.simpleFormalParameter(Keyword.VAR, "a"),
3256 AstFactory.simpleFormalParameter(Keyword.VAR, "b")
3257 ]),
3258 AstFactory.blockFunctionBody2()));
2755 } 3259 }
2756 3260
2757 void test_visitMethodDeclaration_operator() { 3261 void test_visitMethodDeclaration_operator() {
2758 _assertSource("operator +() {}", AstFactory.methodDeclaration2(null, null, 3262 _assertSource(
2759 null, Keyword.OPERATOR, AstFactory.identifier3("+"), 3263 "operator +() {}",
2760 AstFactory.formalParameterList(), AstFactory.blockFunctionBody2())); 3264 AstFactory.methodDeclaration2(
3265 null,
3266 null,
3267 null,
3268 Keyword.OPERATOR,
3269 AstFactory.identifier3("+"),
3270 AstFactory.formalParameterList(),
3271 AstFactory.blockFunctionBody2()));
2761 } 3272 }
2762 3273
2763 void test_visitMethodDeclaration_operator_returnType() { 3274 void test_visitMethodDeclaration_operator_returnType() {
2764 _assertSource("T operator +() {}", AstFactory.methodDeclaration2(null, 3275 _assertSource(
2765 AstFactory.typeName4("T"), null, Keyword.OPERATOR, 3276 "T operator +() {}",
2766 AstFactory.identifier3("+"), AstFactory.formalParameterList(), 3277 AstFactory.methodDeclaration2(
2767 AstFactory.blockFunctionBody2())); 3278 null,
3279 AstFactory.typeName4("T"),
3280 null,
3281 Keyword.OPERATOR,
3282 AstFactory.identifier3("+"),
3283 AstFactory.formalParameterList(),
3284 AstFactory.blockFunctionBody2()));
2768 } 3285 }
2769 3286
2770 void test_visitMethodDeclaration_returnType() { 3287 void test_visitMethodDeclaration_returnType() {
2771 _assertSource("T m() {}", AstFactory.methodDeclaration2(null, 3288 _assertSource(
2772 AstFactory.typeName4("T"), null, null, AstFactory.identifier3("m"), 3289 "T m() {}",
2773 AstFactory.formalParameterList(), AstFactory.blockFunctionBody2())); 3290 AstFactory.methodDeclaration2(
3291 null,
3292 AstFactory.typeName4("T"),
3293 null,
3294 null,
3295 AstFactory.identifier3("m"),
3296 AstFactory.formalParameterList(),
3297 AstFactory.blockFunctionBody2()));
2774 } 3298 }
2775 3299
2776 void test_visitMethodDeclaration_setter() { 3300 void test_visitMethodDeclaration_setter() {
2777 _assertSource("set m(var v) {}", AstFactory.methodDeclaration2(null, null, 3301 _assertSource(
2778 Keyword.SET, null, AstFactory.identifier3("m"), AstFactory 3302 "set m(var v) {}",
2779 .formalParameterList( 3303 AstFactory.methodDeclaration2(
3304 null,
3305 null,
3306 Keyword.SET,
3307 null,
3308 AstFactory.identifier3("m"),
3309 AstFactory.formalParameterList(
2780 [AstFactory.simpleFormalParameter(Keyword.VAR, "v")]), 3310 [AstFactory.simpleFormalParameter(Keyword.VAR, "v")]),
2781 AstFactory.blockFunctionBody2())); 3311 AstFactory.blockFunctionBody2()));
2782 } 3312 }
2783 3313
2784 void test_visitMethodDeclaration_static() { 3314 void test_visitMethodDeclaration_static() {
2785 _assertSource("static m() {}", AstFactory.methodDeclaration2(Keyword.STATIC, 3315 _assertSource(
2786 null, null, null, AstFactory.identifier3("m"), 3316 "static m() {}",
2787 AstFactory.formalParameterList(), AstFactory.blockFunctionBody2())); 3317 AstFactory.methodDeclaration2(
3318 Keyword.STATIC,
3319 null,
3320 null,
3321 null,
3322 AstFactory.identifier3("m"),
3323 AstFactory.formalParameterList(),
3324 AstFactory.blockFunctionBody2()));
2788 } 3325 }
2789 3326
2790 void test_visitMethodDeclaration_static_returnType() { 3327 void test_visitMethodDeclaration_static_returnType() {
2791 _assertSource("static T m() {}", AstFactory.methodDeclaration2( 3328 _assertSource(
2792 Keyword.STATIC, AstFactory.typeName4("T"), null, null, 3329 "static T m() {}",
2793 AstFactory.identifier3("m"), AstFactory.formalParameterList(), 3330 AstFactory.methodDeclaration2(
2794 AstFactory.blockFunctionBody2())); 3331 Keyword.STATIC,
3332 AstFactory.typeName4("T"),
3333 null,
3334 null,
3335 AstFactory.identifier3("m"),
3336 AstFactory.formalParameterList(),
3337 AstFactory.blockFunctionBody2()));
2795 } 3338 }
2796 3339
2797 void test_visitMethodDeclaration_typeParameters() { 3340 void test_visitMethodDeclaration_typeParameters() {
2798 _assertSource("m<E>() {}", AstFactory.methodDeclaration3(null, null, null, 3341 _assertSource(
2799 null, AstFactory.identifier3("m"), AstFactory.typeParameterList(['E']), 3342 "m<E>() {}",
2800 AstFactory.formalParameterList(), AstFactory.blockFunctionBody2())); 3343 AstFactory.methodDeclaration3(
3344 null,
3345 null,
3346 null,
3347 null,
3348 AstFactory.identifier3("m"),
3349 AstFactory.typeParameterList(['E']),
3350 AstFactory.formalParameterList(),
3351 AstFactory.blockFunctionBody2()));
2801 } 3352 }
2802 3353
2803 void test_visitMethodDeclaration_withMetadata() { 3354 void test_visitMethodDeclaration_withMetadata() {
2804 MethodDeclaration declaration = AstFactory.methodDeclaration2(null, null, 3355 MethodDeclaration declaration = AstFactory.methodDeclaration2(
2805 null, null, AstFactory.identifier3("m"), 3356 null,
2806 AstFactory.formalParameterList(), AstFactory.blockFunctionBody2()); 3357 null,
3358 null,
3359 null,
3360 AstFactory.identifier3("m"),
3361 AstFactory.formalParameterList(),
3362 AstFactory.blockFunctionBody2());
2807 declaration.metadata 3363 declaration.metadata
2808 .add(AstFactory.annotation(AstFactory.identifier3("deprecated"))); 3364 .add(AstFactory.annotation(AstFactory.identifier3("deprecated")));
2809 _assertSource("@deprecated m() {}", declaration); 3365 _assertSource("@deprecated m() {}", declaration);
2810 } 3366 }
2811 3367
2812 void test_visitMethodInvocation_conditional() { 3368 void test_visitMethodInvocation_conditional() {
2813 _assertSource("t?.m()", AstFactory.methodInvocation( 3369 _assertSource(
2814 AstFactory.identifier3("t"), "m", null, TokenType.QUESTION_PERIOD)); 3370 "t?.m()",
3371 AstFactory.methodInvocation(
3372 AstFactory.identifier3("t"), "m", null, TokenType.QUESTION_PERIOD));
2815 } 3373 }
2816 3374
2817 void test_visitMethodInvocation_noTarget() { 3375 void test_visitMethodInvocation_noTarget() {
2818 _assertSource("m()", AstFactory.methodInvocation2("m")); 3376 _assertSource("m()", AstFactory.methodInvocation2("m"));
2819 } 3377 }
2820 3378
2821 void test_visitMethodInvocation_target() { 3379 void test_visitMethodInvocation_target() {
2822 _assertSource( 3380 _assertSource(
2823 "t.m()", AstFactory.methodInvocation(AstFactory.identifier3("t"), "m")); 3381 "t.m()", AstFactory.methodInvocation(AstFactory.identifier3("t"), "m"));
2824 } 3382 }
2825 3383
2826 void test_visitMethodInvocation_typeArguments() { 3384 void test_visitMethodInvocation_typeArguments() {
2827 _assertSource("m<A>()", AstFactory.methodInvocation3( 3385 _assertSource(
2828 null, "m", AstFactory.typeArgumentList([AstFactory.typeName4('A')]))); 3386 "m<A>()",
3387 AstFactory.methodInvocation3(null, "m",
3388 AstFactory.typeArgumentList([AstFactory.typeName4('A')])));
2829 } 3389 }
2830 3390
2831 void test_visitNamedExpression() { 3391 void test_visitNamedExpression() {
2832 _assertSource( 3392 _assertSource(
2833 "a: b", AstFactory.namedExpression2("a", AstFactory.identifier3("b"))); 3393 "a: b", AstFactory.namedExpression2("a", AstFactory.identifier3("b")));
2834 } 3394 }
2835 3395
2836 void test_visitNamedFormalParameter() { 3396 void test_visitNamedFormalParameter() {
2837 _assertSource("var a : 0", AstFactory.namedFormalParameter( 3397 _assertSource(
2838 AstFactory.simpleFormalParameter(Keyword.VAR, "a"), 3398 "var a : 0",
2839 AstFactory.integer(0))); 3399 AstFactory.namedFormalParameter(
3400 AstFactory.simpleFormalParameter(Keyword.VAR, "a"),
3401 AstFactory.integer(0)));
2840 } 3402 }
2841 3403
2842 void test_visitNativeClause() { 3404 void test_visitNativeClause() {
2843 _assertSource("native 'code'", AstFactory.nativeClause("code")); 3405 _assertSource("native 'code'", AstFactory.nativeClause("code"));
2844 } 3406 }
2845 3407
2846 void test_visitNativeFunctionBody() { 3408 void test_visitNativeFunctionBody() {
2847 _assertSource("native 'str';", AstFactory.nativeFunctionBody("str")); 3409 _assertSource("native 'str';", AstFactory.nativeFunctionBody("str"));
2848 } 3410 }
2849 3411
(...skipping 24 matching lines...) Expand all
2874 3436
2875 void test_visitPartOfDirective_withMetadata() { 3437 void test_visitPartOfDirective_withMetadata() {
2876 PartOfDirective directive = 3438 PartOfDirective directive =
2877 AstFactory.partOfDirective(AstFactory.libraryIdentifier2(["l"])); 3439 AstFactory.partOfDirective(AstFactory.libraryIdentifier2(["l"]));
2878 directive.metadata 3440 directive.metadata
2879 .add(AstFactory.annotation(AstFactory.identifier3("deprecated"))); 3441 .add(AstFactory.annotation(AstFactory.identifier3("deprecated")));
2880 _assertSource("@deprecated part of l;", directive); 3442 _assertSource("@deprecated part of l;", directive);
2881 } 3443 }
2882 3444
2883 void test_visitPositionalFormalParameter() { 3445 void test_visitPositionalFormalParameter() {
2884 _assertSource("var a = 0", AstFactory.positionalFormalParameter( 3446 _assertSource(
2885 AstFactory.simpleFormalParameter(Keyword.VAR, "a"), 3447 "var a = 0",
2886 AstFactory.integer(0))); 3448 AstFactory.positionalFormalParameter(
3449 AstFactory.simpleFormalParameter(Keyword.VAR, "a"),
3450 AstFactory.integer(0)));
2887 } 3451 }
2888 3452
2889 void test_visitPostfixExpression() { 3453 void test_visitPostfixExpression() {
2890 _assertSource("a++", AstFactory.postfixExpression( 3454 _assertSource(
2891 AstFactory.identifier3("a"), TokenType.PLUS_PLUS)); 3455 "a++",
3456 AstFactory.postfixExpression(
3457 AstFactory.identifier3("a"), TokenType.PLUS_PLUS));
2892 } 3458 }
2893 3459
2894 void test_visitPrefixedIdentifier() { 3460 void test_visitPrefixedIdentifier() {
2895 _assertSource("a.b", AstFactory.identifier5("a", "b")); 3461 _assertSource("a.b", AstFactory.identifier5("a", "b"));
2896 } 3462 }
2897 3463
2898 void test_visitPrefixExpression() { 3464 void test_visitPrefixExpression() {
2899 _assertSource("-a", AstFactory.prefixExpression( 3465 _assertSource(
2900 TokenType.MINUS, AstFactory.identifier3("a"))); 3466 "-a",
3467 AstFactory.prefixExpression(
3468 TokenType.MINUS, AstFactory.identifier3("a")));
2901 } 3469 }
2902 3470
2903 void test_visitPropertyAccess() { 3471 void test_visitPropertyAccess() {
2904 _assertSource( 3472 _assertSource(
2905 "a.b", AstFactory.propertyAccess2(AstFactory.identifier3("a"), "b")); 3473 "a.b", AstFactory.propertyAccess2(AstFactory.identifier3("a"), "b"));
2906 } 3474 }
2907 3475
2908 void test_visitPropertyAccess_conditional() { 3476 void test_visitPropertyAccess_conditional() {
2909 _assertSource("a?.b", AstFactory.propertyAccess2( 3477 _assertSource(
2910 AstFactory.identifier3("a"), "b", TokenType.QUESTION_PERIOD)); 3478 "a?.b",
3479 AstFactory.propertyAccess2(
3480 AstFactory.identifier3("a"), "b", TokenType.QUESTION_PERIOD));
2911 } 3481 }
2912 3482
2913 void test_visitRedirectingConstructorInvocation_named() { 3483 void test_visitRedirectingConstructorInvocation_named() {
2914 _assertSource( 3484 _assertSource(
2915 "this.c()", AstFactory.redirectingConstructorInvocation2("c")); 3485 "this.c()", AstFactory.redirectingConstructorInvocation2("c"));
2916 } 3486 }
2917 3487
2918 void test_visitRedirectingConstructorInvocation_unnamed() { 3488 void test_visitRedirectingConstructorInvocation_unnamed() {
2919 _assertSource("this()", AstFactory.redirectingConstructorInvocation()); 3489 _assertSource("this()", AstFactory.redirectingConstructorInvocation());
2920 } 3490 }
(...skipping 14 matching lines...) Expand all
2935 void test_visitScriptTag() { 3505 void test_visitScriptTag() {
2936 String scriptTag = "!#/bin/dart.exe"; 3506 String scriptTag = "!#/bin/dart.exe";
2937 _assertSource(scriptTag, AstFactory.scriptTag(scriptTag)); 3507 _assertSource(scriptTag, AstFactory.scriptTag(scriptTag));
2938 } 3508 }
2939 3509
2940 void test_visitSimpleFormalParameter_keyword() { 3510 void test_visitSimpleFormalParameter_keyword() {
2941 _assertSource("var a", AstFactory.simpleFormalParameter(Keyword.VAR, "a")); 3511 _assertSource("var a", AstFactory.simpleFormalParameter(Keyword.VAR, "a"));
2942 } 3512 }
2943 3513
2944 void test_visitSimpleFormalParameter_keyword_type() { 3514 void test_visitSimpleFormalParameter_keyword_type() {
2945 _assertSource("final A a", AstFactory.simpleFormalParameter2( 3515 _assertSource(
2946 Keyword.FINAL, AstFactory.typeName4("A"), "a")); 3516 "final A a",
3517 AstFactory.simpleFormalParameter2(
3518 Keyword.FINAL, AstFactory.typeName4("A"), "a"));
2947 } 3519 }
2948 3520
2949 void test_visitSimpleFormalParameter_type() { 3521 void test_visitSimpleFormalParameter_type() {
2950 _assertSource("A a", 3522 _assertSource("A a",
2951 AstFactory.simpleFormalParameter4(AstFactory.typeName4("A"), "a")); 3523 AstFactory.simpleFormalParameter4(AstFactory.typeName4("A"), "a"));
2952 } 3524 }
2953 3525
2954 void test_visitSimpleIdentifier() { 3526 void test_visitSimpleIdentifier() {
2955 _assertSource("a", AstFactory.identifier3("a")); 3527 _assertSource("a", AstFactory.identifier3("a"));
2956 } 3528 }
2957 3529
2958 void test_visitSimpleStringLiteral() { 3530 void test_visitSimpleStringLiteral() {
2959 _assertSource("'a'", AstFactory.string2("a")); 3531 _assertSource("'a'", AstFactory.string2("a"));
2960 } 3532 }
2961 3533
2962 void test_visitStringInterpolation() { 3534 void test_visitStringInterpolation() {
2963 _assertSource("'a\${e}b'", AstFactory.string([ 3535 _assertSource(
2964 AstFactory.interpolationString("'a", "a"), 3536 "'a\${e}b'",
2965 AstFactory.interpolationExpression(AstFactory.identifier3("e")), 3537 AstFactory.string([
2966 AstFactory.interpolationString("b'", "b") 3538 AstFactory.interpolationString("'a", "a"),
2967 ])); 3539 AstFactory.interpolationExpression(AstFactory.identifier3("e")),
3540 AstFactory.interpolationString("b'", "b")
3541 ]));
2968 } 3542 }
2969 3543
2970 void test_visitSuperConstructorInvocation() { 3544 void test_visitSuperConstructorInvocation() {
2971 _assertSource("super()", AstFactory.superConstructorInvocation()); 3545 _assertSource("super()", AstFactory.superConstructorInvocation());
2972 } 3546 }
2973 3547
2974 void test_visitSuperConstructorInvocation_named() { 3548 void test_visitSuperConstructorInvocation_named() {
2975 _assertSource("super.c()", AstFactory.superConstructorInvocation2("c")); 3549 _assertSource("super.c()", AstFactory.superConstructorInvocation2("c"));
2976 } 3550 }
2977 3551
2978 void test_visitSuperExpression() { 3552 void test_visitSuperExpression() {
2979 _assertSource("super", AstFactory.superExpression()); 3553 _assertSource("super", AstFactory.superExpression());
2980 } 3554 }
2981 3555
2982 void test_visitSwitchCase_multipleLabels() { 3556 void test_visitSwitchCase_multipleLabels() {
2983 _assertSource("l1: l2: case a: {}", AstFactory.switchCase2([ 3557 _assertSource(
2984 AstFactory.label2("l1"), 3558 "l1: l2: case a: {}",
2985 AstFactory.label2("l2") 3559 AstFactory.switchCase2(
2986 ], AstFactory.identifier3("a"), [AstFactory.block()])); 3560 [AstFactory.label2("l1"), AstFactory.label2("l2")],
3561 AstFactory.identifier3("a"),
3562 [AstFactory.block()]));
2987 } 3563 }
2988 3564
2989 void test_visitSwitchCase_multipleStatements() { 3565 void test_visitSwitchCase_multipleStatements() {
2990 _assertSource("case a: {} {}", AstFactory.switchCase( 3566 _assertSource(
2991 AstFactory.identifier3("a"), [AstFactory.block(), AstFactory.block()])); 3567 "case a: {} {}",
3568 AstFactory.switchCase(AstFactory.identifier3("a"),
3569 [AstFactory.block(), AstFactory.block()]));
2992 } 3570 }
2993 3571
2994 void test_visitSwitchCase_noLabels() { 3572 void test_visitSwitchCase_noLabels() {
2995 _assertSource("case a: {}", AstFactory.switchCase( 3573 _assertSource(
2996 AstFactory.identifier3("a"), [AstFactory.block()])); 3574 "case a: {}",
3575 AstFactory.switchCase(
3576 AstFactory.identifier3("a"), [AstFactory.block()]));
2997 } 3577 }
2998 3578
2999 void test_visitSwitchCase_singleLabel() { 3579 void test_visitSwitchCase_singleLabel() {
3000 _assertSource("l1: case a: {}", AstFactory.switchCase2( 3580 _assertSource(
3001 [AstFactory.label2("l1")], AstFactory.identifier3("a"), 3581 "l1: case a: {}",
3002 [AstFactory.block()])); 3582 AstFactory.switchCase2([AstFactory.label2("l1")],
3583 AstFactory.identifier3("a"), [AstFactory.block()]));
3003 } 3584 }
3004 3585
3005 void test_visitSwitchDefault_multipleLabels() { 3586 void test_visitSwitchDefault_multipleLabels() {
3006 _assertSource("l1: l2: default: {}", AstFactory.switchDefault([ 3587 _assertSource(
3007 AstFactory.label2("l1"), 3588 "l1: l2: default: {}",
3008 AstFactory.label2("l2") 3589 AstFactory.switchDefault(
3009 ], [AstFactory.block()])); 3590 [AstFactory.label2("l1"), AstFactory.label2("l2")],
3591 [AstFactory.block()]));
3010 } 3592 }
3011 3593
3012 void test_visitSwitchDefault_multipleStatements() { 3594 void test_visitSwitchDefault_multipleStatements() {
3013 _assertSource("default: {} {}", 3595 _assertSource("default: {} {}",
3014 AstFactory.switchDefault2([AstFactory.block(), AstFactory.block()])); 3596 AstFactory.switchDefault2([AstFactory.block(), AstFactory.block()]));
3015 } 3597 }
3016 3598
3017 void test_visitSwitchDefault_noLabels() { 3599 void test_visitSwitchDefault_noLabels() {
3018 _assertSource( 3600 _assertSource(
3019 "default: {}", AstFactory.switchDefault2([AstFactory.block()])); 3601 "default: {}", AstFactory.switchDefault2([AstFactory.block()]));
3020 } 3602 }
3021 3603
3022 void test_visitSwitchDefault_singleLabel() { 3604 void test_visitSwitchDefault_singleLabel() {
3023 _assertSource("l1: default: {}", AstFactory.switchDefault( 3605 _assertSource(
3024 [AstFactory.label2("l1")], [AstFactory.block()])); 3606 "l1: default: {}",
3607 AstFactory.switchDefault(
3608 [AstFactory.label2("l1")], [AstFactory.block()]));
3025 } 3609 }
3026 3610
3027 void test_visitSwitchStatement() { 3611 void test_visitSwitchStatement() {
3028 _assertSource("switch (a) {case 'b': {} default: {}}", AstFactory 3612 _assertSource(
3029 .switchStatement(AstFactory.identifier3("a"), [ 3613 "switch (a) {case 'b': {} default: {}}",
3030 AstFactory.switchCase(AstFactory.string2("b"), [AstFactory.block()]), 3614 AstFactory.switchStatement(AstFactory.identifier3("a"), [
3031 AstFactory.switchDefault2([AstFactory.block()]) 3615 AstFactory.switchCase(AstFactory.string2("b"), [AstFactory.block()]),
3032 ])); 3616 AstFactory.switchDefault2([AstFactory.block()])
3617 ]));
3033 } 3618 }
3034 3619
3035 void test_visitSymbolLiteral_multiple() { 3620 void test_visitSymbolLiteral_multiple() {
3036 _assertSource("#a.b.c", AstFactory.symbolLiteral(["a", "b", "c"])); 3621 _assertSource("#a.b.c", AstFactory.symbolLiteral(["a", "b", "c"]));
3037 } 3622 }
3038 3623
3039 void test_visitSymbolLiteral_single() { 3624 void test_visitSymbolLiteral_single() {
3040 _assertSource("#a", AstFactory.symbolLiteral(["a"])); 3625 _assertSource("#a", AstFactory.symbolLiteral(["a"]));
3041 } 3626 }
3042 3627
3043 void test_visitThisExpression() { 3628 void test_visitThisExpression() {
3044 _assertSource("this", AstFactory.thisExpression()); 3629 _assertSource("this", AstFactory.thisExpression());
3045 } 3630 }
3046 3631
3047 void test_visitThrowStatement() { 3632 void test_visitThrowStatement() {
3048 _assertSource( 3633 _assertSource(
3049 "throw e", AstFactory.throwExpression2(AstFactory.identifier3("e"))); 3634 "throw e", AstFactory.throwExpression2(AstFactory.identifier3("e")));
3050 } 3635 }
3051 3636
3052 void test_visitTopLevelVariableDeclaration_multiple() { 3637 void test_visitTopLevelVariableDeclaration_multiple() {
3053 _assertSource("var a;", AstFactory.topLevelVariableDeclaration2( 3638 _assertSource(
3054 Keyword.VAR, [AstFactory.variableDeclaration("a")])); 3639 "var a;",
3640 AstFactory.topLevelVariableDeclaration2(
3641 Keyword.VAR, [AstFactory.variableDeclaration("a")]));
3055 } 3642 }
3056 3643
3057 void test_visitTopLevelVariableDeclaration_single() { 3644 void test_visitTopLevelVariableDeclaration_single() {
3058 _assertSource("var a, b;", AstFactory.topLevelVariableDeclaration2( 3645 _assertSource(
3059 Keyword.VAR, [ 3646 "var a, b;",
3060 AstFactory.variableDeclaration("a"), 3647 AstFactory.topLevelVariableDeclaration2(Keyword.VAR, [
3061 AstFactory.variableDeclaration("b") 3648 AstFactory.variableDeclaration("a"),
3062 ])); 3649 AstFactory.variableDeclaration("b")
3650 ]));
3063 } 3651 }
3064 3652
3065 void test_visitTryStatement_catch() { 3653 void test_visitTryStatement_catch() {
3066 _assertSource("try {} on E {}", AstFactory.tryStatement2(AstFactory.block(), 3654 _assertSource(
3067 [AstFactory.catchClause3(AstFactory.typeName4("E"))])); 3655 "try {} on E {}",
3656 AstFactory.tryStatement2(AstFactory.block(),
3657 [AstFactory.catchClause3(AstFactory.typeName4("E"))]));
3068 } 3658 }
3069 3659
3070 void test_visitTryStatement_catches() { 3660 void test_visitTryStatement_catches() {
3071 _assertSource("try {} on E {} on F {}", AstFactory.tryStatement2( 3661 _assertSource(
3072 AstFactory.block(), [ 3662 "try {} on E {} on F {}",
3073 AstFactory.catchClause3(AstFactory.typeName4("E")), 3663 AstFactory.tryStatement2(AstFactory.block(), [
3074 AstFactory.catchClause3(AstFactory.typeName4("F")) 3664 AstFactory.catchClause3(AstFactory.typeName4("E")),
3075 ])); 3665 AstFactory.catchClause3(AstFactory.typeName4("F"))
3666 ]));
3076 } 3667 }
3077 3668
3078 void test_visitTryStatement_catchFinally() { 3669 void test_visitTryStatement_catchFinally() {
3079 _assertSource("try {} on E {} finally {}", AstFactory.tryStatement3( 3670 _assertSource(
3080 AstFactory.block(), 3671 "try {} on E {} finally {}",
3081 [AstFactory.catchClause3(AstFactory.typeName4("E"))], 3672 AstFactory.tryStatement3(
3082 AstFactory.block())); 3673 AstFactory.block(),
3674 [AstFactory.catchClause3(AstFactory.typeName4("E"))],
3675 AstFactory.block()));
3083 } 3676 }
3084 3677
3085 void test_visitTryStatement_finally() { 3678 void test_visitTryStatement_finally() {
3086 _assertSource("try {} finally {}", 3679 _assertSource("try {} finally {}",
3087 AstFactory.tryStatement(AstFactory.block(), AstFactory.block())); 3680 AstFactory.tryStatement(AstFactory.block(), AstFactory.block()));
3088 } 3681 }
3089 3682
3090 void test_visitTypeArgumentList_multiple() { 3683 void test_visitTypeArgumentList_multiple() {
3091 _assertSource("<E, F>", AstFactory.typeArgumentList( 3684 _assertSource(
3092 [AstFactory.typeName4("E"), AstFactory.typeName4("F")])); 3685 "<E, F>",
3686 AstFactory.typeArgumentList(
3687 [AstFactory.typeName4("E"), AstFactory.typeName4("F")]));
3093 } 3688 }
3094 3689
3095 void test_visitTypeArgumentList_single() { 3690 void test_visitTypeArgumentList_single() {
3096 _assertSource( 3691 _assertSource(
3097 "<E>", AstFactory.typeArgumentList([AstFactory.typeName4("E")])); 3692 "<E>", AstFactory.typeArgumentList([AstFactory.typeName4("E")]));
3098 } 3693 }
3099 3694
3100 void test_visitTypeName_multipleArgs() { 3695 void test_visitTypeName_multipleArgs() {
3101 _assertSource("C<D, E>", AstFactory.typeName4( 3696 _assertSource(
3102 "C", [AstFactory.typeName4("D"), AstFactory.typeName4("E")])); 3697 "C<D, E>",
3698 AstFactory.typeName4(
3699 "C", [AstFactory.typeName4("D"), AstFactory.typeName4("E")]));
3103 } 3700 }
3104 3701
3105 void test_visitTypeName_nestedArg() { 3702 void test_visitTypeName_nestedArg() {
3106 _assertSource("C<D<E>>", AstFactory.typeName4( 3703 _assertSource(
3107 "C", [AstFactory.typeName4("D", [AstFactory.typeName4("E")])])); 3704 "C<D<E>>",
3705 AstFactory.typeName4("C", [
3706 AstFactory.typeName4("D", [AstFactory.typeName4("E")])
3707 ]));
3108 } 3708 }
3109 3709
3110 void test_visitTypeName_noArgs() { 3710 void test_visitTypeName_noArgs() {
3111 _assertSource("C", AstFactory.typeName4("C")); 3711 _assertSource("C", AstFactory.typeName4("C"));
3112 } 3712 }
3113 3713
3114 void test_visitTypeName_singleArg() { 3714 void test_visitTypeName_singleArg() {
3115 _assertSource( 3715 _assertSource(
3116 "C<D>", AstFactory.typeName4("C", [AstFactory.typeName4("D")])); 3716 "C<D>", AstFactory.typeName4("C", [AstFactory.typeName4("D")]));
3117 } 3717 }
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
3150 } 3750 }
3151 3751
3152 void test_visitVariableDeclaration_withMetadata() { 3752 void test_visitVariableDeclaration_withMetadata() {
3153 VariableDeclaration declaration = AstFactory.variableDeclaration("a"); 3753 VariableDeclaration declaration = AstFactory.variableDeclaration("a");
3154 declaration.metadata 3754 declaration.metadata
3155 .add(AstFactory.annotation(AstFactory.identifier3("deprecated"))); 3755 .add(AstFactory.annotation(AstFactory.identifier3("deprecated")));
3156 _assertSource("@deprecated a", declaration); 3756 _assertSource("@deprecated a", declaration);
3157 } 3757 }
3158 3758
3159 void test_visitVariableDeclarationList_const_type() { 3759 void test_visitVariableDeclarationList_const_type() {
3160 _assertSource("const C a, b", AstFactory.variableDeclarationList( 3760 _assertSource(
3161 Keyword.CONST, AstFactory.typeName4("C"), [ 3761 "const C a, b",
3162 AstFactory.variableDeclaration("a"), 3762 AstFactory.variableDeclarationList(
3163 AstFactory.variableDeclaration("b") 3763 Keyword.CONST, AstFactory.typeName4("C"), [
3164 ])); 3764 AstFactory.variableDeclaration("a"),
3765 AstFactory.variableDeclaration("b")
3766 ]));
3165 } 3767 }
3166 3768
3167 void test_visitVariableDeclarationList_final_noType() { 3769 void test_visitVariableDeclarationList_final_noType() {
3168 _assertSource("final a, b", AstFactory.variableDeclarationList2( 3770 _assertSource(
3169 Keyword.FINAL, [ 3771 "final a, b",
3170 AstFactory.variableDeclaration("a"), 3772 AstFactory.variableDeclarationList2(Keyword.FINAL, [
3171 AstFactory.variableDeclaration("b") 3773 AstFactory.variableDeclaration("a"),
3172 ])); 3774 AstFactory.variableDeclaration("b")
3775 ]));
3173 } 3776 }
3174 3777
3175 void test_visitVariableDeclarationList_final_withMetadata() { 3778 void test_visitVariableDeclarationList_final_withMetadata() {
3176 VariableDeclarationList declarationList = AstFactory 3779 VariableDeclarationList declarationList = AstFactory
3177 .variableDeclarationList2(Keyword.FINAL, [ 3780 .variableDeclarationList2(Keyword.FINAL, [
3178 AstFactory.variableDeclaration("a"), 3781 AstFactory.variableDeclaration("a"),
3179 AstFactory.variableDeclaration("b") 3782 AstFactory.variableDeclaration("b")
3180 ]); 3783 ]);
3181 declarationList.metadata 3784 declarationList.metadata
3182 .add(AstFactory.annotation(AstFactory.identifier3("deprecated"))); 3785 .add(AstFactory.annotation(AstFactory.identifier3("deprecated")));
3183 _assertSource("@deprecated final a, b", declarationList); 3786 _assertSource("@deprecated final a, b", declarationList);
3184 } 3787 }
3185 3788
3186 void test_visitVariableDeclarationList_type() { 3789 void test_visitVariableDeclarationList_type() {
3187 _assertSource("C a, b", AstFactory.variableDeclarationList(null, 3790 _assertSource(
3188 AstFactory.typeName4("C"), [ 3791 "C a, b",
3189 AstFactory.variableDeclaration("a"), 3792 AstFactory.variableDeclarationList(null, AstFactory.typeName4("C"), [
3190 AstFactory.variableDeclaration("b") 3793 AstFactory.variableDeclaration("a"),
3191 ])); 3794 AstFactory.variableDeclaration("b")
3795 ]));
3192 } 3796 }
3193 3797
3194 void test_visitVariableDeclarationList_var() { 3798 void test_visitVariableDeclarationList_var() {
3195 _assertSource("var a, b", AstFactory.variableDeclarationList2(Keyword.VAR, [ 3799 _assertSource(
3196 AstFactory.variableDeclaration("a"), 3800 "var a, b",
3197 AstFactory.variableDeclaration("b") 3801 AstFactory.variableDeclarationList2(Keyword.VAR, [
3198 ])); 3802 AstFactory.variableDeclaration("a"),
3803 AstFactory.variableDeclaration("b")
3804 ]));
3199 } 3805 }
3200 3806
3201 void test_visitVariableDeclarationStatement() { 3807 void test_visitVariableDeclarationStatement() {
3202 _assertSource("C c;", AstFactory.variableDeclarationStatement(null, 3808 _assertSource(
3203 AstFactory.typeName4("C"), [AstFactory.variableDeclaration("c")])); 3809 "C c;",
3810 AstFactory.variableDeclarationStatement(null, AstFactory.typeName4("C"),
3811 [AstFactory.variableDeclaration("c")]));
3204 } 3812 }
3205 3813
3206 void test_visitWhileStatement() { 3814 void test_visitWhileStatement() {
3207 _assertSource("while (c) {}", AstFactory.whileStatement( 3815 _assertSource(
3208 AstFactory.identifier3("c"), AstFactory.block())); 3816 "while (c) {}",
3817 AstFactory.whileStatement(
3818 AstFactory.identifier3("c"), AstFactory.block()));
3209 } 3819 }
3210 3820
3211 void test_visitWithClause_multiple() { 3821 void test_visitWithClause_multiple() {
3212 _assertSource("with A, B, C", AstFactory.withClause([ 3822 _assertSource(
3213 AstFactory.typeName4("A"), 3823 "with A, B, C",
3214 AstFactory.typeName4("B"), 3824 AstFactory.withClause([
3215 AstFactory.typeName4("C") 3825 AstFactory.typeName4("A"),
3216 ])); 3826 AstFactory.typeName4("B"),
3827 AstFactory.typeName4("C")
3828 ]));
3217 } 3829 }
3218 3830
3219 void test_visitWithClause_single() { 3831 void test_visitWithClause_single() {
3220 _assertSource("with A", AstFactory.withClause([AstFactory.typeName4("A")])); 3832 _assertSource("with A", AstFactory.withClause([AstFactory.typeName4("A")]));
3221 } 3833 }
3222 3834
3223 void test_visitYieldStatement() { 3835 void test_visitYieldStatement() {
3224 _assertSource( 3836 _assertSource(
3225 "yield e;", AstFactory.yieldStatement(AstFactory.identifier3("e"))); 3837 "yield e;", AstFactory.yieldStatement(AstFactory.identifier3("e")));
3226 } 3838 }
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
3284 static const List<WrapperKind> values = const [ 3896 static const List<WrapperKind> values = const [
3285 PREFIXED_LEFT, 3897 PREFIXED_LEFT,
3286 PREFIXED_RIGHT, 3898 PREFIXED_RIGHT,
3287 PROPERTY_LEFT, 3899 PROPERTY_LEFT,
3288 PROPERTY_RIGHT, 3900 PROPERTY_RIGHT,
3289 NONE 3901 NONE
3290 ]; 3902 ];
3291 3903
3292 const WrapperKind(String name, int ordinal) : super(name, ordinal); 3904 const WrapperKind(String name, int ordinal) : super(name, ordinal);
3293 } 3905 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/generated/ast.dart ('k') | pkg/analyzer/test/parse_compilation_unit_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698