| Index: pkg/analyzer/test/generated/parser_test.dart
|
| diff --git a/pkg/analyzer/test/generated/parser_test.dart b/pkg/analyzer/test/generated/parser_test.dart
|
| index fc59ced7ea8b4fb5845be77cdab1e66e440d230e..5e56f6ba3c15c2a38acbb871d4283b3be9ae3840 100644
|
| --- a/pkg/analyzer/test/generated/parser_test.dart
|
| +++ b/pkg/analyzer/test/generated/parser_test.dart
|
| @@ -1092,6 +1092,23 @@ abstract class ClassMemberParserTestMixin implements AbstractParserTestCase {
|
| expect(constructor.body, new isInstanceOf<EmptyFunctionBody>());
|
| }
|
|
|
| + void test_parseConstructor_assert() {
|
| + enableAssertInitializer = true;
|
| + createParser('C(x, y) : _x = x, assert (x < y), _y = y;');
|
| + ClassMember member = parser.parseClassMember('C');
|
| + expect(member, isNotNull);
|
| + assertNoErrors();
|
| + expect(member, new isInstanceOf<ConstructorDeclaration>());
|
| + ConstructorDeclaration constructor = member as ConstructorDeclaration;
|
| + NodeList<ConstructorInitializer> initializers = constructor.initializers;
|
| + expect(initializers, hasLength(3));
|
| + ConstructorInitializer initializer = initializers[1];
|
| + expect(initializer, new isInstanceOf<AssertInitializer>());
|
| + AssertInitializer assertInitializer = initializer;
|
| + expect(assertInitializer.condition, isNotNull);
|
| + expect(assertInitializer.message, isNull);
|
| + }
|
| +
|
| void test_parseConstructor_initializers_field() {
|
| createParser('C(x, y) : _x = x, this._y = y;');
|
| ClassMember member = parser.parseClassMember('C');
|
| @@ -1119,23 +1136,6 @@ abstract class ClassMemberParserTestMixin implements AbstractParserTestCase {
|
| }
|
| }
|
|
|
| - void test_parseConstructor_assert() {
|
| - enableAssertInitializer = true;
|
| - createParser('C(x, y) : _x = x, assert (x < y), _y = y;');
|
| - ClassMember member = parser.parseClassMember('C');
|
| - expect(member, isNotNull);
|
| - assertNoErrors();
|
| - expect(member, new isInstanceOf<ConstructorDeclaration>());
|
| - ConstructorDeclaration constructor = member as ConstructorDeclaration;
|
| - NodeList<ConstructorInitializer> initializers = constructor.initializers;
|
| - expect(initializers, hasLength(3));
|
| - ConstructorInitializer initializer = initializers[1];
|
| - expect(initializer, new isInstanceOf<AssertInitializer>());
|
| - AssertInitializer assertInitializer = initializer;
|
| - expect(assertInitializer.condition, isNotNull);
|
| - expect(assertInitializer.message, isNull);
|
| - }
|
| -
|
| void test_parseConstructor_named() {
|
| createParser('C.foo();');
|
| var constructor = parser.parseClassMember('C') as ConstructorDeclaration;
|
| @@ -4162,6 +4162,19 @@ class ExpressionParserTest extends ParserTestCase
|
| with ExpressionParserTestMixin {}
|
|
|
| abstract class ExpressionParserTestMixin implements AbstractParserTestCase {
|
| + void test_namedArgument() {
|
| + var invocation = parseExpression('m(a: 1, b: 2)') as MethodInvocation;
|
| + List<Expression> arguments = invocation.argumentList.arguments;
|
| +
|
| + var a = arguments[0] as NamedExpression;
|
| + expect(a.name.label.name, 'a');
|
| + expect(a.expression, isNotNull);
|
| +
|
| + var b = arguments[1] as NamedExpression;
|
| + expect(b.name.label.name, 'b');
|
| + expect(b.expression, isNotNull);
|
| + }
|
| +
|
| void test_parseAdditiveExpression_normal() {
|
| Expression expression = parseAdditiveExpression('x + y');
|
| expect(expression, isNotNull);
|
| @@ -5619,19 +5632,6 @@ abstract class ExpressionParserTestMixin implements AbstractParserTestCase {
|
| expect(methodInvocation.argumentList, isNotNull);
|
| }
|
|
|
| - void test_namedArgument() {
|
| - var invocation = parseExpression('m(a: 1, b: 2)') as MethodInvocation;
|
| - List<Expression> arguments = invocation.argumentList.arguments;
|
| -
|
| - var a = arguments[0] as NamedExpression;
|
| - expect(a.name.label.name, 'a');
|
| - expect(a.expression, isNotNull);
|
| -
|
| - var b = arguments[1] as NamedExpression;
|
| - expect(b.name.label.name, 'b');
|
| - expect(b.expression, isNotNull);
|
| - }
|
| -
|
| void test_parsePostfixExpression_none_methodInvocation_question_dot() {
|
| Expression expression = parsePostfixExpression('a?.m()');
|
| expect(expression, isNotNull);
|
| @@ -11101,52 +11101,6 @@ void''');
|
| expect(functionBody, new isInstanceOf<EmptyFunctionBody>());
|
| }
|
|
|
| - void test_parseFunctionDeclarationStatement() {
|
| - createParser('void f(int p) => p * 2;');
|
| - FunctionDeclarationStatement statement =
|
| - parser.parseFunctionDeclarationStatement();
|
| - expectNotNullIfNoErrors(statement);
|
| - listener.assertNoErrors();
|
| - expect(statement.functionDeclaration, isNotNull);
|
| - }
|
| -
|
| - void test_parseFunctionDeclarationStatement_typeParameterComments() {
|
| - enableGenericMethodComments = true;
|
| - createParser('/*=E*/ f/*<E>*/(/*=E*/ p) => p * 2;');
|
| - FunctionDeclarationStatement statement =
|
| - parser.parseFunctionDeclarationStatement();
|
| - expectNotNullIfNoErrors(statement);
|
| - listener.assertNoErrors();
|
| - FunctionDeclaration f = statement.functionDeclaration;
|
| - expect(f, isNotNull);
|
| - expect(f.functionExpression.typeParameters, isNotNull);
|
| - expect(f.returnType, isNotNull);
|
| - SimpleFormalParameter p = f.functionExpression.parameters.parameters[0];
|
| - expect(p.type, isNotNull);
|
| - }
|
| -
|
| - void test_parseFunctionDeclarationStatement_typeParameters() {
|
| - createParser('E f<E>(E p) => p * 2;');
|
| - FunctionDeclarationStatement statement =
|
| - parser.parseFunctionDeclarationStatement();
|
| - expectNotNullIfNoErrors(statement);
|
| - listener.assertNoErrors();
|
| - expect(statement.functionDeclaration, isNotNull);
|
| - expect(statement.functionDeclaration.functionExpression.typeParameters,
|
| - isNotNull);
|
| - }
|
| -
|
| - void test_parseFunctionDeclarationStatement_typeParameters_noReturnType() {
|
| - createParser('f<E>(E p) => p * 2;');
|
| - FunctionDeclarationStatement statement =
|
| - parser.parseFunctionDeclarationStatement();
|
| - expectNotNullIfNoErrors(statement);
|
| - listener.assertNoErrors();
|
| - expect(statement.functionDeclaration, isNotNull);
|
| - expect(statement.functionDeclaration.functionExpression.typeParameters,
|
| - isNotNull);
|
| - }
|
| -
|
| void test_parseIdentifierList_multiple() {
|
| createParser('a, b, c');
|
| List<SimpleIdentifier> list = parser.parseIdentifierList();
|
| @@ -12516,6 +12470,44 @@ abstract class StatementParserTestMixin implements AbstractParserTestCase {
|
| expect(forStatement.body, isNotNull);
|
| }
|
|
|
| + void test_parseFunctionDeclarationStatement() {
|
| + var statement = parseStatement('void f(int p) => p * 2;')
|
| + as FunctionDeclarationStatement;
|
| + assertNoErrors();
|
| + expect(statement.functionDeclaration, isNotNull);
|
| + }
|
| +
|
| + void test_parseFunctionDeclarationStatement_typeParameterComments() {
|
| + enableGenericMethodComments = true;
|
| + var statement = parseStatement('/*=E*/ f/*<E>*/(/*=E*/ p) => p * 2;')
|
| + as FunctionDeclarationStatement;
|
| + assertNoErrors();
|
| + FunctionDeclaration f = statement.functionDeclaration;
|
| + expect(f, isNotNull);
|
| + expect(f.functionExpression.typeParameters, isNotNull);
|
| + expect(f.returnType, isNotNull);
|
| + SimpleFormalParameter p = f.functionExpression.parameters.parameters[0];
|
| + expect(p.type, isNotNull);
|
| + }
|
| +
|
| + void test_parseFunctionDeclarationStatement_typeParameters() {
|
| + var statement =
|
| + parseStatement('E f<E>(E p) => p * 2;') as FunctionDeclarationStatement;
|
| + assertNoErrors();
|
| + expect(statement.functionDeclaration, isNotNull);
|
| + expect(statement.functionDeclaration.functionExpression.typeParameters,
|
| + isNotNull);
|
| + }
|
| +
|
| + void test_parseFunctionDeclarationStatement_typeParameters_noReturnType() {
|
| + var statement =
|
| + parseStatement('f<E>(E p) => p * 2;') as FunctionDeclarationStatement;
|
| + assertNoErrors();
|
| + expect(statement.functionDeclaration, isNotNull);
|
| + expect(statement.functionDeclaration.functionExpression.typeParameters,
|
| + isNotNull);
|
| + }
|
| +
|
| void test_parseIfStatement_else_block() {
|
| var statement = parseStatement('if (x) {} else {}') as IfStatement;
|
| assertNoErrors();
|
|
|