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

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

Issue 1044383002: improve parser recovery when top level function is missing parameters (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: merge Created 5 years, 9 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 46c93a0af00d4a39fdc76a460629edf9fff1c402..e4166bd0ef1f1006be6042dba0c344f47cd26dcb 100644
--- a/pkg/analyzer/test/generated/parser_test.dart
+++ b/pkg/analyzer/test/generated/parser_test.dart
@@ -1195,8 +1195,9 @@ class Foo {
}
void test_getterInFunction_block_noReturnType() {
- ParserTestCase.parseStatement(
+ FunctionDeclarationStatement statement = ParserTestCase.parseStatement(
"get x { return _x; }", [ParserErrorCode.GETTER_IN_FUNCTION]);
+ expect(statement.functionDeclaration.functionExpression.parameters, isNull);
}
void test_getterInFunction_block_returnType() {
@@ -1485,13 +1486,17 @@ class Foo {
}
void test_missingFunctionParameters_topLevel_void_block() {
- ParserTestCase.parseCompilationUnit(
+ CompilationUnit unit = ParserTestCase.parseCompilationUnit(
"void f { return x;}", [ParserErrorCode.MISSING_FUNCTION_PARAMETERS]);
+ FunctionDeclaration funct = unit.declarations[0];
+ expect(funct.functionExpression.parameters, hasLength(0));
}
void test_missingFunctionParameters_topLevel_void_expression() {
- ParserTestCase.parseCompilationUnit(
+ CompilationUnit unit = ParserTestCase.parseCompilationUnit(
"void f => x;", [ParserErrorCode.MISSING_FUNCTION_PARAMETERS]);
+ FunctionDeclaration funct = unit.declarations[0];
+ expect(funct.functionExpression.parameters, hasLength(0));
}
void test_missingIdentifier_afterOperator() {
@@ -1554,8 +1559,10 @@ class Foo {
}
void test_missingMethodParameters_void_block() {
- parse3("parseClassMember", <Object>["C"], "void m {} }",
+ MethodDeclaration method = parse3("parseClassMember",
+ <Object>["C"], "void m {} }",
[ParserErrorCode.MISSING_METHOD_PARAMETERS]);
+ expect(method.parameters, hasLength(0));
}
void test_missingMethodParameters_void_expression() {
@@ -1857,6 +1864,13 @@ class Foo {
]);
}
+ void test_topLevel_getter() {
+ FunctionDeclaration funct = parse3("parseCompilationUnitMember",
+ <Object>[emptyCommentAndMetadata()],
+ "get x => 7;");
+ expect(funct.functionExpression.parameters, isNull);
+ }
+
void test_topLevelOperator_withoutType() {
parse3("parseCompilationUnitMember", <Object>[emptyCommentAndMetadata()],
"operator +(bool x, bool y) => x | y;",
@@ -5434,6 +5448,7 @@ class SimpleParserTest extends ParserTestCase {
expect(method.name, isNotNull);
expect(method.operatorKeyword, isNull);
expect(method.body, isNotNull);
+ expect(method.parameters, isNull);
}
void test_parseClassMember_method_external() {
« 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