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 members_test; | 5 library members_test; |
6 | 6 |
7 import 'package:expect/expect.dart'; | 7 import 'package:expect/expect.dart'; |
8 import "package:async_helper/async_helper.dart"; | 8 import "package:async_helper/async_helper.dart"; |
9 import 'type_test_helper.dart'; | 9 import 'type_test_helper.dart'; |
10 import 'package:compiler/src/elements/resolution_types.dart'; | 10 import 'package:compiler/src/elements/resolution_types.dart'; |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 int count = 0; | 156 int count = 0; |
157 if (interfaceMembers) { | 157 if (interfaceMembers) { |
158 cls.element.forEachInterfaceMember((_) => count++); | 158 cls.element.forEachInterfaceMember((_) => count++); |
159 } else { | 159 } else { |
160 cls.element.forEachClassMember((_) => count++); | 160 cls.element.forEachClassMember((_) => count++); |
161 } | 161 } |
162 Expect.equals(expectedCount, count); | 162 Expect.equals(expectedCount, count); |
163 } | 163 } |
164 | 164 |
165 void testClassMembers() { | 165 void testClassMembers() { |
166 asyncTest(() => TypeEnvironment | 166 asyncTest(() => TypeEnvironment.create(r""" |
167 .create( | |
168 r""" | |
169 abstract class A { | 167 abstract class A { |
170 int field; | 168 int field; |
171 final finalField = 0; | 169 final finalField = 0; |
172 static var staticField; | 170 static var staticField; |
173 | 171 |
174 int get getter => 0; | 172 int get getter => 0; |
175 get abstractGetter; | 173 get abstractGetter; |
176 void set setter(int _) {} | 174 void set setter(int _) {} |
177 set abstractSetter(_); | 175 set abstractSetter(_); |
178 | 176 |
179 method() {} | 177 method() {} |
180 abstractMethod(); | 178 abstractMethod(); |
181 static staticMethod() {} | 179 static staticMethod() {} |
182 } | 180 } |
183 class B<T> { | 181 class B<T> { |
184 T field; | 182 T field; |
185 void method(T t) {} | 183 void method(T t) {} |
186 static staticMethod() {} | 184 static staticMethod() {} |
187 toString([T t]) {} | 185 toString([T t]) {} |
188 } | 186 } |
189 class C<S> extends B<S> {} | 187 class C<S> extends B<S> {} |
190 class D extends C<int> {} | 188 class D extends C<int> {} |
191 class E extends D {} | 189 class E extends D {} |
192 """, | 190 """, useMockCompiler: false).then((env) { |
193 useMockCompiler: false) | |
194 .then((env) { | |
195 ResolutionInterfaceType bool_ = env['bool']; | 191 ResolutionInterfaceType bool_ = env['bool']; |
196 ResolutionInterfaceType String_ = env['String']; | 192 ResolutionInterfaceType String_ = env['String']; |
197 ResolutionInterfaceType int_ = env['int']; | 193 ResolutionInterfaceType int_ = env['int']; |
198 ResolutionDynamicType dynamic_ = env['dynamic']; | 194 ResolutionDynamicType dynamic_ = env['dynamic']; |
199 ResolutionVoidType void_ = env['void']; | 195 ResolutionVoidType void_ = env['void']; |
200 ResolutionInterfaceType Type_ = env['Type']; | 196 ResolutionInterfaceType Type_ = env['Type']; |
201 ResolutionInterfaceType Invocation_ = env['Invocation']; | 197 ResolutionInterfaceType Invocation_ = env['Invocation']; |
202 | 198 |
203 ResolutionInterfaceType Object_ = env['Object']; | 199 ResolutionInterfaceType Object_ = env['Object']; |
204 checkMemberCount(Object_, 5 /*declared*/, interfaceMembers: true); | 200 checkMemberCount(Object_, 5 /*declared*/, interfaceMembers: true); |
(...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
746 | 742 |
747 // Ensure that members have been computed on all classes. | 743 // Ensure that members have been computed on all classes. |
748 MembersCreator.computeAllClassMembers(env.resolution, C.element); | 744 MembersCreator.computeAllClassMembers(env.resolution, C.element); |
749 | 745 |
750 checkMember(C, 'm', | 746 checkMember(C, 'm', |
751 checkType: NO_CLASS_MEMBER, | 747 checkType: NO_CLASS_MEMBER, |
752 inheritedFrom: A, | 748 inheritedFrom: A, |
753 functionType: env.functionType(dynamic_, [])); | 749 functionType: env.functionType(dynamic_, [])); |
754 })); | 750 })); |
755 } | 751 } |
OLD | NEW |