| Index: pkg/analyzer/test/generated/ast_test.dart
|
| diff --git a/pkg/analyzer/test/generated/ast_test.dart b/pkg/analyzer/test/generated/ast_test.dart
|
| index 102bb6b30f312dd8908fa3566f645909d8c0adea..347c87e6ddf81bf12bb3b20a3b79ce565c20c573 100644
|
| --- a/pkg/analyzer/test/generated/ast_test.dart
|
| +++ b/pkg/analyzer/test/generated/ast_test.dart
|
| @@ -20,7 +20,6 @@ import '../reflective_tests.dart';
|
| import 'parser_test.dart' show ParserTestCase;
|
| import 'test_support.dart';
|
|
|
| -
|
| main() {
|
| groupSep = ' | ';
|
| runReflectiveTests(BreadthFirstVisitorTest);
|
| @@ -69,22 +68,23 @@ class AssignmentKind extends Enum<AssignmentKind> {
|
| static const AssignmentKind NONE = const AssignmentKind('NONE', 9);
|
|
|
| static const List<AssignmentKind> values = const [
|
| - BINARY,
|
| - COMPOUND_LEFT,
|
| - COMPOUND_RIGHT,
|
| - POSTFIX_INC,
|
| - PREFIX_DEC,
|
| - PREFIX_INC,
|
| - PREFIX_NOT,
|
| - SIMPLE_LEFT,
|
| - SIMPLE_RIGHT,
|
| - NONE];
|
| + BINARY,
|
| + COMPOUND_LEFT,
|
| + COMPOUND_RIGHT,
|
| + POSTFIX_INC,
|
| + PREFIX_DEC,
|
| + PREFIX_INC,
|
| + PREFIX_NOT,
|
| + SIMPLE_LEFT,
|
| + SIMPLE_RIGHT,
|
| + NONE
|
| + ];
|
|
|
| const AssignmentKind(String name, int ordinal) : super(name, ordinal);
|
| }
|
|
|
| -class BreadthFirstVisitor_BreadthFirstVisitorTest_testIt extends
|
| - BreadthFirstVisitor<Object> {
|
| +class BreadthFirstVisitor_BreadthFirstVisitorTest_testIt
|
| + extends BreadthFirstVisitor<Object> {
|
| List<AstNode> nodes;
|
|
|
| BreadthFirstVisitor_BreadthFirstVisitorTest_testIt(this.nodes) : super();
|
| @@ -125,25 +125,16 @@ A f(var p) {
|
| visitor.visitAllNodes(unit);
|
| expect(nodes, hasLength(59));
|
| EngineTestCase.assertInstanceOf(
|
| - (obj) => obj is CompilationUnit,
|
| - CompilationUnit,
|
| - nodes[0]);
|
| + (obj) => obj is CompilationUnit, CompilationUnit, nodes[0]);
|
| EngineTestCase.assertInstanceOf(
|
| - (obj) => obj is ClassDeclaration,
|
| - ClassDeclaration,
|
| - nodes[2]);
|
| + (obj) => obj is ClassDeclaration, ClassDeclaration, nodes[2]);
|
| EngineTestCase.assertInstanceOf(
|
| - (obj) => obj is FunctionDeclaration,
|
| - FunctionDeclaration,
|
| - nodes[3]);
|
| + (obj) => obj is FunctionDeclaration, FunctionDeclaration, nodes[3]);
|
| EngineTestCase.assertInstanceOf(
|
| (obj) => obj is FunctionDeclarationStatement,
|
| - FunctionDeclarationStatement,
|
| - nodes[27]);
|
| + FunctionDeclarationStatement, nodes[27]);
|
| EngineTestCase.assertInstanceOf(
|
| - (obj) => obj is IntegerLiteral,
|
| - IntegerLiteral,
|
| - nodes[58]);
|
| + (obj) => obj is IntegerLiteral, IntegerLiteral, nodes[58]);
|
| //3
|
| }
|
| }
|
| @@ -153,30 +144,17 @@ class ClassDeclarationTest extends ParserTestCase {
|
| void test_getConstructor() {
|
| List<ConstructorInitializer> initializers =
|
| new List<ConstructorInitializer>();
|
| - ConstructorDeclaration defaultConstructor =
|
| - AstFactory.constructorDeclaration(
|
| - AstFactory.identifier3("Test"),
|
| - null,
|
| - AstFactory.formalParameterList(),
|
| - initializers);
|
| + ConstructorDeclaration defaultConstructor = AstFactory
|
| + .constructorDeclaration(AstFactory.identifier3("Test"), null,
|
| + AstFactory.formalParameterList(), initializers);
|
| ConstructorDeclaration aConstructor = AstFactory.constructorDeclaration(
|
| - AstFactory.identifier3("Test"),
|
| - "a",
|
| - AstFactory.formalParameterList(),
|
| + AstFactory.identifier3("Test"), "a", AstFactory.formalParameterList(),
|
| initializers);
|
| ConstructorDeclaration bConstructor = AstFactory.constructorDeclaration(
|
| - AstFactory.identifier3("Test"),
|
| - "b",
|
| - AstFactory.formalParameterList(),
|
| + AstFactory.identifier3("Test"), "b", AstFactory.formalParameterList(),
|
| initializers);
|
| - ClassDeclaration clazz = AstFactory.classDeclaration(
|
| - null,
|
| - "Test",
|
| - null,
|
| - null,
|
| - null,
|
| - null,
|
| - [defaultConstructor, aConstructor, bConstructor]);
|
| + ClassDeclaration clazz = AstFactory.classDeclaration(null, "Test", null,
|
| + null, null, null, [defaultConstructor, aConstructor, bConstructor]);
|
| expect(clazz.getConstructor(null), same(defaultConstructor));
|
| expect(clazz.getConstructor("a"), same(aConstructor));
|
| expect(clazz.getConstructor("b"), same(bConstructor));
|
| @@ -187,16 +165,11 @@ class ClassDeclarationTest extends ParserTestCase {
|
| VariableDeclaration aVar = AstFactory.variableDeclaration("a");
|
| VariableDeclaration bVar = AstFactory.variableDeclaration("b");
|
| VariableDeclaration cVar = AstFactory.variableDeclaration("c");
|
| - ClassDeclaration clazz = AstFactory.classDeclaration(
|
| - null,
|
| - "Test",
|
| - null,
|
| - null,
|
| - null,
|
| - null,
|
| - [
|
| - AstFactory.fieldDeclaration2(false, null, [aVar]),
|
| - AstFactory.fieldDeclaration2(false, null, [bVar, cVar])]);
|
| + ClassDeclaration clazz = AstFactory.classDeclaration(null, "Test", null,
|
| + null, null, null, [
|
| + AstFactory.fieldDeclaration2(false, null, [aVar]),
|
| + AstFactory.fieldDeclaration2(false, null, [bVar, cVar])
|
| + ]);
|
| expect(clazz.getField("a"), same(aVar));
|
| expect(clazz.getField("b"), same(bVar));
|
| expect(clazz.getField("c"), same(cVar));
|
| @@ -204,46 +177,22 @@ class ClassDeclarationTest extends ParserTestCase {
|
| }
|
|
|
| void test_getMethod() {
|
| - MethodDeclaration aMethod = AstFactory.methodDeclaration(
|
| - null,
|
| - null,
|
| - null,
|
| - null,
|
| - AstFactory.identifier3("a"),
|
| - AstFactory.formalParameterList());
|
| - MethodDeclaration bMethod = AstFactory.methodDeclaration(
|
| - null,
|
| - null,
|
| - null,
|
| - null,
|
| - AstFactory.identifier3("b"),
|
| - AstFactory.formalParameterList());
|
| + MethodDeclaration aMethod = AstFactory.methodDeclaration(null, null, null,
|
| + null, AstFactory.identifier3("a"), AstFactory.formalParameterList());
|
| + MethodDeclaration bMethod = AstFactory.methodDeclaration(null, null, null,
|
| + null, AstFactory.identifier3("b"), AstFactory.formalParameterList());
|
| ClassDeclaration clazz = AstFactory.classDeclaration(
|
| - null,
|
| - "Test",
|
| - null,
|
| - null,
|
| - null,
|
| - null,
|
| - [aMethod, bMethod]);
|
| + null, "Test", null, null, null, null, [aMethod, bMethod]);
|
| expect(clazz.getMethod("a"), same(aMethod));
|
| expect(clazz.getMethod("b"), same(bMethod));
|
| expect(clazz.getMethod("noSuchMethod"), same(null));
|
| }
|
|
|
| void test_isAbstract() {
|
| - expect(
|
| - AstFactory.classDeclaration(null, "A", null, null, null, null).isAbstract,
|
| - isFalse);
|
| - expect(
|
| - AstFactory.classDeclaration(
|
| - Keyword.ABSTRACT,
|
| - "B",
|
| - null,
|
| - null,
|
| - null,
|
| - null).isAbstract,
|
| - isTrue);
|
| + expect(AstFactory.classDeclaration(
|
| + null, "A", null, null, null, null).isAbstract, isFalse);
|
| + expect(AstFactory.classDeclaration(
|
| + Keyword.ABSTRACT, "B", null, null, null, null).isAbstract, isTrue);
|
| }
|
| }
|
|
|
| @@ -253,15 +202,8 @@ class ClassTypeAliasTest extends ParserTestCase {
|
| expect(
|
| AstFactory.classTypeAlias("A", null, null, null, null, null).isAbstract,
|
| isFalse);
|
| - expect(
|
| - AstFactory.classTypeAlias(
|
| - "B",
|
| - null,
|
| - Keyword.ABSTRACT,
|
| - null,
|
| - null,
|
| - null).isAbstract,
|
| - isTrue);
|
| + expect(AstFactory.classTypeAlias(
|
| + "B", null, Keyword.ABSTRACT, null, null, null).isAbstract, isTrue);
|
| }
|
| }
|
|
|
| @@ -589,13 +531,8 @@ class ConstructorDeclarationTest extends EngineTestCase {
|
| Token externalKeyword = TokenFactory.tokenFromKeyword(Keyword.EXTERNAL);
|
| externalKeyword.offset = 14;
|
| ConstructorDeclaration declaration = AstFactory.constructorDeclaration2(
|
| - Keyword.CONST,
|
| - Keyword.FACTORY,
|
| - AstFactory.identifier3('int'),
|
| - null,
|
| - null,
|
| - null,
|
| - null);
|
| + Keyword.CONST, Keyword.FACTORY, AstFactory.identifier3('int'), null,
|
| + null, null, null);
|
| declaration.externalKeyword = externalKeyword;
|
| declaration.constKeyword.offset = 8;
|
| Token factoryKeyword = declaration.factoryKeyword;
|
| @@ -607,13 +544,8 @@ class ConstructorDeclarationTest extends EngineTestCase {
|
| Token token = TokenFactory.tokenFromKeyword(Keyword.EXTERNAL);
|
| token.offset = 0;
|
| ConstructorDeclaration declaration = AstFactory.constructorDeclaration2(
|
| - Keyword.CONST,
|
| - Keyword.FACTORY,
|
| - AstFactory.identifier3('int'),
|
| - null,
|
| - null,
|
| - null,
|
| - null);
|
| + Keyword.CONST, Keyword.FACTORY, AstFactory.identifier3('int'), null,
|
| + null, null, null);
|
| declaration.externalKeyword = token;
|
| declaration.constKeyword.offset = 9;
|
| declaration.factoryKeyword.offset = 15;
|
| @@ -622,43 +554,25 @@ class ConstructorDeclarationTest extends EngineTestCase {
|
|
|
| void test_firstTokenAfterCommentAndMetadata_constOnly() {
|
| ConstructorDeclaration declaration = AstFactory.constructorDeclaration2(
|
| - Keyword.CONST,
|
| - null,
|
| - AstFactory.identifier3('int'),
|
| - null,
|
| - null,
|
| - null,
|
| + Keyword.CONST, null, AstFactory.identifier3('int'), null, null, null,
|
| null);
|
| - expect(
|
| - declaration.firstTokenAfterCommentAndMetadata,
|
| + expect(declaration.firstTokenAfterCommentAndMetadata,
|
| declaration.constKeyword);
|
| }
|
|
|
| void test_firstTokenAfterCommentAndMetadata_externalOnly() {
|
| Token externalKeyword = TokenFactory.tokenFromKeyword(Keyword.EXTERNAL);
|
| ConstructorDeclaration declaration = AstFactory.constructorDeclaration2(
|
| - null,
|
| - null,
|
| - AstFactory.identifier3('int'),
|
| - null,
|
| - null,
|
| - null,
|
| - null);
|
| + null, null, AstFactory.identifier3('int'), null, null, null, null);
|
| declaration.externalKeyword = externalKeyword;
|
| expect(declaration.firstTokenAfterCommentAndMetadata, externalKeyword);
|
| }
|
|
|
| void test_firstTokenAfterCommentAndMetadata_factoryOnly() {
|
| ConstructorDeclaration declaration = AstFactory.constructorDeclaration2(
|
| - null,
|
| - Keyword.FACTORY,
|
| - AstFactory.identifier3('int'),
|
| - null,
|
| - null,
|
| - null,
|
| + null, Keyword.FACTORY, AstFactory.identifier3('int'), null, null, null,
|
| null);
|
| - expect(
|
| - declaration.firstTokenAfterCommentAndMetadata,
|
| + expect(declaration.firstTokenAfterCommentAndMetadata,
|
| declaration.factoryKeyword);
|
| }
|
| }
|
| @@ -671,7 +585,8 @@ class FieldFormalParameterTest extends EngineTestCase {
|
| }
|
|
|
| void test_endToken_parameters() {
|
| - FieldFormalParameter parameter = AstFactory.fieldFormalParameter(null, null, 'field', AstFactory.formalParameterList([]));
|
| + FieldFormalParameter parameter = AstFactory.fieldFormalParameter(
|
| + null, null, 'field', AstFactory.formalParameterList([]));
|
| expect(parameter.endToken, parameter.parameters.endToken);
|
| }
|
| }
|
| @@ -680,104 +595,79 @@ class FieldFormalParameterTest extends EngineTestCase {
|
| class IndexExpressionTest extends EngineTestCase {
|
| void test_inGetterContext_assignment_compound_left() {
|
| IndexExpression expression = AstFactory.indexExpression(
|
| - AstFactory.identifier3("a"),
|
| - AstFactory.identifier3("b"));
|
| + AstFactory.identifier3("a"), AstFactory.identifier3("b"));
|
| // a[b] += c
|
| AstFactory.assignmentExpression(
|
| - expression,
|
| - TokenType.PLUS_EQ,
|
| - AstFactory.identifier3("c"));
|
| + expression, TokenType.PLUS_EQ, AstFactory.identifier3("c"));
|
| expect(expression.inGetterContext(), isTrue);
|
| }
|
|
|
| void test_inGetterContext_assignment_simple_left() {
|
| IndexExpression expression = AstFactory.indexExpression(
|
| - AstFactory.identifier3("a"),
|
| - AstFactory.identifier3("b"));
|
| + AstFactory.identifier3("a"), AstFactory.identifier3("b"));
|
| // a[b] = c
|
| AstFactory.assignmentExpression(
|
| - expression,
|
| - TokenType.EQ,
|
| - AstFactory.identifier3("c"));
|
| + expression, TokenType.EQ, AstFactory.identifier3("c"));
|
| expect(expression.inGetterContext(), isFalse);
|
| }
|
|
|
| void test_inGetterContext_nonAssignment() {
|
| IndexExpression expression = AstFactory.indexExpression(
|
| - AstFactory.identifier3("a"),
|
| - AstFactory.identifier3("b"));
|
| + AstFactory.identifier3("a"), AstFactory.identifier3("b"));
|
| // a[b] + c
|
| AstFactory.binaryExpression(
|
| - expression,
|
| - TokenType.PLUS,
|
| - AstFactory.identifier3("c"));
|
| + expression, TokenType.PLUS, AstFactory.identifier3("c"));
|
| expect(expression.inGetterContext(), isTrue);
|
| }
|
|
|
| void test_inSetterContext_assignment_compound_left() {
|
| IndexExpression expression = AstFactory.indexExpression(
|
| - AstFactory.identifier3("a"),
|
| - AstFactory.identifier3("b"));
|
| + AstFactory.identifier3("a"), AstFactory.identifier3("b"));
|
| // a[b] += c
|
| AstFactory.assignmentExpression(
|
| - expression,
|
| - TokenType.PLUS_EQ,
|
| - AstFactory.identifier3("c"));
|
| + expression, TokenType.PLUS_EQ, AstFactory.identifier3("c"));
|
| expect(expression.inSetterContext(), isTrue);
|
| }
|
|
|
| void test_inSetterContext_assignment_compound_right() {
|
| IndexExpression expression = AstFactory.indexExpression(
|
| - AstFactory.identifier3("a"),
|
| - AstFactory.identifier3("b"));
|
| + AstFactory.identifier3("a"), AstFactory.identifier3("b"));
|
| // c += a[b]
|
| AstFactory.assignmentExpression(
|
| - AstFactory.identifier3("c"),
|
| - TokenType.PLUS_EQ,
|
| - expression);
|
| + AstFactory.identifier3("c"), TokenType.PLUS_EQ, expression);
|
| expect(expression.inSetterContext(), isFalse);
|
| }
|
|
|
| void test_inSetterContext_assignment_simple_left() {
|
| IndexExpression expression = AstFactory.indexExpression(
|
| - AstFactory.identifier3("a"),
|
| - AstFactory.identifier3("b"));
|
| + AstFactory.identifier3("a"), AstFactory.identifier3("b"));
|
| // a[b] = c
|
| AstFactory.assignmentExpression(
|
| - expression,
|
| - TokenType.EQ,
|
| - AstFactory.identifier3("c"));
|
| + expression, TokenType.EQ, AstFactory.identifier3("c"));
|
| expect(expression.inSetterContext(), isTrue);
|
| }
|
|
|
| void test_inSetterContext_assignment_simple_right() {
|
| IndexExpression expression = AstFactory.indexExpression(
|
| - AstFactory.identifier3("a"),
|
| - AstFactory.identifier3("b"));
|
| + AstFactory.identifier3("a"), AstFactory.identifier3("b"));
|
| // c = a[b]
|
| AstFactory.assignmentExpression(
|
| - AstFactory.identifier3("c"),
|
| - TokenType.EQ,
|
| - expression);
|
| + AstFactory.identifier3("c"), TokenType.EQ, expression);
|
| expect(expression.inSetterContext(), isFalse);
|
| }
|
|
|
| void test_inSetterContext_nonAssignment() {
|
| IndexExpression expression = AstFactory.indexExpression(
|
| - AstFactory.identifier3("a"),
|
| - AstFactory.identifier3("b"));
|
| + AstFactory.identifier3("a"), AstFactory.identifier3("b"));
|
| AstFactory.binaryExpression(
|
| - expression,
|
| - TokenType.PLUS,
|
| - AstFactory.identifier3("c"));
|
| + expression, TokenType.PLUS, AstFactory.identifier3("c"));
|
| // a[b] + cc
|
| expect(expression.inSetterContext(), isFalse);
|
| }
|
|
|
| void test_inSetterContext_postfix() {
|
| IndexExpression expression = AstFactory.indexExpression(
|
| - AstFactory.identifier3("a"),
|
| - AstFactory.identifier3("b"));
|
| + AstFactory.identifier3("a"), AstFactory.identifier3("b"));
|
| AstFactory.postfixExpression(expression, TokenType.PLUS_PLUS);
|
| // a[b]++
|
| expect(expression.inSetterContext(), isTrue);
|
| @@ -785,8 +675,7 @@ class IndexExpressionTest extends EngineTestCase {
|
|
|
| void test_inSetterContext_prefix_bang() {
|
| IndexExpression expression = AstFactory.indexExpression(
|
| - AstFactory.identifier3("a"),
|
| - AstFactory.identifier3("b"));
|
| + AstFactory.identifier3("a"), AstFactory.identifier3("b"));
|
| // !a[b]
|
| AstFactory.prefixExpression(TokenType.BANG, expression);
|
| expect(expression.inSetterContext(), isFalse);
|
| @@ -794,8 +683,7 @@ class IndexExpressionTest extends EngineTestCase {
|
|
|
| void test_inSetterContext_prefix_minusMinus() {
|
| IndexExpression expression = AstFactory.indexExpression(
|
| - AstFactory.identifier3("a"),
|
| - AstFactory.identifier3("b"));
|
| + AstFactory.identifier3("a"), AstFactory.identifier3("b"));
|
| // --a[b]
|
| AstFactory.prefixExpression(TokenType.MINUS_MINUS, expression);
|
| expect(expression.inSetterContext(), isTrue);
|
| @@ -803,8 +691,7 @@ class IndexExpressionTest extends EngineTestCase {
|
|
|
| void test_inSetterContext_prefix_plusPlus() {
|
| IndexExpression expression = AstFactory.indexExpression(
|
| - AstFactory.identifier3("a"),
|
| - AstFactory.identifier3("b"));
|
| + AstFactory.identifier3("a"), AstFactory.identifier3("b"));
|
| // ++a[b]
|
| AstFactory.prefixExpression(TokenType.PLUS_PLUS, expression);
|
| expect(expression.inSetterContext(), isTrue);
|
| @@ -1045,11 +932,7 @@ class NodeLocatorTest extends ParserTestCase {
|
| CompilationUnit unit =
|
| ParserTestCase.parseCompilationUnit("library myLib;");
|
| _assertLocate(
|
| - unit,
|
| - 4,
|
| - 10,
|
| - (node) => node is LibraryDirective,
|
| - LibraryDirective);
|
| + unit, 4, 10, (node) => node is LibraryDirective, LibraryDirective);
|
| }
|
|
|
| void test_searchWithin_null() {
|
| @@ -1061,11 +944,7 @@ class NodeLocatorTest extends ParserTestCase {
|
| CompilationUnit unit =
|
| ParserTestCase.parseCompilationUnit("library myLib;");
|
| _assertLocate(
|
| - unit,
|
| - 10,
|
| - 10,
|
| - (node) => node is SimpleIdentifier,
|
| - SimpleIdentifier);
|
| + unit, 10, 10, (node) => node is SimpleIdentifier, SimpleIdentifier);
|
| }
|
|
|
| void test_searchWithin_offsetAfterNode() {
|
| @@ -1093,9 +972,7 @@ class B {}''');
|
| expect(node, isNotNull);
|
| expect(locator.foundNode, same(node));
|
| expect(node.offset <= start, isTrue, reason: "Node starts after range");
|
| - expect(
|
| - node.offset + node.length > end,
|
| - isTrue,
|
| + expect(node.offset + node.length > end, isTrue,
|
| reason: "Node ends before range");
|
| EngineTestCase.assertInstanceOf(predicate, expectedClass, node);
|
| }
|
| @@ -1129,10 +1006,7 @@ class SimpleIdentifierTest extends ParserTestCase {
|
|
|
| void test_inDeclarationContext_constructorDeclaration() {
|
| SimpleIdentifier identifier = AstFactory.constructorDeclaration(
|
| - AstFactory.identifier3("C"),
|
| - "c",
|
| - null,
|
| - null).name;
|
| + AstFactory.identifier3("C"), "c", null, null).name;
|
| expect(identifier.inDeclarationContext(), isTrue);
|
| }
|
|
|
| @@ -1190,13 +1064,7 @@ class SimpleIdentifierTest extends ParserTestCase {
|
| void test_inDeclarationContext_methodDeclaration() {
|
| SimpleIdentifier identifier = AstFactory.identifier3("m");
|
| AstFactory.methodDeclaration2(
|
| - null,
|
| - null,
|
| - null,
|
| - null,
|
| - identifier,
|
| - null,
|
| - null);
|
| + null, null, null, null, identifier, null, null);
|
| expect(identifier.inDeclarationContext(), isTrue);
|
| }
|
|
|
| @@ -1259,8 +1127,7 @@ class SimpleIdentifierTest extends ParserTestCase {
|
| void test_inReferenceContext() {
|
| SimpleIdentifier identifier = AstFactory.identifier3("id");
|
| AstFactory.namedExpression(
|
| - AstFactory.label(identifier),
|
| - AstFactory.identifier3("_"));
|
| + AstFactory.label(identifier), AstFactory.identifier3("_"));
|
| expect(identifier.inGetterContext(), isFalse);
|
| expect(identifier.inSetterContext(), isFalse);
|
| }
|
| @@ -1305,9 +1172,9 @@ class SimpleIdentifierTest extends ParserTestCase {
|
|
|
| void test_isQualified_inMethodInvocation_withTarget() {
|
| MethodInvocation invocation = AstFactory.methodInvocation(
|
| - AstFactory.identifier3("target"),
|
| - "test",
|
| - [AstFactory.identifier3("arg0")]);
|
| + AstFactory.identifier3("target"), "test", [
|
| + AstFactory.identifier3("arg0")
|
| + ]);
|
| SimpleIdentifier identifier = invocation.methodName;
|
| expect(identifier.isQualified, isTrue);
|
| }
|
| @@ -1342,8 +1209,8 @@ class SimpleIdentifierTest extends ParserTestCase {
|
| expect(identifier.isQualified, isFalse);
|
| }
|
|
|
| - SimpleIdentifier _createIdentifier(WrapperKind wrapper,
|
| - AssignmentKind assignment) {
|
| + SimpleIdentifier _createIdentifier(
|
| + WrapperKind wrapper, AssignmentKind assignment) {
|
| SimpleIdentifier identifier = AstFactory.identifier3("a");
|
| Expression expression = identifier;
|
| while (true) {
|
| @@ -1358,26 +1225,19 @@ class SimpleIdentifierTest extends ParserTestCase {
|
| } else if (wrapper == WrapperKind.PROPERTY_RIGHT) {
|
| expression =
|
| AstFactory.propertyAccess(AstFactory.identifier3("_"), identifier);
|
| - } else if (wrapper == WrapperKind.NONE) {
|
| - }
|
| + } else if (wrapper == WrapperKind.NONE) {}
|
| break;
|
| }
|
| while (true) {
|
| if (assignment == AssignmentKind.BINARY) {
|
| AstFactory.binaryExpression(
|
| - expression,
|
| - TokenType.PLUS,
|
| - AstFactory.identifier3("_"));
|
| + expression, TokenType.PLUS, AstFactory.identifier3("_"));
|
| } else if (assignment == AssignmentKind.COMPOUND_LEFT) {
|
| AstFactory.assignmentExpression(
|
| - expression,
|
| - TokenType.PLUS_EQ,
|
| - AstFactory.identifier3("_"));
|
| + expression, TokenType.PLUS_EQ, AstFactory.identifier3("_"));
|
| } else if (assignment == AssignmentKind.COMPOUND_RIGHT) {
|
| AstFactory.assignmentExpression(
|
| - AstFactory.identifier3("_"),
|
| - TokenType.PLUS_EQ,
|
| - expression);
|
| + AstFactory.identifier3("_"), TokenType.PLUS_EQ, expression);
|
| } else if (assignment == AssignmentKind.POSTFIX_INC) {
|
| AstFactory.postfixExpression(expression, TokenType.PLUS_PLUS);
|
| } else if (assignment == AssignmentKind.PREFIX_DEC) {
|
| @@ -1388,16 +1248,11 @@ class SimpleIdentifierTest extends ParserTestCase {
|
| AstFactory.prefixExpression(TokenType.BANG, expression);
|
| } else if (assignment == AssignmentKind.SIMPLE_LEFT) {
|
| AstFactory.assignmentExpression(
|
| - expression,
|
| - TokenType.EQ,
|
| - AstFactory.identifier3("_"));
|
| + expression, TokenType.EQ, AstFactory.identifier3("_"));
|
| } else if (assignment == AssignmentKind.SIMPLE_RIGHT) {
|
| AstFactory.assignmentExpression(
|
| - AstFactory.identifier3("_"),
|
| - TokenType.EQ,
|
| - expression);
|
| - } else if (assignment == AssignmentKind.NONE) {
|
| - }
|
| + AstFactory.identifier3("_"), TokenType.EQ, expression);
|
| + } else if (assignment == AssignmentKind.NONE) {}
|
| break;
|
| }
|
| return identifier;
|
| @@ -1423,119 +1278,61 @@ class SimpleIdentifierTest extends ParserTestCase {
|
| @reflectiveTest
|
| class SimpleStringLiteralTest extends ParserTestCase {
|
| void test_contentsEnd() {
|
| - expect(
|
| - new SimpleStringLiteral(TokenFactory.tokenFromString("'X'"), "X").contentsEnd,
|
| - 2);
|
| - expect(
|
| - new SimpleStringLiteral(TokenFactory.tokenFromString("\"X\""), "X").contentsEnd,
|
| - 2);
|
| - expect(
|
| - new SimpleStringLiteral(
|
| - TokenFactory.tokenFromString("\"\"\"X\"\"\""),
|
| - "X").contentsEnd,
|
| - 4);
|
| - expect(
|
| - new SimpleStringLiteral(
|
| - TokenFactory.tokenFromString("'''X'''"),
|
| - "X").contentsEnd,
|
| - 4);
|
| - expect(
|
| - new SimpleStringLiteral(TokenFactory.tokenFromString("r'X'"), "X").contentsEnd,
|
| - 3);
|
| - expect(
|
| - new SimpleStringLiteral(
|
| - TokenFactory.tokenFromString("r\"X\""),
|
| - "X").contentsEnd,
|
| - 3);
|
| - expect(
|
| - new SimpleStringLiteral(
|
| - TokenFactory.tokenFromString("r\"\"\"X\"\"\""),
|
| - "X").contentsEnd,
|
| - 5);
|
| - expect(
|
| - new SimpleStringLiteral(
|
| - TokenFactory.tokenFromString("r'''X'''"),
|
| - "X").contentsEnd,
|
| - 5);
|
| + expect(new SimpleStringLiteral(
|
| + TokenFactory.tokenFromString("'X'"), "X").contentsEnd, 2);
|
| + expect(new SimpleStringLiteral(
|
| + TokenFactory.tokenFromString("\"X\""), "X").contentsEnd, 2);
|
| + expect(new SimpleStringLiteral(
|
| + TokenFactory.tokenFromString("\"\"\"X\"\"\""), "X").contentsEnd, 4);
|
| + expect(new SimpleStringLiteral(
|
| + TokenFactory.tokenFromString("'''X'''"), "X").contentsEnd, 4);
|
| + expect(new SimpleStringLiteral(
|
| + TokenFactory.tokenFromString("r'X'"), "X").contentsEnd, 3);
|
| + expect(new SimpleStringLiteral(
|
| + TokenFactory.tokenFromString("r\"X\""), "X").contentsEnd, 3);
|
| + expect(new SimpleStringLiteral(
|
| + TokenFactory.tokenFromString("r\"\"\"X\"\"\""), "X").contentsEnd, 5);
|
| + expect(new SimpleStringLiteral(
|
| + TokenFactory.tokenFromString("r'''X'''"), "X").contentsEnd, 5);
|
| }
|
|
|
| void test_contentsOffset() {
|
| - expect(
|
| - new SimpleStringLiteral(
|
| - TokenFactory.tokenFromString("'X'"),
|
| - "X").contentsOffset,
|
| - 1);
|
| - expect(
|
| - new SimpleStringLiteral(
|
| - TokenFactory.tokenFromString("\"X\""),
|
| - "X").contentsOffset,
|
| - 1);
|
| - expect(
|
| - new SimpleStringLiteral(
|
| - TokenFactory.tokenFromString("\"\"\"X\"\"\""),
|
| - "X").contentsOffset,
|
| - 3);
|
| - expect(
|
| - new SimpleStringLiteral(
|
| - TokenFactory.tokenFromString("'''X'''"),
|
| - "X").contentsOffset,
|
| - 3);
|
| - expect(
|
| - new SimpleStringLiteral(
|
| - TokenFactory.tokenFromString("r'X'"),
|
| - "X").contentsOffset,
|
| - 2);
|
| - expect(
|
| - new SimpleStringLiteral(
|
| - TokenFactory.tokenFromString("r\"X\""),
|
| - "X").contentsOffset,
|
| - 2);
|
| - expect(
|
| - new SimpleStringLiteral(
|
| - TokenFactory.tokenFromString("r\"\"\"X\"\"\""),
|
| - "X").contentsOffset,
|
| - 4);
|
| - expect(
|
| - new SimpleStringLiteral(
|
| - TokenFactory.tokenFromString("r'''X'''"),
|
| - "X").contentsOffset,
|
| - 4);
|
| + expect(new SimpleStringLiteral(
|
| + TokenFactory.tokenFromString("'X'"), "X").contentsOffset, 1);
|
| + expect(new SimpleStringLiteral(
|
| + TokenFactory.tokenFromString("\"X\""), "X").contentsOffset, 1);
|
| + expect(new SimpleStringLiteral(
|
| + TokenFactory.tokenFromString("\"\"\"X\"\"\""), "X").contentsOffset, 3);
|
| + expect(new SimpleStringLiteral(
|
| + TokenFactory.tokenFromString("'''X'''"), "X").contentsOffset, 3);
|
| + expect(new SimpleStringLiteral(
|
| + TokenFactory.tokenFromString("r'X'"), "X").contentsOffset, 2);
|
| + expect(new SimpleStringLiteral(
|
| + TokenFactory.tokenFromString("r\"X\""), "X").contentsOffset, 2);
|
| + expect(new SimpleStringLiteral(
|
| + TokenFactory.tokenFromString("r\"\"\"X\"\"\""), "X").contentsOffset, 4);
|
| + expect(new SimpleStringLiteral(
|
| + TokenFactory.tokenFromString("r'''X'''"), "X").contentsOffset, 4);
|
| }
|
|
|
| void test_isMultiline() {
|
| - expect(
|
| - new SimpleStringLiteral(TokenFactory.tokenFromString("'X'"), "X").isMultiline,
|
| - isFalse);
|
| - expect(
|
| - new SimpleStringLiteral(TokenFactory.tokenFromString("r'X'"), "X").isMultiline,
|
| - isFalse);
|
| - expect(
|
| - new SimpleStringLiteral(TokenFactory.tokenFromString("\"X\""), "X").isMultiline,
|
| - isFalse);
|
| - expect(
|
| - new SimpleStringLiteral(
|
| - TokenFactory.tokenFromString("r\"X\""),
|
| - "X").isMultiline,
|
| - isFalse);
|
| - expect(
|
| - new SimpleStringLiteral(
|
| - TokenFactory.tokenFromString("'''X'''"),
|
| - "X").isMultiline,
|
| + expect(new SimpleStringLiteral(
|
| + TokenFactory.tokenFromString("'X'"), "X").isMultiline, isFalse);
|
| + expect(new SimpleStringLiteral(
|
| + TokenFactory.tokenFromString("r'X'"), "X").isMultiline, isFalse);
|
| + expect(new SimpleStringLiteral(
|
| + TokenFactory.tokenFromString("\"X\""), "X").isMultiline, isFalse);
|
| + expect(new SimpleStringLiteral(
|
| + TokenFactory.tokenFromString("r\"X\""), "X").isMultiline, isFalse);
|
| + expect(new SimpleStringLiteral(
|
| + TokenFactory.tokenFromString("'''X'''"), "X").isMultiline, isTrue);
|
| + expect(new SimpleStringLiteral(
|
| + TokenFactory.tokenFromString("r'''X'''"), "X").isMultiline, isTrue);
|
| + expect(new SimpleStringLiteral(
|
| + TokenFactory.tokenFromString("\"\"\"X\"\"\""), "X").isMultiline,
|
| isTrue);
|
| - expect(
|
| - new SimpleStringLiteral(
|
| - TokenFactory.tokenFromString("r'''X'''"),
|
| - "X").isMultiline,
|
| - isTrue);
|
| - expect(
|
| - new SimpleStringLiteral(
|
| - TokenFactory.tokenFromString("\"\"\"X\"\"\""),
|
| - "X").isMultiline,
|
| - isTrue);
|
| - expect(
|
| - new SimpleStringLiteral(
|
| - TokenFactory.tokenFromString("r\"\"\"X\"\"\""),
|
| - "X").isMultiline,
|
| + expect(new SimpleStringLiteral(
|
| + TokenFactory.tokenFromString("r\"\"\"X\"\"\""), "X").isMultiline,
|
| isTrue);
|
| }
|
|
|
| @@ -1543,31 +1340,20 @@ class SimpleStringLiteralTest extends ParserTestCase {
|
| expect(
|
| new SimpleStringLiteral(TokenFactory.tokenFromString("'X'"), "X").isRaw,
|
| isFalse);
|
| - expect(
|
| - new SimpleStringLiteral(TokenFactory.tokenFromString("\"X\""), "X").isRaw,
|
| - isFalse);
|
| - expect(
|
| - new SimpleStringLiteral(
|
| - TokenFactory.tokenFromString("\"\"\"X\"\"\""),
|
| - "X").isRaw,
|
| - isFalse);
|
| - expect(
|
| - new SimpleStringLiteral(TokenFactory.tokenFromString("'''X'''"), "X").isRaw,
|
| - isFalse);
|
| - expect(
|
| - new SimpleStringLiteral(TokenFactory.tokenFromString("r'X'"), "X").isRaw,
|
| - isTrue);
|
| - expect(
|
| - new SimpleStringLiteral(TokenFactory.tokenFromString("r\"X\""), "X").isRaw,
|
| - isTrue);
|
| - expect(
|
| - new SimpleStringLiteral(
|
| - TokenFactory.tokenFromString("r\"\"\"X\"\"\""),
|
| - "X").isRaw,
|
| - isTrue);
|
| - expect(
|
| - new SimpleStringLiteral(TokenFactory.tokenFromString("r'''X'''"), "X").isRaw,
|
| - isTrue);
|
| + expect(new SimpleStringLiteral(
|
| + TokenFactory.tokenFromString("\"X\""), "X").isRaw, isFalse);
|
| + expect(new SimpleStringLiteral(
|
| + TokenFactory.tokenFromString("\"\"\"X\"\"\""), "X").isRaw, isFalse);
|
| + expect(new SimpleStringLiteral(
|
| + TokenFactory.tokenFromString("'''X'''"), "X").isRaw, isFalse);
|
| + expect(new SimpleStringLiteral(
|
| + TokenFactory.tokenFromString("r'X'"), "X").isRaw, isTrue);
|
| + expect(new SimpleStringLiteral(
|
| + TokenFactory.tokenFromString("r\"X\""), "X").isRaw, isTrue);
|
| + expect(new SimpleStringLiteral(
|
| + TokenFactory.tokenFromString("r\"\"\"X\"\"\""), "X").isRaw, isTrue);
|
| + expect(new SimpleStringLiteral(
|
| + TokenFactory.tokenFromString("r'''X'''"), "X").isRaw, isTrue);
|
| }
|
|
|
| void test_isSingleQuoted() {
|
| @@ -1767,9 +1553,8 @@ class StringInterpolationTest extends ParserTestCase {
|
| @reflectiveTest
|
| class ToSourceVisitorTest extends EngineTestCase {
|
| void test_visitAdjacentStrings() {
|
| - _assertSource(
|
| - "'a' 'b'",
|
| - AstFactory.adjacentStrings([AstFactory.string2("a"), AstFactory.string2("b")]));
|
| + _assertSource("'a' 'b'", AstFactory
|
| + .adjacentStrings([AstFactory.string2("a"), AstFactory.string2("b")]));
|
| }
|
|
|
| void test_visitAnnotation_constant() {
|
| @@ -1777,57 +1562,40 @@ class ToSourceVisitorTest extends EngineTestCase {
|
| }
|
|
|
| void test_visitAnnotation_constructor() {
|
| - _assertSource(
|
| - "@A.c()",
|
| - AstFactory.annotation2(
|
| - AstFactory.identifier3("A"),
|
| - AstFactory.identifier3("c"),
|
| - AstFactory.argumentList()));
|
| + _assertSource("@A.c()", AstFactory.annotation2(AstFactory.identifier3("A"),
|
| + AstFactory.identifier3("c"), AstFactory.argumentList()));
|
| }
|
|
|
| void test_visitArgumentList() {
|
| - _assertSource(
|
| - "(a, b)",
|
| - AstFactory.argumentList(
|
| - [AstFactory.identifier3("a"), AstFactory.identifier3("b")]));
|
| + _assertSource("(a, b)", AstFactory.argumentList(
|
| + [AstFactory.identifier3("a"), AstFactory.identifier3("b")]));
|
| }
|
|
|
| void test_visitAsExpression() {
|
| - _assertSource(
|
| - "e as T",
|
| - AstFactory.asExpression(
|
| - AstFactory.identifier3("e"),
|
| - AstFactory.typeName4("T")));
|
| + _assertSource("e as T", AstFactory.asExpression(
|
| + AstFactory.identifier3("e"), AstFactory.typeName4("T")));
|
| }
|
|
|
| void test_visitAssertStatement() {
|
| _assertSource(
|
| - "assert (a);",
|
| - AstFactory.assertStatement(AstFactory.identifier3("a")));
|
| + "assert (a);", AstFactory.assertStatement(AstFactory.identifier3("a")));
|
| }
|
|
|
| void test_visitAssignmentExpression() {
|
| - _assertSource(
|
| - "a = b",
|
| - AstFactory.assignmentExpression(
|
| - AstFactory.identifier3("a"),
|
| - TokenType.EQ,
|
| - AstFactory.identifier3("b")));
|
| + _assertSource("a = b", AstFactory.assignmentExpression(
|
| + AstFactory.identifier3("a"), TokenType.EQ,
|
| + AstFactory.identifier3("b")));
|
| }
|
|
|
| void test_visitAwaitExpression() {
|
| _assertSource(
|
| - "await e;",
|
| - AstFactory.awaitExpression(AstFactory.identifier3("e")));
|
| + "await e;", AstFactory.awaitExpression(AstFactory.identifier3("e")));
|
| }
|
|
|
| void test_visitBinaryExpression() {
|
| - _assertSource(
|
| - "a + b",
|
| - AstFactory.binaryExpression(
|
| - AstFactory.identifier3("a"),
|
| - TokenType.PLUS,
|
| - AstFactory.identifier3("b")));
|
| + _assertSource("a + b", AstFactory.binaryExpression(
|
| + AstFactory.identifier3("a"), TokenType.PLUS,
|
| + AstFactory.identifier3("b")));
|
| }
|
|
|
| void test_visitBlock_empty() {
|
| @@ -1835,9 +1603,8 @@ class ToSourceVisitorTest extends EngineTestCase {
|
| }
|
|
|
| void test_visitBlock_nonEmpty() {
|
| - _assertSource(
|
| - "{break; break;}",
|
| - AstFactory.block([AstFactory.breakStatement(), AstFactory.breakStatement()]));
|
| + _assertSource("{break; break;}", AstFactory
|
| + .block([AstFactory.breakStatement(), AstFactory.breakStatement()]));
|
| }
|
|
|
| void test_visitBlockFunctionBody_async() {
|
| @@ -1877,33 +1644,27 @@ class ToSourceVisitorTest extends EngineTestCase {
|
| }
|
|
|
| void test_visitCascadeExpression_field() {
|
| - _assertSource(
|
| - "a..b..c",
|
| - AstFactory.cascadeExpression(
|
| - AstFactory.identifier3("a"),
|
| - [
|
| - AstFactory.cascadedPropertyAccess("b"),
|
| - AstFactory.cascadedPropertyAccess("c")]));
|
| + _assertSource("a..b..c", AstFactory.cascadeExpression(
|
| + AstFactory.identifier3("a"), [
|
| + AstFactory.cascadedPropertyAccess("b"),
|
| + AstFactory.cascadedPropertyAccess("c")
|
| + ]));
|
| }
|
|
|
| void test_visitCascadeExpression_index() {
|
| - _assertSource(
|
| - "a..[0]..[1]",
|
| - AstFactory.cascadeExpression(
|
| - AstFactory.identifier3("a"),
|
| - [
|
| - AstFactory.cascadedIndexExpression(AstFactory.integer(0)),
|
| - AstFactory.cascadedIndexExpression(AstFactory.integer(1))]));
|
| + _assertSource("a..[0]..[1]", AstFactory.cascadeExpression(
|
| + AstFactory.identifier3("a"), [
|
| + AstFactory.cascadedIndexExpression(AstFactory.integer(0)),
|
| + AstFactory.cascadedIndexExpression(AstFactory.integer(1))
|
| + ]));
|
| }
|
|
|
| void test_visitCascadeExpression_method() {
|
| - _assertSource(
|
| - "a..b()..c()",
|
| - AstFactory.cascadeExpression(
|
| - AstFactory.identifier3("a"),
|
| - [
|
| - AstFactory.cascadedMethodInvocation("b"),
|
| - AstFactory.cascadedMethodInvocation("c")]));
|
| + _assertSource("a..b()..c()", AstFactory.cascadeExpression(
|
| + AstFactory.identifier3("a"), [
|
| + AstFactory.cascadedMethodInvocation("b"),
|
| + AstFactory.cascadedMethodInvocation("c")
|
| + ]));
|
| }
|
|
|
| void test_visitCatchClause_catch_noStack() {
|
| @@ -1916,319 +1677,190 @@ class ToSourceVisitorTest extends EngineTestCase {
|
|
|
| void test_visitCatchClause_on() {
|
| _assertSource(
|
| - "on E {}",
|
| - AstFactory.catchClause3(AstFactory.typeName4("E")));
|
| + "on E {}", AstFactory.catchClause3(AstFactory.typeName4("E")));
|
| }
|
|
|
| void test_visitCatchClause_on_catch() {
|
| - _assertSource(
|
| - "on E catch (e) {}",
|
| + _assertSource("on E catch (e) {}",
|
| AstFactory.catchClause4(AstFactory.typeName4("E"), "e"));
|
| }
|
|
|
| void test_visitClassDeclaration_abstract() {
|
| - _assertSource(
|
| - "abstract class C {}",
|
| - AstFactory.classDeclaration(Keyword.ABSTRACT, "C", null, null, null, null));
|
| + _assertSource("abstract class C {}", AstFactory.classDeclaration(
|
| + Keyword.ABSTRACT, "C", null, null, null, null));
|
| }
|
|
|
| void test_visitClassDeclaration_empty() {
|
| - _assertSource(
|
| - "class C {}",
|
| + _assertSource("class C {}",
|
| AstFactory.classDeclaration(null, "C", null, null, null, null));
|
| }
|
|
|
| void test_visitClassDeclaration_extends() {
|
| - _assertSource(
|
| - "class C extends A {}",
|
| - AstFactory.classDeclaration(
|
| - null,
|
| - "C",
|
| - null,
|
| - AstFactory.extendsClause(AstFactory.typeName4("A")),
|
| - null,
|
| - null));
|
| + _assertSource("class C extends A {}", AstFactory.classDeclaration(null, "C",
|
| + null, AstFactory.extendsClause(AstFactory.typeName4("A")), null, null));
|
| }
|
|
|
| void test_visitClassDeclaration_extends_implements() {
|
| - _assertSource(
|
| - "class C extends A implements B {}",
|
| - AstFactory.classDeclaration(
|
| - null,
|
| - "C",
|
| - null,
|
| - AstFactory.extendsClause(AstFactory.typeName4("A")),
|
| - null,
|
| + _assertSource("class C extends A implements B {}", AstFactory
|
| + .classDeclaration(null, "C", null,
|
| + AstFactory.extendsClause(AstFactory.typeName4("A")), null,
|
| AstFactory.implementsClause([AstFactory.typeName4("B")])));
|
| }
|
|
|
| void test_visitClassDeclaration_extends_with() {
|
| - _assertSource(
|
| - "class C extends A with M {}",
|
| - AstFactory.classDeclaration(
|
| - null,
|
| - "C",
|
| - null,
|
| - AstFactory.extendsClause(AstFactory.typeName4("A")),
|
| - AstFactory.withClause([AstFactory.typeName4("M")]),
|
| - null));
|
| + _assertSource("class C extends A with M {}", AstFactory.classDeclaration(
|
| + null, "C", null, AstFactory.extendsClause(AstFactory.typeName4("A")),
|
| + AstFactory.withClause([AstFactory.typeName4("M")]), null));
|
| }
|
|
|
| void test_visitClassDeclaration_extends_with_implements() {
|
| - _assertSource(
|
| - "class C extends A with M implements B {}",
|
| - AstFactory.classDeclaration(
|
| - null,
|
| - "C",
|
| - null,
|
| + _assertSource("class C extends A with M implements B {}", AstFactory
|
| + .classDeclaration(null, "C", null,
|
| AstFactory.extendsClause(AstFactory.typeName4("A")),
|
| AstFactory.withClause([AstFactory.typeName4("M")]),
|
| AstFactory.implementsClause([AstFactory.typeName4("B")])));
|
| }
|
|
|
| void test_visitClassDeclaration_implements() {
|
| - _assertSource(
|
| - "class C implements B {}",
|
| - AstFactory.classDeclaration(
|
| - null,
|
| - "C",
|
| - null,
|
| - null,
|
| - null,
|
| - AstFactory.implementsClause([AstFactory.typeName4("B")])));
|
| + _assertSource("class C implements B {}", AstFactory.classDeclaration(null,
|
| + "C", null, null, null,
|
| + AstFactory.implementsClause([AstFactory.typeName4("B")])));
|
| }
|
|
|
| void test_visitClassDeclaration_multipleMember() {
|
| - _assertSource(
|
| - "class C {var a; var b;}",
|
| - AstFactory.classDeclaration(
|
| - null,
|
| - "C",
|
| - null,
|
| - null,
|
| - null,
|
| - null,
|
| - [
|
| - AstFactory.fieldDeclaration2(
|
| - false,
|
| - Keyword.VAR,
|
| - [AstFactory.variableDeclaration("a")]),
|
| - AstFactory.fieldDeclaration2(
|
| - false,
|
| - Keyword.VAR,
|
| - [AstFactory.variableDeclaration("b")])]));
|
| + _assertSource("class C {var a; var b;}", AstFactory.classDeclaration(null,
|
| + "C", null, null, null, null, [
|
| + AstFactory.fieldDeclaration2(
|
| + false, Keyword.VAR, [AstFactory.variableDeclaration("a")]),
|
| + AstFactory.fieldDeclaration2(
|
| + false, Keyword.VAR, [AstFactory.variableDeclaration("b")])
|
| + ]));
|
| }
|
|
|
| void test_visitClassDeclaration_parameters() {
|
| - _assertSource(
|
| - "class C<E> {}",
|
| - AstFactory.classDeclaration(
|
| - null,
|
| - "C",
|
| - AstFactory.typeParameterList(["E"]),
|
| - null,
|
| - null,
|
| - null));
|
| + _assertSource("class C<E> {}", AstFactory.classDeclaration(
|
| + null, "C", AstFactory.typeParameterList(["E"]), null, null, null));
|
| }
|
|
|
| void test_visitClassDeclaration_parameters_extends() {
|
| - _assertSource(
|
| - "class C<E> extends A {}",
|
| - AstFactory.classDeclaration(
|
| - null,
|
| - "C",
|
| - AstFactory.typeParameterList(["E"]),
|
| - AstFactory.extendsClause(AstFactory.typeName4("A")),
|
| - null,
|
| - null));
|
| + _assertSource("class C<E> extends A {}", AstFactory.classDeclaration(null,
|
| + "C", AstFactory.typeParameterList(["E"]),
|
| + AstFactory.extendsClause(AstFactory.typeName4("A")), null, null));
|
| }
|
|
|
| void test_visitClassDeclaration_parameters_extends_implements() {
|
| - _assertSource(
|
| - "class C<E> extends A implements B {}",
|
| - AstFactory.classDeclaration(
|
| - null,
|
| - "C",
|
| - AstFactory.typeParameterList(["E"]),
|
| - AstFactory.extendsClause(AstFactory.typeName4("A")),
|
| - null,
|
| + _assertSource("class C<E> extends A implements B {}", AstFactory
|
| + .classDeclaration(null, "C", AstFactory.typeParameterList(["E"]),
|
| + AstFactory.extendsClause(AstFactory.typeName4("A")), null,
|
| AstFactory.implementsClause([AstFactory.typeName4("B")])));
|
| }
|
|
|
| void test_visitClassDeclaration_parameters_extends_with() {
|
| - _assertSource(
|
| - "class C<E> extends A with M {}",
|
| - AstFactory.classDeclaration(
|
| - null,
|
| - "C",
|
| - AstFactory.typeParameterList(["E"]),
|
| - AstFactory.extendsClause(AstFactory.typeName4("A")),
|
| - AstFactory.withClause([AstFactory.typeName4("M")]),
|
| - null));
|
| + _assertSource("class C<E> extends A with M {}", AstFactory.classDeclaration(
|
| + null, "C", AstFactory.typeParameterList(["E"]),
|
| + AstFactory.extendsClause(AstFactory.typeName4("A")),
|
| + AstFactory.withClause([AstFactory.typeName4("M")]), null));
|
| }
|
|
|
| void test_visitClassDeclaration_parameters_extends_with_implements() {
|
| - _assertSource(
|
| - "class C<E> extends A with M implements B {}",
|
| - AstFactory.classDeclaration(
|
| - null,
|
| - "C",
|
| - AstFactory.typeParameterList(["E"]),
|
| + _assertSource("class C<E> extends A with M implements B {}", AstFactory
|
| + .classDeclaration(null, "C", AstFactory.typeParameterList(["E"]),
|
| AstFactory.extendsClause(AstFactory.typeName4("A")),
|
| AstFactory.withClause([AstFactory.typeName4("M")]),
|
| AstFactory.implementsClause([AstFactory.typeName4("B")])));
|
| }
|
|
|
| void test_visitClassDeclaration_parameters_implements() {
|
| - _assertSource(
|
| - "class C<E> implements B {}",
|
| - AstFactory.classDeclaration(
|
| - null,
|
| - "C",
|
| - AstFactory.typeParameterList(["E"]),
|
| - null,
|
| - null,
|
| - AstFactory.implementsClause([AstFactory.typeName4("B")])));
|
| + _assertSource("class C<E> implements B {}", AstFactory.classDeclaration(
|
| + null, "C", AstFactory.typeParameterList(["E"]), null, null,
|
| + AstFactory.implementsClause([AstFactory.typeName4("B")])));
|
| }
|
|
|
| void test_visitClassDeclaration_singleMember() {
|
| - _assertSource(
|
| - "class C {var a;}",
|
| - AstFactory.classDeclaration(
|
| - null,
|
| - "C",
|
| - null,
|
| - null,
|
| - null,
|
| - null,
|
| - [
|
| - AstFactory.fieldDeclaration2(
|
| - false,
|
| - Keyword.VAR,
|
| - [AstFactory.variableDeclaration("a")])]));
|
| + _assertSource("class C {var a;}", AstFactory.classDeclaration(null, "C",
|
| + null, null, null, null, [
|
| + AstFactory.fieldDeclaration2(
|
| + false, Keyword.VAR, [AstFactory.variableDeclaration("a")])
|
| + ]));
|
| }
|
|
|
| void test_visitClassDeclaration_withMetadata() {
|
| ClassDeclaration declaration =
|
| AstFactory.classDeclaration(null, "C", null, null, null, null);
|
| - declaration.metadata.add(AstFactory.annotation(AstFactory.identifier3("deprecated")));
|
| + declaration.metadata
|
| + .add(AstFactory.annotation(AstFactory.identifier3("deprecated")));
|
| _assertSource("@deprecated class C {}", declaration);
|
| }
|
|
|
| void test_visitClassTypeAlias_abstract() {
|
| - _assertSource(
|
| - "abstract class C = S with M1;",
|
| - AstFactory.classTypeAlias(
|
| - "C",
|
| - null,
|
| - Keyword.ABSTRACT,
|
| - AstFactory.typeName4("S"),
|
| - AstFactory.withClause([AstFactory.typeName4("M1")]),
|
| - null));
|
| + _assertSource("abstract class C = S with M1;", AstFactory.classTypeAlias(
|
| + "C", null, Keyword.ABSTRACT, AstFactory.typeName4("S"),
|
| + AstFactory.withClause([AstFactory.typeName4("M1")]), null));
|
| }
|
|
|
| void test_visitClassTypeAlias_abstract_implements() {
|
| - _assertSource(
|
| - "abstract class C = S with M1 implements I;",
|
| - AstFactory.classTypeAlias(
|
| - "C",
|
| - null,
|
| - Keyword.ABSTRACT,
|
| - AstFactory.typeName4("S"),
|
| + _assertSource("abstract class C = S with M1 implements I;", AstFactory
|
| + .classTypeAlias("C", null, Keyword.ABSTRACT, AstFactory.typeName4("S"),
|
| AstFactory.withClause([AstFactory.typeName4("M1")]),
|
| AstFactory.implementsClause([AstFactory.typeName4("I")])));
|
| }
|
|
|
| void test_visitClassTypeAlias_generic() {
|
| - _assertSource(
|
| - "class C<E> = S<E> with M1<E>;",
|
| - AstFactory.classTypeAlias(
|
| - "C",
|
| - AstFactory.typeParameterList(["E"]),
|
| - null,
|
| - AstFactory.typeName4("S", [AstFactory.typeName4("E")]),
|
| - AstFactory.withClause(
|
| - [AstFactory.typeName4("M1", [AstFactory.typeName4("E")])]),
|
| - null));
|
| + _assertSource("class C<E> = S<E> with M1<E>;", AstFactory.classTypeAlias(
|
| + "C", AstFactory.typeParameterList(["E"]), null,
|
| + AstFactory.typeName4("S", [AstFactory.typeName4("E")]),
|
| + AstFactory.withClause(
|
| + [AstFactory.typeName4("M1", [AstFactory.typeName4("E")])]), null));
|
| }
|
|
|
| void test_visitClassTypeAlias_implements() {
|
| - _assertSource(
|
| - "class C = S with M1 implements I;",
|
| - AstFactory.classTypeAlias(
|
| - "C",
|
| - null,
|
| - null,
|
| - AstFactory.typeName4("S"),
|
| + _assertSource("class C = S with M1 implements I;", AstFactory
|
| + .classTypeAlias("C", null, null, AstFactory.typeName4("S"),
|
| AstFactory.withClause([AstFactory.typeName4("M1")]),
|
| AstFactory.implementsClause([AstFactory.typeName4("I")])));
|
| }
|
|
|
| void test_visitClassTypeAlias_minimal() {
|
| - _assertSource(
|
| - "class C = S with M1;",
|
| - AstFactory.classTypeAlias(
|
| - "C",
|
| - null,
|
| - null,
|
| - AstFactory.typeName4("S"),
|
| - AstFactory.withClause([AstFactory.typeName4("M1")]),
|
| - null));
|
| + _assertSource("class C = S with M1;", AstFactory.classTypeAlias("C", null,
|
| + null, AstFactory.typeName4("S"),
|
| + AstFactory.withClause([AstFactory.typeName4("M1")]), null));
|
| }
|
|
|
| void test_visitClassTypeAlias_parameters_abstract() {
|
| - _assertSource(
|
| - "abstract class C<E> = S with M1;",
|
| - AstFactory.classTypeAlias(
|
| - "C",
|
| - AstFactory.typeParameterList(["E"]),
|
| - Keyword.ABSTRACT,
|
| - AstFactory.typeName4("S"),
|
| - AstFactory.withClause([AstFactory.typeName4("M1")]),
|
| - null));
|
| + _assertSource("abstract class C<E> = S with M1;", AstFactory.classTypeAlias(
|
| + "C", AstFactory.typeParameterList(["E"]), Keyword.ABSTRACT,
|
| + AstFactory.typeName4("S"),
|
| + AstFactory.withClause([AstFactory.typeName4("M1")]), null));
|
| }
|
|
|
| void test_visitClassTypeAlias_parameters_abstract_implements() {
|
| - _assertSource(
|
| - "abstract class C<E> = S with M1 implements I;",
|
| - AstFactory.classTypeAlias(
|
| - "C",
|
| - AstFactory.typeParameterList(["E"]),
|
| - Keyword.ABSTRACT,
|
| - AstFactory.typeName4("S"),
|
| + _assertSource("abstract class C<E> = S with M1 implements I;", AstFactory
|
| + .classTypeAlias("C", AstFactory.typeParameterList(["E"]),
|
| + Keyword.ABSTRACT, AstFactory.typeName4("S"),
|
| AstFactory.withClause([AstFactory.typeName4("M1")]),
|
| AstFactory.implementsClause([AstFactory.typeName4("I")])));
|
| }
|
|
|
| void test_visitClassTypeAlias_parameters_implements() {
|
| - _assertSource(
|
| - "class C<E> = S with M1 implements I;",
|
| - AstFactory.classTypeAlias(
|
| - "C",
|
| - AstFactory.typeParameterList(["E"]),
|
| - null,
|
| + _assertSource("class C<E> = S with M1 implements I;", AstFactory
|
| + .classTypeAlias("C", AstFactory.typeParameterList(["E"]), null,
|
| AstFactory.typeName4("S"),
|
| AstFactory.withClause([AstFactory.typeName4("M1")]),
|
| AstFactory.implementsClause([AstFactory.typeName4("I")])));
|
| }
|
|
|
| void test_visitClassTypeAlias_withMetadata() {
|
| - ClassTypeAlias declaration = AstFactory.classTypeAlias(
|
| - "C",
|
| - null,
|
| - null,
|
| + ClassTypeAlias declaration = AstFactory.classTypeAlias("C", null, null,
|
| AstFactory.typeName4("S"),
|
| - AstFactory.withClause([AstFactory.typeName4("M1")]),
|
| - null);
|
| - declaration.metadata.add(AstFactory.annotation(AstFactory.identifier3("deprecated")));
|
| + AstFactory.withClause([AstFactory.typeName4("M1")]), null);
|
| + declaration.metadata
|
| + .add(AstFactory.annotation(AstFactory.identifier3("deprecated")));
|
| _assertSource("@deprecated class C = S with M1;", declaration);
|
| }
|
|
|
| void test_visitComment() {
|
| - _assertSource(
|
| - "",
|
| - Comment.createBlockComment(
|
| - <Token>[TokenFactory.tokenFromString("/* comment */")]));
|
| + _assertSource("", Comment.createBlockComment(
|
| + <Token>[TokenFactory.tokenFromString("/* comment */")]));
|
| }
|
|
|
| void test_visitCommentReference() {
|
| @@ -2236,30 +1868,24 @@ class ToSourceVisitorTest extends EngineTestCase {
|
| }
|
|
|
| void test_visitCompilationUnit_declaration() {
|
| - _assertSource(
|
| - "var a;",
|
| - AstFactory.compilationUnit2(
|
| - [
|
| - AstFactory.topLevelVariableDeclaration2(
|
| - Keyword.VAR,
|
| - [AstFactory.variableDeclaration("a")])]));
|
| + _assertSource("var a;", AstFactory.compilationUnit2([
|
| + AstFactory.topLevelVariableDeclaration2(
|
| + Keyword.VAR, [AstFactory.variableDeclaration("a")])
|
| + ]));
|
| }
|
|
|
| void test_visitCompilationUnit_directive() {
|
| - _assertSource(
|
| - "library l;",
|
| + _assertSource("library l;",
|
| AstFactory.compilationUnit3([AstFactory.libraryDirective2("l")]));
|
| }
|
|
|
| void test_visitCompilationUnit_directive_declaration() {
|
| - _assertSource(
|
| - "library l; var a;",
|
| - AstFactory.compilationUnit4(
|
| - [AstFactory.libraryDirective2("l")],
|
| - [
|
| - AstFactory.topLevelVariableDeclaration2(
|
| - Keyword.VAR,
|
| - [AstFactory.variableDeclaration("a")])]));
|
| + _assertSource("library l; var a;", AstFactory.compilationUnit4([
|
| + AstFactory.libraryDirective2("l")
|
| + ], [
|
| + AstFactory.topLevelVariableDeclaration2(
|
| + Keyword.VAR, [AstFactory.variableDeclaration("a")])
|
| + ]));
|
| }
|
|
|
| void test_visitCompilationUnit_empty() {
|
| @@ -2268,196 +1894,125 @@ class ToSourceVisitorTest extends EngineTestCase {
|
|
|
| void test_visitCompilationUnit_script() {
|
| _assertSource(
|
| - "!#/bin/dartvm",
|
| - AstFactory.compilationUnit5("!#/bin/dartvm"));
|
| + "!#/bin/dartvm", AstFactory.compilationUnit5("!#/bin/dartvm"));
|
| }
|
|
|
| void test_visitCompilationUnit_script_declaration() {
|
| - _assertSource(
|
| - "!#/bin/dartvm var a;",
|
| - AstFactory.compilationUnit6(
|
| - "!#/bin/dartvm",
|
| - [
|
| - AstFactory.topLevelVariableDeclaration2(
|
| - Keyword.VAR,
|
| - [AstFactory.variableDeclaration("a")])]));
|
| + _assertSource("!#/bin/dartvm var a;", AstFactory.compilationUnit6(
|
| + "!#/bin/dartvm", [
|
| + AstFactory.topLevelVariableDeclaration2(
|
| + Keyword.VAR, [AstFactory.variableDeclaration("a")])
|
| + ]));
|
| }
|
|
|
| void test_visitCompilationUnit_script_directive() {
|
| - _assertSource(
|
| - "!#/bin/dartvm library l;",
|
| - AstFactory.compilationUnit7(
|
| - "!#/bin/dartvm",
|
| - [AstFactory.libraryDirective2("l")]));
|
| + _assertSource("!#/bin/dartvm library l;", AstFactory.compilationUnit7(
|
| + "!#/bin/dartvm", [AstFactory.libraryDirective2("l")]));
|
| }
|
|
|
| void test_visitCompilationUnit_script_directives_declarations() {
|
| - _assertSource(
|
| - "!#/bin/dartvm library l; var a;",
|
| - AstFactory.compilationUnit8(
|
| - "!#/bin/dartvm",
|
| - [AstFactory.libraryDirective2("l")],
|
| - [
|
| - AstFactory.topLevelVariableDeclaration2(
|
| - Keyword.VAR,
|
| - [AstFactory.variableDeclaration("a")])]));
|
| + _assertSource("!#/bin/dartvm library l; var a;", AstFactory
|
| + .compilationUnit8("!#/bin/dartvm", [
|
| + AstFactory.libraryDirective2("l")
|
| + ], [
|
| + AstFactory.topLevelVariableDeclaration2(
|
| + Keyword.VAR, [AstFactory.variableDeclaration("a")])
|
| + ]));
|
| }
|
|
|
| void test_visitConditionalExpression() {
|
| - _assertSource(
|
| - "a ? b : c",
|
| - AstFactory.conditionalExpression(
|
| - AstFactory.identifier3("a"),
|
| - AstFactory.identifier3("b"),
|
| - AstFactory.identifier3("c")));
|
| + _assertSource("a ? b : c", AstFactory.conditionalExpression(
|
| + AstFactory.identifier3("a"), AstFactory.identifier3("b"),
|
| + AstFactory.identifier3("c")));
|
| }
|
|
|
| void test_visitConstructorDeclaration_const() {
|
| - _assertSource(
|
| - "const C() {}",
|
| - AstFactory.constructorDeclaration2(
|
| - Keyword.CONST,
|
| - null,
|
| - AstFactory.identifier3("C"),
|
| - null,
|
| - AstFactory.formalParameterList(),
|
| - null,
|
| - AstFactory.blockFunctionBody2()));
|
| + _assertSource("const C() {}", AstFactory.constructorDeclaration2(
|
| + Keyword.CONST, null, AstFactory.identifier3("C"), null,
|
| + AstFactory.formalParameterList(), null,
|
| + AstFactory.blockFunctionBody2()));
|
| }
|
|
|
| void test_visitConstructorDeclaration_external() {
|
| - _assertSource(
|
| - "external C();",
|
| - AstFactory.constructorDeclaration(
|
| - AstFactory.identifier3("C"),
|
| - null,
|
| - AstFactory.formalParameterList(),
|
| - null));
|
| + _assertSource("external C();", AstFactory.constructorDeclaration(
|
| + AstFactory.identifier3("C"), null, AstFactory.formalParameterList(),
|
| + null));
|
| }
|
|
|
| void test_visitConstructorDeclaration_minimal() {
|
| - _assertSource(
|
| - "C() {}",
|
| - AstFactory.constructorDeclaration2(
|
| - null,
|
| - null,
|
| - AstFactory.identifier3("C"),
|
| - null,
|
| - AstFactory.formalParameterList(),
|
| - null,
|
| - AstFactory.blockFunctionBody2()));
|
| + _assertSource("C() {}", AstFactory.constructorDeclaration2(null, null,
|
| + AstFactory.identifier3("C"), null, AstFactory.formalParameterList(),
|
| + null, AstFactory.blockFunctionBody2()));
|
| }
|
|
|
| void test_visitConstructorDeclaration_multipleInitializers() {
|
| - _assertSource(
|
| - "C() : a = b, c = d {}",
|
| - AstFactory.constructorDeclaration2(
|
| - null,
|
| - null,
|
| - AstFactory.identifier3("C"),
|
| - null,
|
| - AstFactory.formalParameterList(),
|
| - [
|
| - AstFactory.constructorFieldInitializer(false, "a", AstFactory.identifier3("b")),
|
| - AstFactory.constructorFieldInitializer(
|
| - false,
|
| - "c",
|
| - AstFactory.identifier3("d"))],
|
| - AstFactory.blockFunctionBody2()));
|
| + _assertSource("C() : a = b, c = d {}", AstFactory.constructorDeclaration2(
|
| + null, null, AstFactory.identifier3("C"), null,
|
| + AstFactory.formalParameterList(), [
|
| + AstFactory.constructorFieldInitializer(
|
| + false, "a", AstFactory.identifier3("b")),
|
| + AstFactory.constructorFieldInitializer(
|
| + false, "c", AstFactory.identifier3("d"))
|
| + ], AstFactory.blockFunctionBody2()));
|
| }
|
|
|
| void test_visitConstructorDeclaration_multipleParameters() {
|
| - _assertSource(
|
| - "C(var a, var b) {}",
|
| - AstFactory.constructorDeclaration2(
|
| - null,
|
| - null,
|
| - AstFactory.identifier3("C"),
|
| - null,
|
| - AstFactory.formalParameterList(
|
| - [
|
| - AstFactory.simpleFormalParameter(Keyword.VAR, "a"),
|
| - AstFactory.simpleFormalParameter(Keyword.VAR, "b")]),
|
| - null,
|
| - AstFactory.blockFunctionBody2()));
|
| + _assertSource("C(var a, var b) {}", AstFactory.constructorDeclaration2(null,
|
| + null, AstFactory.identifier3("C"), null, AstFactory.formalParameterList(
|
| + [
|
| + AstFactory.simpleFormalParameter(Keyword.VAR, "a"),
|
| + AstFactory.simpleFormalParameter(Keyword.VAR, "b")
|
| + ]), null, AstFactory.blockFunctionBody2()));
|
| }
|
|
|
| void test_visitConstructorDeclaration_named() {
|
| - _assertSource(
|
| - "C.m() {}",
|
| - AstFactory.constructorDeclaration2(
|
| - null,
|
| - null,
|
| - AstFactory.identifier3("C"),
|
| - "m",
|
| - AstFactory.formalParameterList(),
|
| - null,
|
| - AstFactory.blockFunctionBody2()));
|
| + _assertSource("C.m() {}", AstFactory.constructorDeclaration2(null, null,
|
| + AstFactory.identifier3("C"), "m", AstFactory.formalParameterList(),
|
| + null, AstFactory.blockFunctionBody2()));
|
| }
|
|
|
| void test_visitConstructorDeclaration_singleInitializer() {
|
| - _assertSource(
|
| - "C() : a = b {}",
|
| - AstFactory.constructorDeclaration2(
|
| - null,
|
| - null,
|
| - AstFactory.identifier3("C"),
|
| - null,
|
| - AstFactory.formalParameterList(),
|
| - [
|
| - AstFactory.constructorFieldInitializer(
|
| - false,
|
| - "a",
|
| - AstFactory.identifier3("b"))],
|
| - AstFactory.blockFunctionBody2()));
|
| + _assertSource("C() : a = b {}", AstFactory.constructorDeclaration2(null,
|
| + null, AstFactory.identifier3("C"), null,
|
| + AstFactory.formalParameterList(), [
|
| + AstFactory.constructorFieldInitializer(
|
| + false, "a", AstFactory.identifier3("b"))
|
| + ], AstFactory.blockFunctionBody2()));
|
| }
|
|
|
| void test_visitConstructorDeclaration_withMetadata() {
|
| ConstructorDeclaration declaration = AstFactory.constructorDeclaration2(
|
| - null,
|
| - null,
|
| - AstFactory.identifier3("C"),
|
| - null,
|
| - AstFactory.formalParameterList(),
|
| - null,
|
| + null, null, AstFactory.identifier3("C"), null,
|
| + AstFactory.formalParameterList(), null,
|
| AstFactory.blockFunctionBody2());
|
| - declaration.metadata.add(AstFactory.annotation(AstFactory.identifier3("deprecated")));
|
| + declaration.metadata
|
| + .add(AstFactory.annotation(AstFactory.identifier3("deprecated")));
|
| _assertSource("@deprecated C() {}", declaration);
|
| }
|
|
|
| void test_visitConstructorFieldInitializer_withoutThis() {
|
| - _assertSource(
|
| - "a = b",
|
| - AstFactory.constructorFieldInitializer(
|
| - false,
|
| - "a",
|
| - AstFactory.identifier3("b")));
|
| + _assertSource("a = b", AstFactory.constructorFieldInitializer(
|
| + false, "a", AstFactory.identifier3("b")));
|
| }
|
|
|
| void test_visitConstructorFieldInitializer_withThis() {
|
| - _assertSource(
|
| - "this.a = b",
|
| - AstFactory.constructorFieldInitializer(true, "a", AstFactory.identifier3("b")));
|
| + _assertSource("this.a = b", AstFactory.constructorFieldInitializer(
|
| + true, "a", AstFactory.identifier3("b")));
|
| }
|
|
|
| void test_visitConstructorName_named_prefix() {
|
| - _assertSource(
|
| - "p.C.n",
|
| + _assertSource("p.C.n",
|
| AstFactory.constructorName(AstFactory.typeName4("p.C.n"), null));
|
| }
|
|
|
| void test_visitConstructorName_unnamed_noPrefix() {
|
| _assertSource(
|
| - "C",
|
| - AstFactory.constructorName(AstFactory.typeName4("C"), null));
|
| + "C", AstFactory.constructorName(AstFactory.typeName4("C"), null));
|
| }
|
|
|
| void test_visitConstructorName_unnamed_prefix() {
|
| - _assertSource(
|
| - "p.C",
|
| - AstFactory.constructorName(
|
| - AstFactory.typeName3(AstFactory.identifier5("p", "C")),
|
| - null));
|
| + _assertSource("p.C", AstFactory.constructorName(
|
| + AstFactory.typeName3(AstFactory.identifier5("p", "C")), null));
|
| }
|
|
|
| void test_visitContinueStatement_label() {
|
| @@ -2469,39 +2024,28 @@ class ToSourceVisitorTest extends EngineTestCase {
|
| }
|
|
|
| void test_visitDefaultFormalParameter_named_noValue() {
|
| - _assertSource(
|
| - "p",
|
| - AstFactory.namedFormalParameter(AstFactory.simpleFormalParameter3("p"), null));
|
| + _assertSource("p", AstFactory.namedFormalParameter(
|
| + AstFactory.simpleFormalParameter3("p"), null));
|
| }
|
|
|
| void test_visitDefaultFormalParameter_named_value() {
|
| - _assertSource(
|
| - "p : 0",
|
| - AstFactory.namedFormalParameter(
|
| - AstFactory.simpleFormalParameter3("p"),
|
| - AstFactory.integer(0)));
|
| + _assertSource("p : 0", AstFactory.namedFormalParameter(
|
| + AstFactory.simpleFormalParameter3("p"), AstFactory.integer(0)));
|
| }
|
|
|
| void test_visitDefaultFormalParameter_positional_noValue() {
|
| - _assertSource(
|
| - "p",
|
| - AstFactory.positionalFormalParameter(
|
| - AstFactory.simpleFormalParameter3("p"),
|
| - null));
|
| + _assertSource("p", AstFactory.positionalFormalParameter(
|
| + AstFactory.simpleFormalParameter3("p"), null));
|
| }
|
|
|
| void test_visitDefaultFormalParameter_positional_value() {
|
| - _assertSource(
|
| - "p = 0",
|
| - AstFactory.positionalFormalParameter(
|
| - AstFactory.simpleFormalParameter3("p"),
|
| - AstFactory.integer(0)));
|
| + _assertSource("p = 0", AstFactory.positionalFormalParameter(
|
| + AstFactory.simpleFormalParameter3("p"), AstFactory.integer(0)));
|
| }
|
|
|
| void test_visitDoStatement() {
|
| - _assertSource(
|
| - "do {} while (c);",
|
| - AstFactory.doStatement(AstFactory.block(), AstFactory.identifier3("c")));
|
| + _assertSource("do {} while (c);", AstFactory.doStatement(
|
| + AstFactory.block(), AstFactory.identifier3("c")));
|
| }
|
|
|
| void test_visitDoubleLiteral() {
|
| @@ -2518,8 +2062,7 @@ class ToSourceVisitorTest extends EngineTestCase {
|
|
|
| void test_visitEnumDeclaration_multiple() {
|
| _assertSource(
|
| - "enum E {ONE, TWO}",
|
| - AstFactory.enumDeclaration2("E", ["ONE", "TWO"]));
|
| + "enum E {ONE, TWO}", AstFactory.enumDeclaration2("E", ["ONE", "TWO"]));
|
| }
|
|
|
| void test_visitEnumDeclaration_single() {
|
| @@ -2527,21 +2070,16 @@ class ToSourceVisitorTest extends EngineTestCase {
|
| }
|
|
|
| void test_visitExportDirective_combinator() {
|
| - _assertSource(
|
| - "export 'a.dart' show A;",
|
| - AstFactory.exportDirective2(
|
| - "a.dart",
|
| - [AstFactory.showCombinator([AstFactory.identifier3("A")])]));
|
| + _assertSource("export 'a.dart' show A;", AstFactory.exportDirective2(
|
| + "a.dart", [AstFactory.showCombinator([AstFactory.identifier3("A")])]));
|
| }
|
|
|
| void test_visitExportDirective_combinators() {
|
| - _assertSource(
|
| - "export 'a.dart' show A hide B;",
|
| - AstFactory.exportDirective2(
|
| - "a.dart",
|
| - [
|
| - AstFactory.showCombinator([AstFactory.identifier3("A")]),
|
| - AstFactory.hideCombinator([AstFactory.identifier3("B")])]));
|
| + _assertSource("export 'a.dart' show A hide B;", AstFactory.exportDirective2(
|
| + "a.dart", [
|
| + AstFactory.showCombinator([AstFactory.identifier3("A")]),
|
| + AstFactory.hideCombinator([AstFactory.identifier3("B")])
|
| + ]));
|
| }
|
|
|
| void test_visitExportDirective_minimal() {
|
| @@ -2550,124 +2088,93 @@ class ToSourceVisitorTest extends EngineTestCase {
|
|
|
| void test_visitExportDirective_withMetadata() {
|
| ExportDirective directive = AstFactory.exportDirective2("a.dart");
|
| - directive.metadata.add(AstFactory.annotation(AstFactory.identifier3("deprecated")));
|
| + directive.metadata
|
| + .add(AstFactory.annotation(AstFactory.identifier3("deprecated")));
|
| _assertSource("@deprecated export 'a.dart';", directive);
|
| }
|
|
|
| void test_visitExpressionFunctionBody_async() {
|
| - _assertSource(
|
| - "async => a;",
|
| + _assertSource("async => a;",
|
| AstFactory.asyncExpressionFunctionBody(AstFactory.identifier3("a")));
|
| }
|
|
|
| void test_visitExpressionFunctionBody_simple() {
|
| - _assertSource(
|
| - "=> a;",
|
| + _assertSource("=> a;",
|
| AstFactory.expressionFunctionBody(AstFactory.identifier3("a")));
|
| }
|
|
|
| void test_visitExpressionStatement() {
|
| _assertSource(
|
| - "a;",
|
| - AstFactory.expressionStatement(AstFactory.identifier3("a")));
|
| + "a;", AstFactory.expressionStatement(AstFactory.identifier3("a")));
|
| }
|
|
|
| void test_visitExtendsClause() {
|
| _assertSource(
|
| - "extends C",
|
| - AstFactory.extendsClause(AstFactory.typeName4("C")));
|
| + "extends C", AstFactory.extendsClause(AstFactory.typeName4("C")));
|
| }
|
|
|
| void test_visitFieldDeclaration_instance() {
|
| - _assertSource(
|
| - "var a;",
|
| - AstFactory.fieldDeclaration2(
|
| - false,
|
| - Keyword.VAR,
|
| - [AstFactory.variableDeclaration("a")]));
|
| + _assertSource("var a;", AstFactory.fieldDeclaration2(
|
| + false, Keyword.VAR, [AstFactory.variableDeclaration("a")]));
|
| }
|
|
|
| void test_visitFieldDeclaration_static() {
|
| - _assertSource(
|
| - "static var a;",
|
| - AstFactory.fieldDeclaration2(
|
| - true,
|
| - Keyword.VAR,
|
| - [AstFactory.variableDeclaration("a")]));
|
| + _assertSource("static var a;", AstFactory.fieldDeclaration2(
|
| + true, Keyword.VAR, [AstFactory.variableDeclaration("a")]));
|
| }
|
|
|
| void test_visitFieldDeclaration_withMetadata() {
|
| FieldDeclaration declaration = AstFactory.fieldDeclaration2(
|
| - false,
|
| - Keyword.VAR,
|
| - [AstFactory.variableDeclaration("a")]);
|
| - declaration.metadata.add(AstFactory.annotation(AstFactory.identifier3("deprecated")));
|
| + false, Keyword.VAR, [AstFactory.variableDeclaration("a")]);
|
| + declaration.metadata
|
| + .add(AstFactory.annotation(AstFactory.identifier3("deprecated")));
|
| _assertSource("@deprecated var a;", declaration);
|
| }
|
|
|
| void test_visitFieldFormalParameter_functionTyped() {
|
| - _assertSource(
|
| - "A this.a(b)",
|
| - AstFactory.fieldFormalParameter(
|
| - null,
|
| - AstFactory.typeName4("A"),
|
| - "a",
|
| - AstFactory.formalParameterList([AstFactory.simpleFormalParameter3("b")])));
|
| + _assertSource("A this.a(b)", AstFactory.fieldFormalParameter(null,
|
| + AstFactory.typeName4("A"), "a", AstFactory
|
| + .formalParameterList([AstFactory.simpleFormalParameter3("b")])));
|
| }
|
|
|
| void test_visitFieldFormalParameter_keyword() {
|
| _assertSource(
|
| - "var this.a",
|
| - AstFactory.fieldFormalParameter(Keyword.VAR, null, "a"));
|
| + "var this.a", AstFactory.fieldFormalParameter(Keyword.VAR, null, "a"));
|
| }
|
|
|
| void test_visitFieldFormalParameter_keywordAndType() {
|
| - _assertSource(
|
| - "final A this.a",
|
| - AstFactory.fieldFormalParameter(Keyword.FINAL, AstFactory.typeName4("A"), "a"));
|
| + _assertSource("final A this.a", AstFactory.fieldFormalParameter(
|
| + Keyword.FINAL, AstFactory.typeName4("A"), "a"));
|
| }
|
|
|
| void test_visitFieldFormalParameter_type() {
|
| - _assertSource(
|
| - "A this.a",
|
| + _assertSource("A this.a",
|
| AstFactory.fieldFormalParameter(null, AstFactory.typeName4("A"), "a"));
|
| }
|
|
|
| void test_visitForEachStatement_declared() {
|
| - _assertSource(
|
| - "for (a in b) {}",
|
| - AstFactory.forEachStatement(
|
| - AstFactory.declaredIdentifier3("a"),
|
| - AstFactory.identifier3("b"),
|
| - AstFactory.block()));
|
| + _assertSource("for (a in b) {}", AstFactory.forEachStatement(
|
| + AstFactory.declaredIdentifier3("a"), AstFactory.identifier3("b"),
|
| + AstFactory.block()));
|
| }
|
|
|
| void test_visitForEachStatement_variable() {
|
| - _assertSource(
|
| - "for (a in b) {}",
|
| - new ForEachStatement.con2(
|
| - null,
|
| - TokenFactory.tokenFromKeyword(Keyword.FOR),
|
| - TokenFactory.tokenFromType(TokenType.OPEN_PAREN),
|
| - AstFactory.identifier3("a"),
|
| - TokenFactory.tokenFromKeyword(Keyword.IN),
|
| - AstFactory.identifier3("b"),
|
| - TokenFactory.tokenFromType(TokenType.CLOSE_PAREN),
|
| - AstFactory.block()));
|
| + _assertSource("for (a in b) {}", new ForEachStatement.con2(null,
|
| + TokenFactory.tokenFromKeyword(Keyword.FOR),
|
| + TokenFactory.tokenFromType(TokenType.OPEN_PAREN),
|
| + AstFactory.identifier3("a"), TokenFactory.tokenFromKeyword(Keyword.IN),
|
| + AstFactory.identifier3("b"),
|
| + TokenFactory.tokenFromType(TokenType.CLOSE_PAREN), AstFactory.block()));
|
| }
|
|
|
| void test_visitForEachStatement_variable_await() {
|
| - _assertSource(
|
| - "await for (a in b) {}",
|
| - new ForEachStatement.con2(
|
| - TokenFactory.tokenFromString("await"),
|
| - TokenFactory.tokenFromKeyword(Keyword.FOR),
|
| - TokenFactory.tokenFromType(TokenType.OPEN_PAREN),
|
| - AstFactory.identifier3("a"),
|
| - TokenFactory.tokenFromKeyword(Keyword.IN),
|
| - AstFactory.identifier3("b"),
|
| - TokenFactory.tokenFromType(TokenType.CLOSE_PAREN),
|
| - AstFactory.block()));
|
| + _assertSource("await for (a in b) {}", new ForEachStatement.con2(
|
| + TokenFactory.tokenFromString("await"),
|
| + TokenFactory.tokenFromKeyword(Keyword.FOR),
|
| + TokenFactory.tokenFromType(TokenType.OPEN_PAREN),
|
| + AstFactory.identifier3("a"), TokenFactory.tokenFromKeyword(Keyword.IN),
|
| + AstFactory.identifier3("b"),
|
| + TokenFactory.tokenFromType(TokenType.CLOSE_PAREN), AstFactory.block()));
|
| }
|
|
|
| void test_visitFormalParameterList_empty() {
|
| @@ -2675,378 +2182,251 @@ class ToSourceVisitorTest extends EngineTestCase {
|
| }
|
|
|
| void test_visitFormalParameterList_n() {
|
| - _assertSource(
|
| - "({a : 0})",
|
| - AstFactory.formalParameterList(
|
| - [
|
| - AstFactory.namedFormalParameter(
|
| - AstFactory.simpleFormalParameter3("a"),
|
| - AstFactory.integer(0))]));
|
| + _assertSource("({a : 0})", AstFactory.formalParameterList([
|
| + AstFactory.namedFormalParameter(
|
| + AstFactory.simpleFormalParameter3("a"), AstFactory.integer(0))
|
| + ]));
|
| }
|
|
|
| void test_visitFormalParameterList_nn() {
|
| - _assertSource(
|
| - "({a : 0, b : 1})",
|
| - AstFactory.formalParameterList(
|
| - [
|
| - AstFactory.namedFormalParameter(
|
| - AstFactory.simpleFormalParameter3("a"),
|
| - AstFactory.integer(0)),
|
| - AstFactory.namedFormalParameter(
|
| - AstFactory.simpleFormalParameter3("b"),
|
| - AstFactory.integer(1))]));
|
| + _assertSource("({a : 0, b : 1})", AstFactory.formalParameterList([
|
| + AstFactory.namedFormalParameter(
|
| + AstFactory.simpleFormalParameter3("a"), AstFactory.integer(0)),
|
| + AstFactory.namedFormalParameter(
|
| + AstFactory.simpleFormalParameter3("b"), AstFactory.integer(1))
|
| + ]));
|
| }
|
|
|
| void test_visitFormalParameterList_p() {
|
| - _assertSource(
|
| - "([a = 0])",
|
| - AstFactory.formalParameterList(
|
| - [
|
| - AstFactory.positionalFormalParameter(
|
| - AstFactory.simpleFormalParameter3("a"),
|
| - AstFactory.integer(0))]));
|
| + _assertSource("([a = 0])", AstFactory.formalParameterList([
|
| + AstFactory.positionalFormalParameter(
|
| + AstFactory.simpleFormalParameter3("a"), AstFactory.integer(0))
|
| + ]));
|
| }
|
|
|
| void test_visitFormalParameterList_pp() {
|
| - _assertSource(
|
| - "([a = 0, b = 1])",
|
| - AstFactory.formalParameterList(
|
| - [
|
| - AstFactory.positionalFormalParameter(
|
| - AstFactory.simpleFormalParameter3("a"),
|
| - AstFactory.integer(0)),
|
| - AstFactory.positionalFormalParameter(
|
| - AstFactory.simpleFormalParameter3("b"),
|
| - AstFactory.integer(1))]));
|
| + _assertSource("([a = 0, b = 1])", AstFactory.formalParameterList([
|
| + AstFactory.positionalFormalParameter(
|
| + AstFactory.simpleFormalParameter3("a"), AstFactory.integer(0)),
|
| + AstFactory.positionalFormalParameter(
|
| + AstFactory.simpleFormalParameter3("b"), AstFactory.integer(1))
|
| + ]));
|
| }
|
|
|
| void test_visitFormalParameterList_r() {
|
| - _assertSource(
|
| - "(a)",
|
| - AstFactory.formalParameterList([AstFactory.simpleFormalParameter3("a")]));
|
| + _assertSource("(a)", AstFactory
|
| + .formalParameterList([AstFactory.simpleFormalParameter3("a")]));
|
| }
|
|
|
| void test_visitFormalParameterList_rn() {
|
| - _assertSource(
|
| - "(a, {b : 1})",
|
| - AstFactory.formalParameterList(
|
| - [
|
| - AstFactory.simpleFormalParameter3("a"),
|
| - AstFactory.namedFormalParameter(
|
| - AstFactory.simpleFormalParameter3("b"),
|
| - AstFactory.integer(1))]));
|
| + _assertSource("(a, {b : 1})", AstFactory.formalParameterList([
|
| + AstFactory.simpleFormalParameter3("a"),
|
| + AstFactory.namedFormalParameter(
|
| + AstFactory.simpleFormalParameter3("b"), AstFactory.integer(1))
|
| + ]));
|
| }
|
|
|
| void test_visitFormalParameterList_rnn() {
|
| - _assertSource(
|
| - "(a, {b : 1, c : 2})",
|
| - AstFactory.formalParameterList(
|
| - [
|
| - AstFactory.simpleFormalParameter3("a"),
|
| - AstFactory.namedFormalParameter(
|
| - AstFactory.simpleFormalParameter3("b"),
|
| - AstFactory.integer(1)),
|
| - AstFactory.namedFormalParameter(
|
| - AstFactory.simpleFormalParameter3("c"),
|
| - AstFactory.integer(2))]));
|
| + _assertSource("(a, {b : 1, c : 2})", AstFactory.formalParameterList([
|
| + AstFactory.simpleFormalParameter3("a"),
|
| + AstFactory.namedFormalParameter(
|
| + AstFactory.simpleFormalParameter3("b"), AstFactory.integer(1)),
|
| + AstFactory.namedFormalParameter(
|
| + AstFactory.simpleFormalParameter3("c"), AstFactory.integer(2))
|
| + ]));
|
| }
|
|
|
| void test_visitFormalParameterList_rp() {
|
| - _assertSource(
|
| - "(a, [b = 1])",
|
| - AstFactory.formalParameterList(
|
| - [
|
| - AstFactory.simpleFormalParameter3("a"),
|
| - AstFactory.positionalFormalParameter(
|
| - AstFactory.simpleFormalParameter3("b"),
|
| - AstFactory.integer(1))]));
|
| + _assertSource("(a, [b = 1])", AstFactory.formalParameterList([
|
| + AstFactory.simpleFormalParameter3("a"),
|
| + AstFactory.positionalFormalParameter(
|
| + AstFactory.simpleFormalParameter3("b"), AstFactory.integer(1))
|
| + ]));
|
| }
|
|
|
| void test_visitFormalParameterList_rpp() {
|
| - _assertSource(
|
| - "(a, [b = 1, c = 2])",
|
| - AstFactory.formalParameterList(
|
| - [
|
| - AstFactory.simpleFormalParameter3("a"),
|
| - AstFactory.positionalFormalParameter(
|
| - AstFactory.simpleFormalParameter3("b"),
|
| - AstFactory.integer(1)),
|
| - AstFactory.positionalFormalParameter(
|
| - AstFactory.simpleFormalParameter3("c"),
|
| - AstFactory.integer(2))]));
|
| + _assertSource("(a, [b = 1, c = 2])", AstFactory.formalParameterList([
|
| + AstFactory.simpleFormalParameter3("a"),
|
| + AstFactory.positionalFormalParameter(
|
| + AstFactory.simpleFormalParameter3("b"), AstFactory.integer(1)),
|
| + AstFactory.positionalFormalParameter(
|
| + AstFactory.simpleFormalParameter3("c"), AstFactory.integer(2))
|
| + ]));
|
| }
|
|
|
| void test_visitFormalParameterList_rr() {
|
| - _assertSource(
|
| - "(a, b)",
|
| - AstFactory.formalParameterList(
|
| - [
|
| - AstFactory.simpleFormalParameter3("a"),
|
| - AstFactory.simpleFormalParameter3("b")]));
|
| + _assertSource("(a, b)", AstFactory.formalParameterList([
|
| + AstFactory.simpleFormalParameter3("a"),
|
| + AstFactory.simpleFormalParameter3("b")
|
| + ]));
|
| }
|
|
|
| void test_visitFormalParameterList_rrn() {
|
| - _assertSource(
|
| - "(a, b, {c : 3})",
|
| - AstFactory.formalParameterList(
|
| - [
|
| - AstFactory.simpleFormalParameter3("a"),
|
| - AstFactory.simpleFormalParameter3("b"),
|
| - AstFactory.namedFormalParameter(
|
| - AstFactory.simpleFormalParameter3("c"),
|
| - AstFactory.integer(3))]));
|
| + _assertSource("(a, b, {c : 3})", AstFactory.formalParameterList([
|
| + AstFactory.simpleFormalParameter3("a"),
|
| + AstFactory.simpleFormalParameter3("b"),
|
| + AstFactory.namedFormalParameter(
|
| + AstFactory.simpleFormalParameter3("c"), AstFactory.integer(3))
|
| + ]));
|
| }
|
|
|
| void test_visitFormalParameterList_rrnn() {
|
| - _assertSource(
|
| - "(a, b, {c : 3, d : 4})",
|
| - AstFactory.formalParameterList(
|
| - [
|
| - AstFactory.simpleFormalParameter3("a"),
|
| - AstFactory.simpleFormalParameter3("b"),
|
| - AstFactory.namedFormalParameter(
|
| - AstFactory.simpleFormalParameter3("c"),
|
| - AstFactory.integer(3)),
|
| - AstFactory.namedFormalParameter(
|
| - AstFactory.simpleFormalParameter3("d"),
|
| - AstFactory.integer(4))]));
|
| + _assertSource("(a, b, {c : 3, d : 4})", AstFactory.formalParameterList([
|
| + AstFactory.simpleFormalParameter3("a"),
|
| + AstFactory.simpleFormalParameter3("b"),
|
| + AstFactory.namedFormalParameter(
|
| + AstFactory.simpleFormalParameter3("c"), AstFactory.integer(3)),
|
| + AstFactory.namedFormalParameter(
|
| + AstFactory.simpleFormalParameter3("d"), AstFactory.integer(4))
|
| + ]));
|
| }
|
|
|
| void test_visitFormalParameterList_rrp() {
|
| - _assertSource(
|
| - "(a, b, [c = 3])",
|
| - AstFactory.formalParameterList(
|
| - [
|
| - AstFactory.simpleFormalParameter3("a"),
|
| - AstFactory.simpleFormalParameter3("b"),
|
| - AstFactory.positionalFormalParameter(
|
| - AstFactory.simpleFormalParameter3("c"),
|
| - AstFactory.integer(3))]));
|
| + _assertSource("(a, b, [c = 3])", AstFactory.formalParameterList([
|
| + AstFactory.simpleFormalParameter3("a"),
|
| + AstFactory.simpleFormalParameter3("b"),
|
| + AstFactory.positionalFormalParameter(
|
| + AstFactory.simpleFormalParameter3("c"), AstFactory.integer(3))
|
| + ]));
|
| }
|
|
|
| void test_visitFormalParameterList_rrpp() {
|
| - _assertSource(
|
| - "(a, b, [c = 3, d = 4])",
|
| - AstFactory.formalParameterList(
|
| - [
|
| - AstFactory.simpleFormalParameter3("a"),
|
| - AstFactory.simpleFormalParameter3("b"),
|
| - AstFactory.positionalFormalParameter(
|
| - AstFactory.simpleFormalParameter3("c"),
|
| - AstFactory.integer(3)),
|
| - AstFactory.positionalFormalParameter(
|
| - AstFactory.simpleFormalParameter3("d"),
|
| - AstFactory.integer(4))]));
|
| + _assertSource("(a, b, [c = 3, d = 4])", AstFactory.formalParameterList([
|
| + AstFactory.simpleFormalParameter3("a"),
|
| + AstFactory.simpleFormalParameter3("b"),
|
| + AstFactory.positionalFormalParameter(
|
| + AstFactory.simpleFormalParameter3("c"), AstFactory.integer(3)),
|
| + AstFactory.positionalFormalParameter(
|
| + AstFactory.simpleFormalParameter3("d"), AstFactory.integer(4))
|
| + ]));
|
| }
|
|
|
| void test_visitForStatement_c() {
|
| - _assertSource(
|
| - "for (; c;) {}",
|
| - AstFactory.forStatement(
|
| - null,
|
| - AstFactory.identifier3("c"),
|
| - null,
|
| - AstFactory.block()));
|
| + _assertSource("for (; c;) {}", AstFactory.forStatement(
|
| + null, AstFactory.identifier3("c"), null, AstFactory.block()));
|
| }
|
|
|
| void test_visitForStatement_cu() {
|
| - _assertSource(
|
| - "for (; c; u) {}",
|
| - AstFactory.forStatement(
|
| - null,
|
| - AstFactory.identifier3("c"),
|
| - [AstFactory.identifier3("u")],
|
| - AstFactory.block()));
|
| + _assertSource("for (; c; u) {}", AstFactory.forStatement(null,
|
| + AstFactory.identifier3("c"), [
|
| + AstFactory.identifier3("u")
|
| + ], AstFactory.block()));
|
| }
|
|
|
| void test_visitForStatement_e() {
|
| - _assertSource(
|
| - "for (e;;) {}",
|
| - AstFactory.forStatement(
|
| - AstFactory.identifier3("e"),
|
| - null,
|
| - null,
|
| - AstFactory.block()));
|
| + _assertSource("for (e;;) {}", AstFactory.forStatement(
|
| + AstFactory.identifier3("e"), null, null, AstFactory.block()));
|
| }
|
|
|
| void test_visitForStatement_ec() {
|
| - _assertSource(
|
| - "for (e; c;) {}",
|
| - AstFactory.forStatement(
|
| - AstFactory.identifier3("e"),
|
| - AstFactory.identifier3("c"),
|
| - null,
|
| - AstFactory.block()));
|
| + _assertSource("for (e; c;) {}", AstFactory.forStatement(
|
| + AstFactory.identifier3("e"), AstFactory.identifier3("c"), null,
|
| + AstFactory.block()));
|
| }
|
|
|
| void test_visitForStatement_ecu() {
|
| - _assertSource(
|
| - "for (e; c; u) {}",
|
| - AstFactory.forStatement(
|
| - AstFactory.identifier3("e"),
|
| - AstFactory.identifier3("c"),
|
| - [AstFactory.identifier3("u")],
|
| - AstFactory.block()));
|
| + _assertSource("for (e; c; u) {}", AstFactory.forStatement(
|
| + AstFactory.identifier3("e"), AstFactory.identifier3("c"), [
|
| + AstFactory.identifier3("u")
|
| + ], AstFactory.block()));
|
| }
|
|
|
| void test_visitForStatement_eu() {
|
| - _assertSource(
|
| - "for (e;; u) {}",
|
| - AstFactory.forStatement(
|
| - AstFactory.identifier3("e"),
|
| - null,
|
| - [AstFactory.identifier3("u")],
|
| - AstFactory.block()));
|
| + _assertSource("for (e;; u) {}", AstFactory.forStatement(
|
| + AstFactory.identifier3("e"), null, [
|
| + AstFactory.identifier3("u")
|
| + ], AstFactory.block()));
|
| }
|
|
|
| void test_visitForStatement_i() {
|
| - _assertSource(
|
| - "for (var i;;) {}",
|
| - AstFactory.forStatement2(
|
| - AstFactory.variableDeclarationList2(
|
| - Keyword.VAR,
|
| - [AstFactory.variableDeclaration("i")]),
|
| - null,
|
| - null,
|
| - AstFactory.block()));
|
| + _assertSource("for (var i;;) {}", AstFactory.forStatement2(AstFactory
|
| + .variableDeclarationList2(
|
| + Keyword.VAR, [AstFactory.variableDeclaration("i")]), null, null,
|
| + AstFactory.block()));
|
| }
|
|
|
| void test_visitForStatement_ic() {
|
| - _assertSource(
|
| - "for (var i; c;) {}",
|
| - AstFactory.forStatement2(
|
| - AstFactory.variableDeclarationList2(
|
| - Keyword.VAR,
|
| - [AstFactory.variableDeclaration("i")]),
|
| - AstFactory.identifier3("c"),
|
| - null,
|
| - AstFactory.block()));
|
| + _assertSource("for (var i; c;) {}", AstFactory.forStatement2(AstFactory
|
| + .variableDeclarationList2(Keyword.VAR, [
|
| + AstFactory.variableDeclaration("i")
|
| + ]), AstFactory.identifier3("c"), null, AstFactory.block()));
|
| }
|
|
|
| void test_visitForStatement_icu() {
|
| - _assertSource(
|
| - "for (var i; c; u) {}",
|
| - AstFactory.forStatement2(
|
| - AstFactory.variableDeclarationList2(
|
| - Keyword.VAR,
|
| - [AstFactory.variableDeclaration("i")]),
|
| - AstFactory.identifier3("c"),
|
| - [AstFactory.identifier3("u")],
|
| - AstFactory.block()));
|
| + _assertSource("for (var i; c; u) {}", AstFactory.forStatement2(AstFactory
|
| + .variableDeclarationList2(Keyword.VAR, [
|
| + AstFactory.variableDeclaration("i")
|
| + ]), AstFactory.identifier3("c"), [
|
| + AstFactory.identifier3("u")
|
| + ], AstFactory.block()));
|
| }
|
|
|
| void test_visitForStatement_iu() {
|
| - _assertSource(
|
| - "for (var i;; u) {}",
|
| - AstFactory.forStatement2(
|
| - AstFactory.variableDeclarationList2(
|
| - Keyword.VAR,
|
| - [AstFactory.variableDeclaration("i")]),
|
| - null,
|
| - [AstFactory.identifier3("u")],
|
| - AstFactory.block()));
|
| + _assertSource("for (var i;; u) {}", AstFactory.forStatement2(AstFactory
|
| + .variableDeclarationList2(
|
| + Keyword.VAR, [AstFactory.variableDeclaration("i")]), null, [
|
| + AstFactory.identifier3("u")
|
| + ], AstFactory.block()));
|
| }
|
|
|
| void test_visitForStatement_u() {
|
| - _assertSource(
|
| - "for (;; u) {}",
|
| - AstFactory.forStatement(
|
| - null,
|
| - null,
|
| - [AstFactory.identifier3("u")],
|
| - AstFactory.block()));
|
| + _assertSource("for (;; u) {}", AstFactory.forStatement(
|
| + null, null, [AstFactory.identifier3("u")], AstFactory.block()));
|
| }
|
|
|
| void test_visitFunctionDeclaration_getter() {
|
| - _assertSource(
|
| - "get f() {}",
|
| - AstFactory.functionDeclaration(
|
| - null,
|
| - Keyword.GET,
|
| - "f",
|
| - AstFactory.functionExpression()));
|
| + _assertSource("get f() {}", AstFactory.functionDeclaration(
|
| + null, Keyword.GET, "f", AstFactory.functionExpression()));
|
| }
|
|
|
| void test_visitFunctionDeclaration_local_blockBody() {
|
| FunctionDeclaration f = AstFactory.functionDeclaration(
|
| - null,
|
| - null,
|
| - "f",
|
| - AstFactory.functionExpression());
|
| + null, null, "f", AstFactory.functionExpression());
|
| FunctionDeclarationStatement fStatement =
|
| new FunctionDeclarationStatement(f);
|
| - _assertSource(
|
| - "main() {f() {} 42;}",
|
| - AstFactory.functionDeclaration(
|
| - null,
|
| - null,
|
| - "main",
|
| - AstFactory.functionExpression2(
|
| - AstFactory.formalParameterList(),
|
| - AstFactory.blockFunctionBody2(
|
| - [fStatement, AstFactory.expressionStatement(AstFactory.integer(42))]))));
|
| + _assertSource("main() {f() {} 42;}", AstFactory.functionDeclaration(null,
|
| + null, "main", AstFactory.functionExpression2(
|
| + AstFactory.formalParameterList(), AstFactory.blockFunctionBody2([
|
| + fStatement,
|
| + AstFactory.expressionStatement(AstFactory.integer(42))
|
| + ]))));
|
| }
|
|
|
| void test_visitFunctionDeclaration_local_expressionBody() {
|
| - FunctionDeclaration f = AstFactory.functionDeclaration(
|
| - null,
|
| - null,
|
| - "f",
|
| - AstFactory.functionExpression2(
|
| - AstFactory.formalParameterList(),
|
| + FunctionDeclaration f = AstFactory.functionDeclaration(null, null, "f",
|
| + AstFactory.functionExpression2(AstFactory.formalParameterList(),
|
| AstFactory.expressionFunctionBody(AstFactory.integer(1))));
|
| FunctionDeclarationStatement fStatement =
|
| new FunctionDeclarationStatement(f);
|
| - _assertSource(
|
| - "main() {f() => 1; 2;}",
|
| - AstFactory.functionDeclaration(
|
| - null,
|
| - null,
|
| - "main",
|
| - AstFactory.functionExpression2(
|
| - AstFactory.formalParameterList(),
|
| - AstFactory.blockFunctionBody2(
|
| - [fStatement, AstFactory.expressionStatement(AstFactory.integer(2))]))));
|
| + _assertSource("main() {f() => 1; 2;}", AstFactory.functionDeclaration(null,
|
| + null, "main", AstFactory.functionExpression2(
|
| + AstFactory.formalParameterList(), AstFactory.blockFunctionBody2([
|
| + fStatement,
|
| + AstFactory.expressionStatement(AstFactory.integer(2))
|
| + ]))));
|
| }
|
|
|
| void test_visitFunctionDeclaration_normal() {
|
| - _assertSource(
|
| - "f() {}",
|
| - AstFactory.functionDeclaration(
|
| - null,
|
| - null,
|
| - "f",
|
| - AstFactory.functionExpression()));
|
| + _assertSource("f() {}", AstFactory.functionDeclaration(
|
| + null, null, "f", AstFactory.functionExpression()));
|
| }
|
|
|
| void test_visitFunctionDeclaration_setter() {
|
| - _assertSource(
|
| - "set f() {}",
|
| - AstFactory.functionDeclaration(
|
| - null,
|
| - Keyword.SET,
|
| - "f",
|
| - AstFactory.functionExpression()));
|
| + _assertSource("set f() {}", AstFactory.functionDeclaration(
|
| + null, Keyword.SET, "f", AstFactory.functionExpression()));
|
| }
|
|
|
| void test_visitFunctionDeclaration_withMetadata() {
|
| FunctionDeclaration declaration = AstFactory.functionDeclaration(
|
| - null,
|
| - null,
|
| - "f",
|
| - AstFactory.functionExpression());
|
| - declaration.metadata.add(AstFactory.annotation(AstFactory.identifier3("deprecated")));
|
| + null, null, "f", AstFactory.functionExpression());
|
| + declaration.metadata
|
| + .add(AstFactory.annotation(AstFactory.identifier3("deprecated")));
|
| _assertSource("@deprecated f() {}", declaration);
|
| }
|
|
|
| void test_visitFunctionDeclarationStatement() {
|
| - _assertSource(
|
| - "f() {}",
|
| - AstFactory.functionDeclarationStatement(
|
| - null,
|
| - null,
|
| - "f",
|
| - AstFactory.functionExpression()));
|
| + _assertSource("f() {}", AstFactory.functionDeclarationStatement(
|
| + null, null, "f", AstFactory.functionExpression()));
|
| }
|
|
|
| void test_visitFunctionExpression() {
|
| @@ -3054,38 +2434,27 @@ class ToSourceVisitorTest extends EngineTestCase {
|
| }
|
|
|
| void test_visitFunctionExpressionInvocation() {
|
| - _assertSource(
|
| - "f()",
|
| + _assertSource("f()",
|
| AstFactory.functionExpressionInvocation(AstFactory.identifier3("f")));
|
| }
|
|
|
| void test_visitFunctionTypeAlias_generic() {
|
| - _assertSource(
|
| - "typedef A F<B>();",
|
| - AstFactory.typeAlias(
|
| - AstFactory.typeName4("A"),
|
| - "F",
|
| - AstFactory.typeParameterList(["B"]),
|
| - AstFactory.formalParameterList()));
|
| + _assertSource("typedef A F<B>();", AstFactory.typeAlias(
|
| + AstFactory.typeName4("A"), "F", AstFactory.typeParameterList(["B"]),
|
| + AstFactory.formalParameterList()));
|
| }
|
|
|
| void test_visitFunctionTypeAlias_nonGeneric() {
|
| - _assertSource(
|
| - "typedef A F();",
|
| - AstFactory.typeAlias(
|
| - AstFactory.typeName4("A"),
|
| - "F",
|
| - null,
|
| - AstFactory.formalParameterList()));
|
| + _assertSource("typedef A F();", AstFactory.typeAlias(
|
| + AstFactory.typeName4("A"), "F", null,
|
| + AstFactory.formalParameterList()));
|
| }
|
|
|
| void test_visitFunctionTypeAlias_withMetadata() {
|
| FunctionTypeAlias declaration = AstFactory.typeAlias(
|
| - AstFactory.typeName4("A"),
|
| - "F",
|
| - null,
|
| - AstFactory.formalParameterList());
|
| - declaration.metadata.add(AstFactory.annotation(AstFactory.identifier3("deprecated")));
|
| + AstFactory.typeName4("A"), "F", null, AstFactory.formalParameterList());
|
| + declaration.metadata
|
| + .add(AstFactory.annotation(AstFactory.identifier3("deprecated")));
|
| _assertSource("@deprecated typedef A F();", declaration);
|
| }
|
|
|
| @@ -3094,158 +2463,120 @@ class ToSourceVisitorTest extends EngineTestCase {
|
| }
|
|
|
| void test_visitFunctionTypedFormalParameter_type() {
|
| - _assertSource(
|
| - "T f()",
|
| - AstFactory.functionTypedFormalParameter(AstFactory.typeName4("T"), "f"));
|
| + _assertSource("T f()", AstFactory.functionTypedFormalParameter(
|
| + AstFactory.typeName4("T"), "f"));
|
| }
|
|
|
| void test_visitIfStatement_withElse() {
|
| - _assertSource(
|
| - "if (c) {} else {}",
|
| - AstFactory.ifStatement2(
|
| - AstFactory.identifier3("c"),
|
| - AstFactory.block(),
|
| - AstFactory.block()));
|
| + _assertSource("if (c) {} else {}", AstFactory.ifStatement2(
|
| + AstFactory.identifier3("c"), AstFactory.block(), AstFactory.block()));
|
| }
|
|
|
| void test_visitIfStatement_withoutElse() {
|
| - _assertSource(
|
| - "if (c) {}",
|
| - AstFactory.ifStatement(AstFactory.identifier3("c"), AstFactory.block()));
|
| + _assertSource("if (c) {}", AstFactory.ifStatement(
|
| + AstFactory.identifier3("c"), AstFactory.block()));
|
| }
|
|
|
| void test_visitImplementsClause_multiple() {
|
| - _assertSource(
|
| - "implements A, B",
|
| - AstFactory.implementsClause(
|
| - [AstFactory.typeName4("A"), AstFactory.typeName4("B")]));
|
| + _assertSource("implements A, B", AstFactory.implementsClause(
|
| + [AstFactory.typeName4("A"), AstFactory.typeName4("B")]));
|
| }
|
|
|
| void test_visitImplementsClause_single() {
|
| - _assertSource(
|
| - "implements A",
|
| + _assertSource("implements A",
|
| AstFactory.implementsClause([AstFactory.typeName4("A")]));
|
| }
|
|
|
| void test_visitImportDirective_combinator() {
|
| - _assertSource(
|
| - "import 'a.dart' show A;",
|
| - AstFactory.importDirective3(
|
| - "a.dart",
|
| - null,
|
| - [AstFactory.showCombinator([AstFactory.identifier3("A")])]));
|
| + _assertSource("import 'a.dart' show A;", AstFactory.importDirective3(
|
| + "a.dart", null, [
|
| + AstFactory.showCombinator([AstFactory.identifier3("A")])
|
| + ]));
|
| }
|
|
|
| void test_visitImportDirective_combinators() {
|
| - _assertSource(
|
| - "import 'a.dart' show A hide B;",
|
| - AstFactory.importDirective3(
|
| - "a.dart",
|
| - null,
|
| - [
|
| - AstFactory.showCombinator([AstFactory.identifier3("A")]),
|
| - AstFactory.hideCombinator([AstFactory.identifier3("B")])]));
|
| + _assertSource("import 'a.dart' show A hide B;", AstFactory.importDirective3(
|
| + "a.dart", null, [
|
| + AstFactory.showCombinator([AstFactory.identifier3("A")]),
|
| + AstFactory.hideCombinator([AstFactory.identifier3("B")])
|
| + ]));
|
| }
|
|
|
| void test_visitImportDirective_deferred() {
|
| - _assertSource(
|
| - "import 'a.dart' deferred as p;",
|
| + _assertSource("import 'a.dart' deferred as p;",
|
| AstFactory.importDirective2("a.dart", true, "p"));
|
| }
|
|
|
| void test_visitImportDirective_minimal() {
|
| _assertSource(
|
| - "import 'a.dart';",
|
| - AstFactory.importDirective3("a.dart", null));
|
| + "import 'a.dart';", AstFactory.importDirective3("a.dart", null));
|
| }
|
|
|
| void test_visitImportDirective_prefix() {
|
| _assertSource(
|
| - "import 'a.dart' as p;",
|
| - AstFactory.importDirective3("a.dart", "p"));
|
| + "import 'a.dart' as p;", AstFactory.importDirective3("a.dart", "p"));
|
| }
|
|
|
| void test_visitImportDirective_prefix_combinator() {
|
| - _assertSource(
|
| - "import 'a.dart' as p show A;",
|
| - AstFactory.importDirective3(
|
| - "a.dart",
|
| - "p",
|
| - [AstFactory.showCombinator([AstFactory.identifier3("A")])]));
|
| + _assertSource("import 'a.dart' as p show A;", AstFactory.importDirective3(
|
| + "a.dart", "p", [
|
| + AstFactory.showCombinator([AstFactory.identifier3("A")])
|
| + ]));
|
| }
|
|
|
| void test_visitImportDirective_prefix_combinators() {
|
| - _assertSource(
|
| - "import 'a.dart' as p show A hide B;",
|
| - AstFactory.importDirective3(
|
| - "a.dart",
|
| - "p",
|
| - [
|
| - AstFactory.showCombinator([AstFactory.identifier3("A")]),
|
| - AstFactory.hideCombinator([AstFactory.identifier3("B")])]));
|
| + _assertSource("import 'a.dart' as p show A hide B;", AstFactory
|
| + .importDirective3("a.dart", "p", [
|
| + AstFactory.showCombinator([AstFactory.identifier3("A")]),
|
| + AstFactory.hideCombinator([AstFactory.identifier3("B")])
|
| + ]));
|
| }
|
|
|
| void test_visitImportDirective_withMetadata() {
|
| ImportDirective directive = AstFactory.importDirective3("a.dart", null);
|
| - directive.metadata.add(AstFactory.annotation(AstFactory.identifier3("deprecated")));
|
| + directive.metadata
|
| + .add(AstFactory.annotation(AstFactory.identifier3("deprecated")));
|
| _assertSource("@deprecated import 'a.dart';", directive);
|
| }
|
|
|
| void test_visitImportHideCombinator_multiple() {
|
| - _assertSource(
|
| - "hide a, b",
|
| - AstFactory.hideCombinator(
|
| - [AstFactory.identifier3("a"), AstFactory.identifier3("b")]));
|
| + _assertSource("hide a, b", AstFactory.hideCombinator(
|
| + [AstFactory.identifier3("a"), AstFactory.identifier3("b")]));
|
| }
|
|
|
| void test_visitImportHideCombinator_single() {
|
| _assertSource(
|
| - "hide a",
|
| - AstFactory.hideCombinator([AstFactory.identifier3("a")]));
|
| + "hide a", AstFactory.hideCombinator([AstFactory.identifier3("a")]));
|
| }
|
|
|
| void test_visitImportShowCombinator_multiple() {
|
| - _assertSource(
|
| - "show a, b",
|
| - AstFactory.showCombinator(
|
| - [AstFactory.identifier3("a"), AstFactory.identifier3("b")]));
|
| + _assertSource("show a, b", AstFactory.showCombinator(
|
| + [AstFactory.identifier3("a"), AstFactory.identifier3("b")]));
|
| }
|
|
|
| void test_visitImportShowCombinator_single() {
|
| _assertSource(
|
| - "show a",
|
| - AstFactory.showCombinator([AstFactory.identifier3("a")]));
|
| + "show a", AstFactory.showCombinator([AstFactory.identifier3("a")]));
|
| }
|
|
|
| void test_visitIndexExpression() {
|
| - _assertSource(
|
| - "a[i]",
|
| - AstFactory.indexExpression(
|
| - AstFactory.identifier3("a"),
|
| - AstFactory.identifier3("i")));
|
| + _assertSource("a[i]", AstFactory.indexExpression(
|
| + AstFactory.identifier3("a"), AstFactory.identifier3("i")));
|
| }
|
|
|
| void test_visitInstanceCreationExpression_const() {
|
| - _assertSource(
|
| - "const C()",
|
| - AstFactory.instanceCreationExpression2(
|
| - Keyword.CONST,
|
| - AstFactory.typeName4("C")));
|
| + _assertSource("const C()", AstFactory.instanceCreationExpression2(
|
| + Keyword.CONST, AstFactory.typeName4("C")));
|
| }
|
|
|
| void test_visitInstanceCreationExpression_named() {
|
| - _assertSource(
|
| - "new C.c()",
|
| - AstFactory.instanceCreationExpression3(
|
| - Keyword.NEW,
|
| - AstFactory.typeName4("C"),
|
| - "c"));
|
| + _assertSource("new C.c()", AstFactory.instanceCreationExpression3(
|
| + Keyword.NEW, AstFactory.typeName4("C"), "c"));
|
| }
|
|
|
| void test_visitInstanceCreationExpression_unnamed() {
|
| - _assertSource(
|
| - "new C()",
|
| - AstFactory.instanceCreationExpression2(Keyword.NEW, AstFactory.typeName4("C")));
|
| + _assertSource("new C()", AstFactory.instanceCreationExpression2(
|
| + Keyword.NEW, AstFactory.typeName4("C")));
|
| }
|
|
|
| void test_visitIntegerLiteral() {
|
| @@ -3253,8 +2584,7 @@ class ToSourceVisitorTest extends EngineTestCase {
|
| }
|
|
|
| void test_visitInterpolationExpression_expression() {
|
| - _assertSource(
|
| - "\${a}",
|
| + _assertSource("\${a}",
|
| AstFactory.interpolationExpression(AstFactory.identifier3("a")));
|
| }
|
|
|
| @@ -3267,21 +2597,13 @@ class ToSourceVisitorTest extends EngineTestCase {
|
| }
|
|
|
| void test_visitIsExpression_negated() {
|
| - _assertSource(
|
| - "a is! C",
|
| - AstFactory.isExpression(
|
| - AstFactory.identifier3("a"),
|
| - true,
|
| - AstFactory.typeName4("C")));
|
| + _assertSource("a is! C", AstFactory.isExpression(
|
| + AstFactory.identifier3("a"), true, AstFactory.typeName4("C")));
|
| }
|
|
|
| void test_visitIsExpression_normal() {
|
| - _assertSource(
|
| - "a is C",
|
| - AstFactory.isExpression(
|
| - AstFactory.identifier3("a"),
|
| - false,
|
| - AstFactory.typeName4("C")));
|
| + _assertSource("a is C", AstFactory.isExpression(
|
| + AstFactory.identifier3("a"), false, AstFactory.typeName4("C")));
|
| }
|
|
|
| void test_visitLabel() {
|
| @@ -3289,19 +2611,15 @@ class ToSourceVisitorTest extends EngineTestCase {
|
| }
|
|
|
| void test_visitLabeledStatement_multiple() {
|
| - _assertSource(
|
| - "a: b: return;",
|
| - AstFactory.labeledStatement(
|
| - [AstFactory.label2("a"), AstFactory.label2("b")],
|
| - AstFactory.returnStatement()));
|
| + _assertSource("a: b: return;", AstFactory.labeledStatement([
|
| + AstFactory.label2("a"),
|
| + AstFactory.label2("b")
|
| + ], AstFactory.returnStatement()));
|
| }
|
|
|
| void test_visitLabeledStatement_single() {
|
| - _assertSource(
|
| - "a: return;",
|
| - AstFactory.labeledStatement(
|
| - [AstFactory.label2("a")],
|
| - AstFactory.returnStatement()));
|
| + _assertSource("a: return;", AstFactory.labeledStatement(
|
| + [AstFactory.label2("a")], AstFactory.returnStatement()));
|
| }
|
|
|
| void test_visitLibraryDirective() {
|
| @@ -3310,24 +2628,22 @@ class ToSourceVisitorTest extends EngineTestCase {
|
|
|
| void test_visitLibraryDirective_withMetadata() {
|
| LibraryDirective directive = AstFactory.libraryDirective2("l");
|
| - directive.metadata.add(AstFactory.annotation(AstFactory.identifier3("deprecated")));
|
| + directive.metadata
|
| + .add(AstFactory.annotation(AstFactory.identifier3("deprecated")));
|
| _assertSource("@deprecated library l;", directive);
|
| }
|
|
|
| void test_visitLibraryIdentifier_multiple() {
|
| - _assertSource(
|
| - "a.b.c",
|
| - AstFactory.libraryIdentifier(
|
| - [
|
| - AstFactory.identifier3("a"),
|
| - AstFactory.identifier3("b"),
|
| - AstFactory.identifier3("c")]));
|
| + _assertSource("a.b.c", AstFactory.libraryIdentifier([
|
| + AstFactory.identifier3("a"),
|
| + AstFactory.identifier3("b"),
|
| + AstFactory.identifier3("c")
|
| + ]));
|
| }
|
|
|
| void test_visitLibraryIdentifier_single() {
|
| _assertSource(
|
| - "a",
|
| - AstFactory.libraryIdentifier([AstFactory.identifier3("a")]));
|
| + "a", AstFactory.libraryIdentifier([AstFactory.identifier3("a")]));
|
| }
|
|
|
| void test_visitListLiteral_const() {
|
| @@ -3339,13 +2655,11 @@ class ToSourceVisitorTest extends EngineTestCase {
|
| }
|
|
|
| void test_visitListLiteral_nonEmpty() {
|
| - _assertSource(
|
| - "[a, b, c]",
|
| - AstFactory.listLiteral(
|
| - [
|
| - AstFactory.identifier3("a"),
|
| - AstFactory.identifier3("b"),
|
| - AstFactory.identifier3("c")]));
|
| + _assertSource("[a, b, c]", AstFactory.listLiteral([
|
| + AstFactory.identifier3("a"),
|
| + AstFactory.identifier3("b"),
|
| + AstFactory.identifier3("c")
|
| + ]));
|
| }
|
|
|
| void test_visitMapLiteral_const() {
|
| @@ -3357,203 +2671,111 @@ class ToSourceVisitorTest extends EngineTestCase {
|
| }
|
|
|
| void test_visitMapLiteral_nonEmpty() {
|
| - _assertSource(
|
| - "{'a' : a, 'b' : b, 'c' : c}",
|
| - AstFactory.mapLiteral2(
|
| - [
|
| - AstFactory.mapLiteralEntry("a", AstFactory.identifier3("a")),
|
| - AstFactory.mapLiteralEntry("b", AstFactory.identifier3("b")),
|
| - AstFactory.mapLiteralEntry("c", AstFactory.identifier3("c"))]));
|
| + _assertSource("{'a' : a, 'b' : b, 'c' : c}", AstFactory.mapLiteral2([
|
| + AstFactory.mapLiteralEntry("a", AstFactory.identifier3("a")),
|
| + AstFactory.mapLiteralEntry("b", AstFactory.identifier3("b")),
|
| + AstFactory.mapLiteralEntry("c", AstFactory.identifier3("c"))
|
| + ]));
|
| }
|
|
|
| void test_visitMapLiteralEntry() {
|
| - _assertSource(
|
| - "'a' : b",
|
| + _assertSource("'a' : b",
|
| AstFactory.mapLiteralEntry("a", AstFactory.identifier3("b")));
|
| }
|
|
|
| void test_visitMethodDeclaration_external() {
|
| - _assertSource(
|
| - "external m();",
|
| - AstFactory.methodDeclaration(
|
| - null,
|
| - null,
|
| - null,
|
| - null,
|
| - AstFactory.identifier3("m"),
|
| - AstFactory.formalParameterList()));
|
| + _assertSource("external m();", AstFactory.methodDeclaration(null, null,
|
| + null, null, AstFactory.identifier3("m"),
|
| + AstFactory.formalParameterList()));
|
| }
|
|
|
| void test_visitMethodDeclaration_external_returnType() {
|
| - _assertSource(
|
| - "external T m();",
|
| - AstFactory.methodDeclaration(
|
| - null,
|
| - AstFactory.typeName4("T"),
|
| - null,
|
| - null,
|
| - AstFactory.identifier3("m"),
|
| - AstFactory.formalParameterList()));
|
| + _assertSource("external T m();", AstFactory.methodDeclaration(null,
|
| + AstFactory.typeName4("T"), null, null, AstFactory.identifier3("m"),
|
| + AstFactory.formalParameterList()));
|
| }
|
|
|
| void test_visitMethodDeclaration_getter() {
|
| - _assertSource(
|
| - "get m {}",
|
| - AstFactory.methodDeclaration2(
|
| - null,
|
| - null,
|
| - Keyword.GET,
|
| - null,
|
| - AstFactory.identifier3("m"),
|
| - null,
|
| - AstFactory.blockFunctionBody2()));
|
| + _assertSource("get m {}", AstFactory.methodDeclaration2(null, null,
|
| + Keyword.GET, null, AstFactory.identifier3("m"), null,
|
| + AstFactory.blockFunctionBody2()));
|
| }
|
|
|
| void test_visitMethodDeclaration_getter_returnType() {
|
| - _assertSource(
|
| - "T get m {}",
|
| - AstFactory.methodDeclaration2(
|
| - null,
|
| - AstFactory.typeName4("T"),
|
| - Keyword.GET,
|
| - null,
|
| - AstFactory.identifier3("m"),
|
| - null,
|
| - AstFactory.blockFunctionBody2()));
|
| + _assertSource("T get m {}", AstFactory.methodDeclaration2(null,
|
| + AstFactory.typeName4("T"), Keyword.GET, null,
|
| + AstFactory.identifier3("m"), null, AstFactory.blockFunctionBody2()));
|
| }
|
|
|
| void test_visitMethodDeclaration_getter_seturnType() {
|
| - _assertSource(
|
| - "T set m(var v) {}",
|
| - AstFactory.methodDeclaration2(
|
| - null,
|
| - AstFactory.typeName4("T"),
|
| - Keyword.SET,
|
| - null,
|
| - AstFactory.identifier3("m"),
|
| - AstFactory.formalParameterList(
|
| - [AstFactory.simpleFormalParameter(Keyword.VAR, "v")]),
|
| - AstFactory.blockFunctionBody2()));
|
| + _assertSource("T set m(var v) {}", AstFactory.methodDeclaration2(null,
|
| + AstFactory.typeName4("T"), Keyword.SET, null,
|
| + AstFactory.identifier3("m"), AstFactory.formalParameterList(
|
| + [AstFactory.simpleFormalParameter(Keyword.VAR, "v")]),
|
| + AstFactory.blockFunctionBody2()));
|
| }
|
|
|
| void test_visitMethodDeclaration_minimal() {
|
| - _assertSource(
|
| - "m() {}",
|
| - AstFactory.methodDeclaration2(
|
| - null,
|
| - null,
|
| - null,
|
| - null,
|
| - AstFactory.identifier3("m"),
|
| - AstFactory.formalParameterList(),
|
| - AstFactory.blockFunctionBody2()));
|
| + _assertSource("m() {}", AstFactory.methodDeclaration2(null, null, null,
|
| + null, AstFactory.identifier3("m"), AstFactory.formalParameterList(),
|
| + AstFactory.blockFunctionBody2()));
|
| }
|
|
|
| void test_visitMethodDeclaration_multipleParameters() {
|
| - _assertSource(
|
| - "m(var a, var b) {}",
|
| - AstFactory.methodDeclaration2(
|
| - null,
|
| - null,
|
| - null,
|
| - null,
|
| - AstFactory.identifier3("m"),
|
| - AstFactory.formalParameterList(
|
| - [
|
| - AstFactory.simpleFormalParameter(Keyword.VAR, "a"),
|
| - AstFactory.simpleFormalParameter(Keyword.VAR, "b")]),
|
| - AstFactory.blockFunctionBody2()));
|
| + _assertSource("m(var a, var b) {}", AstFactory.methodDeclaration2(null,
|
| + null, null, null, AstFactory.identifier3("m"), AstFactory
|
| + .formalParameterList([
|
| + AstFactory.simpleFormalParameter(Keyword.VAR, "a"),
|
| + AstFactory.simpleFormalParameter(Keyword.VAR, "b")
|
| + ]), AstFactory.blockFunctionBody2()));
|
| }
|
|
|
| void test_visitMethodDeclaration_operator() {
|
| - _assertSource(
|
| - "operator +() {}",
|
| - AstFactory.methodDeclaration2(
|
| - null,
|
| - null,
|
| - null,
|
| - Keyword.OPERATOR,
|
| - AstFactory.identifier3("+"),
|
| - AstFactory.formalParameterList(),
|
| - AstFactory.blockFunctionBody2()));
|
| + _assertSource("operator +() {}", AstFactory.methodDeclaration2(null, null,
|
| + null, Keyword.OPERATOR, AstFactory.identifier3("+"),
|
| + AstFactory.formalParameterList(), AstFactory.blockFunctionBody2()));
|
| }
|
|
|
| void test_visitMethodDeclaration_operator_returnType() {
|
| - _assertSource(
|
| - "T operator +() {}",
|
| - AstFactory.methodDeclaration2(
|
| - null,
|
| - AstFactory.typeName4("T"),
|
| - null,
|
| - Keyword.OPERATOR,
|
| - AstFactory.identifier3("+"),
|
| - AstFactory.formalParameterList(),
|
| - AstFactory.blockFunctionBody2()));
|
| + _assertSource("T operator +() {}", AstFactory.methodDeclaration2(null,
|
| + AstFactory.typeName4("T"), null, Keyword.OPERATOR,
|
| + AstFactory.identifier3("+"), AstFactory.formalParameterList(),
|
| + AstFactory.blockFunctionBody2()));
|
| }
|
|
|
| void test_visitMethodDeclaration_returnType() {
|
| - _assertSource(
|
| - "T m() {}",
|
| - AstFactory.methodDeclaration2(
|
| - null,
|
| - AstFactory.typeName4("T"),
|
| - null,
|
| - null,
|
| - AstFactory.identifier3("m"),
|
| - AstFactory.formalParameterList(),
|
| - AstFactory.blockFunctionBody2()));
|
| + _assertSource("T m() {}", AstFactory.methodDeclaration2(null,
|
| + AstFactory.typeName4("T"), null, null, AstFactory.identifier3("m"),
|
| + AstFactory.formalParameterList(), AstFactory.blockFunctionBody2()));
|
| }
|
|
|
| void test_visitMethodDeclaration_setter() {
|
| - _assertSource(
|
| - "set m(var v) {}",
|
| - AstFactory.methodDeclaration2(
|
| - null,
|
| - null,
|
| - Keyword.SET,
|
| - null,
|
| - AstFactory.identifier3("m"),
|
| - AstFactory.formalParameterList(
|
| + _assertSource("set m(var v) {}", AstFactory.methodDeclaration2(null, null,
|
| + Keyword.SET, null, AstFactory.identifier3("m"), AstFactory
|
| + .formalParameterList(
|
| [AstFactory.simpleFormalParameter(Keyword.VAR, "v")]),
|
| - AstFactory.blockFunctionBody2()));
|
| + AstFactory.blockFunctionBody2()));
|
| }
|
|
|
| void test_visitMethodDeclaration_static() {
|
| - _assertSource(
|
| - "static m() {}",
|
| - AstFactory.methodDeclaration2(
|
| - Keyword.STATIC,
|
| - null,
|
| - null,
|
| - null,
|
| - AstFactory.identifier3("m"),
|
| - AstFactory.formalParameterList(),
|
| - AstFactory.blockFunctionBody2()));
|
| + _assertSource("static m() {}", AstFactory.methodDeclaration2(Keyword.STATIC,
|
| + null, null, null, AstFactory.identifier3("m"),
|
| + AstFactory.formalParameterList(), AstFactory.blockFunctionBody2()));
|
| }
|
|
|
| void test_visitMethodDeclaration_static_returnType() {
|
| - _assertSource(
|
| - "static T m() {}",
|
| - AstFactory.methodDeclaration2(
|
| - Keyword.STATIC,
|
| - AstFactory.typeName4("T"),
|
| - null,
|
| - null,
|
| - AstFactory.identifier3("m"),
|
| - AstFactory.formalParameterList(),
|
| - AstFactory.blockFunctionBody2()));
|
| + _assertSource("static T m() {}", AstFactory.methodDeclaration2(
|
| + Keyword.STATIC, AstFactory.typeName4("T"), null, null,
|
| + AstFactory.identifier3("m"), AstFactory.formalParameterList(),
|
| + AstFactory.blockFunctionBody2()));
|
| }
|
|
|
| void test_visitMethodDeclaration_withMetadata() {
|
| - MethodDeclaration declaration = AstFactory.methodDeclaration2(
|
| - null,
|
| - null,
|
| - null,
|
| - null,
|
| - AstFactory.identifier3("m"),
|
| - AstFactory.formalParameterList(),
|
| - AstFactory.blockFunctionBody2());
|
| - declaration.metadata.add(AstFactory.annotation(AstFactory.identifier3("deprecated")));
|
| + MethodDeclaration declaration = AstFactory.methodDeclaration2(null, null,
|
| + null, null, AstFactory.identifier3("m"),
|
| + AstFactory.formalParameterList(), AstFactory.blockFunctionBody2());
|
| + declaration.metadata
|
| + .add(AstFactory.annotation(AstFactory.identifier3("deprecated")));
|
| _assertSource("@deprecated m() {}", declaration);
|
| }
|
|
|
| @@ -3563,22 +2785,18 @@ class ToSourceVisitorTest extends EngineTestCase {
|
|
|
| void test_visitMethodInvocation_target() {
|
| _assertSource(
|
| - "t.m()",
|
| - AstFactory.methodInvocation(AstFactory.identifier3("t"), "m"));
|
| + "t.m()", AstFactory.methodInvocation(AstFactory.identifier3("t"), "m"));
|
| }
|
|
|
| void test_visitNamedExpression() {
|
| _assertSource(
|
| - "a: b",
|
| - AstFactory.namedExpression2("a", AstFactory.identifier3("b")));
|
| + "a: b", AstFactory.namedExpression2("a", AstFactory.identifier3("b")));
|
| }
|
|
|
| void test_visitNamedFormalParameter() {
|
| - _assertSource(
|
| - "var a : 0",
|
| - AstFactory.namedFormalParameter(
|
| - AstFactory.simpleFormalParameter(Keyword.VAR, "a"),
|
| - AstFactory.integer(0)));
|
| + _assertSource("var a : 0", AstFactory.namedFormalParameter(
|
| + AstFactory.simpleFormalParameter(Keyword.VAR, "a"),
|
| + AstFactory.integer(0)));
|
| }
|
|
|
| void test_visitNativeClause() {
|
| @@ -3595,8 +2813,7 @@ class ToSourceVisitorTest extends EngineTestCase {
|
|
|
| void test_visitParenthesizedExpression() {
|
| _assertSource(
|
| - "(a)",
|
| - AstFactory.parenthesizedExpression(AstFactory.identifier3("a")));
|
| + "(a)", AstFactory.parenthesizedExpression(AstFactory.identifier3("a")));
|
| }
|
|
|
| void test_visitPartDirective() {
|
| @@ -3605,35 +2822,33 @@ class ToSourceVisitorTest extends EngineTestCase {
|
|
|
| void test_visitPartDirective_withMetadata() {
|
| PartDirective directive = AstFactory.partDirective2("a.dart");
|
| - directive.metadata.add(AstFactory.annotation(AstFactory.identifier3("deprecated")));
|
| + directive.metadata
|
| + .add(AstFactory.annotation(AstFactory.identifier3("deprecated")));
|
| _assertSource("@deprecated part 'a.dart';", directive);
|
| }
|
|
|
| void test_visitPartOfDirective() {
|
| - _assertSource(
|
| - "part of l;",
|
| + _assertSource("part of l;",
|
| AstFactory.partOfDirective(AstFactory.libraryIdentifier2(["l"])));
|
| }
|
|
|
| void test_visitPartOfDirective_withMetadata() {
|
| PartOfDirective directive =
|
| AstFactory.partOfDirective(AstFactory.libraryIdentifier2(["l"]));
|
| - directive.metadata.add(AstFactory.annotation(AstFactory.identifier3("deprecated")));
|
| + directive.metadata
|
| + .add(AstFactory.annotation(AstFactory.identifier3("deprecated")));
|
| _assertSource("@deprecated part of l;", directive);
|
| }
|
|
|
| void test_visitPositionalFormalParameter() {
|
| - _assertSource(
|
| - "var a = 0",
|
| - AstFactory.positionalFormalParameter(
|
| - AstFactory.simpleFormalParameter(Keyword.VAR, "a"),
|
| - AstFactory.integer(0)));
|
| + _assertSource("var a = 0", AstFactory.positionalFormalParameter(
|
| + AstFactory.simpleFormalParameter(Keyword.VAR, "a"),
|
| + AstFactory.integer(0)));
|
| }
|
|
|
| void test_visitPostfixExpression() {
|
| - _assertSource(
|
| - "a++",
|
| - AstFactory.postfixExpression(AstFactory.identifier3("a"), TokenType.PLUS_PLUS));
|
| + _assertSource("a++", AstFactory.postfixExpression(
|
| + AstFactory.identifier3("a"), TokenType.PLUS_PLUS));
|
| }
|
|
|
| void test_visitPrefixedIdentifier() {
|
| @@ -3641,21 +2856,18 @@ class ToSourceVisitorTest extends EngineTestCase {
|
| }
|
|
|
| void test_visitPrefixExpression() {
|
| - _assertSource(
|
| - "-a",
|
| - AstFactory.prefixExpression(TokenType.MINUS, AstFactory.identifier3("a")));
|
| + _assertSource("-a", AstFactory.prefixExpression(
|
| + TokenType.MINUS, AstFactory.identifier3("a")));
|
| }
|
|
|
| void test_visitPropertyAccess() {
|
| _assertSource(
|
| - "a.b",
|
| - AstFactory.propertyAccess2(AstFactory.identifier3("a"), "b"));
|
| + "a.b", AstFactory.propertyAccess2(AstFactory.identifier3("a"), "b"));
|
| }
|
|
|
| void test_visitRedirectingConstructorInvocation_named() {
|
| _assertSource(
|
| - "this.c()",
|
| - AstFactory.redirectingConstructorInvocation2("c"));
|
| + "this.c()", AstFactory.redirectingConstructorInvocation2("c"));
|
| }
|
|
|
| void test_visitRedirectingConstructorInvocation_unnamed() {
|
| @@ -3668,8 +2880,7 @@ class ToSourceVisitorTest extends EngineTestCase {
|
|
|
| void test_visitReturnStatement_expression() {
|
| _assertSource(
|
| - "return a;",
|
| - AstFactory.returnStatement2(AstFactory.identifier3("a")));
|
| + "return a;", AstFactory.returnStatement2(AstFactory.identifier3("a")));
|
| }
|
|
|
| void test_visitReturnStatement_noExpression() {
|
| @@ -3686,17 +2897,12 @@ class ToSourceVisitorTest extends EngineTestCase {
|
| }
|
|
|
| void test_visitSimpleFormalParameter_keyword_type() {
|
| - _assertSource(
|
| - "final A a",
|
| - AstFactory.simpleFormalParameter2(
|
| - Keyword.FINAL,
|
| - AstFactory.typeName4("A"),
|
| - "a"));
|
| + _assertSource("final A a", AstFactory.simpleFormalParameter2(
|
| + Keyword.FINAL, AstFactory.typeName4("A"), "a"));
|
| }
|
|
|
| void test_visitSimpleFormalParameter_type() {
|
| - _assertSource(
|
| - "A a",
|
| + _assertSource("A a",
|
| AstFactory.simpleFormalParameter4(AstFactory.typeName4("A"), "a"));
|
| }
|
|
|
| @@ -3709,13 +2915,11 @@ class ToSourceVisitorTest extends EngineTestCase {
|
| }
|
|
|
| void test_visitStringInterpolation() {
|
| - _assertSource(
|
| - "'a\${e}b'",
|
| - AstFactory.string(
|
| - [
|
| - AstFactory.interpolationString("'a", "a"),
|
| - AstFactory.interpolationExpression(AstFactory.identifier3("e")),
|
| - AstFactory.interpolationString("b'", "b")]));
|
| + _assertSource("'a\${e}b'", AstFactory.string([
|
| + AstFactory.interpolationString("'a", "a"),
|
| + AstFactory.interpolationExpression(AstFactory.identifier3("e")),
|
| + AstFactory.interpolationString("b'", "b")
|
| + ]));
|
| }
|
|
|
| void test_visitSuperConstructorInvocation() {
|
| @@ -3731,71 +2935,56 @@ class ToSourceVisitorTest extends EngineTestCase {
|
| }
|
|
|
| void test_visitSwitchCase_multipleLabels() {
|
| - _assertSource(
|
| - "l1: l2: case a: {}",
|
| - AstFactory.switchCase2(
|
| - [AstFactory.label2("l1"), AstFactory.label2("l2")],
|
| - AstFactory.identifier3("a"),
|
| - [AstFactory.block()]));
|
| + _assertSource("l1: l2: case a: {}", AstFactory.switchCase2([
|
| + AstFactory.label2("l1"),
|
| + AstFactory.label2("l2")
|
| + ], AstFactory.identifier3("a"), [AstFactory.block()]));
|
| }
|
|
|
| void test_visitSwitchCase_multipleStatements() {
|
| - _assertSource(
|
| - "case a: {} {}",
|
| - AstFactory.switchCase(
|
| - AstFactory.identifier3("a"),
|
| - [AstFactory.block(), AstFactory.block()]));
|
| + _assertSource("case a: {} {}", AstFactory.switchCase(
|
| + AstFactory.identifier3("a"), [AstFactory.block(), AstFactory.block()]));
|
| }
|
|
|
| void test_visitSwitchCase_noLabels() {
|
| - _assertSource(
|
| - "case a: {}",
|
| - AstFactory.switchCase(AstFactory.identifier3("a"), [AstFactory.block()]));
|
| + _assertSource("case a: {}", AstFactory.switchCase(
|
| + AstFactory.identifier3("a"), [AstFactory.block()]));
|
| }
|
|
|
| void test_visitSwitchCase_singleLabel() {
|
| - _assertSource(
|
| - "l1: case a: {}",
|
| - AstFactory.switchCase2(
|
| - [AstFactory.label2("l1")],
|
| - AstFactory.identifier3("a"),
|
| - [AstFactory.block()]));
|
| + _assertSource("l1: case a: {}", AstFactory.switchCase2([
|
| + AstFactory.label2("l1")
|
| + ], AstFactory.identifier3("a"), [AstFactory.block()]));
|
| }
|
|
|
| void test_visitSwitchDefault_multipleLabels() {
|
| - _assertSource(
|
| - "l1: l2: default: {}",
|
| - AstFactory.switchDefault(
|
| - [AstFactory.label2("l1"), AstFactory.label2("l2")],
|
| - [AstFactory.block()]));
|
| + _assertSource("l1: l2: default: {}", AstFactory.switchDefault([
|
| + AstFactory.label2("l1"),
|
| + AstFactory.label2("l2")
|
| + ], [AstFactory.block()]));
|
| }
|
|
|
| void test_visitSwitchDefault_multipleStatements() {
|
| - _assertSource(
|
| - "default: {} {}",
|
| + _assertSource("default: {} {}",
|
| AstFactory.switchDefault2([AstFactory.block(), AstFactory.block()]));
|
| }
|
|
|
| void test_visitSwitchDefault_noLabels() {
|
| _assertSource(
|
| - "default: {}",
|
| - AstFactory.switchDefault2([AstFactory.block()]));
|
| + "default: {}", AstFactory.switchDefault2([AstFactory.block()]));
|
| }
|
|
|
| void test_visitSwitchDefault_singleLabel() {
|
| - _assertSource(
|
| - "l1: default: {}",
|
| - AstFactory.switchDefault([AstFactory.label2("l1")], [AstFactory.block()]));
|
| + _assertSource("l1: default: {}", AstFactory.switchDefault(
|
| + [AstFactory.label2("l1")], [AstFactory.block()]));
|
| }
|
|
|
| void test_visitSwitchStatement() {
|
| - _assertSource(
|
| - "switch (a) {case 'b': {} default: {}}",
|
| - AstFactory.switchStatement(
|
| - AstFactory.identifier3("a"),
|
| - [
|
| - AstFactory.switchCase(AstFactory.string2("b"), [AstFactory.block()]),
|
| - AstFactory.switchDefault2([AstFactory.block()])]));
|
| + _assertSource("switch (a) {case 'b': {} default: {}}", AstFactory
|
| + .switchStatement(AstFactory.identifier3("a"), [
|
| + AstFactory.switchCase(AstFactory.string2("b"), [AstFactory.block()]),
|
| + AstFactory.switchDefault2([AstFactory.block()])
|
| + ]));
|
| }
|
|
|
| void test_visitSymbolLiteral_multiple() {
|
| @@ -3812,86 +3001,65 @@ class ToSourceVisitorTest extends EngineTestCase {
|
|
|
| void test_visitThrowStatement() {
|
| _assertSource(
|
| - "throw e",
|
| - AstFactory.throwExpression2(AstFactory.identifier3("e")));
|
| + "throw e", AstFactory.throwExpression2(AstFactory.identifier3("e")));
|
| }
|
|
|
| void test_visitTopLevelVariableDeclaration_multiple() {
|
| - _assertSource(
|
| - "var a;",
|
| - AstFactory.topLevelVariableDeclaration2(
|
| - Keyword.VAR,
|
| - [AstFactory.variableDeclaration("a")]));
|
| + _assertSource("var a;", AstFactory.topLevelVariableDeclaration2(
|
| + Keyword.VAR, [AstFactory.variableDeclaration("a")]));
|
| }
|
|
|
| void test_visitTopLevelVariableDeclaration_single() {
|
| - _assertSource(
|
| - "var a, b;",
|
| - AstFactory.topLevelVariableDeclaration2(
|
| - Keyword.VAR,
|
| - [AstFactory.variableDeclaration("a"), AstFactory.variableDeclaration("b")]));
|
| + _assertSource("var a, b;", AstFactory.topLevelVariableDeclaration2(
|
| + Keyword.VAR, [
|
| + AstFactory.variableDeclaration("a"),
|
| + AstFactory.variableDeclaration("b")
|
| + ]));
|
| }
|
|
|
| void test_visitTryStatement_catch() {
|
| - _assertSource(
|
| - "try {} on E {}",
|
| - AstFactory.tryStatement2(
|
| - AstFactory.block(),
|
| - [AstFactory.catchClause3(AstFactory.typeName4("E"))]));
|
| + _assertSource("try {} on E {}", AstFactory.tryStatement2(AstFactory.block(),
|
| + [AstFactory.catchClause3(AstFactory.typeName4("E"))]));
|
| }
|
|
|
| void test_visitTryStatement_catches() {
|
| - _assertSource(
|
| - "try {} on E {} on F {}",
|
| - AstFactory.tryStatement2(
|
| - AstFactory.block(),
|
| - [
|
| - AstFactory.catchClause3(AstFactory.typeName4("E")),
|
| - AstFactory.catchClause3(AstFactory.typeName4("F"))]));
|
| + _assertSource("try {} on E {} on F {}", AstFactory.tryStatement2(
|
| + AstFactory.block(), [
|
| + AstFactory.catchClause3(AstFactory.typeName4("E")),
|
| + AstFactory.catchClause3(AstFactory.typeName4("F"))
|
| + ]));
|
| }
|
|
|
| void test_visitTryStatement_catchFinally() {
|
| - _assertSource(
|
| - "try {} on E {} finally {}",
|
| - AstFactory.tryStatement3(
|
| - AstFactory.block(),
|
| - [AstFactory.catchClause3(AstFactory.typeName4("E"))],
|
| - AstFactory.block()));
|
| + _assertSource("try {} on E {} finally {}", AstFactory.tryStatement3(
|
| + AstFactory.block(), [
|
| + AstFactory.catchClause3(AstFactory.typeName4("E"))
|
| + ], AstFactory.block()));
|
| }
|
|
|
| void test_visitTryStatement_finally() {
|
| - _assertSource(
|
| - "try {} finally {}",
|
| + _assertSource("try {} finally {}",
|
| AstFactory.tryStatement(AstFactory.block(), AstFactory.block()));
|
| }
|
|
|
| void test_visitTypeArgumentList_multiple() {
|
| - _assertSource(
|
| - "<E, F>",
|
| - AstFactory.typeArgumentList(
|
| - [AstFactory.typeName4("E"), AstFactory.typeName4("F")]));
|
| + _assertSource("<E, F>", AstFactory.typeArgumentList(
|
| + [AstFactory.typeName4("E"), AstFactory.typeName4("F")]));
|
| }
|
|
|
| void test_visitTypeArgumentList_single() {
|
| _assertSource(
|
| - "<E>",
|
| - AstFactory.typeArgumentList([AstFactory.typeName4("E")]));
|
| + "<E>", AstFactory.typeArgumentList([AstFactory.typeName4("E")]));
|
| }
|
|
|
| void test_visitTypeName_multipleArgs() {
|
| - _assertSource(
|
| - "C<D, E>",
|
| - AstFactory.typeName4(
|
| - "C",
|
| - [AstFactory.typeName4("D"), AstFactory.typeName4("E")]));
|
| + _assertSource("C<D, E>", AstFactory.typeName4(
|
| + "C", [AstFactory.typeName4("D"), AstFactory.typeName4("E")]));
|
| }
|
|
|
| void test_visitTypeName_nestedArg() {
|
| - _assertSource(
|
| - "C<D<E>>",
|
| - AstFactory.typeName4(
|
| - "C",
|
| - [AstFactory.typeName4("D", [AstFactory.typeName4("E")])]));
|
| + _assertSource("C<D<E>>", AstFactory.typeName4(
|
| + "C", [AstFactory.typeName4("D", [AstFactory.typeName4("E")])]));
|
| }
|
|
|
| void test_visitTypeName_noArgs() {
|
| @@ -3900,19 +3068,18 @@ class ToSourceVisitorTest extends EngineTestCase {
|
|
|
| void test_visitTypeName_singleArg() {
|
| _assertSource(
|
| - "C<D>",
|
| - AstFactory.typeName4("C", [AstFactory.typeName4("D")]));
|
| + "C<D>", AstFactory.typeName4("C", [AstFactory.typeName4("D")]));
|
| }
|
|
|
| void test_visitTypeParameter_withExtends() {
|
| - _assertSource(
|
| - "E extends C",
|
| + _assertSource("E extends C",
|
| AstFactory.typeParameter2("E", AstFactory.typeName4("C")));
|
| }
|
|
|
| void test_visitTypeParameter_withMetadata() {
|
| TypeParameter parameter = AstFactory.typeParameter("E");
|
| - parameter.metadata.add(AstFactory.annotation(AstFactory.identifier3("deprecated")));
|
| + parameter.metadata
|
| + .add(AstFactory.annotation(AstFactory.identifier3("deprecated")));
|
| _assertSource("@deprecated E", parameter);
|
| }
|
|
|
| @@ -3929,8 +3096,7 @@ class ToSourceVisitorTest extends EngineTestCase {
|
| }
|
|
|
| void test_visitVariableDeclaration_initialized() {
|
| - _assertSource(
|
| - "a = b",
|
| + _assertSource("a = b",
|
| AstFactory.variableDeclaration2("a", AstFactory.identifier3("b")));
|
| }
|
|
|
| @@ -3940,76 +3106,69 @@ class ToSourceVisitorTest extends EngineTestCase {
|
|
|
| void test_visitVariableDeclaration_withMetadata() {
|
| VariableDeclaration declaration = AstFactory.variableDeclaration("a");
|
| - declaration.metadata.add(AstFactory.annotation(AstFactory.identifier3("deprecated")));
|
| + declaration.metadata
|
| + .add(AstFactory.annotation(AstFactory.identifier3("deprecated")));
|
| _assertSource("@deprecated a", declaration);
|
| }
|
|
|
| void test_visitVariableDeclarationList_const_type() {
|
| - _assertSource(
|
| - "const C a, b",
|
| - AstFactory.variableDeclarationList(
|
| - Keyword.CONST,
|
| - AstFactory.typeName4("C"),
|
| - [AstFactory.variableDeclaration("a"), AstFactory.variableDeclaration("b")]));
|
| + _assertSource("const C a, b", AstFactory.variableDeclarationList(
|
| + Keyword.CONST, AstFactory.typeName4("C"), [
|
| + AstFactory.variableDeclaration("a"),
|
| + AstFactory.variableDeclaration("b")
|
| + ]));
|
| }
|
|
|
| void test_visitVariableDeclarationList_final_noType() {
|
| - _assertSource(
|
| - "final a, b",
|
| - AstFactory.variableDeclarationList2(
|
| - Keyword.FINAL,
|
| - [AstFactory.variableDeclaration("a"), AstFactory.variableDeclaration("b")]));
|
| + _assertSource("final a, b", AstFactory.variableDeclarationList2(
|
| + Keyword.FINAL, [
|
| + AstFactory.variableDeclaration("a"),
|
| + AstFactory.variableDeclaration("b")
|
| + ]));
|
| }
|
|
|
| void test_visitVariableDeclarationList_final_withMetadata() {
|
| - VariableDeclarationList declarationList =
|
| - AstFactory.variableDeclarationList2(
|
| - Keyword.FINAL,
|
| - [AstFactory.variableDeclaration("a"), AstFactory.variableDeclaration("b")]);
|
| - declarationList.metadata.add(AstFactory.annotation(AstFactory.identifier3("deprecated")));
|
| + VariableDeclarationList declarationList = AstFactory
|
| + .variableDeclarationList2(Keyword.FINAL, [
|
| + AstFactory.variableDeclaration("a"),
|
| + AstFactory.variableDeclaration("b")
|
| + ]);
|
| + declarationList.metadata
|
| + .add(AstFactory.annotation(AstFactory.identifier3("deprecated")));
|
| _assertSource("@deprecated final a, b", declarationList);
|
| }
|
|
|
| void test_visitVariableDeclarationList_type() {
|
| - _assertSource(
|
| - "C a, b",
|
| - AstFactory.variableDeclarationList(
|
| - null,
|
| - AstFactory.typeName4("C"),
|
| - [AstFactory.variableDeclaration("a"), AstFactory.variableDeclaration("b")]));
|
| + _assertSource("C a, b", AstFactory.variableDeclarationList(null,
|
| + AstFactory.typeName4("C"), [
|
| + AstFactory.variableDeclaration("a"),
|
| + AstFactory.variableDeclaration("b")
|
| + ]));
|
| }
|
|
|
| void test_visitVariableDeclarationList_var() {
|
| - _assertSource(
|
| - "var a, b",
|
| - AstFactory.variableDeclarationList2(
|
| - Keyword.VAR,
|
| - [AstFactory.variableDeclaration("a"), AstFactory.variableDeclaration("b")]));
|
| + _assertSource("var a, b", AstFactory.variableDeclarationList2(Keyword.VAR, [
|
| + AstFactory.variableDeclaration("a"),
|
| + AstFactory.variableDeclaration("b")
|
| + ]));
|
| }
|
|
|
| void test_visitVariableDeclarationStatement() {
|
| - _assertSource(
|
| - "C c;",
|
| - AstFactory.variableDeclarationStatement(
|
| - null,
|
| - AstFactory.typeName4("C"),
|
| - [AstFactory.variableDeclaration("c")]));
|
| + _assertSource("C c;", AstFactory.variableDeclarationStatement(null,
|
| + AstFactory.typeName4("C"), [AstFactory.variableDeclaration("c")]));
|
| }
|
|
|
| void test_visitWhileStatement() {
|
| - _assertSource(
|
| - "while (c) {}",
|
| - AstFactory.whileStatement(AstFactory.identifier3("c"), AstFactory.block()));
|
| + _assertSource("while (c) {}", AstFactory.whileStatement(
|
| + AstFactory.identifier3("c"), AstFactory.block()));
|
| }
|
|
|
| void test_visitWithClause_multiple() {
|
| - _assertSource(
|
| - "with A, B, C",
|
| - AstFactory.withClause(
|
| - [
|
| - AstFactory.typeName4("A"),
|
| - AstFactory.typeName4("B"),
|
| - AstFactory.typeName4("C")]));
|
| + _assertSource("with A, B, C", AstFactory.withClause([
|
| + AstFactory.typeName4("A"),
|
| + AstFactory.typeName4("B"),
|
| + AstFactory.typeName4("C")
|
| + ]));
|
| }
|
|
|
| void test_visitWithClause_single() {
|
| @@ -4018,13 +3177,11 @@ class ToSourceVisitorTest extends EngineTestCase {
|
|
|
| void test_visitYieldStatement() {
|
| _assertSource(
|
| - "yield e;",
|
| - AstFactory.yieldStatement(AstFactory.identifier3("e")));
|
| + "yield e;", AstFactory.yieldStatement(AstFactory.identifier3("e")));
|
| }
|
|
|
| void test_visitYieldStatement_each() {
|
| - _assertSource(
|
| - "yield* e;",
|
| + _assertSource("yield* e;",
|
| AstFactory.yieldEachStatement(AstFactory.identifier3("e")));
|
| }
|
|
|
| @@ -4080,11 +3237,12 @@ class WrapperKind extends Enum<WrapperKind> {
|
| static const WrapperKind NONE = const WrapperKind('NONE', 4);
|
|
|
| static const List<WrapperKind> values = const [
|
| - PREFIXED_LEFT,
|
| - PREFIXED_RIGHT,
|
| - PROPERTY_LEFT,
|
| - PROPERTY_RIGHT,
|
| - NONE];
|
| + PREFIXED_LEFT,
|
| + PREFIXED_RIGHT,
|
| + PROPERTY_LEFT,
|
| + PROPERTY_RIGHT,
|
| + NONE
|
| + ];
|
|
|
| const WrapperKind(String name, int ordinal) : super(name, ordinal);
|
| }
|
|
|