Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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.inheritance_manager_test; | 5 library analyzer.test.generated.inheritance_manager_test; |
| 6 | 6 |
| 7 import 'dart:collection'; | 7 import 'dart:collection'; |
| 8 | 8 |
| 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 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 273 _inheritanceManager.getMembersInheritedFromInterfaces(classB); | 273 _inheritanceManager.getMembersInheritedFromInterfaces(classB); |
| 274 Map<String, ExecutableElement> mapA = | 274 Map<String, ExecutableElement> mapA = |
| 275 _inheritanceManager.getMembersInheritedFromInterfaces(classA); | 275 _inheritanceManager.getMembersInheritedFromInterfaces(classA); |
| 276 expect(mapA.length, _numOfMembersInObject); | 276 expect(mapA.length, _numOfMembersInObject); |
| 277 expect(mapB.length, _numOfMembersInObject + 1); | 277 expect(mapB.length, _numOfMembersInObject + 1); |
| 278 expect(mapB[getterName], same(getterG)); | 278 expect(mapB[getterName], same(getterG)); |
| 279 _assertNoErrors(classA); | 279 _assertNoErrors(classA); |
| 280 _assertNoErrors(classB); | 280 _assertNoErrors(classB); |
| 281 } | 281 } |
| 282 | 282 |
| 283 void test_getMapOfMembersInheritedFromInterfaces_field_indirectWith() { | |
| 284 // class A { int f; } | |
| 285 // class B extends A {} | |
| 286 // class C extends Object with B {} | |
| 287 ClassElementImpl classA = ElementFactory.classElement2('A'); | |
| 288 String fieldName = "f"; | |
| 289 FieldElement fieldF = ElementFactory.fieldElement( | |
| 290 fieldName, false, false, false, _typeProvider.intType); | |
| 291 classA.fields = <FieldElement>[fieldF]; | |
| 292 classA.accessors = <PropertyAccessorElement>[fieldF.getter, fieldF.setter]; | |
| 293 | |
| 294 ClassElementImpl classB = ElementFactory.classElement('B', classA.type); | |
| 295 | |
| 296 ClassElementImpl classC = ElementFactory.classElement2('C'); | |
| 297 classC.mixins = <InterfaceType>[classB.type]; | |
| 298 | |
| 299 Map<String, ExecutableElement> mapC = | |
| 300 _inheritanceManager.getMembersInheritedFromInterfaces(classC); | |
| 301 expect(mapC.length, _numOfMembersInObject + 2); | |
|
scheglov
2016/05/06 17:59:47
expect(mapC, hasLength(_numOfMembersInObject + 2))
Brian Wilkerson
2016/05/06 18:25:36
Done
| |
| 302 expect(mapC[fieldName], same(fieldF.getter)); | |
| 303 expect(mapC['$fieldName='], same(fieldF.setter)); | |
| 304 _assertNoErrors(classA); | |
| 305 _assertNoErrors(classB); | |
| 306 _assertNoErrors(classC); | |
| 307 } | |
| 308 | |
| 283 void test_getMapOfMembersInheritedFromInterfaces_implicitExtends() { | 309 void test_getMapOfMembersInheritedFromInterfaces_implicitExtends() { |
| 284 // class A {} | 310 // class A {} |
| 285 ClassElementImpl classA = ElementFactory.classElement2("A"); | 311 ClassElementImpl classA = ElementFactory.classElement2("A"); |
| 286 Map<String, ExecutableElement> mapA = | 312 Map<String, ExecutableElement> mapA = |
| 287 _inheritanceManager.getMembersInheritedFromInterfaces(classA); | 313 _inheritanceManager.getMembersInheritedFromInterfaces(classA); |
| 288 expect(mapA.length, _numOfMembersInObject); | 314 expect(mapA.length, _numOfMembersInObject); |
| 289 _assertNoErrors(classA); | 315 _assertNoErrors(classA); |
| 290 } | 316 } |
| 291 | 317 |
| 292 void | 318 void |
| (...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 862 classI3.type, | 888 classI3.type, |
| 863 classI4.type | 889 classI4.type |
| 864 ]; | 890 ]; |
| 865 Map<String, ExecutableElement> mapA = | 891 Map<String, ExecutableElement> mapA = |
| 866 _inheritanceManager.getMembersInheritedFromInterfaces(classA); | 892 _inheritanceManager.getMembersInheritedFromInterfaces(classA); |
| 867 expect(mapA.length, _numOfMembersInObject + 1); | 893 expect(mapA.length, _numOfMembersInObject + 1); |
| 868 expect(mapA[methodName], same(methodM4)); | 894 expect(mapA[methodName], same(methodM4)); |
| 869 _assertNoErrors(classA); | 895 _assertNoErrors(classA); |
| 870 } | 896 } |
| 871 | 897 |
| 898 void test_getMembersInheritedFromClasses_field_indirectWith() { | |
| 899 // class A { int f; } | |
| 900 // class B extends A {} | |
| 901 // class C extends Object with B {} | |
| 902 ClassElementImpl classA = ElementFactory.classElement2('A'); | |
| 903 String fieldName = "f"; | |
| 904 FieldElement fieldF = ElementFactory.fieldElement( | |
| 905 fieldName, false, false, false, _typeProvider.intType); | |
| 906 classA.fields = <FieldElement>[fieldF]; | |
| 907 classA.accessors = <PropertyAccessorElement>[fieldF.getter, fieldF.setter]; | |
| 908 | |
| 909 ClassElementImpl classB = ElementFactory.classElement('B', classA.type); | |
| 910 | |
| 911 ClassElementImpl classC = ElementFactory.classElement2('C'); | |
| 912 classC.mixins = <InterfaceType>[classB.type]; | |
| 913 | |
| 914 Map<String, ExecutableElement> mapC = | |
| 915 _inheritanceManager.getMembersInheritedFromClasses(classC); | |
| 916 expect(mapC.length, _numOfMembersInObject); | |
|
scheglov
2016/05/06 17:59:47
expect(mapC, hasLength(_numOfMembersInObject));
Brian Wilkerson
2016/05/06 18:25:36
Done
| |
| 917 _assertNoErrors(classA); | |
| 918 _assertNoErrors(classB); | |
| 919 _assertNoErrors(classC); | |
| 920 } | |
| 921 | |
| 872 void test_lookupInheritance_interface_getter() { | 922 void test_lookupInheritance_interface_getter() { |
| 873 ClassElementImpl classA = ElementFactory.classElement2("A"); | 923 ClassElementImpl classA = ElementFactory.classElement2("A"); |
| 874 String getterName = "g"; | 924 String getterName = "g"; |
| 875 PropertyAccessorElement getterG = | 925 PropertyAccessorElement getterG = |
| 876 ElementFactory.getterElement(getterName, false, _typeProvider.intType); | 926 ElementFactory.getterElement(getterName, false, _typeProvider.intType); |
| 877 classA.accessors = <PropertyAccessorElement>[getterG]; | 927 classA.accessors = <PropertyAccessorElement>[getterG]; |
| 878 ClassElementImpl classB = ElementFactory.classElement2("B"); | 928 ClassElementImpl classB = ElementFactory.classElement2("B"); |
| 879 classB.interfaces = <InterfaceType>[classA.type]; | 929 classB.interfaces = <InterfaceType>[classA.type]; |
| 880 expect(_inheritanceManager.lookupInheritance(classB, getterName), | 930 expect(_inheritanceManager.lookupInheritance(classB, getterName), |
| 881 same(getterG)); | 931 same(getterG)); |
| (...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1261 new FileBasedSource(FileUtilities2.createFile("/test.dart")); | 1311 new FileBasedSource(FileUtilities2.createFile("/test.dart")); |
| 1262 CompilationUnitElementImpl definingCompilationUnit = | 1312 CompilationUnitElementImpl definingCompilationUnit = |
| 1263 new CompilationUnitElementImpl("test.dart"); | 1313 new CompilationUnitElementImpl("test.dart"); |
| 1264 definingCompilationUnit.librarySource = | 1314 definingCompilationUnit.librarySource = |
| 1265 definingCompilationUnit.source = source; | 1315 definingCompilationUnit.source = source; |
| 1266 _definingLibrary = ElementFactory.library(context, "test"); | 1316 _definingLibrary = ElementFactory.library(context, "test"); |
| 1267 _definingLibrary.definingCompilationUnit = definingCompilationUnit; | 1317 _definingLibrary.definingCompilationUnit = definingCompilationUnit; |
| 1268 return new InheritanceManager(_definingLibrary); | 1318 return new InheritanceManager(_definingLibrary); |
| 1269 } | 1319 } |
| 1270 } | 1320 } |
| OLD | NEW |