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

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

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

Powered by Google App Engine
This is Rietveld 408576698