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 1305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1316 } | 1316 } |
1317 // B | 1317 // B |
1318 { | 1318 { |
1319 FieldElement elementB = unitElement.getEnum("B").getField('B2'); | 1319 FieldElement elementB = unitElement.getEnum("B").getField('B2'); |
1320 EnumConstantDeclaration nodeB = elementB.computeNode(); | 1320 EnumConstantDeclaration nodeB = elementB.computeNode(); |
1321 expect(nodeB, isNotNull); | 1321 expect(nodeB, isNotNull); |
1322 expect(nodeB.name.name, "B2"); | 1322 expect(nodeB.name.name, "B2"); |
1323 expect(nodeB.element, same(elementB)); | 1323 expect(nodeB.element, same(elementB)); |
1324 } | 1324 } |
1325 } | 1325 } |
| 1326 |
| 1327 void test_isEnumConstant() { |
| 1328 AnalysisContextHelper contextHelper = new AnalysisContextHelper(); |
| 1329 AnalysisContext context = contextHelper.context; |
| 1330 Source source = contextHelper.addSource( |
| 1331 "/test.dart", |
| 1332 r''' |
| 1333 enum B {B1, B2, B3} |
| 1334 '''); |
| 1335 // prepare CompilationUnitElement |
| 1336 LibraryElement libraryElement = context.computeLibraryElement(source); |
| 1337 CompilationUnitElement unitElement = libraryElement.definingCompilationUnit; |
| 1338 |
| 1339 FieldElement b2Element = unitElement.getEnum("B").getField('B2'); |
| 1340 expect(b2Element.isEnumConstant, isTrue); |
| 1341 |
| 1342 FieldElement indexElement = unitElement.getEnum("B").getField('index'); |
| 1343 expect(indexElement.isEnumConstant, isFalse); |
| 1344 } |
1326 } | 1345 } |
1327 | 1346 |
1328 @reflectiveTest | 1347 @reflectiveTest |
1329 class FunctionTypeImplTest extends EngineTestCase { | 1348 class FunctionTypeImplTest extends EngineTestCase { |
1330 void test_creation() { | 1349 void test_creation() { |
1331 expect( | 1350 expect( |
1332 new FunctionTypeImpl( | 1351 new FunctionTypeImpl( |
1333 new FunctionElementImpl.forNode(AstTestFactory.identifier3("f"))), | 1352 new FunctionElementImpl.forNode(AstTestFactory.identifier3("f"))), |
1334 isNotNull); | 1353 isNotNull); |
1335 } | 1354 } |
(...skipping 3152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4488 } | 4507 } |
4489 | 4508 |
4490 class _FunctionTypeImplTest_isSubtypeOf_baseCase_classFunction | 4509 class _FunctionTypeImplTest_isSubtypeOf_baseCase_classFunction |
4491 extends InterfaceTypeImpl { | 4510 extends InterfaceTypeImpl { |
4492 _FunctionTypeImplTest_isSubtypeOf_baseCase_classFunction(ClassElement arg0) | 4511 _FunctionTypeImplTest_isSubtypeOf_baseCase_classFunction(ClassElement arg0) |
4493 : super(arg0); | 4512 : super(arg0); |
4494 | 4513 |
4495 @override | 4514 @override |
4496 bool get isDartCoreFunction => true; | 4515 bool get isDartCoreFunction => true; |
4497 } | 4516 } |
OLD | NEW |