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.src.dart.element.element_test; | 5 library analyzer.test.src.dart.element.element_test; |
6 | 6 |
7 import 'package:analyzer/dart/ast/ast.dart'; | 7 import 'package:analyzer/dart/ast/ast.dart'; |
8 import 'package:analyzer/dart/constant/value.dart'; | 8 import 'package:analyzer/dart/constant/value.dart'; |
9 import 'package:analyzer/dart/element/element.dart'; | 9 import 'package:analyzer/dart/element/element.dart'; |
10 import 'package:analyzer/dart/element/type.dart'; | 10 import 'package:analyzer/dart/element/type.dart'; |
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 classA.accessors = <PropertyAccessorElement>[getter]; | 275 classA.accessors = <PropertyAccessorElement>[getter]; |
276 expect(classA.hasStaticMember, isFalse); | 276 expect(classA.hasStaticMember, isFalse); |
277 } | 277 } |
278 | 278 |
279 void test_hasStaticMember_true_getter() { | 279 void test_hasStaticMember_true_getter() { |
280 ClassElementImpl classA = ElementFactory.classElement2("A"); | 280 ClassElementImpl classA = ElementFactory.classElement2("A"); |
281 PropertyAccessorElementImpl getter = | 281 PropertyAccessorElementImpl getter = |
282 ElementFactory.getterElement("foo", false, null); | 282 ElementFactory.getterElement("foo", false, null); |
283 classA.accessors = <PropertyAccessorElement>[getter]; | 283 classA.accessors = <PropertyAccessorElement>[getter]; |
284 // "foo" is static | 284 // "foo" is static |
285 getter.static = true; | 285 getter.isStatic = true; |
286 expect(classA.hasStaticMember, isTrue); | 286 expect(classA.hasStaticMember, isTrue); |
287 } | 287 } |
288 | 288 |
289 void test_hasStaticMember_true_method() { | 289 void test_hasStaticMember_true_method() { |
290 ClassElementImpl classA = ElementFactory.classElement2("A"); | 290 ClassElementImpl classA = ElementFactory.classElement2("A"); |
291 MethodElementImpl method = ElementFactory.methodElement("foo", null); | 291 MethodElementImpl method = ElementFactory.methodElement("foo", null); |
292 classA.methods = <MethodElement>[method]; | 292 classA.methods = <MethodElement>[method]; |
293 // "foo" is static | 293 // "foo" is static |
294 method.static = true; | 294 method.isStatic = true; |
295 expect(classA.hasStaticMember, isTrue); | 295 expect(classA.hasStaticMember, isTrue); |
296 } | 296 } |
297 | 297 |
298 void test_hasStaticMember_true_setter() { | 298 void test_hasStaticMember_true_setter() { |
299 ClassElementImpl classA = ElementFactory.classElement2("A"); | 299 ClassElementImpl classA = ElementFactory.classElement2("A"); |
300 PropertyAccessorElementImpl setter = | 300 PropertyAccessorElementImpl setter = |
301 ElementFactory.setterElement("foo", false, null); | 301 ElementFactory.setterElement("foo", false, null); |
302 classA.accessors = <PropertyAccessorElement>[setter]; | 302 classA.accessors = <PropertyAccessorElement>[setter]; |
303 // "foo" is static | 303 // "foo" is static |
304 setter.static = true; | 304 setter.isStatic = true; |
305 expect(classA.hasStaticMember, isTrue); | 305 expect(classA.hasStaticMember, isTrue); |
306 } | 306 } |
307 | 307 |
308 void test_isEnum() { | 308 void test_isEnum() { |
309 String firstConst = "A"; | 309 String firstConst = "A"; |
310 String secondConst = "B"; | 310 String secondConst = "B"; |
311 EnumElementImpl enumE = ElementFactory | 311 EnumElementImpl enumE = ElementFactory |
312 .enumElement(new TestTypeProvider(), "E", [firstConst, secondConst]); | 312 .enumElement(new TestTypeProvider(), "E", [firstConst, secondConst]); |
313 | 313 |
314 // E is an enum | 314 // E is an enum |
(...skipping 1620 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1935 expect(type.newPrune, isNull); | 1935 expect(type.newPrune, isNull); |
1936 } | 1936 } |
1937 | 1937 |
1938 void test_newPrune_synthetic_typedef() { | 1938 void test_newPrune_synthetic_typedef() { |
1939 // No pruning needs to be done for function types that are associated with | 1939 // No pruning needs to be done for function types that are associated with |
1940 // synthetic typedefs because those types are only created for | 1940 // synthetic typedefs because those types are only created for |
1941 // function-typed formal parameters, which can't be directly referred to by | 1941 // function-typed formal parameters, which can't be directly referred to by |
1942 // the user (and hence can't participate in circularities). | 1942 // the user (and hence can't participate in circularities). |
1943 FunctionTypeAliasElementImpl f = | 1943 FunctionTypeAliasElementImpl f = |
1944 ElementFactory.functionTypeAliasElement('f'); | 1944 ElementFactory.functionTypeAliasElement('f'); |
1945 f.synthetic = true; | 1945 f.isSynthetic = true; |
1946 FunctionTypeImpl type = f.type; | 1946 FunctionTypeImpl type = f.type; |
1947 expect(type.newPrune, isNull); | 1947 expect(type.newPrune, isNull); |
1948 } | 1948 } |
1949 | 1949 |
1950 void test_newPrune_with_previous_prune() { | 1950 void test_newPrune_with_previous_prune() { |
1951 FunctionTypeAliasElementImpl f = | 1951 FunctionTypeAliasElementImpl f = |
1952 ElementFactory.functionTypeAliasElement('f'); | 1952 ElementFactory.functionTypeAliasElement('f'); |
1953 FunctionTypeAliasElementImpl g = | 1953 FunctionTypeAliasElementImpl g = |
1954 ElementFactory.functionTypeAliasElement('g'); | 1954 ElementFactory.functionTypeAliasElement('g'); |
1955 FunctionTypeImpl type = f.type; | 1955 FunctionTypeImpl type = f.type; |
(...skipping 2488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4444 } | 4444 } |
4445 | 4445 |
4446 class _FunctionTypeImplTest_isSubtypeOf_baseCase_classFunction | 4446 class _FunctionTypeImplTest_isSubtypeOf_baseCase_classFunction |
4447 extends InterfaceTypeImpl { | 4447 extends InterfaceTypeImpl { |
4448 _FunctionTypeImplTest_isSubtypeOf_baseCase_classFunction(ClassElement arg0) | 4448 _FunctionTypeImplTest_isSubtypeOf_baseCase_classFunction(ClassElement arg0) |
4449 : super(arg0); | 4449 : super(arg0); |
4450 | 4450 |
4451 @override | 4451 @override |
4452 bool get isDartCoreFunction => true; | 4452 bool get isDartCoreFunction => true; |
4453 } | 4453 } |
OLD | NEW |