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

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

Issue 1736873002: Improve parser recovery on missing semicolon (issue 25846) (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 years, 10 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 710be9b836ef5c5038ab7409b5f95b6b923ec6ed..26e424c9d0e76dfee4d6507d9f75d2affedac964 100644
--- a/pkg/analyzer/test/generated/parser_test.dart
+++ b/pkg/analyzer/test/generated/parser_test.dart
@@ -4016,6 +4016,33 @@ class C {
expect(metadata[0].name.name, "override");
}
+ void test_missingSemicolon_varialeDeclarationList() {
+ void verify(CompilationUnitMember member, String expectedTypeName,
+ String expectedName, String expectedSemicolon) {
+ expect(member, new isInstanceOf<TopLevelVariableDeclaration>());
+ TopLevelVariableDeclaration declaration = member;
+ VariableDeclarationList variableList = declaration.variables;
+ expect(variableList, isNotNull);
+ NodeList<VariableDeclaration> variables = variableList.variables;
+ expect(variables, hasLength(1));
+ VariableDeclaration variable = variables[0];
+ expect(variableList.type.toString(), expectedTypeName);
+ expect(variable.name.name, expectedName);
+ expect(declaration.semicolon.lexeme, expectedSemicolon);
+ }
+
+ CompilationUnit unit = ParserTestCase.parseCompilationUnit(
+ 'String n x = "";', [
+ ParserErrorCode.EXPECTED_TOKEN,
+ ParserErrorCode.MISSING_CONST_FINAL_VAR_OR_TYPE
+ ]);
+ expect(unit, isNotNull);
+ NodeList<CompilationUnitMember> declarations = unit.declarations;
+ expect(declarations, hasLength(2));
+ verify(declarations[0], 'String', 'n', '');
+ verify(declarations[1], 'null', 'x', ';');
+ }
+
void test_multiplicativeExpression_missing_LHS() {
BinaryExpression expression =
parseExpression("* y", [ParserErrorCode.MISSING_IDENTIFIER]);
« 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