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

Unified Diff: pkg/analyzer/test/generated/parser_test.dart

Issue 2829693002: Move 'general function type' unit tests into mixins to run them with Fasta. (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 424bd86d535a2601fc3e285261ea7ffcb6850cd9..8dd001abca99f3ad29c692626e54cb0d02aed506 100644
--- a/pkg/analyzer/test/generated/parser_test.dart
+++ b/pkg/analyzer/test/generated/parser_test.dart
@@ -390,6 +390,28 @@ abstract class ClassMemberParserTestMixin implements AbstractParserTestCase {
expect(variable.name, isNotNull);
}
+ void test_parseClassMember_field_gftType_gftReturnType() {
+ createParser('''
+Function(int) Function(String) v;
+''');
+ ClassMember member = parser.parseClassMember('C');
+ assertNoErrors();
+ expect(member, new isInstanceOf<FieldDeclaration>());
+ VariableDeclarationList fields = (member as FieldDeclaration).fields;
+ expect(fields.type, new isInstanceOf<GenericFunctionType>());
+ }
+
+ void test_parseClassMember_field_gftType_noReturnType() {
+ createParser('''
+Function(int, String) v;
+''');
+ ClassMember member = parser.parseClassMember('C');
+ assertNoErrors();
+ expect(member, new isInstanceOf<FieldDeclaration>());
+ VariableDeclarationList fields = (member as FieldDeclaration).fields;
+ expect(fields.type, new isInstanceOf<GenericFunctionType>());
+ }
+
void test_parseClassMember_field_instance_prefixedType() {
createParser('p.A f;');
ClassMember member = parser.parseClassMember('C');
@@ -784,6 +806,28 @@ abstract class ClassMemberParserTestMixin implements AbstractParserTestCase {
expect(method.body, isNotNull);
}
+ void test_parseClassMember_method_gftReturnType_noReturnType() {
+ createParser('''
+Function<A>(core.List<core.int> x) m() => null;
+''');
+ ClassMember member = parser.parseClassMember('C');
+ assertNoErrors();
+ expect(member, new isInstanceOf<MethodDeclaration>());
+ expect((member as MethodDeclaration).body,
+ new isInstanceOf<ExpressionFunctionBody>());
+ }
+
+ void test_parseClassMember_method_gftReturnType_voidReturnType() {
+ createParser('''
+void Function<A>(core.List<core.int> x) m() => null;
+''');
+ ClassMember member = parser.parseClassMember('C');
+ assertNoErrors();
+ expect(member, new isInstanceOf<MethodDeclaration>());
+ expect((member as MethodDeclaration).body,
+ new isInstanceOf<ExpressionFunctionBody>());
+ }
+
void test_parseClassMember_method_native() {
createParser('m() native "str";');
var method = parser.parseClassMember('C') as MethodDeclaration;
@@ -10034,50 +10078,6 @@ class SimpleParserTest extends ParserTestCase {
expect(arguments, hasLength(3));
}
- void test_parseClassMember_field_gftType_gftReturnType() {
- createParser('''
-Function(int) Function(String) v;
-''');
- ClassMember member = parser.parseClassMember('C');
- listener.assertNoErrors();
- expect(member, new isInstanceOf<FieldDeclaration>());
- VariableDeclarationList fields = (member as FieldDeclaration).fields;
- expect(fields.type, new isInstanceOf<GenericFunctionType>());
- }
-
- void test_parseClassMember_field_gftType_noReturnType() {
- createParser('''
-Function(int, String) v;
-''');
- ClassMember member = parser.parseClassMember('C');
- listener.assertNoErrors();
- expect(member, new isInstanceOf<FieldDeclaration>());
- VariableDeclarationList fields = (member as FieldDeclaration).fields;
- expect(fields.type, new isInstanceOf<GenericFunctionType>());
- }
-
- void test_parseClassMember_method_gftReturnType() {
- createParser('''
-void Function<A>(core.List<core.int> x) m() => null;
-''');
- ClassMember member = parser.parseClassMember('C');
- listener.assertNoErrors();
- expect(member, new isInstanceOf<MethodDeclaration>());
- expect((member as MethodDeclaration).body,
- new isInstanceOf<ExpressionFunctionBody>());
- }
-
- void test_parseClassMember_method_noReturnType() {
- createParser('''
-Function<A>(core.List<core.int> x) m() => null;
-''');
- ClassMember member = parser.parseClassMember('C');
- listener.assertNoErrors();
- expect(member, new isInstanceOf<MethodDeclaration>());
- expect((member as MethodDeclaration).body,
- new isInstanceOf<ExpressionFunctionBody>());
- }
-
void test_parseCombinator_hide() {
createParser('hide a;');
Combinator combinator = parser.parseCombinator();
@@ -10678,49 +10678,6 @@ void''');
expect(reference.offset, 15);
}
- void test_parseCompilationUnitMember_function_gftReturnType() {
- createParser('''
-void Function<A>(core.List<core.int> x) f() => null;
-''');
- CompilationUnit unit = parser.parseCompilationUnit2();
- listener.assertNoErrors();
- expect(unit, isNotNull);
- expect(unit.declarations, hasLength(1));
- }
-
- void test_parseCompilationUnitMember_function_noReturnType() {
- createParser('''
-Function<A>(core.List<core.int> x) f() => null;
-''');
- CompilationUnit unit = parser.parseCompilationUnit2();
- listener.assertNoErrors();
- expect(unit, isNotNull);
- expect(unit.declarations, hasLength(1));
- }
-
- void test_parseCompilationUnitMember_variable_gftType_gftReturnType() {
- createParser('''
-Function(int) Function(String) v;
-''');
- CompilationUnit unit = parser.parseCompilationUnit2();
- listener.assertNoErrors();
- expect(unit, isNotNull);
- expect(unit.declarations, hasLength(1));
- TopLevelVariableDeclaration declaration =
- unit.declarations[0] as TopLevelVariableDeclaration;
- expect(declaration.variables.type, new isInstanceOf<GenericFunctionType>());
- }
-
- void test_parseCompilationUnitMember_variable_gftType_noReturnType() {
- createParser('''
-Function(int, String) v;
-''');
- CompilationUnit unit = parser.parseCompilationUnit2();
- listener.assertNoErrors();
- expect(unit, isNotNull);
- expect(unit.declarations, hasLength(1));
- }
-
void test_parseConfiguration_noOperator_dottedIdentifier() {
createParser("if (a.b) 'c.dart'");
Configuration configuration = parser.parseConfiguration();
@@ -11321,75 +11278,6 @@ Function(int, String) v;
expect(modifiers.varKeyword, isNotNull);
}
- void test_parseNonLabeledStatement_localFunction_gftReturnType() {
- createParser('int Function(int) f(String s) => null;');
- Statement statement = parser.parseNonLabeledStatement();
- expectNotNullIfNoErrors(statement);
- listener.assertNoErrors();
- }
-
- void test_parseNonLabeledStatement_variableDeclaration_final_namedFunction() {
- createParser('final int Function = 0;');
- Statement statement = parser.parseNonLabeledStatement();
- expectNotNullIfNoErrors(statement);
- listener.assertNoErrors();
- }
-
- void test_parseNonLabeledStatement_variableDeclaration_gftType() {
- createParser('int Function(int) v;');
- Statement statement = parser.parseNonLabeledStatement();
- expectNotNullIfNoErrors(statement);
- listener.assertNoErrors();
- }
-
- void
- test_parseNonLabeledStatement_variableDeclaration_gftType_functionReturnType() {
- createParser(
- 'Function Function(int x1, {Function x}) Function<B extends core.int>(int x) l771;');
- Statement statement = parser.parseNonLabeledStatement();
- expectNotNullIfNoErrors(statement);
- listener.assertNoErrors();
- }
-
- void
- test_parseNonLabeledStatement_variableDeclaration_gftType_gftReturnType() {
- createParser('Function(int) Function(int) v;');
- Statement statement = parser.parseNonLabeledStatement();
- expectNotNullIfNoErrors(statement);
- listener.assertNoErrors();
- }
-
- void
- test_parseNonLabeledStatement_variableDeclaration_gftType_gftReturnType2() {
- createParser('int Function(int) Function(int) v;');
- Statement statement = parser.parseNonLabeledStatement();
- expectNotNullIfNoErrors(statement);
- listener.assertNoErrors();
- }
-
- void
- test_parseNonLabeledStatement_variableDeclaration_gftType_noReturnType() {
- createParser('Function(int) v;');
- Statement statement = parser.parseNonLabeledStatement();
- expectNotNullIfNoErrors(statement);
- listener.assertNoErrors();
- }
-
- void test_parseNonLabeledStatement_variableDeclaration_gftType_returnType() {
- createParser('int Function<T>() v;');
- Statement statement = parser.parseNonLabeledStatement();
- expectNotNullIfNoErrors(statement);
- listener.assertNoErrors();
- }
-
- void
- test_parseNonLabeledStatement_variableDeclaration_gftType_voidReturnType() {
- createParser('void Function() v;');
- Statement statement = parser.parseNonLabeledStatement();
- expectNotNullIfNoErrors(statement);
- listener.assertNoErrors();
- }
-
void test_parseOptionalReturnType() {
// TODO(brianwilkerson) Implement tests for this method.
}
@@ -11446,20 +11334,6 @@ Function(int, String) v;
expect(typeName.typeArguments, isNull);
}
- void test_parseStatement_function_gftReturnType() {
- createParser('''
-void Function<A>(core.List<core.int> x) m() => null;
-''');
- Statement statement = parser.parseStatement2();
- expect(statement, new isInstanceOf<FunctionDeclarationStatement>());
- expect(
- (statement as FunctionDeclarationStatement)
- .functionDeclaration
- .functionExpression
- .body,
- new isInstanceOf<ExpressionFunctionBody>());
- }
-
void test_parseStatement_function_noReturnType() {
createParser('''
Function<A>(core.List<core.int> x) m() => null;
@@ -12685,6 +12559,14 @@ abstract class StatementParserTestMixin implements AbstractParserTestCase {
expect(invocation.argumentList.arguments, hasLength(1));
}
+ void test_parseNonLabeledStatement_localFunction_gftReturnType() {
+ var statement = parseStatement('int Function(int) f(String s) => null;')
+ as FunctionDeclarationStatement;
+ assertNoErrors();
+ FunctionDeclaration function = statement.functionDeclaration;
+ expect(function.returnType, new isInstanceOf<GenericFunctionType>());
+ }
+
void test_parseNonLabeledStatement_null() {
var statement = parseStatement('null;') as ExpressionStatement;
assertNoErrors();
@@ -12709,6 +12591,98 @@ abstract class StatementParserTestMixin implements AbstractParserTestCase {
expect(statement.expression, isNotNull);
}
+ void test_parseNonLabeledStatement_variableDeclaration_final_namedFunction() {
+ var statement = parseStatement('final int Function = 0;')
+ as VariableDeclarationStatement;
+ assertNoErrors();
+ List<VariableDeclaration> variables = statement.variables.variables;
+ expect(variables, hasLength(1));
+ expect(variables[0].name.name, 'Function');
+ }
+
+ void test_parseNonLabeledStatement_variableDeclaration_gftType() {
+ var statement =
+ parseStatement('int Function(int) v;') as VariableDeclarationStatement;
+ assertNoErrors();
+ VariableDeclarationList variableList = statement.variables;
+ List<VariableDeclaration> variables = variableList.variables;
+ expect(variables, hasLength(1));
+ expect(variables[0].name.name, 'v');
+ expect(variableList.type, new isInstanceOf<GenericFunctionType>());
+ }
+
+ void
+ test_parseNonLabeledStatement_variableDeclaration_gftType_functionReturnType() {
+ var statement = parseStatement(
+ 'Function Function(int x1, {Function x}) Function<B extends core.int>(int x) v;')
+ as VariableDeclarationStatement;
+ assertNoErrors();
+ VariableDeclarationList variableList = statement.variables;
+ List<VariableDeclaration> variables = variableList.variables;
+ expect(variables, hasLength(1));
+ expect(variables[0].name.name, 'v');
+ expect(variableList.type, new isInstanceOf<GenericFunctionType>());
+ }
+
+ void
+ test_parseNonLabeledStatement_variableDeclaration_gftType_gftReturnType() {
+ var statement = parseStatement('Function(int) Function(int) v;')
+ as VariableDeclarationStatement;
+ assertNoErrors();
+ VariableDeclarationList variableList = statement.variables;
+ List<VariableDeclaration> variables = variableList.variables;
+ expect(variables, hasLength(1));
+ expect(variables[0].name.name, 'v');
+ expect(variableList.type, new isInstanceOf<GenericFunctionType>());
+ }
+
+ void
+ test_parseNonLabeledStatement_variableDeclaration_gftType_gftReturnType2() {
+ var statement = parseStatement('int Function(int) Function(int) v;')
+ as VariableDeclarationStatement;
+ assertNoErrors();
+ VariableDeclarationList variableList = statement.variables;
+ List<VariableDeclaration> variables = variableList.variables;
+ expect(variables, hasLength(1));
+ expect(variables[0].name.name, 'v');
+ expect(variableList.type, new isInstanceOf<GenericFunctionType>());
+ }
+
+ void
+ test_parseNonLabeledStatement_variableDeclaration_gftType_noReturnType() {
+ var statement =
+ parseStatement('Function(int) v;') as VariableDeclarationStatement;
+ assertNoErrors();
+ VariableDeclarationList variableList = statement.variables;
+ List<VariableDeclaration> variables = variableList.variables;
+ expect(variables, hasLength(1));
+ expect(variables[0].name.name, 'v');
+ expect(variableList.type, new isInstanceOf<GenericFunctionType>());
+ }
+
+ void test_parseNonLabeledStatement_variableDeclaration_gftType_returnType() {
+ var statement =
+ parseStatement('int Function<T>() v;') as VariableDeclarationStatement;
+ assertNoErrors();
+ VariableDeclarationList variableList = statement.variables;
+ List<VariableDeclaration> variables = variableList.variables;
+ expect(variables, hasLength(1));
+ expect(variables[0].name.name, 'v');
+ expect(variableList.type, new isInstanceOf<GenericFunctionType>());
+ }
+
+ void
+ test_parseNonLabeledStatement_variableDeclaration_gftType_voidReturnType() {
+ var statement =
+ parseStatement('void Function() v;') as VariableDeclarationStatement;
+ assertNoErrors();
+ VariableDeclarationList variableList = statement.variables;
+ List<VariableDeclaration> variables = variableList.variables;
+ expect(variables, hasLength(1));
+ expect(variables[0].name.name, 'v');
+ expect(variableList.type, new isInstanceOf<GenericFunctionType>());
+ }
+
void test_parseStatement_emptyTypeArgumentList() {
var declaration = parseStatement('C<> c;') as VariableDeclarationStatement;
assertErrorsWithCodes([ParserErrorCode.EXPECTED_TYPE_NAME]);
@@ -12721,6 +12695,14 @@ abstract class StatementParserTestMixin implements AbstractParserTestCase {
expect(argumentList.rightBracket, isNotNull);
}
+ void test_parseStatement_function_gftReturnType() {
+ var statement =
+ parseStatement('void Function<A>(core.List<core.int> x) m() => null;')
+ as FunctionDeclarationStatement;
+ expect(statement.functionDeclaration.functionExpression.body,
+ new isInstanceOf<ExpressionFunctionBody>());
+ }
+
void test_parseStatement_functionDeclaration_noReturnType() {
var statement = parseStatement('true;') as ExpressionStatement;
assertNoErrors();
@@ -13759,6 +13741,26 @@ abstract class TopLevelParserTestMixin implements AbstractParserTestCase {
expect(declaration.propertyKeyword, isNull);
}
+ void test_parseCompilationUnitMember_function_gftReturnType() {
+ createParser('''
+void Function<A>(core.List<core.int> x) f() => null;
+''');
+ CompilationUnit unit = parser.parseCompilationUnit2();
+ assertNoErrors();
+ expect(unit, isNotNull);
+ expect(unit.declarations, hasLength(1));
+ }
+
+ void test_parseCompilationUnitMember_function_noReturnType() {
+ createParser('''
+Function<A>(core.List<core.int> x) f() => null;
+''');
+ CompilationUnit unit = parser.parseCompilationUnit2();
+ assertNoErrors();
+ expect(unit, isNotNull);
+ expect(unit.declarations, hasLength(1));
+ }
+
void test_parseCompilationUnitMember_function_noType() {
createParser('f() {}');
CompilationUnitMember member = parseFullCompilationUnitMember();
@@ -14003,6 +14005,29 @@ abstract class TopLevelParserTestMixin implements AbstractParserTestCase {
expect(declaration.variables.keyword.lexeme, 'var');
}
+ void test_parseCompilationUnitMember_variable_gftType_gftReturnType() {
+ createParser('''
+Function(int) Function(String) v;
+''');
+ CompilationUnit unit = parser.parseCompilationUnit2();
+ assertNoErrors();
+ expect(unit, isNotNull);
+ expect(unit.declarations, hasLength(1));
+ TopLevelVariableDeclaration declaration =
+ unit.declarations[0] as TopLevelVariableDeclaration;
+ expect(declaration.variables.type, new isInstanceOf<GenericFunctionType>());
+ }
+
+ void test_parseCompilationUnitMember_variable_gftType_noReturnType() {
+ createParser('''
+Function(int, String) v;
+''');
+ CompilationUnit unit = parser.parseCompilationUnit2();
+ assertNoErrors();
+ expect(unit, isNotNull);
+ expect(unit.declarations, hasLength(1));
+ }
+
void test_parseCompilationUnitMember_variable_withDocumentationComment() {
createParser('/// Doc\nvar x = 0;');
var declaration =
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698