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_field_gftType_gftReturnType() { |
| 10044 createParser(''' |
| 10045 Function(int) Function(String) v; |
| 10046 '''); |
| 10047 ClassMember member = parser.parseClassMember('C'); |
| 10048 listener.assertNoErrors(); |
| 10049 expect(member, new isInstanceOf<FieldDeclaration>()); |
| 10050 VariableDeclarationList fields = (member as FieldDeclaration).fields; |
| 10051 expect(fields.type, new isInstanceOf<GenericFunctionType>()); |
| 10052 } |
| 10053 |
10043 void test_parseClassMember_field_gftType_noReturnType() { | 10054 void test_parseClassMember_field_gftType_noReturnType() { |
10044 createParser(''' | 10055 createParser(''' |
10045 Function(int, String) v; | 10056 Function(int, String) v; |
10046 '''); | 10057 '''); |
10047 ClassMember member = parser.parseClassMember('C'); | 10058 ClassMember member = parser.parseClassMember('C'); |
10048 listener.assertNoErrors(); | 10059 listener.assertNoErrors(); |
10049 expect(member, new isInstanceOf<FieldDeclaration>()); | 10060 expect(member, new isInstanceOf<FieldDeclaration>()); |
10050 VariableDeclarationList fields = (member as FieldDeclaration).fields; | 10061 VariableDeclarationList fields = (member as FieldDeclaration).fields; |
10051 expect(fields.type, new isInstanceOf<GenericFunctionType>()); | 10062 expect(fields.type, new isInstanceOf<GenericFunctionType>()); |
10052 } | 10063 } |
(...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10686 void test_parseCompilationUnitMember_function_noReturnType() { | 10697 void test_parseCompilationUnitMember_function_noReturnType() { |
10687 createParser(''' | 10698 createParser(''' |
10688 Function<A>(core.List<core.int> x) f() => null; | 10699 Function<A>(core.List<core.int> x) f() => null; |
10689 '''); | 10700 '''); |
10690 CompilationUnit unit = parser.parseCompilationUnit2(); | 10701 CompilationUnit unit = parser.parseCompilationUnit2(); |
10691 listener.assertNoErrors(); | 10702 listener.assertNoErrors(); |
10692 expect(unit, isNotNull); | 10703 expect(unit, isNotNull); |
10693 expect(unit.declarations, hasLength(1)); | 10704 expect(unit.declarations, hasLength(1)); |
10694 } | 10705 } |
10695 | 10706 |
| 10707 void test_parseCompilationUnitMember_variable_gftType_gftReturnType() { |
| 10708 createParser(''' |
| 10709 Function(int) Function(String) v; |
| 10710 '''); |
| 10711 CompilationUnit unit = parser.parseCompilationUnit2(); |
| 10712 listener.assertNoErrors(); |
| 10713 expect(unit, isNotNull); |
| 10714 expect(unit.declarations, hasLength(1)); |
| 10715 TopLevelVariableDeclaration declaration = |
| 10716 unit.declarations[0] as TopLevelVariableDeclaration; |
| 10717 expect(declaration.variables.type, new isInstanceOf<GenericFunctionType>()); |
| 10718 } |
| 10719 |
10696 void test_parseCompilationUnitMember_variable_gftType_noReturnType() { | 10720 void test_parseCompilationUnitMember_variable_gftType_noReturnType() { |
10697 createParser(''' | 10721 createParser(''' |
10698 Function(int, String) v; | 10722 Function(int, String) v; |
10699 '''); | 10723 '''); |
10700 CompilationUnit unit = parser.parseCompilationUnit2(); | 10724 CompilationUnit unit = parser.parseCompilationUnit2(); |
10701 listener.assertNoErrors(); | 10725 listener.assertNoErrors(); |
10702 expect(unit, isNotNull); | 10726 expect(unit, isNotNull); |
10703 expect(unit.declarations, hasLength(1)); | 10727 expect(unit.declarations, hasLength(1)); |
10704 } | 10728 } |
10705 | 10729 |
(...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11318 } | 11342 } |
11319 | 11343 |
11320 void test_parseNonLabeledStatement_variableDeclaration_gftType() { | 11344 void test_parseNonLabeledStatement_variableDeclaration_gftType() { |
11321 createParser('int Function(int) v;'); | 11345 createParser('int Function(int) v;'); |
11322 Statement statement = parser.parseNonLabeledStatement(); | 11346 Statement statement = parser.parseNonLabeledStatement(); |
11323 expectNotNullIfNoErrors(statement); | 11347 expectNotNullIfNoErrors(statement); |
11324 listener.assertNoErrors(); | 11348 listener.assertNoErrors(); |
11325 } | 11349 } |
11326 | 11350 |
11327 void | 11351 void |
| 11352 test_parseNonLabeledStatement_variableDeclaration_gftType_gftReturnType()
{ |
| 11353 createParser('Function(int) Function(int) v;'); |
| 11354 Statement statement = parser.parseNonLabeledStatement(); |
| 11355 expectNotNullIfNoErrors(statement); |
| 11356 listener.assertNoErrors(); |
| 11357 } |
| 11358 |
| 11359 void |
11328 test_parseNonLabeledStatement_variableDeclaration_gftType_noReturnType() { | 11360 test_parseNonLabeledStatement_variableDeclaration_gftType_noReturnType() { |
11329 createParser('Function(int) v;'); | 11361 createParser('Function(int) v;'); |
11330 Statement statement = parser.parseNonLabeledStatement(); | 11362 Statement statement = parser.parseNonLabeledStatement(); |
11331 expectNotNullIfNoErrors(statement); | 11363 expectNotNullIfNoErrors(statement); |
11332 listener.assertNoErrors(); | 11364 listener.assertNoErrors(); |
11333 } | 11365 } |
11334 | 11366 |
11335 void test_parseOptionalReturnType() { | 11367 void test_parseOptionalReturnType() { |
11336 // TODO(brianwilkerson) Implement tests for this method. | 11368 // TODO(brianwilkerson) Implement tests for this method. |
11337 } | 11369 } |
(...skipping 3525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14863 expectCommentText(typeVariable.documentationComment, '/// Doc'); | 14895 expectCommentText(typeVariable.documentationComment, '/// Doc'); |
14864 } | 14896 } |
14865 | 14897 |
14866 /** | 14898 /** |
14867 * Assert that the given [name] is in declaration context. | 14899 * Assert that the given [name] is in declaration context. |
14868 */ | 14900 */ |
14869 void _assertIsDeclarationName(SimpleIdentifier name) { | 14901 void _assertIsDeclarationName(SimpleIdentifier name) { |
14870 expect(name.inDeclarationContext(), isTrue); | 14902 expect(name.inDeclarationContext(), isTrue); |
14871 } | 14903 } |
14872 } | 14904 } |
OLD | NEW |