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 1100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1111 ConstructorDeclaration constructor = member as ConstructorDeclaration; | 1111 ConstructorDeclaration constructor = member as ConstructorDeclaration; |
1112 NodeList<ConstructorInitializer> initializers = constructor.initializers; | 1112 NodeList<ConstructorInitializer> initializers = constructor.initializers; |
1113 expect(initializers, hasLength(3)); | 1113 expect(initializers, hasLength(3)); |
1114 ConstructorInitializer initializer = initializers[1]; | 1114 ConstructorInitializer initializer = initializers[1]; |
1115 expect(initializer, new isInstanceOf<AssertInitializer>()); | 1115 expect(initializer, new isInstanceOf<AssertInitializer>()); |
1116 AssertInitializer assertInitializer = initializer; | 1116 AssertInitializer assertInitializer = initializer; |
1117 expect(assertInitializer.condition, isNotNull); | 1117 expect(assertInitializer.condition, isNotNull); |
1118 expect(assertInitializer.message, isNull); | 1118 expect(assertInitializer.message, isNull); |
1119 } | 1119 } |
1120 | 1120 |
| 1121 void test_parseConstructor_factory_named() { |
| 1122 createParser('factory C.foo() => null;'); |
| 1123 var constructor = parser.parseClassMember('C') as ConstructorDeclaration; |
| 1124 assertNoErrors(); |
| 1125 expect(constructor, isNotNull); |
| 1126 expect(constructor.externalKeyword, isNull); |
| 1127 expect(constructor.constKeyword, isNull); |
| 1128 expect(constructor.factoryKeyword, isNotNull); |
| 1129 expect(constructor.returnType.name, 'C'); |
| 1130 _assertIsDeclarationName(constructor.returnType, false); |
| 1131 expect(constructor.period.type, TokenType.PERIOD); |
| 1132 expect(constructor.name.name, 'foo'); |
| 1133 _assertIsDeclarationName(constructor.name); |
| 1134 expect(constructor.parameters, isNotNull); |
| 1135 expect(constructor.parameters.parameters, isEmpty); |
| 1136 expect(constructor.separator, isNull); |
| 1137 expect(constructor.initializers, isEmpty); |
| 1138 expect(constructor.redirectedConstructor, isNull); |
| 1139 expect(constructor.body, new isInstanceOf<ExpressionFunctionBody>()); |
| 1140 } |
| 1141 |
1121 void test_parseConstructor_initializers_field() { | 1142 void test_parseConstructor_initializers_field() { |
1122 createParser('C(x, y) : _x = x, this._y = y;'); | 1143 createParser('C(x, y) : _x = x, this._y = y;'); |
1123 ClassMember member = parser.parseClassMember('C'); | 1144 ClassMember member = parser.parseClassMember('C'); |
1124 expect(member, isNotNull); | 1145 expect(member, isNotNull); |
1125 assertNoErrors(); | 1146 assertNoErrors(); |
1126 expect(member, new isInstanceOf<ConstructorDeclaration>()); | 1147 expect(member, new isInstanceOf<ConstructorDeclaration>()); |
1127 ConstructorDeclaration constructor = member as ConstructorDeclaration; | 1148 ConstructorDeclaration constructor = member as ConstructorDeclaration; |
1128 NodeList<ConstructorInitializer> initializers = constructor.initializers; | 1149 NodeList<ConstructorInitializer> initializers = constructor.initializers; |
1129 expect(initializers, hasLength(2)); | 1150 expect(initializers, hasLength(2)); |
1130 | 1151 |
(...skipping 13598 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14729 expectCommentText(typeVariable.documentationComment, '/// Doc'); | 14750 expectCommentText(typeVariable.documentationComment, '/// Doc'); |
14730 } | 14751 } |
14731 | 14752 |
14732 /** | 14753 /** |
14733 * Assert that the given [name] is in declaration context. | 14754 * Assert that the given [name] is in declaration context. |
14734 */ | 14755 */ |
14735 void _assertIsDeclarationName(SimpleIdentifier name) { | 14756 void _assertIsDeclarationName(SimpleIdentifier name) { |
14736 expect(name.inDeclarationContext(), isTrue); | 14757 expect(name.inDeclarationContext(), isTrue); |
14737 } | 14758 } |
14738 } | 14759 } |
OLD | NEW |