Chromium Code Reviews| 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 // This code was auto-generated, is not intended to be edited, and is subject to | 5 // This code was auto-generated, is not intended to be edited, and is subject to |
| 6 // significant change. Please see the README file for more information. | 6 // significant change. Please see the README file for more information. |
| 7 | 7 |
| 8 library engine.element_test; | 8 library engine.element_test; |
| 9 | 9 |
| 10 import 'package:analyzer/src/generated/ast.dart'; | 10 import 'package:analyzer/src/generated/ast.dart'; |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 41 runReflectiveTests(ParameterElementImplTest); | 41 runReflectiveTests(ParameterElementImplTest); |
| 42 } | 42 } |
| 43 | 43 |
| 44 @reflectiveTest | 44 @reflectiveTest |
| 45 class ClassElementImplTest extends EngineTestCase { | 45 class ClassElementImplTest extends EngineTestCase { |
| 46 void test_computeNode_ClassDeclaration() { | 46 void test_computeNode_ClassDeclaration() { |
| 47 AnalysisContextHelper contextHelper = new AnalysisContextHelper(); | 47 AnalysisContextHelper contextHelper = new AnalysisContextHelper(); |
| 48 AnalysisContext context = contextHelper.context; | 48 AnalysisContext context = contextHelper.context; |
| 49 Source source = contextHelper.addSource("/test.dart", r''' | 49 Source source = contextHelper.addSource("/test.dart", r''' |
| 50 class A {} | 50 class A {} |
| 51 class B {} | 51 @deprecated class B {} |
| 52 enum C {C1, C2, C3}'''); | 52 enum C {C1, C2, C3} |
| 53 @deprecated enum D {D1, D2, D3}'''); | |
| 53 // prepare CompilationUnitElement | 54 // prepare CompilationUnitElement |
| 54 LibraryElement libraryElement = context.computeLibraryElement(source); | 55 LibraryElement libraryElement = context.computeLibraryElement(source); |
| 55 CompilationUnitElement unitElement = libraryElement.definingCompilationUnit; | 56 CompilationUnitElement unitElement = libraryElement.definingCompilationUnit; |
| 56 // A | 57 // A |
| 57 { | 58 { |
| 58 ClassElement elementA = unitElement.getType("A"); | 59 ClassElement elementA = unitElement.getType("A"); |
| 60 expect(elementA.isDeprecated, isFalse); | |
|
scheglov
2015/06/05 15:08:37
This test is not an appropriate place to test isEn
Brian Wilkerson
2015/06/05 15:14:33
I disagree. Most of our test classes test the full
| |
| 61 expect(elementA.isEnum, isFalse); | |
| 59 ClassDeclaration nodeA = elementA.computeNode(); | 62 ClassDeclaration nodeA = elementA.computeNode(); |
| 60 expect(nodeA, isNotNull); | 63 expect(nodeA, isNotNull); |
| 61 expect(nodeA.name.name, "A"); | 64 expect(nodeA.name.name, "A"); |
| 62 expect(nodeA.element, same(elementA)); | 65 expect(nodeA.element, same(elementA)); |
| 63 } | 66 } |
| 64 // B | 67 // B |
| 65 { | 68 { |
| 66 ClassElement elementB = unitElement.getType("B"); | 69 ClassElement elementB = unitElement.getType("B"); |
| 70 expect(elementB.isDeprecated, isTrue); | |
| 71 expect(elementB.isEnum, isFalse); | |
| 67 ClassDeclaration nodeB = elementB.computeNode(); | 72 ClassDeclaration nodeB = elementB.computeNode(); |
| 68 expect(nodeB, isNotNull); | 73 expect(nodeB, isNotNull); |
| 69 expect(nodeB.name.name, "B"); | 74 expect(nodeB.name.name, "B"); |
| 70 expect(nodeB.element, same(elementB)); | 75 expect(nodeB.element, same(elementB)); |
| 71 } | 76 } |
| 72 // C | 77 // C |
| 73 { | 78 { |
| 74 ClassElement elementC = unitElement.getEnum("C"); | 79 ClassElement elementC = unitElement.getEnum("C"); |
| 80 expect(elementC.isDeprecated, isFalse); | |
| 81 expect(elementC.isEnum, isTrue); | |
| 75 EnumDeclaration nodeC = elementC.computeNode(); | 82 EnumDeclaration nodeC = elementC.computeNode(); |
| 76 expect(nodeC, isNotNull); | 83 expect(nodeC, isNotNull); |
| 77 expect(nodeC.name.name, "C"); | 84 expect(nodeC.name.name, "C"); |
| 78 expect(nodeC.element, same(elementC)); | 85 expect(nodeC.element, same(elementC)); |
| 79 } | 86 } |
| 87 // D | |
| 88 { | |
| 89 ClassElement elementD = unitElement.getEnum("D"); | |
| 90 expect(elementD.isDeprecated, isTrue); | |
| 91 expect(elementD.isEnum, isTrue); | |
| 92 EnumDeclaration nodeC = elementD.computeNode(); | |
| 93 expect(nodeC, isNotNull); | |
| 94 expect(nodeC.name.name, "D"); | |
| 95 expect(nodeC.element, same(elementD)); | |
| 96 } | |
| 80 } | 97 } |
| 81 | 98 |
| 82 void test_computeNode_ClassTypeAlias() { | 99 void test_computeNode_ClassTypeAlias() { |
| 83 AnalysisContextHelper contextHelper = new AnalysisContextHelper(); | 100 AnalysisContextHelper contextHelper = new AnalysisContextHelper(); |
| 84 AnalysisContext context = contextHelper.context; | 101 AnalysisContext context = contextHelper.context; |
| 85 Source source = contextHelper.addSource("/test.dart", r''' | 102 Source source = contextHelper.addSource("/test.dart", r''' |
| 86 abstract class A<K, V> = Object with MapMixin<K, V>; | 103 abstract class A<K, V> = Object with MapMixin<K, V>; |
| 87 '''); | 104 '''); |
| 88 // prepare CompilationUnitElement | 105 // prepare CompilationUnitElement |
| 89 LibraryElement libraryElement = context.computeLibraryElement(source); | 106 LibraryElement libraryElement = context.computeLibraryElement(source); |
| (...skipping 4098 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4188 } | 4205 } |
| 4189 | 4206 |
| 4190 class _FunctionTypeImplTest_isSubtypeOf_baseCase_classFunction | 4207 class _FunctionTypeImplTest_isSubtypeOf_baseCase_classFunction |
| 4191 extends InterfaceTypeImpl { | 4208 extends InterfaceTypeImpl { |
| 4192 _FunctionTypeImplTest_isSubtypeOf_baseCase_classFunction(ClassElement arg0) | 4209 _FunctionTypeImplTest_isSubtypeOf_baseCase_classFunction(ClassElement arg0) |
| 4193 : super(arg0); | 4210 : super(arg0); |
| 4194 | 4211 |
| 4195 @override | 4212 @override |
| 4196 bool get isDartCoreFunction => true; | 4213 bool get isDartCoreFunction => true; |
| 4197 } | 4214 } |
| OLD | NEW |