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