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

Side by Side Diff: pkg/analyzer/test/generated/parser_test.dart

Issue 2551533002: Handle generic local functions without a return type (issue 27965) (Closed)
Patch Set: Created 4 years 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 unified diff | Download patch
« no previous file with comments | « pkg/analyzer/lib/src/generated/parser.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library analyzer.test.generated.parser_test; 5 library analyzer.test.generated.parser_test;
6 6
7 import 'package:analyzer/dart/ast/ast.dart'; 7 import 'package:analyzer/dart/ast/ast.dart';
8 import 'package:analyzer/dart/ast/standard_ast_factory.dart'; 8 import 'package:analyzer/dart/ast/standard_ast_factory.dart';
9 import 'package:analyzer/dart/ast/token.dart'; 9 import 'package:analyzer/dart/ast/token.dart';
10 import 'package:analyzer/dart/ast/visitor.dart'; 10 import 'package:analyzer/dart/ast/visitor.dart';
(...skipping 1901 matching lines...) Expand 10 before | Expand all | Expand 10 after
1912 } 1912 }
1913 1913
1914 void test_missingIdentifier_beforeClosingCurly() { 1914 void test_missingIdentifier_beforeClosingCurly() {
1915 createParser('int}'); 1915 createParser('int}');
1916 ClassMember member = parser.parseClassMember('C'); 1916 ClassMember member = parser.parseClassMember('C');
1917 expectNotNullIfNoErrors(member); 1917 expectNotNullIfNoErrors(member);
1918 listener.assertErrorsWithCodes( 1918 listener.assertErrorsWithCodes(
1919 [ParserErrorCode.MISSING_IDENTIFIER, ParserErrorCode.EXPECTED_TOKEN]); 1919 [ParserErrorCode.MISSING_IDENTIFIER, ParserErrorCode.EXPECTED_TOKEN]);
1920 } 1920 }
1921 1921
1922 void test_missingIdentifier_functionDeclaration_returnTypeWithoutName() {
1923 createParser('A<T> () {}');
1924 Statement statement = parser.parseFunctionDeclarationStatement();
1925 expectNotNullIfNoErrors(statement);
1926 listener.assertErrorsWithCodes([ParserErrorCode.MISSING_IDENTIFIER]);
1927 }
1928
1929 void test_missingIdentifier_inEnum() { 1922 void test_missingIdentifier_inEnum() {
1930 createParser('enum E {, TWO}'); 1923 createParser('enum E {, TWO}');
1931 EnumDeclaration declaration = 1924 EnumDeclaration declaration =
1932 parser.parseEnumDeclaration(emptyCommentAndMetadata()); 1925 parser.parseEnumDeclaration(emptyCommentAndMetadata());
1933 expectNotNullIfNoErrors(declaration); 1926 expectNotNullIfNoErrors(declaration);
1934 listener.assertErrorsWithCodes([ParserErrorCode.MISSING_IDENTIFIER]); 1927 listener.assertErrorsWithCodes([ParserErrorCode.MISSING_IDENTIFIER]);
1935 } 1928 }
1936 1929
1937 void test_missingIdentifier_inSymbol_afterPeriod() { 1930 void test_missingIdentifier_inSymbol_afterPeriod() {
1938 createParser('#a.'); 1931 createParser('#a.');
(...skipping 7613 matching lines...) Expand 10 before | Expand all | Expand 10 after
9552 createParser('E f<E>(E p) => p * 2;'); 9545 createParser('E f<E>(E p) => p * 2;');
9553 FunctionDeclarationStatement statement = 9546 FunctionDeclarationStatement statement =
9554 parser.parseFunctionDeclarationStatement(); 9547 parser.parseFunctionDeclarationStatement();
9555 expectNotNullIfNoErrors(statement); 9548 expectNotNullIfNoErrors(statement);
9556 listener.assertNoErrors(); 9549 listener.assertNoErrors();
9557 expect(statement.functionDeclaration, isNotNull); 9550 expect(statement.functionDeclaration, isNotNull);
9558 expect(statement.functionDeclaration.functionExpression.typeParameters, 9551 expect(statement.functionDeclaration.functionExpression.typeParameters,
9559 isNotNull); 9552 isNotNull);
9560 } 9553 }
9561 9554
9555 void test_parseFunctionDeclarationStatement_typeParameters_noReturnType() {
9556 createParser('f<E>(E p) => p * 2;');
9557 FunctionDeclarationStatement statement =
9558 parser.parseFunctionDeclarationStatement();
9559 expectNotNullIfNoErrors(statement);
9560 listener.assertNoErrors();
9561 expect(statement.functionDeclaration, isNotNull);
9562 expect(statement.functionDeclaration.functionExpression.typeParameters,
9563 isNotNull);
9564 }
9565
9562 void test_parseFunctionExpression_body_inExpression() { 9566 void test_parseFunctionExpression_body_inExpression() {
9563 createParser('(int i) => i++'); 9567 createParser('(int i) => i++');
9564 FunctionExpression expression = parser.parseFunctionExpression(); 9568 FunctionExpression expression = parser.parseFunctionExpression();
9565 expectNotNullIfNoErrors(expression); 9569 expectNotNullIfNoErrors(expression);
9566 listener.assertNoErrors(); 9570 listener.assertNoErrors();
9567 expect(expression.body, isNotNull); 9571 expect(expression.body, isNotNull);
9568 expect(expression.typeParameters, isNull); 9572 expect(expression.typeParameters, isNull);
9569 expect(expression.parameters, isNotNull); 9573 expect(expression.parameters, isNotNull);
9570 expect((expression.body as ExpressionFunctionBody).semicolon, isNull); 9574 expect((expression.body as ExpressionFunctionBody).semicolon, isNull);
9571 } 9575 }
(...skipping 2288 matching lines...) Expand 10 before | Expand all | Expand 10 after
11860 Statement statement = parser.parseStatement2(); 11864 Statement statement = parser.parseStatement2();
11861 expectNotNullIfNoErrors(statement); 11865 expectNotNullIfNoErrors(statement);
11862 listener.assertNoErrors(); 11866 listener.assertNoErrors();
11863 expect(statement, new isInstanceOf<FunctionDeclarationStatement>()); 11867 expect(statement, new isInstanceOf<FunctionDeclarationStatement>());
11864 FunctionDeclarationStatement declaration = statement; 11868 FunctionDeclarationStatement declaration = statement;
11865 expect(declaration.functionDeclaration, isNotNull); 11869 expect(declaration.functionDeclaration, isNotNull);
11866 expect(declaration.functionDeclaration.functionExpression.typeParameters, 11870 expect(declaration.functionDeclaration.functionExpression.typeParameters,
11867 isNotNull); 11871 isNotNull);
11868 } 11872 }
11869 11873
11870 @failingTest
11871 void test_parseStatement_functionDeclaration_noReturnType_typeParameters() { 11874 void test_parseStatement_functionDeclaration_noReturnType_typeParameters() {
11872 createParser('f<E>(a, b) {};'); 11875 createParser('f<E>(a, b) {};');
11873 Statement statement = parser.parseStatement2(); 11876 Statement statement = parser.parseStatement2();
11874 expectNotNullIfNoErrors(statement); 11877 expectNotNullIfNoErrors(statement);
11875 listener.assertNoErrors(); 11878 listener.assertNoErrors();
11876 expect(statement, new isInstanceOf<FunctionDeclarationStatement>()); 11879 expect(statement, new isInstanceOf<FunctionDeclarationStatement>());
11877 FunctionDeclarationStatement declaration = statement; 11880 FunctionDeclarationStatement declaration = statement;
11878 expect(declaration.functionDeclaration, isNotNull); 11881 expect(declaration.functionDeclaration, isNotNull);
11879 } 11882 }
11880 11883
(...skipping 1577 matching lines...) Expand 10 before | Expand all | Expand 10 after
13458 CompilationUnit _parseDirectives(String source, 13461 CompilationUnit _parseDirectives(String source,
13459 [List<ErrorCode> errorCodes = const <ErrorCode>[]]) { 13462 [List<ErrorCode> errorCodes = const <ErrorCode>[]]) {
13460 createParser(source); 13463 createParser(source);
13461 CompilationUnit unit = parser.parseDirectives2(); 13464 CompilationUnit unit = parser.parseDirectives2();
13462 expect(unit, isNotNull); 13465 expect(unit, isNotNull);
13463 expect(unit.declarations, hasLength(0)); 13466 expect(unit.declarations, hasLength(0));
13464 listener.assertErrorsWithCodes(errorCodes); 13467 listener.assertErrorsWithCodes(errorCodes);
13465 return unit; 13468 return unit;
13466 } 13469 }
13467 } 13470 }
OLDNEW
« 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