fasta parser tests for 33647
The fasta parser correctly handles the code specified in
https://github.com/dart-lang/sdk/issues/33647
Change-Id: I690311ce031e458dc9c5ea978c954ba7a4b60262
Reviewed-on: https://dart-review.googlesource.com/64200
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Dan Rubel <danrubel@google.com>
diff --git a/pkg/analyzer/test/generated/parser_test.dart b/pkg/analyzer/test/generated/parser_test.dart
index f0062c5..26af58d 100644
--- a/pkg/analyzer/test/generated/parser_test.dart
+++ b/pkg/analyzer/test/generated/parser_test.dart
@@ -14223,6 +14223,37 @@
expect(creation.typeArguments.toSource(), '<int, int Function(String)>');
}
+ void test_parseInstanceCreation_keyword_33647() {
+ enableOptionalNewAndConst = true;
+ CompilationUnit unit = parseCompilationUnit('''
+var c = new Future<int>.sync(() => 3).then<int>((e) => e);
+''');
+ expect(unit, isNotNull);
+ TopLevelVariableDeclaration v = unit.declarations[0];
+ MethodInvocation init = v.variables.variables[0].initializer;
+ expect(init.methodName.name, 'then');
+ NodeList<TypeAnnotation> typeArg = init.typeArguments.arguments;
+ expect(typeArg, hasLength(1));
+ expect(typeArg[0].beginToken.lexeme, 'int');
+ }
+
+ void test_parseInstanceCreation_noKeyword_33647() {
+ enableOptionalNewAndConst = true;
+ // Old parser produces errors
+ if (usingFastaParser) {
+ CompilationUnit unit = parseCompilationUnit('''
+var c = Future<int>.sync(() => 3).then<int>((e) => e);
+''');
+ expect(unit, isNotNull);
+ TopLevelVariableDeclaration v = unit.declarations[0];
+ MethodInvocation init = v.variables.variables[0].initializer;
+ expect(init.methodName.name, 'then');
+ NodeList<TypeAnnotation> typeArg = init.typeArguments.arguments;
+ expect(typeArg, hasLength(1));
+ expect(typeArg[0].beginToken.lexeme, 'int');
+ }
+ }
+
void test_parseLibraryIdentifier_builtin() {
String name = "deferred";
LibraryIdentifier identifier = parseLibraryIdentifier(name);