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

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

Issue 2817753002: More parser fixes for generic function types (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 | « pkg/analyzer/lib/src/generated/parser.dart ('k') | 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 57e81b22d6072a156d73924c80fa6237a183fd16..15b94b78b1cee37b1a30fda4633571e423752678 100644
--- a/pkg/analyzer/test/generated/parser_test.dart
+++ b/pkg/analyzer/test/generated/parser_test.dart
@@ -10040,11 +10040,23 @@ class SimpleParserTest extends ParserTestCase {
expect(arguments, hasLength(3));
}
+ 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>());
@@ -10055,6 +10067,7 @@ void Function<A>(core.List<core.int> x) m() => null;
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>());
@@ -10665,6 +10678,7 @@ void''');
void Function<A>(core.List<core.int> x) f() => null;
''');
CompilationUnit unit = parser.parseCompilationUnit2();
+ listener.assertNoErrors();
expect(unit, isNotNull);
expect(unit.declarations, hasLength(1));
}
@@ -10674,6 +10688,17 @@ void Function<A>(core.List<core.int> x) f() => null;
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_noReturnType() {
+ createParser('''
+Function(int, String) v;
+''');
+ CompilationUnit unit = parser.parseCompilationUnit2();
+ listener.assertNoErrors();
expect(unit, isNotNull);
expect(unit.declarations, hasLength(1));
}
@@ -11278,6 +11303,13 @@ Function<A>(core.List<core.int> x) f() => null;
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();
@@ -11285,6 +11317,21 @@ Function<A>(core.List<core.int> x) f() => null;
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_noReturnType() {
+ createParser('Function(int) v;');
+ Statement statement = parser.parseNonLabeledStatement();
+ expectNotNullIfNoErrors(statement);
+ listener.assertNoErrors();
+ }
+
void test_parseOptionalReturnType() {
// TODO(brianwilkerson) Implement tests for this method.
}
« no previous file with comments | « pkg/analyzer/lib/src/generated/parser.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698