OLD | NEW |
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 10022 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10033 | 10033 |
10034 void test_parseArgumentList_trailing_comma() { | 10034 void test_parseArgumentList_trailing_comma() { |
10035 createParser('(x, y, z,)'); | 10035 createParser('(x, y, z,)'); |
10036 ArgumentList argumentList = parser.parseArgumentList(); | 10036 ArgumentList argumentList = parser.parseArgumentList(); |
10037 expectNotNullIfNoErrors(argumentList); | 10037 expectNotNullIfNoErrors(argumentList); |
10038 listener.assertNoErrors(); | 10038 listener.assertNoErrors(); |
10039 NodeList<Expression> arguments = argumentList.arguments; | 10039 NodeList<Expression> arguments = argumentList.arguments; |
10040 expect(arguments, hasLength(3)); | 10040 expect(arguments, hasLength(3)); |
10041 } | 10041 } |
10042 | 10042 |
| 10043 void test_parseClassMember_method_gftReturnType() { |
| 10044 createParser(''' |
| 10045 void Function<A>(core.List<core.int> x) m() => null; |
| 10046 '''); |
| 10047 ClassMember member = parser.parseClassMember('C'); |
| 10048 expect(member, new isInstanceOf<MethodDeclaration>()); |
| 10049 expect((member as MethodDeclaration).body, |
| 10050 new isInstanceOf<ExpressionFunctionBody>()); |
| 10051 } |
| 10052 |
| 10053 void test_parseClassMember_method_noReturnType() { |
| 10054 createParser(''' |
| 10055 Function<A>(core.List<core.int> x) m() => null; |
| 10056 '''); |
| 10057 ClassMember member = parser.parseClassMember('C'); |
| 10058 expect(member, new isInstanceOf<MethodDeclaration>()); |
| 10059 expect((member as MethodDeclaration).body, |
| 10060 new isInstanceOf<ExpressionFunctionBody>()); |
| 10061 } |
| 10062 |
10043 void test_parseCombinator_hide() { | 10063 void test_parseCombinator_hide() { |
10044 createParser('hide a;'); | 10064 createParser('hide a;'); |
10045 Combinator combinator = parser.parseCombinator(); | 10065 Combinator combinator = parser.parseCombinator(); |
10046 expectNotNullIfNoErrors(combinator); | 10066 expectNotNullIfNoErrors(combinator); |
10047 listener.assertNoErrors(); | 10067 listener.assertNoErrors(); |
10048 expect(combinator, new isInstanceOf<HideCombinator>()); | 10068 expect(combinator, new isInstanceOf<HideCombinator>()); |
10049 HideCombinator hideCombinator = combinator; | 10069 HideCombinator hideCombinator = combinator; |
10050 expect(hideCombinator.keyword, isNotNull); | 10070 expect(hideCombinator.keyword, isNotNull); |
10051 expect(hideCombinator.hiddenNames, hasLength(1)); | 10071 expect(hideCombinator.hiddenNames, hasLength(1)); |
10052 } | 10072 } |
(...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10633 List<CommentReference> references = parser.parseCommentReferences(tokens); | 10653 List<CommentReference> references = parser.parseCommentReferences(tokens); |
10634 expectNotNullIfNoErrors(references); | 10654 expectNotNullIfNoErrors(references); |
10635 listener.assertNoErrors(); | 10655 listener.assertNoErrors(); |
10636 expect(references, hasLength(1)); | 10656 expect(references, hasLength(1)); |
10637 CommentReference reference = references[0]; | 10657 CommentReference reference = references[0]; |
10638 expect(reference, isNotNull); | 10658 expect(reference, isNotNull); |
10639 expect(reference.identifier, isNotNull); | 10659 expect(reference.identifier, isNotNull); |
10640 expect(reference.offset, 15); | 10660 expect(reference.offset, 15); |
10641 } | 10661 } |
10642 | 10662 |
| 10663 void test_parseCompilationUnitMember_function_gftReturnType() { |
| 10664 createParser(''' |
| 10665 void Function<A>(core.List<core.int> x) f() => null; |
| 10666 '''); |
| 10667 CompilationUnit unit = parser.parseCompilationUnit2(); |
| 10668 expect(unit, isNotNull); |
| 10669 expect(unit.declarations, hasLength(1)); |
| 10670 } |
| 10671 |
| 10672 void test_parseCompilationUnitMember_function_noReturnType() { |
| 10673 createParser(''' |
| 10674 Function<A>(core.List<core.int> x) f() => null; |
| 10675 '''); |
| 10676 CompilationUnit unit = parser.parseCompilationUnit2(); |
| 10677 expect(unit, isNotNull); |
| 10678 expect(unit.declarations, hasLength(1)); |
| 10679 } |
| 10680 |
10643 void test_parseConfiguration_noOperator_dottedIdentifier() { | 10681 void test_parseConfiguration_noOperator_dottedIdentifier() { |
10644 createParser("if (a.b) 'c.dart'"); | 10682 createParser("if (a.b) 'c.dart'"); |
10645 Configuration configuration = parser.parseConfiguration(); | 10683 Configuration configuration = parser.parseConfiguration(); |
10646 expectNotNullIfNoErrors(configuration); | 10684 expectNotNullIfNoErrors(configuration); |
10647 listener.assertNoErrors(); | 10685 listener.assertNoErrors(); |
10648 expect(configuration.ifKeyword, isNotNull); | 10686 expect(configuration.ifKeyword, isNotNull); |
10649 expect(configuration.leftParenthesis, isNotNull); | 10687 expect(configuration.leftParenthesis, isNotNull); |
10650 expectDottedName(configuration.name, ["a", "b"]); | 10688 expectDottedName(configuration.name, ["a", "b"]); |
10651 expect(configuration.equalToken, isNull); | 10689 expect(configuration.equalToken, isNull); |
10652 expect(configuration.value, isNull); | 10690 expect(configuration.value, isNull); |
(...skipping 643 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11296 | 11334 |
11297 void test_parseReturnType_void() { | 11335 void test_parseReturnType_void() { |
11298 createParser('void'); | 11336 createParser('void'); |
11299 TypeName typeName = parser.parseReturnType(false); | 11337 TypeName typeName = parser.parseReturnType(false); |
11300 expectNotNullIfNoErrors(typeName); | 11338 expectNotNullIfNoErrors(typeName); |
11301 listener.assertNoErrors(); | 11339 listener.assertNoErrors(); |
11302 expect(typeName.name, isNotNull); | 11340 expect(typeName.name, isNotNull); |
11303 expect(typeName.typeArguments, isNull); | 11341 expect(typeName.typeArguments, isNull); |
11304 } | 11342 } |
11305 | 11343 |
| 11344 void test_parseStatement_function_gftReturnType() { |
| 11345 createParser(''' |
| 11346 void Function<A>(core.List<core.int> x) m() => null; |
| 11347 '''); |
| 11348 Statement statement = parser.parseStatement2(); |
| 11349 expect(statement, new isInstanceOf<FunctionDeclarationStatement>()); |
| 11350 expect( |
| 11351 (statement as FunctionDeclarationStatement) |
| 11352 .functionDeclaration |
| 11353 .functionExpression |
| 11354 .body, |
| 11355 new isInstanceOf<ExpressionFunctionBody>()); |
| 11356 } |
| 11357 |
| 11358 void test_parseStatement_function_noReturnType() { |
| 11359 createParser(''' |
| 11360 Function<A>(core.List<core.int> x) m() => null; |
| 11361 '''); |
| 11362 Statement statement = parser.parseStatement2(); |
| 11363 expect(statement, new isInstanceOf<FunctionDeclarationStatement>()); |
| 11364 expect( |
| 11365 (statement as FunctionDeclarationStatement) |
| 11366 .functionDeclaration |
| 11367 .functionExpression |
| 11368 .body, |
| 11369 new isInstanceOf<ExpressionFunctionBody>()); |
| 11370 } |
| 11371 |
11306 void test_parseStatements_multiple() { | 11372 void test_parseStatements_multiple() { |
11307 List<Statement> statements = parseStatements("return; return;", 2); | 11373 List<Statement> statements = parseStatements("return; return;", 2); |
11308 expect(statements, hasLength(2)); | 11374 expect(statements, hasLength(2)); |
11309 } | 11375 } |
11310 | 11376 |
11311 void test_parseStatements_single() { | 11377 void test_parseStatements_single() { |
11312 List<Statement> statements = parseStatements("return;", 1); | 11378 List<Statement> statements = parseStatements("return;", 1); |
11313 expect(statements, hasLength(1)); | 11379 expect(statements, hasLength(1)); |
11314 } | 11380 } |
11315 | 11381 |
(...skipping 3434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14750 expectCommentText(typeVariable.documentationComment, '/// Doc'); | 14816 expectCommentText(typeVariable.documentationComment, '/// Doc'); |
14751 } | 14817 } |
14752 | 14818 |
14753 /** | 14819 /** |
14754 * Assert that the given [name] is in declaration context. | 14820 * Assert that the given [name] is in declaration context. |
14755 */ | 14821 */ |
14756 void _assertIsDeclarationName(SimpleIdentifier name) { | 14822 void _assertIsDeclarationName(SimpleIdentifier name) { |
14757 expect(name.inDeclarationContext(), isTrue); | 14823 expect(name.inDeclarationContext(), isTrue); |
14758 } | 14824 } |
14759 } | 14825 } |
OLD | NEW |