| 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/java_core.dart'; | 10 import 'package:analyzer/src/generated/java_core.dart'; |
| 11 import 'package:analyzer/src/generated/java_junit.dart'; | |
| 12 import 'package:analyzer/src/generated/source_io.dart'; | 11 import 'package:analyzer/src/generated/source_io.dart'; |
| 13 import 'package:analyzer/src/generated/ast.dart'; | 12 import 'package:analyzer/src/generated/ast.dart'; |
| 14 import 'package:analyzer/src/generated/element.dart'; | 13 import 'package:analyzer/src/generated/element.dart'; |
| 15 import 'package:analyzer/src/generated/engine.dart' show AnalysisContext, Analys
isContextImpl; | 14 import 'package:analyzer/src/generated/engine.dart' show AnalysisContext, Analys
isContextImpl; |
| 16 import 'package:unittest/unittest.dart' as _ut; | 15 import 'package:unittest/unittest.dart'; |
| 17 import 'test_support.dart'; | 16 import 'test_support.dart'; |
| 18 import 'package:analyzer/src/generated/testing/ast_factory.dart'; | 17 import 'package:analyzer/src/generated/testing/ast_factory.dart'; |
| 19 import 'package:analyzer/src/generated/testing/element_factory.dart'; | 18 import 'package:analyzer/src/generated/testing/element_factory.dart'; |
| 20 import 'resolver_test.dart' show TestTypeProvider, AnalysisContextHelper; | 19 import 'resolver_test.dart' show TestTypeProvider, AnalysisContextHelper; |
| 21 | 20 |
| 22 import '../reflective_tests.dart'; | 21 import '../reflective_tests.dart'; |
| 23 | 22 |
| 24 | 23 |
| 25 class AngularPropertyKindTest extends EngineTestCase { | 24 class AngularPropertyKindTest extends EngineTestCase { |
| 26 void test_ATTR() { | 25 void test_ATTR() { |
| 27 AngularPropertyKind kind = AngularPropertyKind.ATTR; | 26 AngularPropertyKind kind = AngularPropertyKind.ATTR; |
| 28 JUnitTestCase.assertFalse(kind.callsGetter()); | 27 expect(kind.callsGetter(), isFalse); |
| 29 JUnitTestCase.assertTrue(kind.callsSetter()); | 28 expect(kind.callsSetter(), isTrue); |
| 30 } | 29 } |
| 31 | 30 |
| 32 void test_CALLBACK() { | 31 void test_CALLBACK() { |
| 33 AngularPropertyKind kind = AngularPropertyKind.CALLBACK; | 32 AngularPropertyKind kind = AngularPropertyKind.CALLBACK; |
| 34 JUnitTestCase.assertFalse(kind.callsGetter()); | 33 expect(kind.callsGetter(), isFalse); |
| 35 JUnitTestCase.assertTrue(kind.callsSetter()); | 34 expect(kind.callsSetter(), isTrue); |
| 36 } | 35 } |
| 37 | 36 |
| 38 void test_ONE_WAY() { | 37 void test_ONE_WAY() { |
| 39 AngularPropertyKind kind = AngularPropertyKind.ONE_WAY; | 38 AngularPropertyKind kind = AngularPropertyKind.ONE_WAY; |
| 40 JUnitTestCase.assertFalse(kind.callsGetter()); | 39 expect(kind.callsGetter(), isFalse); |
| 41 JUnitTestCase.assertTrue(kind.callsSetter()); | 40 expect(kind.callsSetter(), isTrue); |
| 42 } | 41 } |
| 43 | 42 |
| 44 void test_ONE_WAY_ONE_TIME() { | 43 void test_ONE_WAY_ONE_TIME() { |
| 45 AngularPropertyKind kind = AngularPropertyKind.ONE_WAY_ONE_TIME; | 44 AngularPropertyKind kind = AngularPropertyKind.ONE_WAY_ONE_TIME; |
| 46 JUnitTestCase.assertFalse(kind.callsGetter()); | 45 expect(kind.callsGetter(), isFalse); |
| 47 JUnitTestCase.assertTrue(kind.callsSetter()); | 46 expect(kind.callsSetter(), isTrue); |
| 48 } | 47 } |
| 49 | 48 |
| 50 void test_TWO_WAY() { | 49 void test_TWO_WAY() { |
| 51 AngularPropertyKind kind = AngularPropertyKind.TWO_WAY; | 50 AngularPropertyKind kind = AngularPropertyKind.TWO_WAY; |
| 52 JUnitTestCase.assertTrue(kind.callsGetter()); | 51 expect(kind.callsGetter(), isTrue); |
| 53 JUnitTestCase.assertTrue(kind.callsSetter()); | 52 expect(kind.callsSetter(), isTrue); |
| 54 } | 53 } |
| 55 } | 54 } |
| 56 | 55 |
| 57 class ClassElementImplTest extends EngineTestCase { | 56 class ClassElementImplTest extends EngineTestCase { |
| 58 void test_getAllSupertypes_interface() { | 57 void test_getAllSupertypes_interface() { |
| 59 ClassElement classA = ElementFactory.classElement2("A", []); | 58 ClassElement classA = ElementFactory.classElement2("A", []); |
| 60 ClassElement classB = ElementFactory.classElement("B", classA.type, []); | 59 ClassElement classB = ElementFactory.classElement("B", classA.type, []); |
| 61 ClassElementImpl elementC = ElementFactory.classElement2("C", []); | 60 ClassElementImpl elementC = ElementFactory.classElement2("C", []); |
| 62 InterfaceType typeObject = classA.supertype; | 61 InterfaceType typeObject = classA.supertype; |
| 63 InterfaceType typeA = classA.type; | 62 InterfaceType typeA = classA.type; |
| 64 InterfaceType typeB = classB.type; | 63 InterfaceType typeB = classB.type; |
| 65 InterfaceType typeC = elementC.type; | 64 InterfaceType typeC = elementC.type; |
| 66 elementC.interfaces = <InterfaceType> [typeB]; | 65 elementC.interfaces = <InterfaceType> [typeB]; |
| 67 List<InterfaceType> supers = elementC.allSupertypes; | 66 List<InterfaceType> supers = elementC.allSupertypes; |
| 68 List<InterfaceType> types = new List<InterfaceType>(); | 67 List<InterfaceType> types = new List<InterfaceType>(); |
| 69 types.addAll(supers); | 68 types.addAll(supers); |
| 70 JUnitTestCase.assertTrue(types.contains(typeA)); | 69 expect(types.contains(typeA), isTrue); |
| 71 JUnitTestCase.assertTrue(types.contains(typeB)); | 70 expect(types.contains(typeB), isTrue); |
| 72 JUnitTestCase.assertTrue(types.contains(typeObject)); | 71 expect(types.contains(typeObject), isTrue); |
| 73 JUnitTestCase.assertFalse(types.contains(typeC)); | 72 expect(types.contains(typeC), isFalse); |
| 74 } | 73 } |
| 75 | 74 |
| 76 void test_getAllSupertypes_mixins() { | 75 void test_getAllSupertypes_mixins() { |
| 77 ClassElement classA = ElementFactory.classElement2("A", []); | 76 ClassElement classA = ElementFactory.classElement2("A", []); |
| 78 ClassElement classB = ElementFactory.classElement("B", classA.type, []); | 77 ClassElement classB = ElementFactory.classElement("B", classA.type, []); |
| 79 ClassElementImpl classC = ElementFactory.classElement2("C", []); | 78 ClassElementImpl classC = ElementFactory.classElement2("C", []); |
| 80 InterfaceType typeObject = classA.supertype; | 79 InterfaceType typeObject = classA.supertype; |
| 81 InterfaceType typeA = classA.type; | 80 InterfaceType typeA = classA.type; |
| 82 InterfaceType typeB = classB.type; | 81 InterfaceType typeB = classB.type; |
| 83 InterfaceType typeC = classC.type; | 82 InterfaceType typeC = classC.type; |
| 84 classC.mixins = <InterfaceType> [typeB]; | 83 classC.mixins = <InterfaceType> [typeB]; |
| 85 List<InterfaceType> supers = classC.allSupertypes; | 84 List<InterfaceType> supers = classC.allSupertypes; |
| 86 List<InterfaceType> types = new List<InterfaceType>(); | 85 List<InterfaceType> types = new List<InterfaceType>(); |
| 87 types.addAll(supers); | 86 types.addAll(supers); |
| 88 JUnitTestCase.assertFalse(types.contains(typeA)); | 87 expect(types.contains(typeA), isFalse); |
| 89 JUnitTestCase.assertTrue(types.contains(typeB)); | 88 expect(types.contains(typeB), isTrue); |
| 90 JUnitTestCase.assertTrue(types.contains(typeObject)); | 89 expect(types.contains(typeObject), isTrue); |
| 91 JUnitTestCase.assertFalse(types.contains(typeC)); | 90 expect(types.contains(typeC), isFalse); |
| 92 } | 91 } |
| 93 | 92 |
| 94 void test_getAllSupertypes_recursive() { | 93 void test_getAllSupertypes_recursive() { |
| 95 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 94 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 96 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); | 95 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); |
| 97 classA.supertype = classB.type; | 96 classA.supertype = classB.type; |
| 98 List<InterfaceType> supers = classB.allSupertypes; | 97 List<InterfaceType> supers = classB.allSupertypes; |
| 99 EngineTestCase.assertLength(1, supers); | 98 EngineTestCase.assertLength(1, supers); |
| 100 } | 99 } |
| 101 | 100 |
| 102 void test_getField() { | 101 void test_getField() { |
| 103 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 102 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 104 String fieldName = "f"; | 103 String fieldName = "f"; |
| 105 FieldElementImpl field = ElementFactory.fieldElement(fieldName, false, false
, false, null); | 104 FieldElementImpl field = ElementFactory.fieldElement(fieldName, false, false
, false, null); |
| 106 classA.fields = <FieldElement> [field]; | 105 classA.fields = <FieldElement> [field]; |
| 107 JUnitTestCase.assertSame(field, classA.getField(fieldName)); | 106 expect(classA.getField(fieldName), same(field)); |
| 108 // no such field | 107 // no such field |
| 109 JUnitTestCase.assertSame(null, classA.getField("noSuchField")); | 108 expect(classA.getField("noSuchField"), same(null)); |
| 110 } | 109 } |
| 111 | 110 |
| 112 void test_getMethod_declared() { | 111 void test_getMethod_declared() { |
| 113 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 112 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 114 String methodName = "m"; | 113 String methodName = "m"; |
| 115 MethodElement method = ElementFactory.methodElement(methodName, null, []); | 114 MethodElement method = ElementFactory.methodElement(methodName, null, []); |
| 116 classA.methods = <MethodElement> [method]; | 115 classA.methods = <MethodElement> [method]; |
| 117 JUnitTestCase.assertSame(method, classA.getMethod(methodName)); | 116 expect(classA.getMethod(methodName), same(method)); |
| 118 } | 117 } |
| 119 | 118 |
| 120 void test_getMethod_undeclared() { | 119 void test_getMethod_undeclared() { |
| 121 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 120 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 122 String methodName = "m"; | 121 String methodName = "m"; |
| 123 MethodElement method = ElementFactory.methodElement(methodName, null, []); | 122 MethodElement method = ElementFactory.methodElement(methodName, null, []); |
| 124 classA.methods = <MethodElement> [method]; | 123 classA.methods = <MethodElement> [method]; |
| 125 JUnitTestCase.assertNull(classA.getMethod("${methodName}x")); | 124 expect(classA.getMethod("${methodName}x"), isNull); |
| 126 } | 125 } |
| 127 | 126 |
| 128 void test_getNode() { | 127 void test_getNode() { |
| 129 AnalysisContextHelper contextHelper = new AnalysisContextHelper(); | 128 AnalysisContextHelper contextHelper = new AnalysisContextHelper(); |
| 130 AnalysisContext context = contextHelper.context; | 129 AnalysisContext context = contextHelper.context; |
| 131 Source source = contextHelper.addSource("/test.dart", r''' | 130 Source source = contextHelper.addSource("/test.dart", r''' |
| 132 class A {} | 131 class A {} |
| 133 class B {}'''); | 132 class B {}'''); |
| 134 // prepare CompilationUnitElement | 133 // prepare CompilationUnitElement |
| 135 LibraryElement libraryElement = context.computeLibraryElement(source); | 134 LibraryElement libraryElement = context.computeLibraryElement(source); |
| 136 CompilationUnitElement unitElement = libraryElement.definingCompilationUnit; | 135 CompilationUnitElement unitElement = libraryElement.definingCompilationUnit; |
| 137 // A | 136 // A |
| 138 { | 137 { |
| 139 ClassElement elementA = unitElement.getType("A"); | 138 ClassElement elementA = unitElement.getType("A"); |
| 140 ClassDeclaration nodeA = elementA.node; | 139 ClassDeclaration nodeA = elementA.node; |
| 141 JUnitTestCase.assertNotNull(nodeA); | 140 expect(nodeA, isNotNull); |
| 142 JUnitTestCase.assertEquals("A", nodeA.name.name); | 141 expect(nodeA.name.name, "A"); |
| 143 JUnitTestCase.assertSame(elementA, nodeA.element); | 142 expect(nodeA.element, same(elementA)); |
| 144 } | 143 } |
| 145 // B | 144 // B |
| 146 { | 145 { |
| 147 ClassElement elementB = unitElement.getType("B"); | 146 ClassElement elementB = unitElement.getType("B"); |
| 148 ClassDeclaration nodeB = elementB.node; | 147 ClassDeclaration nodeB = elementB.node; |
| 149 JUnitTestCase.assertNotNull(nodeB); | 148 expect(nodeB, isNotNull); |
| 150 JUnitTestCase.assertEquals("B", nodeB.name.name); | 149 expect(nodeB.name.name, "B"); |
| 151 JUnitTestCase.assertSame(elementB, nodeB.element); | 150 expect(nodeB.element, same(elementB)); |
| 152 } | 151 } |
| 153 } | 152 } |
| 154 | 153 |
| 155 void test_hasNonFinalField_false_const() { | 154 void test_hasNonFinalField_false_const() { |
| 156 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 155 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 157 classA.fields = <FieldElement> [ElementFactory.fieldElement("f", false, fals
e, true, classA.type)]; | 156 classA.fields = <FieldElement> [ElementFactory.fieldElement("f", false, fals
e, true, classA.type)]; |
| 158 JUnitTestCase.assertFalse(classA.hasNonFinalField); | 157 expect(classA.hasNonFinalField, isFalse); |
| 159 } | 158 } |
| 160 | 159 |
| 161 void test_hasNonFinalField_false_final() { | 160 void test_hasNonFinalField_false_final() { |
| 162 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 161 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 163 classA.fields = <FieldElement> [ElementFactory.fieldElement("f", false, true
, false, classA.type)]; | 162 classA.fields = <FieldElement> [ElementFactory.fieldElement("f", false, true
, false, classA.type)]; |
| 164 JUnitTestCase.assertFalse(classA.hasNonFinalField); | 163 expect(classA.hasNonFinalField, isFalse); |
| 165 } | 164 } |
| 166 | 165 |
| 167 void test_hasNonFinalField_false_recursive() { | 166 void test_hasNonFinalField_false_recursive() { |
| 168 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 167 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 169 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); | 168 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); |
| 170 classA.supertype = classB.type; | 169 classA.supertype = classB.type; |
| 171 JUnitTestCase.assertFalse(classA.hasNonFinalField); | 170 expect(classA.hasNonFinalField, isFalse); |
| 172 } | 171 } |
| 173 | 172 |
| 174 void test_hasNonFinalField_true_immediate() { | 173 void test_hasNonFinalField_true_immediate() { |
| 175 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 174 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 176 classA.fields = <FieldElement> [ElementFactory.fieldElement("f", false, fals
e, false, classA.type)]; | 175 classA.fields = <FieldElement> [ElementFactory.fieldElement("f", false, fals
e, false, classA.type)]; |
| 177 JUnitTestCase.assertTrue(classA.hasNonFinalField); | 176 expect(classA.hasNonFinalField, isTrue); |
| 178 } | 177 } |
| 179 | 178 |
| 180 void test_hasNonFinalField_true_inherited() { | 179 void test_hasNonFinalField_true_inherited() { |
| 181 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 180 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 182 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); | 181 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); |
| 183 classA.fields = <FieldElement> [ElementFactory.fieldElement("f", false, fals
e, false, classA.type)]; | 182 classA.fields = <FieldElement> [ElementFactory.fieldElement("f", false, fals
e, false, classA.type)]; |
| 184 JUnitTestCase.assertTrue(classB.hasNonFinalField); | 183 expect(classB.hasNonFinalField, isTrue); |
| 185 } | 184 } |
| 186 | 185 |
| 187 void test_hasStaticMember_false_empty() { | 186 void test_hasStaticMember_false_empty() { |
| 188 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 187 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 189 // no members | 188 // no members |
| 190 JUnitTestCase.assertFalse(classA.hasStaticMember); | 189 expect(classA.hasStaticMember, isFalse); |
| 191 } | 190 } |
| 192 | 191 |
| 193 void test_hasStaticMember_false_instanceMethod() { | 192 void test_hasStaticMember_false_instanceMethod() { |
| 194 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 193 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 195 MethodElement method = ElementFactory.methodElement("foo", null, []); | 194 MethodElement method = ElementFactory.methodElement("foo", null, []); |
| 196 classA.methods = <MethodElement> [method]; | 195 classA.methods = <MethodElement> [method]; |
| 197 JUnitTestCase.assertFalse(classA.hasStaticMember); | 196 expect(classA.hasStaticMember, isFalse); |
| 198 } | 197 } |
| 199 | 198 |
| 200 void test_hasStaticMember_instanceGetter() { | 199 void test_hasStaticMember_instanceGetter() { |
| 201 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 200 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 202 PropertyAccessorElement getter = ElementFactory.getterElement("foo", false,
null); | 201 PropertyAccessorElement getter = ElementFactory.getterElement("foo", false,
null); |
| 203 classA.accessors = <PropertyAccessorElement> [getter]; | 202 classA.accessors = <PropertyAccessorElement> [getter]; |
| 204 JUnitTestCase.assertFalse(classA.hasStaticMember); | 203 expect(classA.hasStaticMember, isFalse); |
| 205 } | 204 } |
| 206 | 205 |
| 207 void test_hasStaticMember_true_getter() { | 206 void test_hasStaticMember_true_getter() { |
| 208 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 207 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 209 PropertyAccessorElementImpl getter = ElementFactory.getterElement("foo", fal
se, null); | 208 PropertyAccessorElementImpl getter = ElementFactory.getterElement("foo", fal
se, null); |
| 210 classA.accessors = <PropertyAccessorElement> [getter]; | 209 classA.accessors = <PropertyAccessorElement> [getter]; |
| 211 // "foo" is static | 210 // "foo" is static |
| 212 getter.static = true; | 211 getter.static = true; |
| 213 JUnitTestCase.assertTrue(classA.hasStaticMember); | 212 expect(classA.hasStaticMember, isTrue); |
| 214 } | 213 } |
| 215 | 214 |
| 216 void test_hasStaticMember_true_method() { | 215 void test_hasStaticMember_true_method() { |
| 217 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 216 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 218 MethodElementImpl method = ElementFactory.methodElement("foo", null, []); | 217 MethodElementImpl method = ElementFactory.methodElement("foo", null, []); |
| 219 classA.methods = <MethodElement> [method]; | 218 classA.methods = <MethodElement> [method]; |
| 220 // "foo" is static | 219 // "foo" is static |
| 221 method.static = true; | 220 method.static = true; |
| 222 JUnitTestCase.assertTrue(classA.hasStaticMember); | 221 expect(classA.hasStaticMember, isTrue); |
| 223 } | 222 } |
| 224 | 223 |
| 225 void test_hasStaticMember_true_setter() { | 224 void test_hasStaticMember_true_setter() { |
| 226 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 225 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 227 PropertyAccessorElementImpl setter = ElementFactory.setterElement("foo", fal
se, null); | 226 PropertyAccessorElementImpl setter = ElementFactory.setterElement("foo", fal
se, null); |
| 228 classA.accessors = <PropertyAccessorElement> [setter]; | 227 classA.accessors = <PropertyAccessorElement> [setter]; |
| 229 // "foo" is static | 228 // "foo" is static |
| 230 setter.static = true; | 229 setter.static = true; |
| 231 JUnitTestCase.assertTrue(classA.hasStaticMember); | 230 expect(classA.hasStaticMember, isTrue); |
| 232 } | 231 } |
| 233 | 232 |
| 234 void test_lookUpConcreteMethod_declared() { | 233 void test_lookUpConcreteMethod_declared() { |
| 235 // class A { | 234 // class A { |
| 236 // m() {} | 235 // m() {} |
| 237 // } | 236 // } |
| 238 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(),
"lib"); | 237 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(),
"lib"); |
| 239 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 238 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 240 String methodName = "m"; | 239 String methodName = "m"; |
| 241 MethodElement method = ElementFactory.methodElement(methodName, null, []); | 240 MethodElement method = ElementFactory.methodElement(methodName, null, []); |
| 242 classA.methods = <MethodElement> [method]; | 241 classA.methods = <MethodElement> [method]; |
| 243 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla
ssElement> [classA]; | 242 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla
ssElement> [classA]; |
| 244 JUnitTestCase.assertSame(method, classA.lookUpConcreteMethod(methodName, lib
rary)); | 243 expect(classA.lookUpConcreteMethod(methodName, library), same(method)); |
| 245 } | 244 } |
| 246 | 245 |
| 247 void test_lookUpConcreteMethod_declaredAbstract() { | 246 void test_lookUpConcreteMethod_declaredAbstract() { |
| 248 // class A { | 247 // class A { |
| 249 // m(); | 248 // m(); |
| 250 // } | 249 // } |
| 251 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(),
"lib"); | 250 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(),
"lib"); |
| 252 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 251 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 253 String methodName = "m"; | 252 String methodName = "m"; |
| 254 MethodElementImpl method = ElementFactory.methodElement(methodName, null, []
); | 253 MethodElementImpl method = ElementFactory.methodElement(methodName, null, []
); |
| 255 method.abstract = true; | 254 method.abstract = true; |
| 256 classA.methods = <MethodElement> [method]; | 255 classA.methods = <MethodElement> [method]; |
| 257 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla
ssElement> [classA]; | 256 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla
ssElement> [classA]; |
| 258 JUnitTestCase.assertNull(classA.lookUpConcreteMethod(methodName, library)); | 257 expect(classA.lookUpConcreteMethod(methodName, library), isNull); |
| 259 } | 258 } |
| 260 | 259 |
| 261 void test_lookUpConcreteMethod_declaredAbstractAndInherited() { | 260 void test_lookUpConcreteMethod_declaredAbstractAndInherited() { |
| 262 // class A { | 261 // class A { |
| 263 // m() {} | 262 // m() {} |
| 264 // } | 263 // } |
| 265 // class B extends A { | 264 // class B extends A { |
| 266 // m(); | 265 // m(); |
| 267 // } | 266 // } |
| 268 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(),
"lib"); | 267 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(),
"lib"); |
| 269 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 268 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 270 String methodName = "m"; | 269 String methodName = "m"; |
| 271 MethodElement inheritedMethod = ElementFactory.methodElement(methodName, nul
l, []); | 270 MethodElement inheritedMethod = ElementFactory.methodElement(methodName, nul
l, []); |
| 272 classA.methods = <MethodElement> [inheritedMethod]; | 271 classA.methods = <MethodElement> [inheritedMethod]; |
| 273 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); | 272 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); |
| 274 MethodElementImpl method = ElementFactory.methodElement(methodName, null, []
); | 273 MethodElementImpl method = ElementFactory.methodElement(methodName, null, []
); |
| 275 method.abstract = true; | 274 method.abstract = true; |
| 276 classB.methods = <MethodElement> [method]; | 275 classB.methods = <MethodElement> [method]; |
| 277 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla
ssElement> [classA, classB]; | 276 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla
ssElement> [classA, classB]; |
| 278 JUnitTestCase.assertSame(inheritedMethod, classB.lookUpConcreteMethod(method
Name, library)); | 277 expect(classB.lookUpConcreteMethod(methodName, library), same(inheritedMetho
d)); |
| 279 } | 278 } |
| 280 | 279 |
| 281 void test_lookUpConcreteMethod_declaredAndInherited() { | 280 void test_lookUpConcreteMethod_declaredAndInherited() { |
| 282 // class A { | 281 // class A { |
| 283 // m() {} | 282 // m() {} |
| 284 // } | 283 // } |
| 285 // class B extends A { | 284 // class B extends A { |
| 286 // m() {} | 285 // m() {} |
| 287 // } | 286 // } |
| 288 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(),
"lib"); | 287 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(),
"lib"); |
| 289 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 288 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 290 String methodName = "m"; | 289 String methodName = "m"; |
| 291 MethodElement inheritedMethod = ElementFactory.methodElement(methodName, nul
l, []); | 290 MethodElement inheritedMethod = ElementFactory.methodElement(methodName, nul
l, []); |
| 292 classA.methods = <MethodElement> [inheritedMethod]; | 291 classA.methods = <MethodElement> [inheritedMethod]; |
| 293 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); | 292 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); |
| 294 MethodElement method = ElementFactory.methodElement(methodName, null, []); | 293 MethodElement method = ElementFactory.methodElement(methodName, null, []); |
| 295 classB.methods = <MethodElement> [method]; | 294 classB.methods = <MethodElement> [method]; |
| 296 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla
ssElement> [classA, classB]; | 295 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla
ssElement> [classA, classB]; |
| 297 JUnitTestCase.assertSame(method, classB.lookUpConcreteMethod(methodName, lib
rary)); | 296 expect(classB.lookUpConcreteMethod(methodName, library), same(method)); |
| 298 } | 297 } |
| 299 | 298 |
| 300 void test_lookUpConcreteMethod_declaredAndInheritedAbstract() { | 299 void test_lookUpConcreteMethod_declaredAndInheritedAbstract() { |
| 301 // abstract class A { | 300 // abstract class A { |
| 302 // m(); | 301 // m(); |
| 303 // } | 302 // } |
| 304 // class B extends A { | 303 // class B extends A { |
| 305 // m() {} | 304 // m() {} |
| 306 // } | 305 // } |
| 307 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(),
"lib"); | 306 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(),
"lib"); |
| 308 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 307 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 309 classA.abstract = true; | 308 classA.abstract = true; |
| 310 String methodName = "m"; | 309 String methodName = "m"; |
| 311 MethodElementImpl inheritedMethod = ElementFactory.methodElement(methodName,
null, []); | 310 MethodElementImpl inheritedMethod = ElementFactory.methodElement(methodName,
null, []); |
| 312 inheritedMethod.abstract = true; | 311 inheritedMethod.abstract = true; |
| 313 classA.methods = <MethodElement> [inheritedMethod]; | 312 classA.methods = <MethodElement> [inheritedMethod]; |
| 314 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); | 313 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); |
| 315 MethodElement method = ElementFactory.methodElement(methodName, null, []); | 314 MethodElement method = ElementFactory.methodElement(methodName, null, []); |
| 316 classB.methods = <MethodElement> [method]; | 315 classB.methods = <MethodElement> [method]; |
| 317 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla
ssElement> [classA, classB]; | 316 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla
ssElement> [classA, classB]; |
| 318 JUnitTestCase.assertSame(method, classB.lookUpConcreteMethod(methodName, lib
rary)); | 317 expect(classB.lookUpConcreteMethod(methodName, library), same(method)); |
| 319 } | 318 } |
| 320 | 319 |
| 321 void test_lookUpConcreteMethod_inherited() { | 320 void test_lookUpConcreteMethod_inherited() { |
| 322 // class A { | 321 // class A { |
| 323 // m() {} | 322 // m() {} |
| 324 // } | 323 // } |
| 325 // class B extends A { | 324 // class B extends A { |
| 326 // } | 325 // } |
| 327 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(),
"lib"); | 326 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(),
"lib"); |
| 328 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 327 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 329 String methodName = "m"; | 328 String methodName = "m"; |
| 330 MethodElement inheritedMethod = ElementFactory.methodElement(methodName, nul
l, []); | 329 MethodElement inheritedMethod = ElementFactory.methodElement(methodName, nul
l, []); |
| 331 classA.methods = <MethodElement> [inheritedMethod]; | 330 classA.methods = <MethodElement> [inheritedMethod]; |
| 332 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); | 331 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); |
| 333 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla
ssElement> [classA, classB]; | 332 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla
ssElement> [classA, classB]; |
| 334 JUnitTestCase.assertSame(inheritedMethod, classB.lookUpConcreteMethod(method
Name, library)); | 333 expect(classB.lookUpConcreteMethod(methodName, library), same(inheritedMetho
d)); |
| 335 } | 334 } |
| 336 | 335 |
| 337 void test_lookUpConcreteMethod_undeclared() { | 336 void test_lookUpConcreteMethod_undeclared() { |
| 338 // class A { | 337 // class A { |
| 339 // } | 338 // } |
| 340 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(),
"lib"); | 339 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(),
"lib"); |
| 341 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 340 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 342 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla
ssElement> [classA]; | 341 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla
ssElement> [classA]; |
| 343 JUnitTestCase.assertNull(classA.lookUpConcreteMethod("m", library)); | 342 expect(classA.lookUpConcreteMethod("m", library), isNull); |
| 344 } | 343 } |
| 345 | 344 |
| 346 void test_lookUpGetter_declared() { | 345 void test_lookUpGetter_declared() { |
| 347 // class A { | 346 // class A { |
| 348 // get g {} | 347 // get g {} |
| 349 // } | 348 // } |
| 350 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(),
"lib"); | 349 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(),
"lib"); |
| 351 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 350 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 352 String getterName = "g"; | 351 String getterName = "g"; |
| 353 PropertyAccessorElement getter = ElementFactory.getterElement(getterName, fa
lse, null); | 352 PropertyAccessorElement getter = ElementFactory.getterElement(getterName, fa
lse, null); |
| 354 classA.accessors = <PropertyAccessorElement> [getter]; | 353 classA.accessors = <PropertyAccessorElement> [getter]; |
| 355 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla
ssElement> [classA]; | 354 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla
ssElement> [classA]; |
| 356 JUnitTestCase.assertSame(getter, classA.lookUpGetter(getterName, library)); | 355 expect(classA.lookUpGetter(getterName, library), same(getter)); |
| 357 } | 356 } |
| 358 | 357 |
| 359 void test_lookUpGetter_inherited() { | 358 void test_lookUpGetter_inherited() { |
| 360 // class A { | 359 // class A { |
| 361 // get g {} | 360 // get g {} |
| 362 // } | 361 // } |
| 363 // class B extends A { | 362 // class B extends A { |
| 364 // } | 363 // } |
| 365 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(),
"lib"); | 364 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(),
"lib"); |
| 366 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 365 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 367 String getterName = "g"; | 366 String getterName = "g"; |
| 368 PropertyAccessorElement getter = ElementFactory.getterElement(getterName, fa
lse, null); | 367 PropertyAccessorElement getter = ElementFactory.getterElement(getterName, fa
lse, null); |
| 369 classA.accessors = <PropertyAccessorElement> [getter]; | 368 classA.accessors = <PropertyAccessorElement> [getter]; |
| 370 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); | 369 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); |
| 371 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla
ssElement> [classA, classB]; | 370 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla
ssElement> [classA, classB]; |
| 372 JUnitTestCase.assertSame(getter, classB.lookUpGetter(getterName, library)); | 371 expect(classB.lookUpGetter(getterName, library), same(getter)); |
| 373 } | 372 } |
| 374 | 373 |
| 375 void test_lookUpGetter_undeclared() { | 374 void test_lookUpGetter_undeclared() { |
| 376 // class A { | 375 // class A { |
| 377 // } | 376 // } |
| 378 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(),
"lib"); | 377 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(),
"lib"); |
| 379 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 378 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 380 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla
ssElement> [classA]; | 379 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla
ssElement> [classA]; |
| 381 JUnitTestCase.assertNull(classA.lookUpGetter("g", library)); | 380 expect(classA.lookUpGetter("g", library), isNull); |
| 382 } | 381 } |
| 383 | 382 |
| 384 void test_lookUpGetter_undeclared_recursive() { | 383 void test_lookUpGetter_undeclared_recursive() { |
| 385 // class A extends B { | 384 // class A extends B { |
| 386 // } | 385 // } |
| 387 // class B extends A { | 386 // class B extends A { |
| 388 // } | 387 // } |
| 389 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(),
"lib"); | 388 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(),
"lib"); |
| 390 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 389 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 391 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); | 390 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); |
| 392 classA.supertype = classB.type; | 391 classA.supertype = classB.type; |
| 393 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla
ssElement> [classA, classB]; | 392 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla
ssElement> [classA, classB]; |
| 394 JUnitTestCase.assertNull(classA.lookUpGetter("g", library)); | 393 expect(classA.lookUpGetter("g", library), isNull); |
| 395 } | 394 } |
| 396 | 395 |
| 397 void test_lookUpInheritedConcreteGetter_declared() { | 396 void test_lookUpInheritedConcreteGetter_declared() { |
| 398 // class A { | 397 // class A { |
| 399 // get g {} | 398 // get g {} |
| 400 // } | 399 // } |
| 401 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(),
"lib"); | 400 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(),
"lib"); |
| 402 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 401 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 403 String getterName = "g"; | 402 String getterName = "g"; |
| 404 PropertyAccessorElement getter = ElementFactory.getterElement(getterName, fa
lse, null); | 403 PropertyAccessorElement getter = ElementFactory.getterElement(getterName, fa
lse, null); |
| 405 classA.accessors = <PropertyAccessorElement> [getter]; | 404 classA.accessors = <PropertyAccessorElement> [getter]; |
| 406 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla
ssElement> [classA]; | 405 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla
ssElement> [classA]; |
| 407 JUnitTestCase.assertNull(classA.lookUpInheritedConcreteGetter(getterName, li
brary)); | 406 expect(classA.lookUpInheritedConcreteGetter(getterName, library), isNull); |
| 408 } | 407 } |
| 409 | 408 |
| 410 void test_lookUpInheritedConcreteGetter_inherited() { | 409 void test_lookUpInheritedConcreteGetter_inherited() { |
| 411 // class A { | 410 // class A { |
| 412 // get g {} | 411 // get g {} |
| 413 // } | 412 // } |
| 414 // class B extends A { | 413 // class B extends A { |
| 415 // } | 414 // } |
| 416 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(),
"lib"); | 415 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(),
"lib"); |
| 417 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 416 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 418 String getterName = "g"; | 417 String getterName = "g"; |
| 419 PropertyAccessorElement inheritedGetter = ElementFactory.getterElement(gette
rName, false, null); | 418 PropertyAccessorElement inheritedGetter = ElementFactory.getterElement(gette
rName, false, null); |
| 420 classA.accessors = <PropertyAccessorElement> [inheritedGetter]; | 419 classA.accessors = <PropertyAccessorElement> [inheritedGetter]; |
| 421 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); | 420 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); |
| 422 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla
ssElement> [classA, classB]; | 421 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla
ssElement> [classA, classB]; |
| 423 JUnitTestCase.assertSame(inheritedGetter, classB.lookUpInheritedConcreteGett
er(getterName, library)); | 422 expect(classB.lookUpInheritedConcreteGetter(getterName, library), same(inher
itedGetter)); |
| 424 } | 423 } |
| 425 | 424 |
| 426 void test_lookUpInheritedConcreteGetter_undeclared() { | 425 void test_lookUpInheritedConcreteGetter_undeclared() { |
| 427 // class A { | 426 // class A { |
| 428 // } | 427 // } |
| 429 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(),
"lib"); | 428 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(),
"lib"); |
| 430 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 429 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 431 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla
ssElement> [classA]; | 430 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla
ssElement> [classA]; |
| 432 JUnitTestCase.assertNull(classA.lookUpInheritedConcreteGetter("g", library))
; | 431 expect(classA.lookUpInheritedConcreteGetter("g", library), isNull); |
| 433 } | 432 } |
| 434 | 433 |
| 435 void test_lookUpInheritedConcreteGetter_undeclared_recursive() { | 434 void test_lookUpInheritedConcreteGetter_undeclared_recursive() { |
| 436 // class A extends B { | 435 // class A extends B { |
| 437 // } | 436 // } |
| 438 // class B extends A { | 437 // class B extends A { |
| 439 // } | 438 // } |
| 440 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(),
"lib"); | 439 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(),
"lib"); |
| 441 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 440 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 442 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); | 441 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); |
| 443 classA.supertype = classB.type; | 442 classA.supertype = classB.type; |
| 444 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla
ssElement> [classA, classB]; | 443 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla
ssElement> [classA, classB]; |
| 445 JUnitTestCase.assertNull(classA.lookUpInheritedConcreteGetter("g", library))
; | 444 expect(classA.lookUpInheritedConcreteGetter("g", library), isNull); |
| 446 } | 445 } |
| 447 | 446 |
| 448 void test_lookUpInheritedConcreteMethod_declared() { | 447 void test_lookUpInheritedConcreteMethod_declared() { |
| 449 // class A { | 448 // class A { |
| 450 // m() {} | 449 // m() {} |
| 451 // } | 450 // } |
| 452 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(),
"lib"); | 451 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(),
"lib"); |
| 453 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 452 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 454 String methodName = "m"; | 453 String methodName = "m"; |
| 455 MethodElement method = ElementFactory.methodElement(methodName, null, []); | 454 MethodElement method = ElementFactory.methodElement(methodName, null, []); |
| 456 classA.methods = <MethodElement> [method]; | 455 classA.methods = <MethodElement> [method]; |
| 457 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla
ssElement> [classA]; | 456 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla
ssElement> [classA]; |
| 458 JUnitTestCase.assertNull(classA.lookUpInheritedConcreteMethod(methodName, li
brary)); | 457 expect(classA.lookUpInheritedConcreteMethod(methodName, library), isNull); |
| 459 } | 458 } |
| 460 | 459 |
| 461 void test_lookUpInheritedConcreteMethod_declaredAbstractAndInherited() { | 460 void test_lookUpInheritedConcreteMethod_declaredAbstractAndInherited() { |
| 462 // class A { | 461 // class A { |
| 463 // m() {} | 462 // m() {} |
| 464 // } | 463 // } |
| 465 // class B extends A { | 464 // class B extends A { |
| 466 // m(); | 465 // m(); |
| 467 // } | 466 // } |
| 468 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(),
"lib"); | 467 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(),
"lib"); |
| 469 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 468 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 470 String methodName = "m"; | 469 String methodName = "m"; |
| 471 MethodElement inheritedMethod = ElementFactory.methodElement(methodName, nul
l, []); | 470 MethodElement inheritedMethod = ElementFactory.methodElement(methodName, nul
l, []); |
| 472 classA.methods = <MethodElement> [inheritedMethod]; | 471 classA.methods = <MethodElement> [inheritedMethod]; |
| 473 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); | 472 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); |
| 474 MethodElementImpl method = ElementFactory.methodElement(methodName, null, []
); | 473 MethodElementImpl method = ElementFactory.methodElement(methodName, null, []
); |
| 475 method.abstract = true; | 474 method.abstract = true; |
| 476 classB.methods = <MethodElement> [method]; | 475 classB.methods = <MethodElement> [method]; |
| 477 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla
ssElement> [classA, classB]; | 476 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla
ssElement> [classA, classB]; |
| 478 JUnitTestCase.assertSame(inheritedMethod, classB.lookUpInheritedConcreteMeth
od(methodName, library)); | 477 expect(classB.lookUpInheritedConcreteMethod(methodName, library), same(inher
itedMethod)); |
| 479 } | 478 } |
| 480 | 479 |
| 481 void test_lookUpInheritedConcreteMethod_declaredAndInherited() { | 480 void test_lookUpInheritedConcreteMethod_declaredAndInherited() { |
| 482 // class A { | 481 // class A { |
| 483 // m() {} | 482 // m() {} |
| 484 // } | 483 // } |
| 485 // class B extends A { | 484 // class B extends A { |
| 486 // m() {} | 485 // m() {} |
| 487 // } | 486 // } |
| 488 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(),
"lib"); | 487 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(),
"lib"); |
| 489 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 488 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 490 String methodName = "m"; | 489 String methodName = "m"; |
| 491 MethodElement inheritedMethod = ElementFactory.methodElement(methodName, nul
l, []); | 490 MethodElement inheritedMethod = ElementFactory.methodElement(methodName, nul
l, []); |
| 492 classA.methods = <MethodElement> [inheritedMethod]; | 491 classA.methods = <MethodElement> [inheritedMethod]; |
| 493 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); | 492 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); |
| 494 MethodElement method = ElementFactory.methodElement(methodName, null, []); | 493 MethodElement method = ElementFactory.methodElement(methodName, null, []); |
| 495 classB.methods = <MethodElement> [method]; | 494 classB.methods = <MethodElement> [method]; |
| 496 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla
ssElement> [classA, classB]; | 495 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla
ssElement> [classA, classB]; |
| 497 JUnitTestCase.assertSame(inheritedMethod, classB.lookUpInheritedConcreteMeth
od(methodName, library)); | 496 expect(classB.lookUpInheritedConcreteMethod(methodName, library), same(inher
itedMethod)); |
| 498 } | 497 } |
| 499 | 498 |
| 500 void test_lookUpInheritedConcreteMethod_declaredAndInheritedAbstract() { | 499 void test_lookUpInheritedConcreteMethod_declaredAndInheritedAbstract() { |
| 501 // abstract class A { | 500 // abstract class A { |
| 502 // m(); | 501 // m(); |
| 503 // } | 502 // } |
| 504 // class B extends A { | 503 // class B extends A { |
| 505 // m() {} | 504 // m() {} |
| 506 // } | 505 // } |
| 507 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(),
"lib"); | 506 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(),
"lib"); |
| 508 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 507 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 509 classA.abstract = true; | 508 classA.abstract = true; |
| 510 String methodName = "m"; | 509 String methodName = "m"; |
| 511 MethodElementImpl inheritedMethod = ElementFactory.methodElement(methodName,
null, []); | 510 MethodElementImpl inheritedMethod = ElementFactory.methodElement(methodName,
null, []); |
| 512 inheritedMethod.abstract = true; | 511 inheritedMethod.abstract = true; |
| 513 classA.methods = <MethodElement> [inheritedMethod]; | 512 classA.methods = <MethodElement> [inheritedMethod]; |
| 514 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); | 513 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); |
| 515 MethodElement method = ElementFactory.methodElement(methodName, null, []); | 514 MethodElement method = ElementFactory.methodElement(methodName, null, []); |
| 516 classB.methods = <MethodElement> [method]; | 515 classB.methods = <MethodElement> [method]; |
| 517 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla
ssElement> [classA, classB]; | 516 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla
ssElement> [classA, classB]; |
| 518 JUnitTestCase.assertNull(classB.lookUpInheritedConcreteMethod(methodName, li
brary)); | 517 expect(classB.lookUpInheritedConcreteMethod(methodName, library), isNull); |
| 519 } | 518 } |
| 520 | 519 |
| 521 void test_lookUpInheritedConcreteMethod_declaredAndInheritedWithAbstractBetwee
n() { | 520 void test_lookUpInheritedConcreteMethod_declaredAndInheritedWithAbstractBetwee
n() { |
| 522 // class A { | 521 // class A { |
| 523 // m() {} | 522 // m() {} |
| 524 // } | 523 // } |
| 525 // class B extends A { | 524 // class B extends A { |
| 526 // m(); | 525 // m(); |
| 527 // } | 526 // } |
| 528 // class C extends B { | 527 // class C extends B { |
| 529 // m() {} | 528 // m() {} |
| 530 // } | 529 // } |
| 531 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(),
"lib"); | 530 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(),
"lib"); |
| 532 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 531 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 533 String methodName = "m"; | 532 String methodName = "m"; |
| 534 MethodElement inheritedMethod = ElementFactory.methodElement(methodName, nul
l, []); | 533 MethodElement inheritedMethod = ElementFactory.methodElement(methodName, nul
l, []); |
| 535 classA.methods = <MethodElement> [inheritedMethod]; | 534 classA.methods = <MethodElement> [inheritedMethod]; |
| 536 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); | 535 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); |
| 537 MethodElementImpl abstractMethod = ElementFactory.methodElement(methodName,
null, []); | 536 MethodElementImpl abstractMethod = ElementFactory.methodElement(methodName,
null, []); |
| 538 abstractMethod.abstract = true; | 537 abstractMethod.abstract = true; |
| 539 classB.methods = <MethodElement> [abstractMethod]; | 538 classB.methods = <MethodElement> [abstractMethod]; |
| 540 ClassElementImpl classC = ElementFactory.classElement("C", classB.type, []); | 539 ClassElementImpl classC = ElementFactory.classElement("C", classB.type, []); |
| 541 MethodElementImpl method = ElementFactory.methodElement(methodName, null, []
); | 540 MethodElementImpl method = ElementFactory.methodElement(methodName, null, []
); |
| 542 classC.methods = <MethodElement> [method]; | 541 classC.methods = <MethodElement> [method]; |
| 543 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla
ssElement> [classA, classB, classC]; | 542 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla
ssElement> [classA, classB, classC]; |
| 544 JUnitTestCase.assertSame(inheritedMethod, classC.lookUpInheritedConcreteMeth
od(methodName, library)); | 543 expect(classC.lookUpInheritedConcreteMethod(methodName, library), same(inher
itedMethod)); |
| 545 } | 544 } |
| 546 | 545 |
| 547 void test_lookUpInheritedConcreteMethod_inherited() { | 546 void test_lookUpInheritedConcreteMethod_inherited() { |
| 548 // class A { | 547 // class A { |
| 549 // m() {} | 548 // m() {} |
| 550 // } | 549 // } |
| 551 // class B extends A { | 550 // class B extends A { |
| 552 // } | 551 // } |
| 553 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(),
"lib"); | 552 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(),
"lib"); |
| 554 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 553 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 555 String methodName = "m"; | 554 String methodName = "m"; |
| 556 MethodElement inheritedMethod = ElementFactory.methodElement(methodName, nul
l, []); | 555 MethodElement inheritedMethod = ElementFactory.methodElement(methodName, nul
l, []); |
| 557 classA.methods = <MethodElement> [inheritedMethod]; | 556 classA.methods = <MethodElement> [inheritedMethod]; |
| 558 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); | 557 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); |
| 559 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla
ssElement> [classA, classB]; | 558 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla
ssElement> [classA, classB]; |
| 560 JUnitTestCase.assertSame(inheritedMethod, classB.lookUpInheritedConcreteMeth
od(methodName, library)); | 559 expect(classB.lookUpInheritedConcreteMethod(methodName, library), same(inher
itedMethod)); |
| 561 } | 560 } |
| 562 | 561 |
| 563 void test_lookUpInheritedConcreteMethod_undeclared() { | 562 void test_lookUpInheritedConcreteMethod_undeclared() { |
| 564 // class A { | 563 // class A { |
| 565 // } | 564 // } |
| 566 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(),
"lib"); | 565 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(),
"lib"); |
| 567 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 566 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 568 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla
ssElement> [classA]; | 567 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla
ssElement> [classA]; |
| 569 JUnitTestCase.assertNull(classA.lookUpInheritedConcreteMethod("m", library))
; | 568 expect(classA.lookUpInheritedConcreteMethod("m", library), isNull); |
| 570 } | 569 } |
| 571 | 570 |
| 572 void test_lookUpInheritedConcreteSetter_declared() { | 571 void test_lookUpInheritedConcreteSetter_declared() { |
| 573 // class A { | 572 // class A { |
| 574 // set g(x) {} | 573 // set g(x) {} |
| 575 // } | 574 // } |
| 576 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(),
"lib"); | 575 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(),
"lib"); |
| 577 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 576 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 578 String setterName = "s"; | 577 String setterName = "s"; |
| 579 PropertyAccessorElement setter = ElementFactory.setterElement(setterName, fa
lse, null); | 578 PropertyAccessorElement setter = ElementFactory.setterElement(setterName, fa
lse, null); |
| 580 classA.accessors = <PropertyAccessorElement> [setter]; | 579 classA.accessors = <PropertyAccessorElement> [setter]; |
| 581 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla
ssElement> [classA]; | 580 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla
ssElement> [classA]; |
| 582 JUnitTestCase.assertNull(classA.lookUpInheritedConcreteSetter(setterName, li
brary)); | 581 expect(classA.lookUpInheritedConcreteSetter(setterName, library), isNull); |
| 583 } | 582 } |
| 584 | 583 |
| 585 void test_lookUpInheritedConcreteSetter_inherited() { | 584 void test_lookUpInheritedConcreteSetter_inherited() { |
| 586 // class A { | 585 // class A { |
| 587 // set g(x) {} | 586 // set g(x) {} |
| 588 // } | 587 // } |
| 589 // class B extends A { | 588 // class B extends A { |
| 590 // } | 589 // } |
| 591 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(),
"lib"); | 590 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(),
"lib"); |
| 592 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 591 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 593 String setterName = "s"; | 592 String setterName = "s"; |
| 594 PropertyAccessorElement setter = ElementFactory.setterElement(setterName, fa
lse, null); | 593 PropertyAccessorElement setter = ElementFactory.setterElement(setterName, fa
lse, null); |
| 595 classA.accessors = <PropertyAccessorElement> [setter]; | 594 classA.accessors = <PropertyAccessorElement> [setter]; |
| 596 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); | 595 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); |
| 597 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla
ssElement> [classA, classB]; | 596 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla
ssElement> [classA, classB]; |
| 598 JUnitTestCase.assertSame(setter, classB.lookUpInheritedConcreteSetter(setter
Name, library)); | 597 expect(classB.lookUpInheritedConcreteSetter(setterName, library), same(sette
r)); |
| 599 } | 598 } |
| 600 | 599 |
| 601 void test_lookUpInheritedConcreteSetter_undeclared() { | 600 void test_lookUpInheritedConcreteSetter_undeclared() { |
| 602 // class A { | 601 // class A { |
| 603 // } | 602 // } |
| 604 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(),
"lib"); | 603 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(),
"lib"); |
| 605 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 604 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 606 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla
ssElement> [classA]; | 605 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla
ssElement> [classA]; |
| 607 JUnitTestCase.assertNull(classA.lookUpInheritedConcreteSetter("s", library))
; | 606 expect(classA.lookUpInheritedConcreteSetter("s", library), isNull); |
| 608 } | 607 } |
| 609 | 608 |
| 610 void test_lookUpInheritedConcreteSetter_undeclared_recursive() { | 609 void test_lookUpInheritedConcreteSetter_undeclared_recursive() { |
| 611 // class A extends B { | 610 // class A extends B { |
| 612 // } | 611 // } |
| 613 // class B extends A { | 612 // class B extends A { |
| 614 // } | 613 // } |
| 615 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(),
"lib"); | 614 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(),
"lib"); |
| 616 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 615 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 617 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); | 616 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); |
| 618 classA.supertype = classB.type; | 617 classA.supertype = classB.type; |
| 619 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla
ssElement> [classA, classB]; | 618 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla
ssElement> [classA, classB]; |
| 620 JUnitTestCase.assertNull(classA.lookUpInheritedConcreteSetter("s", library))
; | 619 expect(classA.lookUpInheritedConcreteSetter("s", library), isNull); |
| 621 } | 620 } |
| 622 | 621 |
| 623 void test_lookUpInheritedMethod_declared() { | 622 void test_lookUpInheritedMethod_declared() { |
| 624 // class A { | 623 // class A { |
| 625 // m() {} | 624 // m() {} |
| 626 // } | 625 // } |
| 627 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(),
"lib"); | 626 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(),
"lib"); |
| 628 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 627 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 629 String methodName = "m"; | 628 String methodName = "m"; |
| 630 MethodElement method = ElementFactory.methodElement(methodName, null, []); | 629 MethodElement method = ElementFactory.methodElement(methodName, null, []); |
| 631 classA.methods = <MethodElement> [method]; | 630 classA.methods = <MethodElement> [method]; |
| 632 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla
ssElement> [classA]; | 631 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla
ssElement> [classA]; |
| 633 JUnitTestCase.assertNull(classA.lookUpInheritedMethod(methodName, library)); | 632 expect(classA.lookUpInheritedMethod(methodName, library), isNull); |
| 634 } | 633 } |
| 635 | 634 |
| 636 void test_lookUpInheritedMethod_declaredAndInherited() { | 635 void test_lookUpInheritedMethod_declaredAndInherited() { |
| 637 // class A { | 636 // class A { |
| 638 // m() {} | 637 // m() {} |
| 639 // } | 638 // } |
| 640 // class B extends A { | 639 // class B extends A { |
| 641 // m() {} | 640 // m() {} |
| 642 // } | 641 // } |
| 643 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(),
"lib"); | 642 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(),
"lib"); |
| 644 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 643 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 645 String methodName = "m"; | 644 String methodName = "m"; |
| 646 MethodElement inheritedMethod = ElementFactory.methodElement(methodName, nul
l, []); | 645 MethodElement inheritedMethod = ElementFactory.methodElement(methodName, nul
l, []); |
| 647 classA.methods = <MethodElement> [inheritedMethod]; | 646 classA.methods = <MethodElement> [inheritedMethod]; |
| 648 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); | 647 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); |
| 649 MethodElement method = ElementFactory.methodElement(methodName, null, []); | 648 MethodElement method = ElementFactory.methodElement(methodName, null, []); |
| 650 classB.methods = <MethodElement> [method]; | 649 classB.methods = <MethodElement> [method]; |
| 651 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla
ssElement> [classA, classB]; | 650 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla
ssElement> [classA, classB]; |
| 652 JUnitTestCase.assertSame(inheritedMethod, classB.lookUpInheritedMethod(metho
dName, library)); | 651 expect(classB.lookUpInheritedMethod(methodName, library), same(inheritedMeth
od)); |
| 653 } | 652 } |
| 654 | 653 |
| 655 void test_lookUpInheritedMethod_inherited() { | 654 void test_lookUpInheritedMethod_inherited() { |
| 656 // class A { | 655 // class A { |
| 657 // m() {} | 656 // m() {} |
| 658 // } | 657 // } |
| 659 // class B extends A { | 658 // class B extends A { |
| 660 // } | 659 // } |
| 661 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(),
"lib"); | 660 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(),
"lib"); |
| 662 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 661 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 663 String methodName = "m"; | 662 String methodName = "m"; |
| 664 MethodElement inheritedMethod = ElementFactory.methodElement(methodName, nul
l, []); | 663 MethodElement inheritedMethod = ElementFactory.methodElement(methodName, nul
l, []); |
| 665 classA.methods = <MethodElement> [inheritedMethod]; | 664 classA.methods = <MethodElement> [inheritedMethod]; |
| 666 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); | 665 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); |
| 667 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla
ssElement> [classA, classB]; | 666 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla
ssElement> [classA, classB]; |
| 668 JUnitTestCase.assertSame(inheritedMethod, classB.lookUpInheritedMethod(metho
dName, library)); | 667 expect(classB.lookUpInheritedMethod(methodName, library), same(inheritedMeth
od)); |
| 669 } | 668 } |
| 670 | 669 |
| 671 void test_lookUpInheritedMethod_undeclared() { | 670 void test_lookUpInheritedMethod_undeclared() { |
| 672 // class A { | 671 // class A { |
| 673 // } | 672 // } |
| 674 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(),
"lib"); | 673 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(),
"lib"); |
| 675 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 674 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 676 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla
ssElement> [classA]; | 675 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla
ssElement> [classA]; |
| 677 JUnitTestCase.assertNull(classA.lookUpInheritedMethod("m", library)); | 676 expect(classA.lookUpInheritedMethod("m", library), isNull); |
| 678 } | 677 } |
| 679 | 678 |
| 680 void test_lookUpMethod_declared() { | 679 void test_lookUpMethod_declared() { |
| 681 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(),
"lib"); | 680 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(),
"lib"); |
| 682 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 681 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 683 String methodName = "m"; | 682 String methodName = "m"; |
| 684 MethodElement method = ElementFactory.methodElement(methodName, null, []); | 683 MethodElement method = ElementFactory.methodElement(methodName, null, []); |
| 685 classA.methods = <MethodElement> [method]; | 684 classA.methods = <MethodElement> [method]; |
| 686 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla
ssElement> [classA]; | 685 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla
ssElement> [classA]; |
| 687 JUnitTestCase.assertSame(method, classA.lookUpMethod(methodName, library)); | 686 expect(classA.lookUpMethod(methodName, library), same(method)); |
| 688 } | 687 } |
| 689 | 688 |
| 690 void test_lookUpMethod_inherited() { | 689 void test_lookUpMethod_inherited() { |
| 691 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(),
"lib"); | 690 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(),
"lib"); |
| 692 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 691 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 693 String methodName = "m"; | 692 String methodName = "m"; |
| 694 MethodElement method = ElementFactory.methodElement(methodName, null, []); | 693 MethodElement method = ElementFactory.methodElement(methodName, null, []); |
| 695 classA.methods = <MethodElement> [method]; | 694 classA.methods = <MethodElement> [method]; |
| 696 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); | 695 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); |
| 697 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla
ssElement> [classA, classB]; | 696 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla
ssElement> [classA, classB]; |
| 698 JUnitTestCase.assertSame(method, classB.lookUpMethod(methodName, library)); | 697 expect(classB.lookUpMethod(methodName, library), same(method)); |
| 699 } | 698 } |
| 700 | 699 |
| 701 void test_lookUpMethod_undeclared() { | 700 void test_lookUpMethod_undeclared() { |
| 702 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(),
"lib"); | 701 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(),
"lib"); |
| 703 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 702 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 704 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla
ssElement> [classA]; | 703 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla
ssElement> [classA]; |
| 705 JUnitTestCase.assertNull(classA.lookUpMethod("m", library)); | 704 expect(classA.lookUpMethod("m", library), isNull); |
| 706 } | 705 } |
| 707 | 706 |
| 708 void test_lookUpMethod_undeclared_recursive() { | 707 void test_lookUpMethod_undeclared_recursive() { |
| 709 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(),
"lib"); | 708 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(),
"lib"); |
| 710 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 709 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 711 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); | 710 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); |
| 712 classA.supertype = classB.type; | 711 classA.supertype = classB.type; |
| 713 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla
ssElement> [classA, classB]; | 712 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla
ssElement> [classA, classB]; |
| 714 JUnitTestCase.assertNull(classA.lookUpMethod("m", library)); | 713 expect(classA.lookUpMethod("m", library), isNull); |
| 715 } | 714 } |
| 716 | 715 |
| 717 void test_lookUpSetter_declared() { | 716 void test_lookUpSetter_declared() { |
| 718 // class A { | 717 // class A { |
| 719 // set g(x) {} | 718 // set g(x) {} |
| 720 // } | 719 // } |
| 721 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(),
"lib"); | 720 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(),
"lib"); |
| 722 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 721 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 723 String setterName = "s"; | 722 String setterName = "s"; |
| 724 PropertyAccessorElement setter = ElementFactory.setterElement(setterName, fa
lse, null); | 723 PropertyAccessorElement setter = ElementFactory.setterElement(setterName, fa
lse, null); |
| 725 classA.accessors = <PropertyAccessorElement> [setter]; | 724 classA.accessors = <PropertyAccessorElement> [setter]; |
| 726 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla
ssElement> [classA]; | 725 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla
ssElement> [classA]; |
| 727 JUnitTestCase.assertSame(setter, classA.lookUpSetter(setterName, library)); | 726 expect(classA.lookUpSetter(setterName, library), same(setter)); |
| 728 } | 727 } |
| 729 | 728 |
| 730 void test_lookUpSetter_inherited() { | 729 void test_lookUpSetter_inherited() { |
| 731 // class A { | 730 // class A { |
| 732 // set g(x) {} | 731 // set g(x) {} |
| 733 // } | 732 // } |
| 734 // class B extends A { | 733 // class B extends A { |
| 735 // } | 734 // } |
| 736 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(),
"lib"); | 735 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(),
"lib"); |
| 737 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 736 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 738 String setterName = "s"; | 737 String setterName = "s"; |
| 739 PropertyAccessorElement setter = ElementFactory.setterElement(setterName, fa
lse, null); | 738 PropertyAccessorElement setter = ElementFactory.setterElement(setterName, fa
lse, null); |
| 740 classA.accessors = <PropertyAccessorElement> [setter]; | 739 classA.accessors = <PropertyAccessorElement> [setter]; |
| 741 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); | 740 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); |
| 742 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla
ssElement> [classA, classB]; | 741 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla
ssElement> [classA, classB]; |
| 743 JUnitTestCase.assertSame(setter, classB.lookUpSetter(setterName, library)); | 742 expect(classB.lookUpSetter(setterName, library), same(setter)); |
| 744 } | 743 } |
| 745 | 744 |
| 746 void test_lookUpSetter_undeclared() { | 745 void test_lookUpSetter_undeclared() { |
| 747 // class A { | 746 // class A { |
| 748 // } | 747 // } |
| 749 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(),
"lib"); | 748 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(),
"lib"); |
| 750 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 749 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 751 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla
ssElement> [classA]; | 750 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla
ssElement> [classA]; |
| 752 JUnitTestCase.assertNull(classA.lookUpSetter("s", library)); | 751 expect(classA.lookUpSetter("s", library), isNull); |
| 753 } | 752 } |
| 754 | 753 |
| 755 void test_lookUpSetter_undeclared_recursive() { | 754 void test_lookUpSetter_undeclared_recursive() { |
| 756 // class A extends B { | 755 // class A extends B { |
| 757 // } | 756 // } |
| 758 // class B extends A { | 757 // class B extends A { |
| 759 // } | 758 // } |
| 760 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(),
"lib"); | 759 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(),
"lib"); |
| 761 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 760 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 762 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); | 761 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); |
| 763 classA.supertype = classB.type; | 762 classA.supertype = classB.type; |
| 764 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla
ssElement> [classA, classB]; | 763 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla
ssElement> [classA, classB]; |
| 765 JUnitTestCase.assertNull(classA.lookUpSetter("s", library)); | 764 expect(classA.lookUpSetter("s", library), isNull); |
| 766 } | 765 } |
| 767 } | 766 } |
| 768 | 767 |
| 769 class CompilationUnitElementImplTest extends EngineTestCase { | 768 class CompilationUnitElementImplTest extends EngineTestCase { |
| 770 void test_getEnum_declared() { | 769 void test_getEnum_declared() { |
| 771 TestTypeProvider typeProvider = new TestTypeProvider(); | 770 TestTypeProvider typeProvider = new TestTypeProvider(); |
| 772 CompilationUnitElementImpl unit = ElementFactory.compilationUnit("/lib.dart"
); | 771 CompilationUnitElementImpl unit = ElementFactory.compilationUnit("/lib.dart"
); |
| 773 String enumName = "E"; | 772 String enumName = "E"; |
| 774 ClassElement enumElement = ElementFactory.enumElement(typeProvider, enumName
, []); | 773 ClassElement enumElement = ElementFactory.enumElement(typeProvider, enumName
, []); |
| 775 unit.enums = <ClassElement> [enumElement]; | 774 unit.enums = <ClassElement> [enumElement]; |
| 776 JUnitTestCase.assertSame(enumElement, unit.getEnum(enumName)); | 775 expect(unit.getEnum(enumName), same(enumElement)); |
| 777 } | 776 } |
| 778 | 777 |
| 779 void test_getEnum_undeclared() { | 778 void test_getEnum_undeclared() { |
| 780 TestTypeProvider typeProvider = new TestTypeProvider(); | 779 TestTypeProvider typeProvider = new TestTypeProvider(); |
| 781 CompilationUnitElementImpl unit = ElementFactory.compilationUnit("/lib.dart"
); | 780 CompilationUnitElementImpl unit = ElementFactory.compilationUnit("/lib.dart"
); |
| 782 String enumName = "E"; | 781 String enumName = "E"; |
| 783 ClassElement enumElement = ElementFactory.enumElement(typeProvider, enumName
, []); | 782 ClassElement enumElement = ElementFactory.enumElement(typeProvider, enumName
, []); |
| 784 unit.enums = <ClassElement> [enumElement]; | 783 unit.enums = <ClassElement> [enumElement]; |
| 785 JUnitTestCase.assertNull(unit.getEnum("${enumName}x")); | 784 expect(unit.getEnum("${enumName}x"), isNull); |
| 786 } | 785 } |
| 787 | 786 |
| 788 void test_getType_declared() { | 787 void test_getType_declared() { |
| 789 CompilationUnitElementImpl unit = ElementFactory.compilationUnit("/lib.dart"
); | 788 CompilationUnitElementImpl unit = ElementFactory.compilationUnit("/lib.dart"
); |
| 790 String className = "C"; | 789 String className = "C"; |
| 791 ClassElement classElement = ElementFactory.classElement2(className, []); | 790 ClassElement classElement = ElementFactory.classElement2(className, []); |
| 792 unit.types = <ClassElement> [classElement]; | 791 unit.types = <ClassElement> [classElement]; |
| 793 JUnitTestCase.assertSame(classElement, unit.getType(className)); | 792 expect(unit.getType(className), same(classElement)); |
| 794 } | 793 } |
| 795 | 794 |
| 796 void test_getType_undeclared() { | 795 void test_getType_undeclared() { |
| 797 CompilationUnitElementImpl unit = ElementFactory.compilationUnit("/lib.dart"
); | 796 CompilationUnitElementImpl unit = ElementFactory.compilationUnit("/lib.dart"
); |
| 798 String className = "C"; | 797 String className = "C"; |
| 799 ClassElement classElement = ElementFactory.classElement2(className, []); | 798 ClassElement classElement = ElementFactory.classElement2(className, []); |
| 800 unit.types = <ClassElement> [classElement]; | 799 unit.types = <ClassElement> [classElement]; |
| 801 JUnitTestCase.assertNull(unit.getType("${className}x")); | 800 expect(unit.getType("${className}x"), isNull); |
| 802 } | 801 } |
| 803 } | 802 } |
| 804 | 803 |
| 805 class ElementImplTest extends EngineTestCase { | 804 class ElementImplTest extends EngineTestCase { |
| 806 void test_equals() { | 805 void test_equals() { |
| 807 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(),
"lib"); | 806 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(),
"lib"); |
| 808 ClassElementImpl classElement = ElementFactory.classElement2("C", []); | 807 ClassElementImpl classElement = ElementFactory.classElement2("C", []); |
| 809 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla
ssElement> [classElement]; | 808 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla
ssElement> [classElement]; |
| 810 FieldElement field = ElementFactory.fieldElement("next", false, false, false
, classElement.type); | 809 FieldElement field = ElementFactory.fieldElement("next", false, false, false
, classElement.type); |
| 811 classElement.fields = <FieldElement> [field]; | 810 classElement.fields = <FieldElement> [field]; |
| 812 JUnitTestCase.assertTrue(field == field); | 811 expect(field == field, isTrue); |
| 813 JUnitTestCase.assertFalse(field == field.getter); | 812 expect(field == field.getter, isFalse); |
| 814 JUnitTestCase.assertFalse(field == field.setter); | 813 expect(field == field.setter, isFalse); |
| 815 JUnitTestCase.assertFalse(field.getter == field.setter); | 814 expect(field.getter == field.setter, isFalse); |
| 816 } | 815 } |
| 817 | 816 |
| 818 void test_isAccessibleIn_private_differentLibrary() { | 817 void test_isAccessibleIn_private_differentLibrary() { |
| 819 AnalysisContextImpl context = createAnalysisContext(); | 818 AnalysisContextImpl context = createAnalysisContext(); |
| 820 LibraryElementImpl library1 = ElementFactory.library(context, "lib1"); | 819 LibraryElementImpl library1 = ElementFactory.library(context, "lib1"); |
| 821 ClassElement classElement = ElementFactory.classElement2("_C", []); | 820 ClassElement classElement = ElementFactory.classElement2("_C", []); |
| 822 (library1.definingCompilationUnit as CompilationUnitElementImpl).types = <Cl
assElement> [classElement]; | 821 (library1.definingCompilationUnit as CompilationUnitElementImpl).types = <Cl
assElement> [classElement]; |
| 823 LibraryElementImpl library2 = ElementFactory.library(context, "lib2"); | 822 LibraryElementImpl library2 = ElementFactory.library(context, "lib2"); |
| 824 JUnitTestCase.assertFalse(classElement.isAccessibleIn(library2)); | 823 expect(classElement.isAccessibleIn(library2), isFalse); |
| 825 } | 824 } |
| 826 | 825 |
| 827 void test_isAccessibleIn_private_sameLibrary() { | 826 void test_isAccessibleIn_private_sameLibrary() { |
| 828 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(),
"lib"); | 827 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(),
"lib"); |
| 829 ClassElement classElement = ElementFactory.classElement2("_C", []); | 828 ClassElement classElement = ElementFactory.classElement2("_C", []); |
| 830 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla
ssElement> [classElement]; | 829 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla
ssElement> [classElement]; |
| 831 JUnitTestCase.assertTrue(classElement.isAccessibleIn(library)); | 830 expect(classElement.isAccessibleIn(library), isTrue); |
| 832 } | 831 } |
| 833 | 832 |
| 834 void test_isAccessibleIn_public_differentLibrary() { | 833 void test_isAccessibleIn_public_differentLibrary() { |
| 835 AnalysisContextImpl context = createAnalysisContext(); | 834 AnalysisContextImpl context = createAnalysisContext(); |
| 836 LibraryElementImpl library1 = ElementFactory.library(context, "lib1"); | 835 LibraryElementImpl library1 = ElementFactory.library(context, "lib1"); |
| 837 ClassElement classElement = ElementFactory.classElement2("C", []); | 836 ClassElement classElement = ElementFactory.classElement2("C", []); |
| 838 (library1.definingCompilationUnit as CompilationUnitElementImpl).types = <Cl
assElement> [classElement]; | 837 (library1.definingCompilationUnit as CompilationUnitElementImpl).types = <Cl
assElement> [classElement]; |
| 839 LibraryElementImpl library2 = ElementFactory.library(context, "lib2"); | 838 LibraryElementImpl library2 = ElementFactory.library(context, "lib2"); |
| 840 JUnitTestCase.assertTrue(classElement.isAccessibleIn(library2)); | 839 expect(classElement.isAccessibleIn(library2), isTrue); |
| 841 } | 840 } |
| 842 | 841 |
| 843 void test_isAccessibleIn_public_sameLibrary() { | 842 void test_isAccessibleIn_public_sameLibrary() { |
| 844 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(),
"lib"); | 843 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(),
"lib"); |
| 845 ClassElement classElement = ElementFactory.classElement2("C", []); | 844 ClassElement classElement = ElementFactory.classElement2("C", []); |
| 846 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla
ssElement> [classElement]; | 845 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla
ssElement> [classElement]; |
| 847 JUnitTestCase.assertTrue(classElement.isAccessibleIn(library)); | 846 expect(classElement.isAccessibleIn(library), isTrue); |
| 848 } | 847 } |
| 849 | 848 |
| 850 void test_isPrivate_false() { | 849 void test_isPrivate_false() { |
| 851 Element element = ElementFactory.classElement2("C", []); | 850 Element element = ElementFactory.classElement2("C", []); |
| 852 JUnitTestCase.assertFalse(element.isPrivate); | 851 expect(element.isPrivate, isFalse); |
| 853 } | 852 } |
| 854 | 853 |
| 855 void test_isPrivate_null() { | 854 void test_isPrivate_null() { |
| 856 Element element = ElementFactory.classElement2(null, []); | 855 Element element = ElementFactory.classElement2(null, []); |
| 857 JUnitTestCase.assertTrue(element.isPrivate); | 856 expect(element.isPrivate, isTrue); |
| 858 } | 857 } |
| 859 | 858 |
| 860 void test_isPrivate_true() { | 859 void test_isPrivate_true() { |
| 861 Element element = ElementFactory.classElement2("_C", []); | 860 Element element = ElementFactory.classElement2("_C", []); |
| 862 JUnitTestCase.assertTrue(element.isPrivate); | 861 expect(element.isPrivate, isTrue); |
| 863 } | 862 } |
| 864 | 863 |
| 865 void test_isPublic_false() { | 864 void test_isPublic_false() { |
| 866 Element element = ElementFactory.classElement2("_C", []); | 865 Element element = ElementFactory.classElement2("_C", []); |
| 867 JUnitTestCase.assertFalse(element.isPublic); | 866 expect(element.isPublic, isFalse); |
| 868 } | 867 } |
| 869 | 868 |
| 870 void test_isPublic_null() { | 869 void test_isPublic_null() { |
| 871 Element element = ElementFactory.classElement2(null, []); | 870 Element element = ElementFactory.classElement2(null, []); |
| 872 JUnitTestCase.assertFalse(element.isPublic); | 871 expect(element.isPublic, isFalse); |
| 873 } | 872 } |
| 874 | 873 |
| 875 void test_isPublic_true() { | 874 void test_isPublic_true() { |
| 876 Element element = ElementFactory.classElement2("C", []); | 875 Element element = ElementFactory.classElement2("C", []); |
| 877 JUnitTestCase.assertTrue(element.isPublic); | 876 expect(element.isPublic, isTrue); |
| 878 } | 877 } |
| 879 | 878 |
| 880 void test_SORT_BY_OFFSET() { | 879 void test_SORT_BY_OFFSET() { |
| 881 ClassElementImpl classElementA = ElementFactory.classElement2("A", []); | 880 ClassElementImpl classElementA = ElementFactory.classElement2("A", []); |
| 882 classElementA.nameOffset = 1; | 881 classElementA.nameOffset = 1; |
| 883 ClassElementImpl classElementB = ElementFactory.classElement2("B", []); | 882 ClassElementImpl classElementB = ElementFactory.classElement2("B", []); |
| 884 classElementB.nameOffset = 2; | 883 classElementB.nameOffset = 2; |
| 885 JUnitTestCase.assertEquals(0, Element.SORT_BY_OFFSET(classElementA, classEle
mentA)); | 884 expect(Element.SORT_BY_OFFSET(classElementA, classElementA), 0); |
| 886 JUnitTestCase.assertTrue(Element.SORT_BY_OFFSET(classElementA, classElementB
) < 0); | 885 expect(Element.SORT_BY_OFFSET(classElementA, classElementB) < 0, isTrue); |
| 887 JUnitTestCase.assertTrue(Element.SORT_BY_OFFSET(classElementB, classElementA
) > 0); | 886 expect(Element.SORT_BY_OFFSET(classElementB, classElementA) > 0, isTrue); |
| 888 } | 887 } |
| 889 } | 888 } |
| 890 | 889 |
| 891 class ElementKindTest extends EngineTestCase { | 890 class ElementKindTest extends EngineTestCase { |
| 892 void test_of_nonNull() { | 891 void test_of_nonNull() { |
| 893 JUnitTestCase.assertSame(ElementKind.CLASS, ElementKind.of(ElementFactory.cl
assElement2("A", []))); | 892 expect(ElementKind.of(ElementFactory.classElement2("A", [])), same(ElementKi
nd.CLASS)); |
| 894 } | 893 } |
| 895 | 894 |
| 896 void test_of_null() { | 895 void test_of_null() { |
| 897 JUnitTestCase.assertSame(ElementKind.ERROR, ElementKind.of(null)); | 896 expect(ElementKind.of(null), same(ElementKind.ERROR)); |
| 898 } | 897 } |
| 899 } | 898 } |
| 900 | 899 |
| 901 class ElementLocationImplTest extends EngineTestCase { | 900 class ElementLocationImplTest extends EngineTestCase { |
| 902 void test_create_encoding() { | 901 void test_create_encoding() { |
| 903 String encoding = "a;b;c"; | 902 String encoding = "a;b;c"; |
| 904 ElementLocationImpl location = new ElementLocationImpl.con2(encoding); | 903 ElementLocationImpl location = new ElementLocationImpl.con2(encoding); |
| 905 JUnitTestCase.assertEquals(encoding, location.encoding); | 904 expect(location.encoding, encoding); |
| 906 } | 905 } |
| 907 | 906 |
| 908 /** | 907 /** |
| 909 * For example unnamed constructor. | 908 * For example unnamed constructor. |
| 910 */ | 909 */ |
| 911 void test_create_encoding_emptyLast() { | 910 void test_create_encoding_emptyLast() { |
| 912 String encoding = "a;b;c;"; | 911 String encoding = "a;b;c;"; |
| 913 ElementLocationImpl location = new ElementLocationImpl.con2(encoding); | 912 ElementLocationImpl location = new ElementLocationImpl.con2(encoding); |
| 914 JUnitTestCase.assertEquals(encoding, location.encoding); | 913 expect(location.encoding, encoding); |
| 915 } | 914 } |
| 916 | 915 |
| 917 void test_equals_equal() { | 916 void test_equals_equal() { |
| 918 String encoding = "a;b;c"; | 917 String encoding = "a;b;c"; |
| 919 ElementLocationImpl first = new ElementLocationImpl.con2(encoding); | 918 ElementLocationImpl first = new ElementLocationImpl.con2(encoding); |
| 920 ElementLocationImpl second = new ElementLocationImpl.con2(encoding); | 919 ElementLocationImpl second = new ElementLocationImpl.con2(encoding); |
| 921 JUnitTestCase.assertTrue(first == second); | 920 expect(first == second, isTrue); |
| 922 } | 921 } |
| 923 | 922 |
| 924 void test_equals_notEqual_differentLengths() { | 923 void test_equals_notEqual_differentLengths() { |
| 925 ElementLocationImpl first = new ElementLocationImpl.con2("a;b;c"); | 924 ElementLocationImpl first = new ElementLocationImpl.con2("a;b;c"); |
| 926 ElementLocationImpl second = new ElementLocationImpl.con2("a;b;c;d"); | 925 ElementLocationImpl second = new ElementLocationImpl.con2("a;b;c;d"); |
| 927 JUnitTestCase.assertFalse(first == second); | 926 expect(first == second, isFalse); |
| 928 } | 927 } |
| 929 | 928 |
| 930 void test_equals_notEqual_notLocation() { | 929 void test_equals_notEqual_notLocation() { |
| 931 ElementLocationImpl first = new ElementLocationImpl.con2("a;b;c"); | 930 ElementLocationImpl first = new ElementLocationImpl.con2("a;b;c"); |
| 932 JUnitTestCase.assertFalse(first == "a;b;d"); | 931 expect(first == "a;b;d", isFalse); |
| 933 } | 932 } |
| 934 | 933 |
| 935 void test_equals_notEqual_sameLengths() { | 934 void test_equals_notEqual_sameLengths() { |
| 936 ElementLocationImpl first = new ElementLocationImpl.con2("a;b;c"); | 935 ElementLocationImpl first = new ElementLocationImpl.con2("a;b;c"); |
| 937 ElementLocationImpl second = new ElementLocationImpl.con2("a;b;d"); | 936 ElementLocationImpl second = new ElementLocationImpl.con2("a;b;d"); |
| 938 JUnitTestCase.assertFalse(first == second); | 937 expect(first == second, isFalse); |
| 939 } | 938 } |
| 940 | 939 |
| 941 void test_getComponents() { | 940 void test_getComponents() { |
| 942 String encoding = "a;b;c"; | 941 String encoding = "a;b;c"; |
| 943 ElementLocationImpl location = new ElementLocationImpl.con2(encoding); | 942 ElementLocationImpl location = new ElementLocationImpl.con2(encoding); |
| 944 List<String> components = location.components; | 943 List<String> components = location.components; |
| 945 EngineTestCase.assertLength(3, components); | 944 EngineTestCase.assertLength(3, components); |
| 946 JUnitTestCase.assertEquals("a", components[0]); | 945 expect(components[0], "a"); |
| 947 JUnitTestCase.assertEquals("b", components[1]); | 946 expect(components[1], "b"); |
| 948 JUnitTestCase.assertEquals("c", components[2]); | 947 expect(components[2], "c"); |
| 949 } | 948 } |
| 950 | 949 |
| 951 void test_getEncoding() { | 950 void test_getEncoding() { |
| 952 String encoding = "a;b;c;;d"; | 951 String encoding = "a;b;c;;d"; |
| 953 ElementLocationImpl location = new ElementLocationImpl.con2(encoding); | 952 ElementLocationImpl location = new ElementLocationImpl.con2(encoding); |
| 954 JUnitTestCase.assertEquals(encoding, location.encoding); | 953 expect(location.encoding, encoding); |
| 955 } | 954 } |
| 956 | 955 |
| 957 void test_hashCode_equal() { | 956 void test_hashCode_equal() { |
| 958 String encoding = "a;b;c"; | 957 String encoding = "a;b;c"; |
| 959 ElementLocationImpl first = new ElementLocationImpl.con2(encoding); | 958 ElementLocationImpl first = new ElementLocationImpl.con2(encoding); |
| 960 ElementLocationImpl second = new ElementLocationImpl.con2(encoding); | 959 ElementLocationImpl second = new ElementLocationImpl.con2(encoding); |
| 961 JUnitTestCase.assertTrue(first.hashCode == second.hashCode); | 960 expect(first.hashCode == second.hashCode, isTrue); |
| 962 } | 961 } |
| 963 } | 962 } |
| 964 | 963 |
| 965 class FunctionTypeImplTest extends EngineTestCase { | 964 class FunctionTypeImplTest extends EngineTestCase { |
| 966 void test_creation() { | 965 void test_creation() { |
| 967 JUnitTestCase.assertNotNull(new FunctionTypeImpl.con1(new FunctionElementImp
l.forNode(AstFactory.identifier3("f")))); | 966 expect(new FunctionTypeImpl.con1(new FunctionElementImpl.forNode(AstFactory.
identifier3("f"))), isNotNull); |
| 968 } | 967 } |
| 969 | 968 |
| 970 void test_getElement() { | 969 void test_getElement() { |
| 971 FunctionElementImpl typeElement = new FunctionElementImpl.forNode(AstFactory
.identifier3("f")); | 970 FunctionElementImpl typeElement = new FunctionElementImpl.forNode(AstFactory
.identifier3("f")); |
| 972 FunctionTypeImpl type = new FunctionTypeImpl.con1(typeElement); | 971 FunctionTypeImpl type = new FunctionTypeImpl.con1(typeElement); |
| 973 JUnitTestCase.assertEquals(typeElement, type.element); | 972 expect(type.element, typeElement); |
| 974 } | 973 } |
| 975 | 974 |
| 976 void test_getNamedParameterTypes() { | 975 void test_getNamedParameterTypes() { |
| 977 FunctionTypeImpl type = new FunctionTypeImpl.con1(new FunctionElementImpl.fo
rNode(AstFactory.identifier3("f"))); | 976 FunctionTypeImpl type = new FunctionTypeImpl.con1(new FunctionElementImpl.fo
rNode(AstFactory.identifier3("f"))); |
| 978 Map<String, DartType> types = type.namedParameterTypes; | 977 Map<String, DartType> types = type.namedParameterTypes; |
| 979 EngineTestCase.assertSizeOfMap(0, types); | 978 EngineTestCase.assertSizeOfMap(0, types); |
| 980 } | 979 } |
| 981 | 980 |
| 982 void test_getNormalParameterTypes() { | 981 void test_getNormalParameterTypes() { |
| 983 FunctionTypeImpl type = new FunctionTypeImpl.con1(new FunctionElementImpl.fo
rNode(AstFactory.identifier3("f"))); | 982 FunctionTypeImpl type = new FunctionTypeImpl.con1(new FunctionElementImpl.fo
rNode(AstFactory.identifier3("f"))); |
| 984 List<DartType> types = type.normalParameterTypes; | 983 List<DartType> types = type.normalParameterTypes; |
| 985 EngineTestCase.assertLength(0, types); | 984 EngineTestCase.assertLength(0, types); |
| 986 } | 985 } |
| 987 | 986 |
| 988 void test_getReturnType() { | 987 void test_getReturnType() { |
| 989 DartType expectedReturnType = VoidTypeImpl.instance; | 988 DartType expectedReturnType = VoidTypeImpl.instance; |
| 990 FunctionElementImpl functionElement = new FunctionElementImpl.forNode(AstFac
tory.identifier3("f")); | 989 FunctionElementImpl functionElement = new FunctionElementImpl.forNode(AstFac
tory.identifier3("f")); |
| 991 functionElement.returnType = expectedReturnType; | 990 functionElement.returnType = expectedReturnType; |
| 992 FunctionTypeImpl type = new FunctionTypeImpl.con1(functionElement); | 991 FunctionTypeImpl type = new FunctionTypeImpl.con1(functionElement); |
| 993 DartType returnType = type.returnType; | 992 DartType returnType = type.returnType; |
| 994 JUnitTestCase.assertEquals(expectedReturnType, returnType); | 993 expect(returnType, expectedReturnType); |
| 995 } | 994 } |
| 996 | 995 |
| 997 void test_getTypeArguments() { | 996 void test_getTypeArguments() { |
| 998 FunctionTypeImpl type = new FunctionTypeImpl.con1(new FunctionElementImpl.fo
rNode(AstFactory.identifier3("f"))); | 997 FunctionTypeImpl type = new FunctionTypeImpl.con1(new FunctionElementImpl.fo
rNode(AstFactory.identifier3("f"))); |
| 999 List<DartType> types = type.typeArguments; | 998 List<DartType> types = type.typeArguments; |
| 1000 EngineTestCase.assertLength(0, types); | 999 EngineTestCase.assertLength(0, types); |
| 1001 } | 1000 } |
| 1002 | 1001 |
| 1003 void test_hashCode_element() { | 1002 void test_hashCode_element() { |
| 1004 FunctionTypeImpl type = new FunctionTypeImpl.con1(new FunctionElementImpl.fo
rNode(AstFactory.identifier3("f"))); | 1003 FunctionTypeImpl type = new FunctionTypeImpl.con1(new FunctionElementImpl.fo
rNode(AstFactory.identifier3("f"))); |
| 1005 type.hashCode; | 1004 type.hashCode; |
| 1006 } | 1005 } |
| 1007 | 1006 |
| 1008 void test_hashCode_noElement() { | 1007 void test_hashCode_noElement() { |
| 1009 FunctionTypeImpl type = new FunctionTypeImpl.con1(null); | 1008 FunctionTypeImpl type = new FunctionTypeImpl.con1(null); |
| 1010 type.hashCode; | 1009 type.hashCode; |
| 1011 } | 1010 } |
| 1012 | 1011 |
| 1013 void test_isAssignableTo_normalAndPositionalArgs() { | 1012 void test_isAssignableTo_normalAndPositionalArgs() { |
| 1014 // ([a]) -> void <: (a) -> void | 1013 // ([a]) -> void <: (a) -> void |
| 1015 ClassElement a = ElementFactory.classElement2("A", []); | 1014 ClassElement a = ElementFactory.classElement2("A", []); |
| 1016 FunctionType t = ElementFactory.functionElement6("t", null, <ClassElement> [
a]).type; | 1015 FunctionType t = ElementFactory.functionElement6("t", null, <ClassElement> [
a]).type; |
| 1017 FunctionType s = ElementFactory.functionElement5("s", <ClassElement> [a]).ty
pe; | 1016 FunctionType s = ElementFactory.functionElement5("s", <ClassElement> [a]).ty
pe; |
| 1018 JUnitTestCase.assertTrue(t.isSubtypeOf(s)); | 1017 expect(t.isSubtypeOf(s), isTrue); |
| 1019 JUnitTestCase.assertFalse(s.isSubtypeOf(t)); | 1018 expect(s.isSubtypeOf(t), isFalse); |
| 1020 // assignable iff subtype | 1019 // assignable iff subtype |
| 1021 JUnitTestCase.assertTrue(t.isAssignableTo(s)); | 1020 expect(t.isAssignableTo(s), isTrue); |
| 1022 JUnitTestCase.assertFalse(s.isAssignableTo(t)); | 1021 expect(s.isAssignableTo(t), isFalse); |
| 1023 } | 1022 } |
| 1024 | 1023 |
| 1025 void test_isSubtypeOf_baseCase_classFunction() { | 1024 void test_isSubtypeOf_baseCase_classFunction() { |
| 1026 // () -> void <: Function | 1025 // () -> void <: Function |
| 1027 ClassElementImpl functionElement = ElementFactory.classElement2("Function",
[]); | 1026 ClassElementImpl functionElement = ElementFactory.classElement2("Function",
[]); |
| 1028 InterfaceTypeImpl functionType = new InterfaceTypeImpl_FunctionTypeImplTest_
test_isSubtypeOf_baseCase_classFunction(functionElement); | 1027 InterfaceTypeImpl functionType = new InterfaceTypeImpl_FunctionTypeImplTest_
test_isSubtypeOf_baseCase_classFunction(functionElement); |
| 1029 FunctionType f = ElementFactory.functionElement("f").type; | 1028 FunctionType f = ElementFactory.functionElement("f").type; |
| 1030 JUnitTestCase.assertTrue(f.isSubtypeOf(functionType)); | 1029 expect(f.isSubtypeOf(functionType), isTrue); |
| 1031 } | 1030 } |
| 1032 | 1031 |
| 1033 void test_isSubtypeOf_baseCase_notFunctionType() { | 1032 void test_isSubtypeOf_baseCase_notFunctionType() { |
| 1034 // class C | 1033 // class C |
| 1035 // ! () -> void <: C | 1034 // ! () -> void <: C |
| 1036 FunctionType f = ElementFactory.functionElement("f").type; | 1035 FunctionType f = ElementFactory.functionElement("f").type; |
| 1037 InterfaceType t = ElementFactory.classElement2("C", []).type; | 1036 InterfaceType t = ElementFactory.classElement2("C", []).type; |
| 1038 JUnitTestCase.assertFalse(f.isSubtypeOf(t)); | 1037 expect(f.isSubtypeOf(t), isFalse); |
| 1039 } | 1038 } |
| 1040 | 1039 |
| 1041 void test_isSubtypeOf_baseCase_null() { | 1040 void test_isSubtypeOf_baseCase_null() { |
| 1042 // ! () -> void <: null | 1041 // ! () -> void <: null |
| 1043 FunctionType f = ElementFactory.functionElement("f").type; | 1042 FunctionType f = ElementFactory.functionElement("f").type; |
| 1044 JUnitTestCase.assertFalse(f.isSubtypeOf(null)); | 1043 expect(f.isSubtypeOf(null), isFalse); |
| 1045 } | 1044 } |
| 1046 | 1045 |
| 1047 void test_isSubtypeOf_baseCase_self() { | 1046 void test_isSubtypeOf_baseCase_self() { |
| 1048 // () -> void <: () -> void | 1047 // () -> void <: () -> void |
| 1049 FunctionType f = ElementFactory.functionElement("f").type; | 1048 FunctionType f = ElementFactory.functionElement("f").type; |
| 1050 JUnitTestCase.assertTrue(f.isSubtypeOf(f)); | 1049 expect(f.isSubtypeOf(f), isTrue); |
| 1051 } | 1050 } |
| 1052 | 1051 |
| 1053 void test_isSubtypeOf_namedParameters_isAssignable() { | 1052 void test_isSubtypeOf_namedParameters_isAssignable() { |
| 1054 // B extends A | 1053 // B extends A |
| 1055 // ({name: A}) -> void <: ({name: B}) -> void | 1054 // ({name: A}) -> void <: ({name: B}) -> void |
| 1056 // ({name: B}) -> void <: ({name: A}) -> void | 1055 // ({name: B}) -> void <: ({name: A}) -> void |
| 1057 ClassElement a = ElementFactory.classElement2("A", []); | 1056 ClassElement a = ElementFactory.classElement2("A", []); |
| 1058 ClassElement b = ElementFactory.classElement("B", a.type, []); | 1057 ClassElement b = ElementFactory.classElement("B", a.type, []); |
| 1059 FunctionType t = ElementFactory.functionElement4("t", null, null, <String> [
"name"], <ClassElement> [a]).type; | 1058 FunctionType t = ElementFactory.functionElement4("t", null, null, <String> [
"name"], <ClassElement> [a]).type; |
| 1060 FunctionType s = ElementFactory.functionElement4("s", null, null, <String> [
"name"], <ClassElement> [b]).type; | 1059 FunctionType s = ElementFactory.functionElement4("s", null, null, <String> [
"name"], <ClassElement> [b]).type; |
| 1061 JUnitTestCase.assertTrue(t.isSubtypeOf(s)); | 1060 expect(t.isSubtypeOf(s), isTrue); |
| 1062 JUnitTestCase.assertTrue(s.isSubtypeOf(t)); | 1061 expect(s.isSubtypeOf(t), isTrue); |
| 1063 } | 1062 } |
| 1064 | 1063 |
| 1065 void test_isSubtypeOf_namedParameters_isNotAssignable() { | 1064 void test_isSubtypeOf_namedParameters_isNotAssignable() { |
| 1066 // ! ({name: A}) -> void <: ({name: B}) -> void | 1065 // ! ({name: A}) -> void <: ({name: B}) -> void |
| 1067 FunctionType t = ElementFactory.functionElement4("t", null, null, <String> [
"name"], <ClassElement> [ElementFactory.classElement2("A", [])]).type; | 1066 FunctionType t = ElementFactory.functionElement4("t", null, null, <String> [
"name"], <ClassElement> [ElementFactory.classElement2("A", [])]).type; |
| 1068 FunctionType s = ElementFactory.functionElement4("s", null, null, <String> [
"name"], <ClassElement> [ElementFactory.classElement2("B", [])]).type; | 1067 FunctionType s = ElementFactory.functionElement4("s", null, null, <String> [
"name"], <ClassElement> [ElementFactory.classElement2("B", [])]).type; |
| 1069 JUnitTestCase.assertFalse(t.isSubtypeOf(s)); | 1068 expect(t.isSubtypeOf(s), isFalse); |
| 1070 } | 1069 } |
| 1071 | 1070 |
| 1072 void test_isSubtypeOf_namedParameters_namesDifferent() { | 1071 void test_isSubtypeOf_namedParameters_namesDifferent() { |
| 1073 // B extends A | 1072 // B extends A |
| 1074 // void t({A name}) {} | 1073 // void t({A name}) {} |
| 1075 // void s({A diff}) {} | 1074 // void s({A diff}) {} |
| 1076 // ! t <: s | 1075 // ! t <: s |
| 1077 // ! s <: t | 1076 // ! s <: t |
| 1078 ClassElement a = ElementFactory.classElement2("A", []); | 1077 ClassElement a = ElementFactory.classElement2("A", []); |
| 1079 ClassElement b = ElementFactory.classElement("B", a.type, []); | 1078 ClassElement b = ElementFactory.classElement("B", a.type, []); |
| 1080 FunctionType t = ElementFactory.functionElement4("t", null, null, <String> [
"name"], <ClassElement> [a]).type; | 1079 FunctionType t = ElementFactory.functionElement4("t", null, null, <String> [
"name"], <ClassElement> [a]).type; |
| 1081 FunctionType s = ElementFactory.functionElement4("s", null, null, <String> [
"diff"], <ClassElement> [b]).type; | 1080 FunctionType s = ElementFactory.functionElement4("s", null, null, <String> [
"diff"], <ClassElement> [b]).type; |
| 1082 JUnitTestCase.assertFalse(t.isSubtypeOf(s)); | 1081 expect(t.isSubtypeOf(s), isFalse); |
| 1083 JUnitTestCase.assertFalse(s.isSubtypeOf(t)); | 1082 expect(s.isSubtypeOf(t), isFalse); |
| 1084 } | 1083 } |
| 1085 | 1084 |
| 1086 void test_isSubtypeOf_namedParameters_orderOfParams() { | 1085 void test_isSubtypeOf_namedParameters_orderOfParams() { |
| 1087 // B extends A | 1086 // B extends A |
| 1088 // ({A: A, B: B}) -> void <: ({B: B, A: A}) -> void | 1087 // ({A: A, B: B}) -> void <: ({B: B, A: A}) -> void |
| 1089 ClassElement a = ElementFactory.classElement2("A", []); | 1088 ClassElement a = ElementFactory.classElement2("A", []); |
| 1090 ClassElement b = ElementFactory.classElement("B", a.type, []); | 1089 ClassElement b = ElementFactory.classElement("B", a.type, []); |
| 1091 FunctionType t = ElementFactory.functionElement4("t", null, null, <String> [
"A", "B"], <ClassElement> [a, b]).type; | 1090 FunctionType t = ElementFactory.functionElement4("t", null, null, <String> [
"A", "B"], <ClassElement> [a, b]).type; |
| 1092 FunctionType s = ElementFactory.functionElement4("s", null, null, <String> [
"B", "A"], <ClassElement> [b, a]).type; | 1091 FunctionType s = ElementFactory.functionElement4("s", null, null, <String> [
"B", "A"], <ClassElement> [b, a]).type; |
| 1093 JUnitTestCase.assertTrue(t.isSubtypeOf(s)); | 1092 expect(t.isSubtypeOf(s), isTrue); |
| 1094 } | 1093 } |
| 1095 | 1094 |
| 1096 void test_isSubtypeOf_namedParameters_orderOfParams2() { | 1095 void test_isSubtypeOf_namedParameters_orderOfParams2() { |
| 1097 // B extends A | 1096 // B extends A |
| 1098 // ! ({B: B}) -> void <: ({B: B, A: A}) -> void | 1097 // ! ({B: B}) -> void <: ({B: B, A: A}) -> void |
| 1099 ClassElement a = ElementFactory.classElement2("A", []); | 1098 ClassElement a = ElementFactory.classElement2("A", []); |
| 1100 ClassElement b = ElementFactory.classElement("B", a.type, []); | 1099 ClassElement b = ElementFactory.classElement("B", a.type, []); |
| 1101 FunctionType t = ElementFactory.functionElement4("t", null, null, <String> [
"B"], <ClassElement> [b]).type; | 1100 FunctionType t = ElementFactory.functionElement4("t", null, null, <String> [
"B"], <ClassElement> [b]).type; |
| 1102 FunctionType s = ElementFactory.functionElement4("s", null, null, <String> [
"B", "A"], <ClassElement> [b, a]).type; | 1101 FunctionType s = ElementFactory.functionElement4("s", null, null, <String> [
"B", "A"], <ClassElement> [b, a]).type; |
| 1103 JUnitTestCase.assertFalse(t.isSubtypeOf(s)); | 1102 expect(t.isSubtypeOf(s), isFalse); |
| 1104 } | 1103 } |
| 1105 | 1104 |
| 1106 void test_isSubtypeOf_namedParameters_orderOfParams3() { | 1105 void test_isSubtypeOf_namedParameters_orderOfParams3() { |
| 1107 // B extends A | 1106 // B extends A |
| 1108 // ({A: A, B: B}) -> void <: ({A: A}) -> void | 1107 // ({A: A, B: B}) -> void <: ({A: A}) -> void |
| 1109 ClassElement a = ElementFactory.classElement2("A", []); | 1108 ClassElement a = ElementFactory.classElement2("A", []); |
| 1110 ClassElement b = ElementFactory.classElement("B", a.type, []); | 1109 ClassElement b = ElementFactory.classElement("B", a.type, []); |
| 1111 FunctionType t = ElementFactory.functionElement4("t", null, null, <String> [
"A", "B"], <ClassElement> [a, b]).type; | 1110 FunctionType t = ElementFactory.functionElement4("t", null, null, <String> [
"A", "B"], <ClassElement> [a, b]).type; |
| 1112 FunctionType s = ElementFactory.functionElement4("s", null, null, <String> [
"B"], <ClassElement> [b]).type; | 1111 FunctionType s = ElementFactory.functionElement4("s", null, null, <String> [
"B"], <ClassElement> [b]).type; |
| 1113 JUnitTestCase.assertTrue(t.isSubtypeOf(s)); | 1112 expect(t.isSubtypeOf(s), isTrue); |
| 1114 } | 1113 } |
| 1115 | 1114 |
| 1116 void test_isSubtypeOf_namedParameters_sHasMoreParams() { | 1115 void test_isSubtypeOf_namedParameters_sHasMoreParams() { |
| 1117 // B extends A | 1116 // B extends A |
| 1118 // ! ({name: A}) -> void <: ({name: B, name2: B}) -> void | 1117 // ! ({name: A}) -> void <: ({name: B, name2: B}) -> void |
| 1119 ClassElement a = ElementFactory.classElement2("A", []); | 1118 ClassElement a = ElementFactory.classElement2("A", []); |
| 1120 ClassElement b = ElementFactory.classElement("B", a.type, []); | 1119 ClassElement b = ElementFactory.classElement("B", a.type, []); |
| 1121 FunctionType t = ElementFactory.functionElement4("t", null, null, <String> [
"name"], <ClassElement> [a]).type; | 1120 FunctionType t = ElementFactory.functionElement4("t", null, null, <String> [
"name"], <ClassElement> [a]).type; |
| 1122 FunctionType s = ElementFactory.functionElement4("s", null, null, <String> [
"name", "name2"], <ClassElement> [b, b]).type; | 1121 FunctionType s = ElementFactory.functionElement4("s", null, null, <String> [
"name", "name2"], <ClassElement> [b, b]).type; |
| 1123 JUnitTestCase.assertFalse(t.isSubtypeOf(s)); | 1122 expect(t.isSubtypeOf(s), isFalse); |
| 1124 } | 1123 } |
| 1125 | 1124 |
| 1126 void test_isSubtypeOf_namedParameters_tHasMoreParams() { | 1125 void test_isSubtypeOf_namedParameters_tHasMoreParams() { |
| 1127 // B extends A | 1126 // B extends A |
| 1128 // ({name: A, name2: A}) -> void <: ({name: B}) -> void | 1127 // ({name: A, name2: A}) -> void <: ({name: B}) -> void |
| 1129 ClassElement a = ElementFactory.classElement2("A", []); | 1128 ClassElement a = ElementFactory.classElement2("A", []); |
| 1130 ClassElement b = ElementFactory.classElement("B", a.type, []); | 1129 ClassElement b = ElementFactory.classElement("B", a.type, []); |
| 1131 FunctionType t = ElementFactory.functionElement4("t", null, null, <String> [
"name", "name2"], <ClassElement> [a, a]).type; | 1130 FunctionType t = ElementFactory.functionElement4("t", null, null, <String> [
"name", "name2"], <ClassElement> [a, a]).type; |
| 1132 FunctionType s = ElementFactory.functionElement4("s", null, null, <String> [
"name"], <ClassElement> [b]).type; | 1131 FunctionType s = ElementFactory.functionElement4("s", null, null, <String> [
"name"], <ClassElement> [b]).type; |
| 1133 JUnitTestCase.assertTrue(t.isSubtypeOf(s)); | 1132 expect(t.isSubtypeOf(s), isTrue); |
| 1134 } | 1133 } |
| 1135 | 1134 |
| 1136 void test_isSubtypeOf_normalAndPositionalArgs_1() { | 1135 void test_isSubtypeOf_normalAndPositionalArgs_1() { |
| 1137 // ([a]) -> void <: (a) -> void | 1136 // ([a]) -> void <: (a) -> void |
| 1138 ClassElement a = ElementFactory.classElement2("A", []); | 1137 ClassElement a = ElementFactory.classElement2("A", []); |
| 1139 FunctionType t = ElementFactory.functionElement6("t", null, <ClassElement> [
a]).type; | 1138 FunctionType t = ElementFactory.functionElement6("t", null, <ClassElement> [
a]).type; |
| 1140 FunctionType s = ElementFactory.functionElement5("s", <ClassElement> [a]).ty
pe; | 1139 FunctionType s = ElementFactory.functionElement5("s", <ClassElement> [a]).ty
pe; |
| 1141 JUnitTestCase.assertTrue(t.isSubtypeOf(s)); | 1140 expect(t.isSubtypeOf(s), isTrue); |
| 1142 JUnitTestCase.assertFalse(s.isSubtypeOf(t)); | 1141 expect(s.isSubtypeOf(t), isFalse); |
| 1143 } | 1142 } |
| 1144 | 1143 |
| 1145 void test_isSubtypeOf_normalAndPositionalArgs_2() { | 1144 void test_isSubtypeOf_normalAndPositionalArgs_2() { |
| 1146 // (a, [a]) -> void <: (a) -> void | 1145 // (a, [a]) -> void <: (a) -> void |
| 1147 ClassElement a = ElementFactory.classElement2("A", []); | 1146 ClassElement a = ElementFactory.classElement2("A", []); |
| 1148 FunctionType t = ElementFactory.functionElement6("t", <ClassElement> [a], <C
lassElement> [a]).type; | 1147 FunctionType t = ElementFactory.functionElement6("t", <ClassElement> [a], <C
lassElement> [a]).type; |
| 1149 FunctionType s = ElementFactory.functionElement5("s", <ClassElement> [a]).ty
pe; | 1148 FunctionType s = ElementFactory.functionElement5("s", <ClassElement> [a]).ty
pe; |
| 1150 JUnitTestCase.assertTrue(t.isSubtypeOf(s)); | 1149 expect(t.isSubtypeOf(s), isTrue); |
| 1151 JUnitTestCase.assertFalse(s.isSubtypeOf(t)); | 1150 expect(s.isSubtypeOf(t), isFalse); |
| 1152 } | 1151 } |
| 1153 | 1152 |
| 1154 void test_isSubtypeOf_normalAndPositionalArgs_3() { | 1153 void test_isSubtypeOf_normalAndPositionalArgs_3() { |
| 1155 // ([a]) -> void <: () -> void | 1154 // ([a]) -> void <: () -> void |
| 1156 ClassElement a = ElementFactory.classElement2("A", []); | 1155 ClassElement a = ElementFactory.classElement2("A", []); |
| 1157 FunctionType t = ElementFactory.functionElement6("t", null, <ClassElement> [
a]).type; | 1156 FunctionType t = ElementFactory.functionElement6("t", null, <ClassElement> [
a]).type; |
| 1158 FunctionType s = ElementFactory.functionElement("s").type; | 1157 FunctionType s = ElementFactory.functionElement("s").type; |
| 1159 JUnitTestCase.assertTrue(t.isSubtypeOf(s)); | 1158 expect(t.isSubtypeOf(s), isTrue); |
| 1160 JUnitTestCase.assertFalse(s.isSubtypeOf(t)); | 1159 expect(s.isSubtypeOf(t), isFalse); |
| 1161 } | 1160 } |
| 1162 | 1161 |
| 1163 void test_isSubtypeOf_normalAndPositionalArgs_4() { | 1162 void test_isSubtypeOf_normalAndPositionalArgs_4() { |
| 1164 // (a, b, [c, d, e]) -> void <: (a, b, c, [d]) -> void | 1163 // (a, b, [c, d, e]) -> void <: (a, b, c, [d]) -> void |
| 1165 ClassElement a = ElementFactory.classElement2("A", []); | 1164 ClassElement a = ElementFactory.classElement2("A", []); |
| 1166 ClassElement b = ElementFactory.classElement2("B", []); | 1165 ClassElement b = ElementFactory.classElement2("B", []); |
| 1167 ClassElement c = ElementFactory.classElement2("C", []); | 1166 ClassElement c = ElementFactory.classElement2("C", []); |
| 1168 ClassElement d = ElementFactory.classElement2("D", []); | 1167 ClassElement d = ElementFactory.classElement2("D", []); |
| 1169 ClassElement e = ElementFactory.classElement2("E", []); | 1168 ClassElement e = ElementFactory.classElement2("E", []); |
| 1170 FunctionType t = ElementFactory.functionElement6("t", <ClassElement> [a, b],
<ClassElement> [c, d, e]).type; | 1169 FunctionType t = ElementFactory.functionElement6("t", <ClassElement> [a, b],
<ClassElement> [c, d, e]).type; |
| 1171 FunctionType s = ElementFactory.functionElement6("s", <ClassElement> [a, b,
c], <ClassElement> [d]).type; | 1170 FunctionType s = ElementFactory.functionElement6("s", <ClassElement> [a, b,
c], <ClassElement> [d]).type; |
| 1172 JUnitTestCase.assertTrue(t.isSubtypeOf(s)); | 1171 expect(t.isSubtypeOf(s), isTrue); |
| 1173 JUnitTestCase.assertFalse(s.isSubtypeOf(t)); | 1172 expect(s.isSubtypeOf(t), isFalse); |
| 1174 } | 1173 } |
| 1175 | 1174 |
| 1176 void test_isSubtypeOf_normalParameters_isAssignable() { | 1175 void test_isSubtypeOf_normalParameters_isAssignable() { |
| 1177 // B extends A | 1176 // B extends A |
| 1178 // (a) -> void <: (b) -> void | 1177 // (a) -> void <: (b) -> void |
| 1179 // (b) -> void <: (a) -> void | 1178 // (b) -> void <: (a) -> void |
| 1180 ClassElement a = ElementFactory.classElement2("A", []); | 1179 ClassElement a = ElementFactory.classElement2("A", []); |
| 1181 ClassElement b = ElementFactory.classElement("B", a.type, []); | 1180 ClassElement b = ElementFactory.classElement("B", a.type, []); |
| 1182 FunctionType t = ElementFactory.functionElement5("t", <ClassElement> [a]).ty
pe; | 1181 FunctionType t = ElementFactory.functionElement5("t", <ClassElement> [a]).ty
pe; |
| 1183 FunctionType s = ElementFactory.functionElement5("s", <ClassElement> [b]).ty
pe; | 1182 FunctionType s = ElementFactory.functionElement5("s", <ClassElement> [b]).ty
pe; |
| 1184 JUnitTestCase.assertTrue(t.isSubtypeOf(s)); | 1183 expect(t.isSubtypeOf(s), isTrue); |
| 1185 JUnitTestCase.assertTrue(s.isSubtypeOf(t)); | 1184 expect(s.isSubtypeOf(t), isTrue); |
| 1186 } | 1185 } |
| 1187 | 1186 |
| 1188 void test_isSubtypeOf_normalParameters_isNotAssignable() { | 1187 void test_isSubtypeOf_normalParameters_isNotAssignable() { |
| 1189 // ! (a) -> void <: (b) -> void | 1188 // ! (a) -> void <: (b) -> void |
| 1190 FunctionType t = ElementFactory.functionElement5("t", <ClassElement> [Elemen
tFactory.classElement2("A", [])]).type; | 1189 FunctionType t = ElementFactory.functionElement5("t", <ClassElement> [Elemen
tFactory.classElement2("A", [])]).type; |
| 1191 FunctionType s = ElementFactory.functionElement5("s", <ClassElement> [Elemen
tFactory.classElement2("B", [])]).type; | 1190 FunctionType s = ElementFactory.functionElement5("s", <ClassElement> [Elemen
tFactory.classElement2("B", [])]).type; |
| 1192 JUnitTestCase.assertFalse(t.isSubtypeOf(s)); | 1191 expect(t.isSubtypeOf(s), isFalse); |
| 1193 } | 1192 } |
| 1194 | 1193 |
| 1195 void test_isSubtypeOf_normalParameters_sHasMoreParams() { | 1194 void test_isSubtypeOf_normalParameters_sHasMoreParams() { |
| 1196 // B extends A | 1195 // B extends A |
| 1197 // ! (a) -> void <: (b, b) -> void | 1196 // ! (a) -> void <: (b, b) -> void |
| 1198 ClassElement a = ElementFactory.classElement2("A", []); | 1197 ClassElement a = ElementFactory.classElement2("A", []); |
| 1199 ClassElement b = ElementFactory.classElement("B", a.type, []); | 1198 ClassElement b = ElementFactory.classElement("B", a.type, []); |
| 1200 FunctionType t = ElementFactory.functionElement5("t", <ClassElement> [a]).ty
pe; | 1199 FunctionType t = ElementFactory.functionElement5("t", <ClassElement> [a]).ty
pe; |
| 1201 FunctionType s = ElementFactory.functionElement5("s", <ClassElement> [b, b])
.type; | 1200 FunctionType s = ElementFactory.functionElement5("s", <ClassElement> [b, b])
.type; |
| 1202 JUnitTestCase.assertFalse(t.isSubtypeOf(s)); | 1201 expect(t.isSubtypeOf(s), isFalse); |
| 1203 } | 1202 } |
| 1204 | 1203 |
| 1205 void test_isSubtypeOf_normalParameters_tHasMoreParams() { | 1204 void test_isSubtypeOf_normalParameters_tHasMoreParams() { |
| 1206 // B extends A | 1205 // B extends A |
| 1207 // ! (a, a) -> void <: (a) -> void | 1206 // ! (a, a) -> void <: (a) -> void |
| 1208 ClassElement a = ElementFactory.classElement2("A", []); | 1207 ClassElement a = ElementFactory.classElement2("A", []); |
| 1209 ClassElement b = ElementFactory.classElement("B", a.type, []); | 1208 ClassElement b = ElementFactory.classElement("B", a.type, []); |
| 1210 FunctionType t = ElementFactory.functionElement5("t", <ClassElement> [a, a])
.type; | 1209 FunctionType t = ElementFactory.functionElement5("t", <ClassElement> [a, a])
.type; |
| 1211 FunctionType s = ElementFactory.functionElement5("s", <ClassElement> [b]).ty
pe; | 1210 FunctionType s = ElementFactory.functionElement5("s", <ClassElement> [b]).ty
pe; |
| 1212 // note, this is a different assertion from the other "tHasMoreParams" tests
, this is | 1211 // note, this is a different assertion from the other "tHasMoreParams" tests
, this is |
| 1213 // intentional as it is a difference of the "normal parameters" | 1212 // intentional as it is a difference of the "normal parameters" |
| 1214 JUnitTestCase.assertFalse(t.isSubtypeOf(s)); | 1213 expect(t.isSubtypeOf(s), isFalse); |
| 1215 } | 1214 } |
| 1216 | 1215 |
| 1217 void test_isSubtypeOf_Object() { | 1216 void test_isSubtypeOf_Object() { |
| 1218 // () -> void <: Object | 1217 // () -> void <: Object |
| 1219 FunctionType f = ElementFactory.functionElement("f").type; | 1218 FunctionType f = ElementFactory.functionElement("f").type; |
| 1220 InterfaceType t = ElementFactory.object.type; | 1219 InterfaceType t = ElementFactory.object.type; |
| 1221 JUnitTestCase.assertTrue(f.isSubtypeOf(t)); | 1220 expect(f.isSubtypeOf(t), isTrue); |
| 1222 } | 1221 } |
| 1223 | 1222 |
| 1224 void test_isSubtypeOf_positionalParameters_isAssignable() { | 1223 void test_isSubtypeOf_positionalParameters_isAssignable() { |
| 1225 // B extends A | 1224 // B extends A |
| 1226 // ([a]) -> void <: ([b]) -> void | 1225 // ([a]) -> void <: ([b]) -> void |
| 1227 // ([b]) -> void <: ([a]) -> void | 1226 // ([b]) -> void <: ([a]) -> void |
| 1228 ClassElement a = ElementFactory.classElement2("A", []); | 1227 ClassElement a = ElementFactory.classElement2("A", []); |
| 1229 ClassElement b = ElementFactory.classElement("B", a.type, []); | 1228 ClassElement b = ElementFactory.classElement("B", a.type, []); |
| 1230 FunctionType t = ElementFactory.functionElement6("t", null, <ClassElement> [
a]).type; | 1229 FunctionType t = ElementFactory.functionElement6("t", null, <ClassElement> [
a]).type; |
| 1231 FunctionType s = ElementFactory.functionElement6("s", null, <ClassElement> [
b]).type; | 1230 FunctionType s = ElementFactory.functionElement6("s", null, <ClassElement> [
b]).type; |
| 1232 JUnitTestCase.assertTrue(t.isSubtypeOf(s)); | 1231 expect(t.isSubtypeOf(s), isTrue); |
| 1233 JUnitTestCase.assertTrue(s.isSubtypeOf(t)); | 1232 expect(s.isSubtypeOf(t), isTrue); |
| 1234 } | 1233 } |
| 1235 | 1234 |
| 1236 void test_isSubtypeOf_positionalParameters_isNotAssignable() { | 1235 void test_isSubtypeOf_positionalParameters_isNotAssignable() { |
| 1237 // ! ([a]) -> void <: ([b]) -> void | 1236 // ! ([a]) -> void <: ([b]) -> void |
| 1238 FunctionType t = ElementFactory.functionElement6("t", null, <ClassElement> [
ElementFactory.classElement2("A", [])]).type; | 1237 FunctionType t = ElementFactory.functionElement6("t", null, <ClassElement> [
ElementFactory.classElement2("A", [])]).type; |
| 1239 FunctionType s = ElementFactory.functionElement6("s", null, <ClassElement> [
ElementFactory.classElement2("B", [])]).type; | 1238 FunctionType s = ElementFactory.functionElement6("s", null, <ClassElement> [
ElementFactory.classElement2("B", [])]).type; |
| 1240 JUnitTestCase.assertFalse(t.isSubtypeOf(s)); | 1239 expect(t.isSubtypeOf(s), isFalse); |
| 1241 } | 1240 } |
| 1242 | 1241 |
| 1243 void test_isSubtypeOf_positionalParameters_sHasMoreParams() { | 1242 void test_isSubtypeOf_positionalParameters_sHasMoreParams() { |
| 1244 // B extends A | 1243 // B extends A |
| 1245 // ! ([a]) -> void <: ([b, b]) -> void | 1244 // ! ([a]) -> void <: ([b, b]) -> void |
| 1246 ClassElement a = ElementFactory.classElement2("A", []); | 1245 ClassElement a = ElementFactory.classElement2("A", []); |
| 1247 ClassElement b = ElementFactory.classElement("B", a.type, []); | 1246 ClassElement b = ElementFactory.classElement("B", a.type, []); |
| 1248 FunctionType t = ElementFactory.functionElement6("t", null, <ClassElement> [
a]).type; | 1247 FunctionType t = ElementFactory.functionElement6("t", null, <ClassElement> [
a]).type; |
| 1249 FunctionType s = ElementFactory.functionElement6("s", null, <ClassElement> [
b, b]).type; | 1248 FunctionType s = ElementFactory.functionElement6("s", null, <ClassElement> [
b, b]).type; |
| 1250 JUnitTestCase.assertFalse(t.isSubtypeOf(s)); | 1249 expect(t.isSubtypeOf(s), isFalse); |
| 1251 } | 1250 } |
| 1252 | 1251 |
| 1253 void test_isSubtypeOf_positionalParameters_tHasMoreParams() { | 1252 void test_isSubtypeOf_positionalParameters_tHasMoreParams() { |
| 1254 // B extends A | 1253 // B extends A |
| 1255 // ([a, a]) -> void <: ([b]) -> void | 1254 // ([a, a]) -> void <: ([b]) -> void |
| 1256 ClassElement a = ElementFactory.classElement2("A", []); | 1255 ClassElement a = ElementFactory.classElement2("A", []); |
| 1257 ClassElement b = ElementFactory.classElement("B", a.type, []); | 1256 ClassElement b = ElementFactory.classElement("B", a.type, []); |
| 1258 FunctionType t = ElementFactory.functionElement6("t", null, <ClassElement> [
a, a]).type; | 1257 FunctionType t = ElementFactory.functionElement6("t", null, <ClassElement> [
a, a]).type; |
| 1259 FunctionType s = ElementFactory.functionElement6("s", null, <ClassElement> [
b]).type; | 1258 FunctionType s = ElementFactory.functionElement6("s", null, <ClassElement> [
b]).type; |
| 1260 JUnitTestCase.assertTrue(t.isSubtypeOf(s)); | 1259 expect(t.isSubtypeOf(s), isTrue); |
| 1261 } | 1260 } |
| 1262 | 1261 |
| 1263 void test_isSubtypeOf_returnType_sIsVoid() { | 1262 void test_isSubtypeOf_returnType_sIsVoid() { |
| 1264 // () -> void <: void | 1263 // () -> void <: void |
| 1265 FunctionType t = ElementFactory.functionElement("t").type; | 1264 FunctionType t = ElementFactory.functionElement("t").type; |
| 1266 FunctionType s = ElementFactory.functionElement("s").type; | 1265 FunctionType s = ElementFactory.functionElement("s").type; |
| 1267 // function s has the implicit return type of void, we assert it here | 1266 // function s has the implicit return type of void, we assert it here |
| 1268 JUnitTestCase.assertTrue(VoidTypeImpl.instance == s.returnType); | 1267 expect(VoidTypeImpl.instance == s.returnType, isTrue); |
| 1269 JUnitTestCase.assertTrue(t.isSubtypeOf(s)); | 1268 expect(t.isSubtypeOf(s), isTrue); |
| 1270 } | 1269 } |
| 1271 | 1270 |
| 1272 void test_isSubtypeOf_returnType_tAssignableToS() { | 1271 void test_isSubtypeOf_returnType_tAssignableToS() { |
| 1273 // B extends A | 1272 // B extends A |
| 1274 // () -> A <: () -> B | 1273 // () -> A <: () -> B |
| 1275 // () -> B <: () -> A | 1274 // () -> B <: () -> A |
| 1276 ClassElement a = ElementFactory.classElement2("A", []); | 1275 ClassElement a = ElementFactory.classElement2("A", []); |
| 1277 ClassElement b = ElementFactory.classElement("B", a.type, []); | 1276 ClassElement b = ElementFactory.classElement("B", a.type, []); |
| 1278 FunctionType t = ElementFactory.functionElement2("t", a).type; | 1277 FunctionType t = ElementFactory.functionElement2("t", a).type; |
| 1279 FunctionType s = ElementFactory.functionElement2("s", b).type; | 1278 FunctionType s = ElementFactory.functionElement2("s", b).type; |
| 1280 JUnitTestCase.assertTrue(t.isSubtypeOf(s)); | 1279 expect(t.isSubtypeOf(s), isTrue); |
| 1281 JUnitTestCase.assertTrue(s.isSubtypeOf(t)); | 1280 expect(s.isSubtypeOf(t), isTrue); |
| 1282 } | 1281 } |
| 1283 | 1282 |
| 1284 void test_isSubtypeOf_returnType_tNotAssignableToS() { | 1283 void test_isSubtypeOf_returnType_tNotAssignableToS() { |
| 1285 // ! () -> A <: () -> B | 1284 // ! () -> A <: () -> B |
| 1286 FunctionType t = ElementFactory.functionElement2("t", ElementFactory.classEl
ement2("A", [])).type; | 1285 FunctionType t = ElementFactory.functionElement2("t", ElementFactory.classEl
ement2("A", [])).type; |
| 1287 FunctionType s = ElementFactory.functionElement2("s", ElementFactory.classEl
ement2("B", [])).type; | 1286 FunctionType s = ElementFactory.functionElement2("s", ElementFactory.classEl
ement2("B", [])).type; |
| 1288 JUnitTestCase.assertFalse(t.isSubtypeOf(s)); | 1287 expect(t.isSubtypeOf(s), isFalse); |
| 1289 } | 1288 } |
| 1290 | 1289 |
| 1291 void test_isSubtypeOf_typeParameters_matchesBounds() { | 1290 void test_isSubtypeOf_typeParameters_matchesBounds() { |
| 1292 TestTypeProvider provider = new TestTypeProvider(); | 1291 TestTypeProvider provider = new TestTypeProvider(); |
| 1293 InterfaceType boolType = provider.boolType; | 1292 InterfaceType boolType = provider.boolType; |
| 1294 InterfaceType stringType = provider.stringType; | 1293 InterfaceType stringType = provider.stringType; |
| 1295 TypeParameterElementImpl parameterB = new TypeParameterElementImpl.forNode(A
stFactory.identifier3("B")); | 1294 TypeParameterElementImpl parameterB = new TypeParameterElementImpl.forNode(A
stFactory.identifier3("B")); |
| 1296 parameterB.bound = boolType; | 1295 parameterB.bound = boolType; |
| 1297 TypeParameterTypeImpl typeB = new TypeParameterTypeImpl(parameterB); | 1296 TypeParameterTypeImpl typeB = new TypeParameterTypeImpl(parameterB); |
| 1298 TypeParameterElementImpl parameterS = new TypeParameterElementImpl.forNode(A
stFactory.identifier3("S")); | 1297 TypeParameterElementImpl parameterS = new TypeParameterElementImpl.forNode(A
stFactory.identifier3("S")); |
| 1299 parameterS.bound = stringType; | 1298 parameterS.bound = stringType; |
| 1300 TypeParameterTypeImpl typeS = new TypeParameterTypeImpl(parameterS); | 1299 TypeParameterTypeImpl typeS = new TypeParameterTypeImpl(parameterS); |
| 1301 FunctionElementImpl functionAliasElement = new FunctionElementImpl.forNode(A
stFactory.identifier3("func")); | 1300 FunctionElementImpl functionAliasElement = new FunctionElementImpl.forNode(A
stFactory.identifier3("func")); |
| 1302 functionAliasElement.parameters = <ParameterElement> [ | 1301 functionAliasElement.parameters = <ParameterElement> [ |
| 1303 ElementFactory.requiredParameter2("a", typeB), | 1302 ElementFactory.requiredParameter2("a", typeB), |
| 1304 ElementFactory.positionalParameter2("b", typeS)]; | 1303 ElementFactory.positionalParameter2("b", typeS)]; |
| 1305 functionAliasElement.returnType = stringType; | 1304 functionAliasElement.returnType = stringType; |
| 1306 FunctionTypeImpl functionAliasType = new FunctionTypeImpl.con1(functionAlias
Element); | 1305 FunctionTypeImpl functionAliasType = new FunctionTypeImpl.con1(functionAlias
Element); |
| 1307 functionAliasElement.type = functionAliasType; | 1306 functionAliasElement.type = functionAliasType; |
| 1308 FunctionElementImpl functionElement = new FunctionElementImpl.forNode(AstFac
tory.identifier3("f")); | 1307 FunctionElementImpl functionElement = new FunctionElementImpl.forNode(AstFac
tory.identifier3("f")); |
| 1309 functionElement.parameters = <ParameterElement> [ | 1308 functionElement.parameters = <ParameterElement> [ |
| 1310 ElementFactory.requiredParameter2("c", boolType), | 1309 ElementFactory.requiredParameter2("c", boolType), |
| 1311 ElementFactory.positionalParameter2("d", stringType)]; | 1310 ElementFactory.positionalParameter2("d", stringType)]; |
| 1312 functionElement.returnType = provider.dynamicType; | 1311 functionElement.returnType = provider.dynamicType; |
| 1313 FunctionTypeImpl functionType = new FunctionTypeImpl.con1(functionElement); | 1312 FunctionTypeImpl functionType = new FunctionTypeImpl.con1(functionElement); |
| 1314 functionElement.type = functionType; | 1313 functionElement.type = functionType; |
| 1315 JUnitTestCase.assertTrue(functionType.isAssignableTo(functionAliasType)); | 1314 expect(functionType.isAssignableTo(functionAliasType), isTrue); |
| 1316 } | 1315 } |
| 1317 | 1316 |
| 1318 void test_isSubtypeOf_wrongFunctionType_normal_named() { | 1317 void test_isSubtypeOf_wrongFunctionType_normal_named() { |
| 1319 // ! (a) -> void <: ({name: A}) -> void | 1318 // ! (a) -> void <: ({name: A}) -> void |
| 1320 // ! ({name: A}) -> void <: (a) -> void | 1319 // ! ({name: A}) -> void <: (a) -> void |
| 1321 ClassElement a = ElementFactory.classElement2("A", []); | 1320 ClassElement a = ElementFactory.classElement2("A", []); |
| 1322 FunctionType t = ElementFactory.functionElement5("t", <ClassElement> [a]).ty
pe; | 1321 FunctionType t = ElementFactory.functionElement5("t", <ClassElement> [a]).ty
pe; |
| 1323 FunctionType s = ElementFactory.functionElement7("s", null, <String> ["name"
], <ClassElement> [a]).type; | 1322 FunctionType s = ElementFactory.functionElement7("s", null, <String> ["name"
], <ClassElement> [a]).type; |
| 1324 JUnitTestCase.assertFalse(t.isSubtypeOf(s)); | 1323 expect(t.isSubtypeOf(s), isFalse); |
| 1325 JUnitTestCase.assertFalse(s.isSubtypeOf(t)); | 1324 expect(s.isSubtypeOf(t), isFalse); |
| 1326 } | 1325 } |
| 1327 | 1326 |
| 1328 void test_isSubtypeOf_wrongFunctionType_optional_named() { | 1327 void test_isSubtypeOf_wrongFunctionType_optional_named() { |
| 1329 // ! ([a]) -> void <: ({name: A}) -> void | 1328 // ! ([a]) -> void <: ({name: A}) -> void |
| 1330 // ! ({name: A}) -> void <: ([a]) -> void | 1329 // ! ({name: A}) -> void <: ([a]) -> void |
| 1331 ClassElement a = ElementFactory.classElement2("A", []); | 1330 ClassElement a = ElementFactory.classElement2("A", []); |
| 1332 FunctionType t = ElementFactory.functionElement6("t", null, <ClassElement> [
a]).type; | 1331 FunctionType t = ElementFactory.functionElement6("t", null, <ClassElement> [
a]).type; |
| 1333 FunctionType s = ElementFactory.functionElement7("s", null, <String> ["name"
], <ClassElement> [a]).type; | 1332 FunctionType s = ElementFactory.functionElement7("s", null, <String> ["name"
], <ClassElement> [a]).type; |
| 1334 JUnitTestCase.assertFalse(t.isSubtypeOf(s)); | 1333 expect(t.isSubtypeOf(s), isFalse); |
| 1335 JUnitTestCase.assertFalse(s.isSubtypeOf(t)); | 1334 expect(s.isSubtypeOf(t), isFalse); |
| 1336 } | 1335 } |
| 1337 | 1336 |
| 1338 void test_setTypeArguments() { | 1337 void test_setTypeArguments() { |
| 1339 ClassElementImpl enclosingClass = ElementFactory.classElement2("C", ["E"]); | 1338 ClassElementImpl enclosingClass = ElementFactory.classElement2("C", ["E"]); |
| 1340 MethodElementImpl methodElement = new MethodElementImpl.forNode(AstFactory.i
dentifier3("m")); | 1339 MethodElementImpl methodElement = new MethodElementImpl.forNode(AstFactory.i
dentifier3("m")); |
| 1341 enclosingClass.methods = <MethodElement> [methodElement]; | 1340 enclosingClass.methods = <MethodElement> [methodElement]; |
| 1342 FunctionTypeImpl type = new FunctionTypeImpl.con1(methodElement); | 1341 FunctionTypeImpl type = new FunctionTypeImpl.con1(methodElement); |
| 1343 DartType expectedType = enclosingClass.typeParameters[0].type; | 1342 DartType expectedType = enclosingClass.typeParameters[0].type; |
| 1344 type.typeArguments = <DartType> [expectedType]; | 1343 type.typeArguments = <DartType> [expectedType]; |
| 1345 List<DartType> arguments = type.typeArguments; | 1344 List<DartType> arguments = type.typeArguments; |
| 1346 EngineTestCase.assertLength(1, arguments); | 1345 EngineTestCase.assertLength(1, arguments); |
| 1347 JUnitTestCase.assertEquals(expectedType, arguments[0]); | 1346 expect(arguments[0], expectedType); |
| 1348 } | 1347 } |
| 1349 | 1348 |
| 1350 void test_substitute2_equal() { | 1349 void test_substitute2_equal() { |
| 1351 ClassElementImpl definingClass = ElementFactory.classElement2("C", ["E"]); | 1350 ClassElementImpl definingClass = ElementFactory.classElement2("C", ["E"]); |
| 1352 TypeParameterType parameterType = definingClass.typeParameters[0].type; | 1351 TypeParameterType parameterType = definingClass.typeParameters[0].type; |
| 1353 MethodElementImpl functionElement = new MethodElementImpl.forNode(AstFactory
.identifier3("m")); | 1352 MethodElementImpl functionElement = new MethodElementImpl.forNode(AstFactory
.identifier3("m")); |
| 1354 String namedParameterName = "c"; | 1353 String namedParameterName = "c"; |
| 1355 functionElement.parameters = <ParameterElement> [ | 1354 functionElement.parameters = <ParameterElement> [ |
| 1356 ElementFactory.requiredParameter2("a", parameterType), | 1355 ElementFactory.requiredParameter2("a", parameterType), |
| 1357 ElementFactory.positionalParameter2("b", parameterType), | 1356 ElementFactory.positionalParameter2("b", parameterType), |
| 1358 ElementFactory.namedParameter2(namedParameterName, parameterType)]; | 1357 ElementFactory.namedParameter2(namedParameterName, parameterType)]; |
| 1359 functionElement.returnType = parameterType; | 1358 functionElement.returnType = parameterType; |
| 1360 definingClass.methods = <MethodElement> [functionElement]; | 1359 definingClass.methods = <MethodElement> [functionElement]; |
| 1361 FunctionTypeImpl functionType = new FunctionTypeImpl.con1(functionElement); | 1360 FunctionTypeImpl functionType = new FunctionTypeImpl.con1(functionElement); |
| 1362 functionType.typeArguments = <DartType> [parameterType]; | 1361 functionType.typeArguments = <DartType> [parameterType]; |
| 1363 InterfaceTypeImpl argumentType = new InterfaceTypeImpl.con1(new ClassElement
Impl.forNode(AstFactory.identifier3("D"))); | 1362 InterfaceTypeImpl argumentType = new InterfaceTypeImpl.con1(new ClassElement
Impl.forNode(AstFactory.identifier3("D"))); |
| 1364 FunctionType result = functionType.substitute2(<DartType> [argumentType], <D
artType> [parameterType]); | 1363 FunctionType result = functionType.substitute2(<DartType> [argumentType], <D
artType> [parameterType]); |
| 1365 JUnitTestCase.assertEquals(argumentType, result.returnType); | 1364 expect(result.returnType, argumentType); |
| 1366 List<DartType> normalParameters = result.normalParameterTypes; | 1365 List<DartType> normalParameters = result.normalParameterTypes; |
| 1367 EngineTestCase.assertLength(1, normalParameters); | 1366 EngineTestCase.assertLength(1, normalParameters); |
| 1368 JUnitTestCase.assertEquals(argumentType, normalParameters[0]); | 1367 expect(normalParameters[0], argumentType); |
| 1369 List<DartType> optionalParameters = result.optionalParameterTypes; | 1368 List<DartType> optionalParameters = result.optionalParameterTypes; |
| 1370 EngineTestCase.assertLength(1, optionalParameters); | 1369 EngineTestCase.assertLength(1, optionalParameters); |
| 1371 JUnitTestCase.assertEquals(argumentType, optionalParameters[0]); | 1370 expect(optionalParameters[0], argumentType); |
| 1372 Map<String, DartType> namedParameters = result.namedParameterTypes; | 1371 Map<String, DartType> namedParameters = result.namedParameterTypes; |
| 1373 EngineTestCase.assertSizeOfMap(1, namedParameters); | 1372 EngineTestCase.assertSizeOfMap(1, namedParameters); |
| 1374 JUnitTestCase.assertEquals(argumentType, namedParameters[namedParameterName]
); | 1373 expect(namedParameters[namedParameterName], argumentType); |
| 1375 } | 1374 } |
| 1376 | 1375 |
| 1377 void test_substitute2_notEqual() { | 1376 void test_substitute2_notEqual() { |
| 1378 DartType returnType = new InterfaceTypeImpl.con1(new ClassElementImpl.forNod
e(AstFactory.identifier3("R"))); | 1377 DartType returnType = new InterfaceTypeImpl.con1(new ClassElementImpl.forNod
e(AstFactory.identifier3("R"))); |
| 1379 DartType normalParameterType = new InterfaceTypeImpl.con1(new ClassElementIm
pl.forNode(AstFactory.identifier3("A"))); | 1378 DartType normalParameterType = new InterfaceTypeImpl.con1(new ClassElementIm
pl.forNode(AstFactory.identifier3("A"))); |
| 1380 DartType optionalParameterType = new InterfaceTypeImpl.con1(new ClassElement
Impl.forNode(AstFactory.identifier3("B"))); | 1379 DartType optionalParameterType = new InterfaceTypeImpl.con1(new ClassElement
Impl.forNode(AstFactory.identifier3("B"))); |
| 1381 DartType namedParameterType = new InterfaceTypeImpl.con1(new ClassElementImp
l.forNode(AstFactory.identifier3("C"))); | 1380 DartType namedParameterType = new InterfaceTypeImpl.con1(new ClassElementImp
l.forNode(AstFactory.identifier3("C"))); |
| 1382 FunctionElementImpl functionElement = new FunctionElementImpl.forNode(AstFac
tory.identifier3("f")); | 1381 FunctionElementImpl functionElement = new FunctionElementImpl.forNode(AstFac
tory.identifier3("f")); |
| 1383 String namedParameterName = "c"; | 1382 String namedParameterName = "c"; |
| 1384 functionElement.parameters = <ParameterElement> [ | 1383 functionElement.parameters = <ParameterElement> [ |
| 1385 ElementFactory.requiredParameter2("a", normalParameterType), | 1384 ElementFactory.requiredParameter2("a", normalParameterType), |
| 1386 ElementFactory.positionalParameter2("b", optionalParameterType), | 1385 ElementFactory.positionalParameter2("b", optionalParameterType), |
| 1387 ElementFactory.namedParameter2(namedParameterName, namedParameterType)]; | 1386 ElementFactory.namedParameter2(namedParameterName, namedParameterType)]; |
| 1388 functionElement.returnType = returnType; | 1387 functionElement.returnType = returnType; |
| 1389 FunctionTypeImpl functionType = new FunctionTypeImpl.con1(functionElement); | 1388 FunctionTypeImpl functionType = new FunctionTypeImpl.con1(functionElement); |
| 1390 InterfaceTypeImpl argumentType = new InterfaceTypeImpl.con1(new ClassElement
Impl.forNode(AstFactory.identifier3("D"))); | 1389 InterfaceTypeImpl argumentType = new InterfaceTypeImpl.con1(new ClassElement
Impl.forNode(AstFactory.identifier3("D"))); |
| 1391 TypeParameterTypeImpl parameterType = new TypeParameterTypeImpl(new TypePara
meterElementImpl.forNode(AstFactory.identifier3("E"))); | 1390 TypeParameterTypeImpl parameterType = new TypeParameterTypeImpl(new TypePara
meterElementImpl.forNode(AstFactory.identifier3("E"))); |
| 1392 FunctionType result = functionType.substitute2(<DartType> [argumentType], <D
artType> [parameterType]); | 1391 FunctionType result = functionType.substitute2(<DartType> [argumentType], <D
artType> [parameterType]); |
| 1393 JUnitTestCase.assertEquals(returnType, result.returnType); | 1392 expect(result.returnType, returnType); |
| 1394 List<DartType> normalParameters = result.normalParameterTypes; | 1393 List<DartType> normalParameters = result.normalParameterTypes; |
| 1395 EngineTestCase.assertLength(1, normalParameters); | 1394 EngineTestCase.assertLength(1, normalParameters); |
| 1396 JUnitTestCase.assertEquals(normalParameterType, normalParameters[0]); | 1395 expect(normalParameters[0], normalParameterType); |
| 1397 List<DartType> optionalParameters = result.optionalParameterTypes; | 1396 List<DartType> optionalParameters = result.optionalParameterTypes; |
| 1398 EngineTestCase.assertLength(1, optionalParameters); | 1397 EngineTestCase.assertLength(1, optionalParameters); |
| 1399 JUnitTestCase.assertEquals(optionalParameterType, optionalParameters[0]); | 1398 expect(optionalParameters[0], optionalParameterType); |
| 1400 Map<String, DartType> namedParameters = result.namedParameterTypes; | 1399 Map<String, DartType> namedParameters = result.namedParameterTypes; |
| 1401 EngineTestCase.assertSizeOfMap(1, namedParameters); | 1400 EngineTestCase.assertSizeOfMap(1, namedParameters); |
| 1402 JUnitTestCase.assertEquals(namedParameterType, namedParameters[namedParamete
rName]); | 1401 expect(namedParameters[namedParameterName], namedParameterType); |
| 1403 } | 1402 } |
| 1404 } | 1403 } |
| 1405 | 1404 |
| 1406 class HtmlElementImplTest extends EngineTestCase { | 1405 class HtmlElementImplTest extends EngineTestCase { |
| 1407 void test_equals_differentSource() { | 1406 void test_equals_differentSource() { |
| 1408 AnalysisContextImpl context = createAnalysisContext(); | 1407 AnalysisContextImpl context = createAnalysisContext(); |
| 1409 HtmlElementImpl elementA = ElementFactory.htmlUnit(context, "indexA.html"); | 1408 HtmlElementImpl elementA = ElementFactory.htmlUnit(context, "indexA.html"); |
| 1410 HtmlElementImpl elementB = ElementFactory.htmlUnit(context, "indexB.html"); | 1409 HtmlElementImpl elementB = ElementFactory.htmlUnit(context, "indexB.html"); |
| 1411 JUnitTestCase.assertFalse(elementA == elementB); | 1410 expect(elementA == elementB, isFalse); |
| 1412 } | 1411 } |
| 1413 | 1412 |
| 1414 void test_equals_null() { | 1413 void test_equals_null() { |
| 1415 AnalysisContextImpl context = createAnalysisContext(); | 1414 AnalysisContextImpl context = createAnalysisContext(); |
| 1416 HtmlElementImpl element = ElementFactory.htmlUnit(context, "index.html"); | 1415 HtmlElementImpl element = ElementFactory.htmlUnit(context, "index.html"); |
| 1417 JUnitTestCase.assertFalse(element == null); | 1416 expect(element == null, isFalse); |
| 1418 } | 1417 } |
| 1419 | 1418 |
| 1420 void test_equals_sameSource() { | 1419 void test_equals_sameSource() { |
| 1421 AnalysisContextImpl context = createAnalysisContext(); | 1420 AnalysisContextImpl context = createAnalysisContext(); |
| 1422 HtmlElementImpl elementA = ElementFactory.htmlUnit(context, "index.html"); | 1421 HtmlElementImpl elementA = ElementFactory.htmlUnit(context, "index.html"); |
| 1423 HtmlElementImpl elementB = ElementFactory.htmlUnit(context, "index.html"); | 1422 HtmlElementImpl elementB = ElementFactory.htmlUnit(context, "index.html"); |
| 1424 JUnitTestCase.assertTrue(elementA == elementB); | 1423 expect(elementA == elementB, isTrue); |
| 1425 } | 1424 } |
| 1426 | 1425 |
| 1427 void test_equals_self() { | 1426 void test_equals_self() { |
| 1428 AnalysisContextImpl context = createAnalysisContext(); | 1427 AnalysisContextImpl context = createAnalysisContext(); |
| 1429 HtmlElementImpl element = ElementFactory.htmlUnit(context, "index.html"); | 1428 HtmlElementImpl element = ElementFactory.htmlUnit(context, "index.html"); |
| 1430 JUnitTestCase.assertTrue(element == element); | 1429 expect(element == element, isTrue); |
| 1431 } | 1430 } |
| 1432 } | 1431 } |
| 1433 | 1432 |
| 1434 class InterfaceTypeImplTest extends EngineTestCase { | 1433 class InterfaceTypeImplTest extends EngineTestCase { |
| 1435 /** | 1434 /** |
| 1436 * The type provider used to access the types. | 1435 * The type provider used to access the types. |
| 1437 */ | 1436 */ |
| 1438 TestTypeProvider _typeProvider; | 1437 TestTypeProvider _typeProvider; |
| 1439 | 1438 |
| 1440 @override | 1439 @override |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1458 ClassElementImpl classB = ElementFactory.classElement2("B", []); | 1457 ClassElementImpl classB = ElementFactory.classElement2("B", []); |
| 1459 ClassElementImpl classC = ElementFactory.classElement2("C", []); | 1458 ClassElementImpl classC = ElementFactory.classElement2("C", []); |
| 1460 ClassElementImpl classD = ElementFactory.classElement2("D", []); | 1459 ClassElementImpl classD = ElementFactory.classElement2("D", []); |
| 1461 ClassElementImpl classE = ElementFactory.classElement2("E", []); | 1460 ClassElementImpl classE = ElementFactory.classElement2("E", []); |
| 1462 classB.interfaces = <InterfaceType> [classA.type]; | 1461 classB.interfaces = <InterfaceType> [classA.type]; |
| 1463 classC.interfaces = <InterfaceType> [classA.type]; | 1462 classC.interfaces = <InterfaceType> [classA.type]; |
| 1464 classD.interfaces = <InterfaceType> [classC.type]; | 1463 classD.interfaces = <InterfaceType> [classC.type]; |
| 1465 classE.interfaces = <InterfaceType> [classB.type, classD.type]; | 1464 classE.interfaces = <InterfaceType> [classB.type, classD.type]; |
| 1466 // assertion: even though the longest path to Object for typeB is 2, and typ
eE implements typeB, | 1465 // assertion: even though the longest path to Object for typeB is 2, and typ
eE implements typeB, |
| 1467 // the longest path for typeE is 4 since it also implements typeD | 1466 // the longest path for typeE is 4 since it also implements typeD |
| 1468 JUnitTestCase.assertEquals(2, InterfaceTypeImpl.computeLongestInheritancePat
hToObject(classB.type)); | 1467 expect(InterfaceTypeImpl.computeLongestInheritancePathToObject(classB.type),
2); |
| 1469 JUnitTestCase.assertEquals(4, InterfaceTypeImpl.computeLongestInheritancePat
hToObject(classE.type)); | 1468 expect(InterfaceTypeImpl.computeLongestInheritancePathToObject(classE.type),
4); |
| 1470 } | 1469 } |
| 1471 | 1470 |
| 1472 void test_computeLongestInheritancePathToObject_multipleSuperclassPaths() { | 1471 void test_computeLongestInheritancePathToObject_multipleSuperclassPaths() { |
| 1473 // | 1472 // |
| 1474 // Object | 1473 // Object |
| 1475 // | | 1474 // | |
| 1476 // A | 1475 // A |
| 1477 // / \ | 1476 // / \ |
| 1478 // B C | 1477 // B C |
| 1479 // | | | 1478 // | | |
| 1480 // | D | 1479 // | D |
| 1481 // \ / | 1480 // \ / |
| 1482 // E | 1481 // E |
| 1483 // | 1482 // |
| 1484 ClassElement classA = ElementFactory.classElement2("A", []); | 1483 ClassElement classA = ElementFactory.classElement2("A", []); |
| 1485 ClassElement classB = ElementFactory.classElement("B", classA.type, []); | 1484 ClassElement classB = ElementFactory.classElement("B", classA.type, []); |
| 1486 ClassElement classC = ElementFactory.classElement("C", classA.type, []); | 1485 ClassElement classC = ElementFactory.classElement("C", classA.type, []); |
| 1487 ClassElement classD = ElementFactory.classElement("D", classC.type, []); | 1486 ClassElement classD = ElementFactory.classElement("D", classC.type, []); |
| 1488 ClassElementImpl classE = ElementFactory.classElement("E", classB.type, []); | 1487 ClassElementImpl classE = ElementFactory.classElement("E", classB.type, []); |
| 1489 classE.interfaces = <InterfaceType> [classD.type]; | 1488 classE.interfaces = <InterfaceType> [classD.type]; |
| 1490 // assertion: even though the longest path to Object for typeB is 2, and typ
eE extends typeB, | 1489 // assertion: even though the longest path to Object for typeB is 2, and typ
eE extends typeB, |
| 1491 // the longest path for typeE is 4 since it also implements typeD | 1490 // the longest path for typeE is 4 since it also implements typeD |
| 1492 JUnitTestCase.assertEquals(2, InterfaceTypeImpl.computeLongestInheritancePat
hToObject(classB.type)); | 1491 expect(InterfaceTypeImpl.computeLongestInheritancePathToObject(classB.type),
2); |
| 1493 JUnitTestCase.assertEquals(4, InterfaceTypeImpl.computeLongestInheritancePat
hToObject(classE.type)); | 1492 expect(InterfaceTypeImpl.computeLongestInheritancePathToObject(classE.type),
4); |
| 1494 } | 1493 } |
| 1495 | 1494 |
| 1496 void test_computeLongestInheritancePathToObject_object() { | 1495 void test_computeLongestInheritancePathToObject_object() { |
| 1497 // | 1496 // |
| 1498 // Object | 1497 // Object |
| 1499 // | | 1498 // | |
| 1500 // A | 1499 // A |
| 1501 // | 1500 // |
| 1502 ClassElement classA = ElementFactory.classElement2("A", []); | 1501 ClassElement classA = ElementFactory.classElement2("A", []); |
| 1503 InterfaceType object = classA.supertype; | 1502 InterfaceType object = classA.supertype; |
| 1504 JUnitTestCase.assertEquals(0, InterfaceTypeImpl.computeLongestInheritancePat
hToObject(object)); | 1503 expect(InterfaceTypeImpl.computeLongestInheritancePathToObject(object), 0); |
| 1505 } | 1504 } |
| 1506 | 1505 |
| 1507 void test_computeLongestInheritancePathToObject_recursion() { | 1506 void test_computeLongestInheritancePathToObject_recursion() { |
| 1508 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 1507 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 1509 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); | 1508 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); |
| 1510 classA.supertype = classB.type; | 1509 classA.supertype = classB.type; |
| 1511 JUnitTestCase.assertEquals(2, InterfaceTypeImpl.computeLongestInheritancePat
hToObject(classA.type)); | 1510 expect(InterfaceTypeImpl.computeLongestInheritancePathToObject(classA.type),
2); |
| 1512 } | 1511 } |
| 1513 | 1512 |
| 1514 void test_computeLongestInheritancePathToObject_singleInterfacePath() { | 1513 void test_computeLongestInheritancePathToObject_singleInterfacePath() { |
| 1515 // | 1514 // |
| 1516 // Object | 1515 // Object |
| 1517 // | | 1516 // | |
| 1518 // A | 1517 // A |
| 1519 // | | 1518 // | |
| 1520 // B | 1519 // B |
| 1521 // | | 1520 // | |
| 1522 // C | 1521 // C |
| 1523 // | 1522 // |
| 1524 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 1523 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 1525 ClassElementImpl classB = ElementFactory.classElement2("B", []); | 1524 ClassElementImpl classB = ElementFactory.classElement2("B", []); |
| 1526 ClassElementImpl classC = ElementFactory.classElement2("C", []); | 1525 ClassElementImpl classC = ElementFactory.classElement2("C", []); |
| 1527 classB.interfaces = <InterfaceType> [classA.type]; | 1526 classB.interfaces = <InterfaceType> [classA.type]; |
| 1528 classC.interfaces = <InterfaceType> [classB.type]; | 1527 classC.interfaces = <InterfaceType> [classB.type]; |
| 1529 JUnitTestCase.assertEquals(1, InterfaceTypeImpl.computeLongestInheritancePat
hToObject(classA.type)); | 1528 expect(InterfaceTypeImpl.computeLongestInheritancePathToObject(classA.type),
1); |
| 1530 JUnitTestCase.assertEquals(2, InterfaceTypeImpl.computeLongestInheritancePat
hToObject(classB.type)); | 1529 expect(InterfaceTypeImpl.computeLongestInheritancePathToObject(classB.type),
2); |
| 1531 JUnitTestCase.assertEquals(3, InterfaceTypeImpl.computeLongestInheritancePat
hToObject(classC.type)); | 1530 expect(InterfaceTypeImpl.computeLongestInheritancePathToObject(classC.type),
3); |
| 1532 } | 1531 } |
| 1533 | 1532 |
| 1534 void test_computeLongestInheritancePathToObject_singleSuperclassPath() { | 1533 void test_computeLongestInheritancePathToObject_singleSuperclassPath() { |
| 1535 // | 1534 // |
| 1536 // Object | 1535 // Object |
| 1537 // | | 1536 // | |
| 1538 // A | 1537 // A |
| 1539 // | | 1538 // | |
| 1540 // B | 1539 // B |
| 1541 // | | 1540 // | |
| 1542 // C | 1541 // C |
| 1543 // | 1542 // |
| 1544 ClassElement classA = ElementFactory.classElement2("A", []); | 1543 ClassElement classA = ElementFactory.classElement2("A", []); |
| 1545 ClassElement classB = ElementFactory.classElement("B", classA.type, []); | 1544 ClassElement classB = ElementFactory.classElement("B", classA.type, []); |
| 1546 ClassElement classC = ElementFactory.classElement("C", classB.type, []); | 1545 ClassElement classC = ElementFactory.classElement("C", classB.type, []); |
| 1547 JUnitTestCase.assertEquals(1, InterfaceTypeImpl.computeLongestInheritancePat
hToObject(classA.type)); | 1546 expect(InterfaceTypeImpl.computeLongestInheritancePathToObject(classA.type),
1); |
| 1548 JUnitTestCase.assertEquals(2, InterfaceTypeImpl.computeLongestInheritancePat
hToObject(classB.type)); | 1547 expect(InterfaceTypeImpl.computeLongestInheritancePathToObject(classB.type),
2); |
| 1549 JUnitTestCase.assertEquals(3, InterfaceTypeImpl.computeLongestInheritancePat
hToObject(classC.type)); | 1548 expect(InterfaceTypeImpl.computeLongestInheritancePathToObject(classC.type),
3); |
| 1550 } | 1549 } |
| 1551 | 1550 |
| 1552 void test_computeSuperinterfaceSet_genericInterfacePath() { | 1551 void test_computeSuperinterfaceSet_genericInterfacePath() { |
| 1553 // | 1552 // |
| 1554 // A | 1553 // A |
| 1555 // | implements | 1554 // | implements |
| 1556 // B<T> | 1555 // B<T> |
| 1557 // | implements | 1556 // | implements |
| 1558 // C<T> | 1557 // C<T> |
| 1559 // | 1558 // |
| 1560 // D | 1559 // D |
| 1561 // | 1560 // |
| 1562 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 1561 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 1563 ClassElementImpl classB = ElementFactory.classElement2("B", ["T"]); | 1562 ClassElementImpl classB = ElementFactory.classElement2("B", ["T"]); |
| 1564 ClassElementImpl classC = ElementFactory.classElement2("C", ["T"]); | 1563 ClassElementImpl classC = ElementFactory.classElement2("C", ["T"]); |
| 1565 ClassElement classD = ElementFactory.classElement2("D", []); | 1564 ClassElement classD = ElementFactory.classElement2("D", []); |
| 1566 InterfaceType typeA = classA.type; | 1565 InterfaceType typeA = classA.type; |
| 1567 classB.interfaces = <InterfaceType> [typeA]; | 1566 classB.interfaces = <InterfaceType> [typeA]; |
| 1568 InterfaceTypeImpl typeBT = new InterfaceTypeImpl.con1(classB); | 1567 InterfaceTypeImpl typeBT = new InterfaceTypeImpl.con1(classB); |
| 1569 DartType typeT = classC.type.typeArguments[0]; | 1568 DartType typeT = classC.type.typeArguments[0]; |
| 1570 typeBT.typeArguments = <DartType> [typeT]; | 1569 typeBT.typeArguments = <DartType> [typeT]; |
| 1571 classC.interfaces = <InterfaceType> [typeBT]; | 1570 classC.interfaces = <InterfaceType> [typeBT]; |
| 1572 // A | 1571 // A |
| 1573 Set<InterfaceType> superinterfacesOfA = InterfaceTypeImpl.computeSuperinterf
aceSet(typeA); | 1572 Set<InterfaceType> superinterfacesOfA = InterfaceTypeImpl.computeSuperinterf
aceSet(typeA); |
| 1574 EngineTestCase.assertSizeOfSet(1, superinterfacesOfA); | 1573 EngineTestCase.assertSizeOfSet(1, superinterfacesOfA); |
| 1575 InterfaceType typeObject = ElementFactory.object.type; | 1574 InterfaceType typeObject = ElementFactory.object.type; |
| 1576 JUnitTestCase.assertTrue(superinterfacesOfA.contains(typeObject)); | 1575 expect(superinterfacesOfA.contains(typeObject), isTrue); |
| 1577 // B<D> | 1576 // B<D> |
| 1578 InterfaceTypeImpl typeBD = new InterfaceTypeImpl.con1(classB); | 1577 InterfaceTypeImpl typeBD = new InterfaceTypeImpl.con1(classB); |
| 1579 typeBD.typeArguments = <DartType> [classD.type]; | 1578 typeBD.typeArguments = <DartType> [classD.type]; |
| 1580 Set<InterfaceType> superinterfacesOfBD = InterfaceTypeImpl.computeSuperinter
faceSet(typeBD); | 1579 Set<InterfaceType> superinterfacesOfBD = InterfaceTypeImpl.computeSuperinter
faceSet(typeBD); |
| 1581 EngineTestCase.assertSizeOfSet(2, superinterfacesOfBD); | 1580 EngineTestCase.assertSizeOfSet(2, superinterfacesOfBD); |
| 1582 JUnitTestCase.assertTrue(superinterfacesOfBD.contains(typeObject)); | 1581 expect(superinterfacesOfBD.contains(typeObject), isTrue); |
| 1583 JUnitTestCase.assertTrue(superinterfacesOfBD.contains(typeA)); | 1582 expect(superinterfacesOfBD.contains(typeA), isTrue); |
| 1584 // C<D> | 1583 // C<D> |
| 1585 InterfaceTypeImpl typeCD = new InterfaceTypeImpl.con1(classC); | 1584 InterfaceTypeImpl typeCD = new InterfaceTypeImpl.con1(classC); |
| 1586 typeCD.typeArguments = <DartType> [classD.type]; | 1585 typeCD.typeArguments = <DartType> [classD.type]; |
| 1587 Set<InterfaceType> superinterfacesOfCD = InterfaceTypeImpl.computeSuperinter
faceSet(typeCD); | 1586 Set<InterfaceType> superinterfacesOfCD = InterfaceTypeImpl.computeSuperinter
faceSet(typeCD); |
| 1588 EngineTestCase.assertSizeOfSet(3, superinterfacesOfCD); | 1587 EngineTestCase.assertSizeOfSet(3, superinterfacesOfCD); |
| 1589 JUnitTestCase.assertTrue(superinterfacesOfCD.contains(typeObject)); | 1588 expect(superinterfacesOfCD.contains(typeObject), isTrue); |
| 1590 JUnitTestCase.assertTrue(superinterfacesOfCD.contains(typeA)); | 1589 expect(superinterfacesOfCD.contains(typeA), isTrue); |
| 1591 JUnitTestCase.assertTrue(superinterfacesOfCD.contains(typeBD)); | 1590 expect(superinterfacesOfCD.contains(typeBD), isTrue); |
| 1592 } | 1591 } |
| 1593 | 1592 |
| 1594 void test_computeSuperinterfaceSet_genericSuperclassPath() { | 1593 void test_computeSuperinterfaceSet_genericSuperclassPath() { |
| 1595 // | 1594 // |
| 1596 // A | 1595 // A |
| 1597 // | | 1596 // | |
| 1598 // B<T> | 1597 // B<T> |
| 1599 // | | 1598 // | |
| 1600 // C<T> | 1599 // C<T> |
| 1601 // | 1600 // |
| 1602 // D | 1601 // D |
| 1603 // | 1602 // |
| 1604 ClassElement classA = ElementFactory.classElement2("A", []); | 1603 ClassElement classA = ElementFactory.classElement2("A", []); |
| 1605 InterfaceType typeA = classA.type; | 1604 InterfaceType typeA = classA.type; |
| 1606 ClassElement classB = ElementFactory.classElement("B", typeA, ["T"]); | 1605 ClassElement classB = ElementFactory.classElement("B", typeA, ["T"]); |
| 1607 ClassElementImpl classC = ElementFactory.classElement2("C", ["T"]); | 1606 ClassElementImpl classC = ElementFactory.classElement2("C", ["T"]); |
| 1608 InterfaceTypeImpl typeBT = new InterfaceTypeImpl.con1(classB); | 1607 InterfaceTypeImpl typeBT = new InterfaceTypeImpl.con1(classB); |
| 1609 DartType typeT = classC.type.typeArguments[0]; | 1608 DartType typeT = classC.type.typeArguments[0]; |
| 1610 typeBT.typeArguments = <DartType> [typeT]; | 1609 typeBT.typeArguments = <DartType> [typeT]; |
| 1611 classC.supertype = typeBT; | 1610 classC.supertype = typeBT; |
| 1612 ClassElement classD = ElementFactory.classElement2("D", []); | 1611 ClassElement classD = ElementFactory.classElement2("D", []); |
| 1613 // A | 1612 // A |
| 1614 Set<InterfaceType> superinterfacesOfA = InterfaceTypeImpl.computeSuperinterf
aceSet(typeA); | 1613 Set<InterfaceType> superinterfacesOfA = InterfaceTypeImpl.computeSuperinterf
aceSet(typeA); |
| 1615 EngineTestCase.assertSizeOfSet(1, superinterfacesOfA); | 1614 EngineTestCase.assertSizeOfSet(1, superinterfacesOfA); |
| 1616 InterfaceType typeObject = ElementFactory.object.type; | 1615 InterfaceType typeObject = ElementFactory.object.type; |
| 1617 JUnitTestCase.assertTrue(superinterfacesOfA.contains(typeObject)); | 1616 expect(superinterfacesOfA.contains(typeObject), isTrue); |
| 1618 // B<D> | 1617 // B<D> |
| 1619 InterfaceTypeImpl typeBD = new InterfaceTypeImpl.con1(classB); | 1618 InterfaceTypeImpl typeBD = new InterfaceTypeImpl.con1(classB); |
| 1620 typeBD.typeArguments = <DartType> [classD.type]; | 1619 typeBD.typeArguments = <DartType> [classD.type]; |
| 1621 Set<InterfaceType> superinterfacesOfBD = InterfaceTypeImpl.computeSuperinter
faceSet(typeBD); | 1620 Set<InterfaceType> superinterfacesOfBD = InterfaceTypeImpl.computeSuperinter
faceSet(typeBD); |
| 1622 EngineTestCase.assertSizeOfSet(2, superinterfacesOfBD); | 1621 EngineTestCase.assertSizeOfSet(2, superinterfacesOfBD); |
| 1623 JUnitTestCase.assertTrue(superinterfacesOfBD.contains(typeObject)); | 1622 expect(superinterfacesOfBD.contains(typeObject), isTrue); |
| 1624 JUnitTestCase.assertTrue(superinterfacesOfBD.contains(typeA)); | 1623 expect(superinterfacesOfBD.contains(typeA), isTrue); |
| 1625 // C<D> | 1624 // C<D> |
| 1626 InterfaceTypeImpl typeCD = new InterfaceTypeImpl.con1(classC); | 1625 InterfaceTypeImpl typeCD = new InterfaceTypeImpl.con1(classC); |
| 1627 typeCD.typeArguments = <DartType> [classD.type]; | 1626 typeCD.typeArguments = <DartType> [classD.type]; |
| 1628 Set<InterfaceType> superinterfacesOfCD = InterfaceTypeImpl.computeSuperinter
faceSet(typeCD); | 1627 Set<InterfaceType> superinterfacesOfCD = InterfaceTypeImpl.computeSuperinter
faceSet(typeCD); |
| 1629 EngineTestCase.assertSizeOfSet(3, superinterfacesOfCD); | 1628 EngineTestCase.assertSizeOfSet(3, superinterfacesOfCD); |
| 1630 JUnitTestCase.assertTrue(superinterfacesOfCD.contains(typeObject)); | 1629 expect(superinterfacesOfCD.contains(typeObject), isTrue); |
| 1631 JUnitTestCase.assertTrue(superinterfacesOfCD.contains(typeA)); | 1630 expect(superinterfacesOfCD.contains(typeA), isTrue); |
| 1632 JUnitTestCase.assertTrue(superinterfacesOfCD.contains(typeBD)); | 1631 expect(superinterfacesOfCD.contains(typeBD), isTrue); |
| 1633 } | 1632 } |
| 1634 | 1633 |
| 1635 void test_computeSuperinterfaceSet_multipleInterfacePaths() { | 1634 void test_computeSuperinterfaceSet_multipleInterfacePaths() { |
| 1636 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 1635 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 1637 ClassElementImpl classB = ElementFactory.classElement2("B", []); | 1636 ClassElementImpl classB = ElementFactory.classElement2("B", []); |
| 1638 ClassElementImpl classC = ElementFactory.classElement2("C", []); | 1637 ClassElementImpl classC = ElementFactory.classElement2("C", []); |
| 1639 ClassElementImpl classD = ElementFactory.classElement2("D", []); | 1638 ClassElementImpl classD = ElementFactory.classElement2("D", []); |
| 1640 ClassElementImpl classE = ElementFactory.classElement2("E", []); | 1639 ClassElementImpl classE = ElementFactory.classElement2("E", []); |
| 1641 classB.interfaces = <InterfaceType> [classA.type]; | 1640 classB.interfaces = <InterfaceType> [classA.type]; |
| 1642 classC.interfaces = <InterfaceType> [classA.type]; | 1641 classC.interfaces = <InterfaceType> [classA.type]; |
| 1643 classD.interfaces = <InterfaceType> [classC.type]; | 1642 classD.interfaces = <InterfaceType> [classC.type]; |
| 1644 classE.interfaces = <InterfaceType> [classB.type, classD.type]; | 1643 classE.interfaces = <InterfaceType> [classB.type, classD.type]; |
| 1645 // D | 1644 // D |
| 1646 Set<InterfaceType> superinterfacesOfD = InterfaceTypeImpl.computeSuperinterf
aceSet(classD.type); | 1645 Set<InterfaceType> superinterfacesOfD = InterfaceTypeImpl.computeSuperinterf
aceSet(classD.type); |
| 1647 EngineTestCase.assertSizeOfSet(3, superinterfacesOfD); | 1646 EngineTestCase.assertSizeOfSet(3, superinterfacesOfD); |
| 1648 JUnitTestCase.assertTrue(superinterfacesOfD.contains(ElementFactory.object.t
ype)); | 1647 expect(superinterfacesOfD.contains(ElementFactory.object.type), isTrue); |
| 1649 JUnitTestCase.assertTrue(superinterfacesOfD.contains(classA.type)); | 1648 expect(superinterfacesOfD.contains(classA.type), isTrue); |
| 1650 JUnitTestCase.assertTrue(superinterfacesOfD.contains(classC.type)); | 1649 expect(superinterfacesOfD.contains(classC.type), isTrue); |
| 1651 // E | 1650 // E |
| 1652 Set<InterfaceType> superinterfacesOfE = InterfaceTypeImpl.computeSuperinterf
aceSet(classE.type); | 1651 Set<InterfaceType> superinterfacesOfE = InterfaceTypeImpl.computeSuperinterf
aceSet(classE.type); |
| 1653 EngineTestCase.assertSizeOfSet(5, superinterfacesOfE); | 1652 EngineTestCase.assertSizeOfSet(5, superinterfacesOfE); |
| 1654 JUnitTestCase.assertTrue(superinterfacesOfE.contains(ElementFactory.object.t
ype)); | 1653 expect(superinterfacesOfE.contains(ElementFactory.object.type), isTrue); |
| 1655 JUnitTestCase.assertTrue(superinterfacesOfE.contains(classA.type)); | 1654 expect(superinterfacesOfE.contains(classA.type), isTrue); |
| 1656 JUnitTestCase.assertTrue(superinterfacesOfE.contains(classB.type)); | 1655 expect(superinterfacesOfE.contains(classB.type), isTrue); |
| 1657 JUnitTestCase.assertTrue(superinterfacesOfE.contains(classC.type)); | 1656 expect(superinterfacesOfE.contains(classC.type), isTrue); |
| 1658 JUnitTestCase.assertTrue(superinterfacesOfE.contains(classD.type)); | 1657 expect(superinterfacesOfE.contains(classD.type), isTrue); |
| 1659 } | 1658 } |
| 1660 | 1659 |
| 1661 void test_computeSuperinterfaceSet_multipleSuperclassPaths() { | 1660 void test_computeSuperinterfaceSet_multipleSuperclassPaths() { |
| 1662 ClassElement classA = ElementFactory.classElement2("A", []); | 1661 ClassElement classA = ElementFactory.classElement2("A", []); |
| 1663 ClassElement classB = ElementFactory.classElement("B", classA.type, []); | 1662 ClassElement classB = ElementFactory.classElement("B", classA.type, []); |
| 1664 ClassElement classC = ElementFactory.classElement("C", classA.type, []); | 1663 ClassElement classC = ElementFactory.classElement("C", classA.type, []); |
| 1665 ClassElement classD = ElementFactory.classElement("D", classC.type, []); | 1664 ClassElement classD = ElementFactory.classElement("D", classC.type, []); |
| 1666 ClassElementImpl classE = ElementFactory.classElement("E", classB.type, []); | 1665 ClassElementImpl classE = ElementFactory.classElement("E", classB.type, []); |
| 1667 classE.interfaces = <InterfaceType> [classD.type]; | 1666 classE.interfaces = <InterfaceType> [classD.type]; |
| 1668 // D | 1667 // D |
| 1669 Set<InterfaceType> superinterfacesOfD = InterfaceTypeImpl.computeSuperinterf
aceSet(classD.type); | 1668 Set<InterfaceType> superinterfacesOfD = InterfaceTypeImpl.computeSuperinterf
aceSet(classD.type); |
| 1670 EngineTestCase.assertSizeOfSet(3, superinterfacesOfD); | 1669 EngineTestCase.assertSizeOfSet(3, superinterfacesOfD); |
| 1671 JUnitTestCase.assertTrue(superinterfacesOfD.contains(ElementFactory.object.t
ype)); | 1670 expect(superinterfacesOfD.contains(ElementFactory.object.type), isTrue); |
| 1672 JUnitTestCase.assertTrue(superinterfacesOfD.contains(classA.type)); | 1671 expect(superinterfacesOfD.contains(classA.type), isTrue); |
| 1673 JUnitTestCase.assertTrue(superinterfacesOfD.contains(classC.type)); | 1672 expect(superinterfacesOfD.contains(classC.type), isTrue); |
| 1674 // E | 1673 // E |
| 1675 Set<InterfaceType> superinterfacesOfE = InterfaceTypeImpl.computeSuperinterf
aceSet(classE.type); | 1674 Set<InterfaceType> superinterfacesOfE = InterfaceTypeImpl.computeSuperinterf
aceSet(classE.type); |
| 1676 EngineTestCase.assertSizeOfSet(5, superinterfacesOfE); | 1675 EngineTestCase.assertSizeOfSet(5, superinterfacesOfE); |
| 1677 JUnitTestCase.assertTrue(superinterfacesOfE.contains(ElementFactory.object.t
ype)); | 1676 expect(superinterfacesOfE.contains(ElementFactory.object.type), isTrue); |
| 1678 JUnitTestCase.assertTrue(superinterfacesOfE.contains(classA.type)); | 1677 expect(superinterfacesOfE.contains(classA.type), isTrue); |
| 1679 JUnitTestCase.assertTrue(superinterfacesOfE.contains(classB.type)); | 1678 expect(superinterfacesOfE.contains(classB.type), isTrue); |
| 1680 JUnitTestCase.assertTrue(superinterfacesOfE.contains(classC.type)); | 1679 expect(superinterfacesOfE.contains(classC.type), isTrue); |
| 1681 JUnitTestCase.assertTrue(superinterfacesOfE.contains(classD.type)); | 1680 expect(superinterfacesOfE.contains(classD.type), isTrue); |
| 1682 } | 1681 } |
| 1683 | 1682 |
| 1684 void test_computeSuperinterfaceSet_recursion() { | 1683 void test_computeSuperinterfaceSet_recursion() { |
| 1685 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 1684 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 1686 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); | 1685 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); |
| 1687 classA.supertype = classB.type; | 1686 classA.supertype = classB.type; |
| 1688 Set<InterfaceType> superinterfacesOfB = InterfaceTypeImpl.computeSuperinterf
aceSet(classB.type); | 1687 Set<InterfaceType> superinterfacesOfB = InterfaceTypeImpl.computeSuperinterf
aceSet(classB.type); |
| 1689 EngineTestCase.assertSizeOfSet(2, superinterfacesOfB); | 1688 EngineTestCase.assertSizeOfSet(2, superinterfacesOfB); |
| 1690 } | 1689 } |
| 1691 | 1690 |
| 1692 void test_computeSuperinterfaceSet_singleInterfacePath() { | 1691 void test_computeSuperinterfaceSet_singleInterfacePath() { |
| 1693 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 1692 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 1694 ClassElementImpl classB = ElementFactory.classElement2("B", []); | 1693 ClassElementImpl classB = ElementFactory.classElement2("B", []); |
| 1695 ClassElementImpl classC = ElementFactory.classElement2("C", []); | 1694 ClassElementImpl classC = ElementFactory.classElement2("C", []); |
| 1696 classB.interfaces = <InterfaceType> [classA.type]; | 1695 classB.interfaces = <InterfaceType> [classA.type]; |
| 1697 classC.interfaces = <InterfaceType> [classB.type]; | 1696 classC.interfaces = <InterfaceType> [classB.type]; |
| 1698 // A | 1697 // A |
| 1699 Set<InterfaceType> superinterfacesOfA = InterfaceTypeImpl.computeSuperinterf
aceSet(classA.type); | 1698 Set<InterfaceType> superinterfacesOfA = InterfaceTypeImpl.computeSuperinterf
aceSet(classA.type); |
| 1700 EngineTestCase.assertSizeOfSet(1, superinterfacesOfA); | 1699 EngineTestCase.assertSizeOfSet(1, superinterfacesOfA); |
| 1701 JUnitTestCase.assertTrue(superinterfacesOfA.contains(ElementFactory.object.t
ype)); | 1700 expect(superinterfacesOfA.contains(ElementFactory.object.type), isTrue); |
| 1702 // B | 1701 // B |
| 1703 Set<InterfaceType> superinterfacesOfB = InterfaceTypeImpl.computeSuperinterf
aceSet(classB.type); | 1702 Set<InterfaceType> superinterfacesOfB = InterfaceTypeImpl.computeSuperinterf
aceSet(classB.type); |
| 1704 EngineTestCase.assertSizeOfSet(2, superinterfacesOfB); | 1703 EngineTestCase.assertSizeOfSet(2, superinterfacesOfB); |
| 1705 JUnitTestCase.assertTrue(superinterfacesOfB.contains(ElementFactory.object.t
ype)); | 1704 expect(superinterfacesOfB.contains(ElementFactory.object.type), isTrue); |
| 1706 JUnitTestCase.assertTrue(superinterfacesOfB.contains(classA.type)); | 1705 expect(superinterfacesOfB.contains(classA.type), isTrue); |
| 1707 // C | 1706 // C |
| 1708 Set<InterfaceType> superinterfacesOfC = InterfaceTypeImpl.computeSuperinterf
aceSet(classC.type); | 1707 Set<InterfaceType> superinterfacesOfC = InterfaceTypeImpl.computeSuperinterf
aceSet(classC.type); |
| 1709 EngineTestCase.assertSizeOfSet(3, superinterfacesOfC); | 1708 EngineTestCase.assertSizeOfSet(3, superinterfacesOfC); |
| 1710 JUnitTestCase.assertTrue(superinterfacesOfC.contains(ElementFactory.object.t
ype)); | 1709 expect(superinterfacesOfC.contains(ElementFactory.object.type), isTrue); |
| 1711 JUnitTestCase.assertTrue(superinterfacesOfC.contains(classA.type)); | 1710 expect(superinterfacesOfC.contains(classA.type), isTrue); |
| 1712 JUnitTestCase.assertTrue(superinterfacesOfC.contains(classB.type)); | 1711 expect(superinterfacesOfC.contains(classB.type), isTrue); |
| 1713 } | 1712 } |
| 1714 | 1713 |
| 1715 void test_computeSuperinterfaceSet_singleSuperclassPath() { | 1714 void test_computeSuperinterfaceSet_singleSuperclassPath() { |
| 1716 // | 1715 // |
| 1717 // A | 1716 // A |
| 1718 // | | 1717 // | |
| 1719 // B | 1718 // B |
| 1720 // | | 1719 // | |
| 1721 // C | 1720 // C |
| 1722 // | 1721 // |
| 1723 ClassElement classA = ElementFactory.classElement2("A", []); | 1722 ClassElement classA = ElementFactory.classElement2("A", []); |
| 1724 ClassElement classB = ElementFactory.classElement("B", classA.type, []); | 1723 ClassElement classB = ElementFactory.classElement("B", classA.type, []); |
| 1725 ClassElement classC = ElementFactory.classElement("C", classB.type, []); | 1724 ClassElement classC = ElementFactory.classElement("C", classB.type, []); |
| 1726 // A | 1725 // A |
| 1727 Set<InterfaceType> superinterfacesOfA = InterfaceTypeImpl.computeSuperinterf
aceSet(classA.type); | 1726 Set<InterfaceType> superinterfacesOfA = InterfaceTypeImpl.computeSuperinterf
aceSet(classA.type); |
| 1728 EngineTestCase.assertSizeOfSet(1, superinterfacesOfA); | 1727 EngineTestCase.assertSizeOfSet(1, superinterfacesOfA); |
| 1729 JUnitTestCase.assertTrue(superinterfacesOfA.contains(ElementFactory.object.t
ype)); | 1728 expect(superinterfacesOfA.contains(ElementFactory.object.type), isTrue); |
| 1730 // B | 1729 // B |
| 1731 Set<InterfaceType> superinterfacesOfB = InterfaceTypeImpl.computeSuperinterf
aceSet(classB.type); | 1730 Set<InterfaceType> superinterfacesOfB = InterfaceTypeImpl.computeSuperinterf
aceSet(classB.type); |
| 1732 EngineTestCase.assertSizeOfSet(2, superinterfacesOfB); | 1731 EngineTestCase.assertSizeOfSet(2, superinterfacesOfB); |
| 1733 JUnitTestCase.assertTrue(superinterfacesOfB.contains(ElementFactory.object.t
ype)); | 1732 expect(superinterfacesOfB.contains(ElementFactory.object.type), isTrue); |
| 1734 JUnitTestCase.assertTrue(superinterfacesOfB.contains(classA.type)); | 1733 expect(superinterfacesOfB.contains(classA.type), isTrue); |
| 1735 // C | 1734 // C |
| 1736 Set<InterfaceType> superinterfacesOfC = InterfaceTypeImpl.computeSuperinterf
aceSet(classC.type); | 1735 Set<InterfaceType> superinterfacesOfC = InterfaceTypeImpl.computeSuperinterf
aceSet(classC.type); |
| 1737 EngineTestCase.assertSizeOfSet(3, superinterfacesOfC); | 1736 EngineTestCase.assertSizeOfSet(3, superinterfacesOfC); |
| 1738 JUnitTestCase.assertTrue(superinterfacesOfC.contains(ElementFactory.object.t
ype)); | 1737 expect(superinterfacesOfC.contains(ElementFactory.object.type), isTrue); |
| 1739 JUnitTestCase.assertTrue(superinterfacesOfC.contains(classA.type)); | 1738 expect(superinterfacesOfC.contains(classA.type), isTrue); |
| 1740 JUnitTestCase.assertTrue(superinterfacesOfC.contains(classB.type)); | 1739 expect(superinterfacesOfC.contains(classB.type), isTrue); |
| 1741 } | 1740 } |
| 1742 | 1741 |
| 1743 void test_creation() { | 1742 void test_creation() { |
| 1744 JUnitTestCase.assertNotNull(new InterfaceTypeImpl.con1(ElementFactory.classE
lement2("A", []))); | 1743 expect(new InterfaceTypeImpl.con1(ElementFactory.classElement2("A", [])), is
NotNull); |
| 1745 } | 1744 } |
| 1746 | 1745 |
| 1747 void test_getAccessors() { | 1746 void test_getAccessors() { |
| 1748 ClassElementImpl typeElement = ElementFactory.classElement2("A", []); | 1747 ClassElementImpl typeElement = ElementFactory.classElement2("A", []); |
| 1749 PropertyAccessorElement getterG = ElementFactory.getterElement("g", false, n
ull); | 1748 PropertyAccessorElement getterG = ElementFactory.getterElement("g", false, n
ull); |
| 1750 PropertyAccessorElement getterH = ElementFactory.getterElement("h", false, n
ull); | 1749 PropertyAccessorElement getterH = ElementFactory.getterElement("h", false, n
ull); |
| 1751 typeElement.accessors = <PropertyAccessorElement> [getterG, getterH]; | 1750 typeElement.accessors = <PropertyAccessorElement> [getterG, getterH]; |
| 1752 InterfaceTypeImpl type = new InterfaceTypeImpl.con1(typeElement); | 1751 InterfaceTypeImpl type = new InterfaceTypeImpl.con1(typeElement); |
| 1753 JUnitTestCase.assertEquals(2, type.accessors.length); | 1752 expect(type.accessors.length, 2); |
| 1754 } | 1753 } |
| 1755 | 1754 |
| 1756 void test_getAccessors_empty() { | 1755 void test_getAccessors_empty() { |
| 1757 ClassElementImpl typeElement = ElementFactory.classElement2("A", []); | 1756 ClassElementImpl typeElement = ElementFactory.classElement2("A", []); |
| 1758 InterfaceTypeImpl type = new InterfaceTypeImpl.con1(typeElement); | 1757 InterfaceTypeImpl type = new InterfaceTypeImpl.con1(typeElement); |
| 1759 JUnitTestCase.assertEquals(0, type.accessors.length); | 1758 expect(type.accessors.length, 0); |
| 1760 } | 1759 } |
| 1761 | 1760 |
| 1762 void test_getElement() { | 1761 void test_getElement() { |
| 1763 ClassElementImpl typeElement = ElementFactory.classElement2("A", []); | 1762 ClassElementImpl typeElement = ElementFactory.classElement2("A", []); |
| 1764 InterfaceTypeImpl type = new InterfaceTypeImpl.con1(typeElement); | 1763 InterfaceTypeImpl type = new InterfaceTypeImpl.con1(typeElement); |
| 1765 JUnitTestCase.assertEquals(typeElement, type.element); | 1764 expect(type.element, typeElement); |
| 1766 } | 1765 } |
| 1767 | 1766 |
| 1768 void test_getGetter_implemented() { | 1767 void test_getGetter_implemented() { |
| 1769 // | 1768 // |
| 1770 // class A { g {} } | 1769 // class A { g {} } |
| 1771 // | 1770 // |
| 1772 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 1771 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 1773 String getterName = "g"; | 1772 String getterName = "g"; |
| 1774 PropertyAccessorElement getterG = ElementFactory.getterElement(getterName, f
alse, null); | 1773 PropertyAccessorElement getterG = ElementFactory.getterElement(getterName, f
alse, null); |
| 1775 classA.accessors = <PropertyAccessorElement> [getterG]; | 1774 classA.accessors = <PropertyAccessorElement> [getterG]; |
| 1776 InterfaceType typeA = classA.type; | 1775 InterfaceType typeA = classA.type; |
| 1777 JUnitTestCase.assertSame(getterG, typeA.getGetter(getterName)); | 1776 expect(typeA.getGetter(getterName), same(getterG)); |
| 1778 } | 1777 } |
| 1779 | 1778 |
| 1780 void test_getGetter_parameterized() { | 1779 void test_getGetter_parameterized() { |
| 1781 // | 1780 // |
| 1782 // class A<E> { E get g {} } | 1781 // class A<E> { E get g {} } |
| 1783 // | 1782 // |
| 1784 ClassElementImpl classA = ElementFactory.classElement2("A", ["E"]); | 1783 ClassElementImpl classA = ElementFactory.classElement2("A", ["E"]); |
| 1785 DartType typeE = classA.type.typeArguments[0]; | 1784 DartType typeE = classA.type.typeArguments[0]; |
| 1786 String getterName = "g"; | 1785 String getterName = "g"; |
| 1787 PropertyAccessorElement getterG = ElementFactory.getterElement(getterName, f
alse, typeE); | 1786 PropertyAccessorElement getterG = ElementFactory.getterElement(getterName, f
alse, typeE); |
| 1788 classA.accessors = <PropertyAccessorElement> [getterG]; | 1787 classA.accessors = <PropertyAccessorElement> [getterG]; |
| 1789 (getterG.type as FunctionTypeImpl).typeArguments = classA.type.typeArguments
; | 1788 (getterG.type as FunctionTypeImpl).typeArguments = classA.type.typeArguments
; |
| 1790 // | 1789 // |
| 1791 // A<I> | 1790 // A<I> |
| 1792 // | 1791 // |
| 1793 InterfaceType typeI = ElementFactory.classElement2("I", []).type; | 1792 InterfaceType typeI = ElementFactory.classElement2("I", []).type; |
| 1794 InterfaceTypeImpl typeAI = new InterfaceTypeImpl.con1(classA); | 1793 InterfaceTypeImpl typeAI = new InterfaceTypeImpl.con1(classA); |
| 1795 typeAI.typeArguments = <DartType> [typeI]; | 1794 typeAI.typeArguments = <DartType> [typeI]; |
| 1796 PropertyAccessorElement getter = typeAI.getGetter(getterName); | 1795 PropertyAccessorElement getter = typeAI.getGetter(getterName); |
| 1797 JUnitTestCase.assertNotNull(getter); | 1796 expect(getter, isNotNull); |
| 1798 FunctionType getterType = getter.type; | 1797 FunctionType getterType = getter.type; |
| 1799 JUnitTestCase.assertSame(typeI, getterType.returnType); | 1798 expect(getterType.returnType, same(typeI)); |
| 1800 } | 1799 } |
| 1801 | 1800 |
| 1802 void test_getGetter_unimplemented() { | 1801 void test_getGetter_unimplemented() { |
| 1803 // | 1802 // |
| 1804 // class A {} | 1803 // class A {} |
| 1805 // | 1804 // |
| 1806 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 1805 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 1807 InterfaceType typeA = classA.type; | 1806 InterfaceType typeA = classA.type; |
| 1808 JUnitTestCase.assertNull(typeA.getGetter("g")); | 1807 expect(typeA.getGetter("g"), isNull); |
| 1809 } | 1808 } |
| 1810 | 1809 |
| 1811 void test_getInterfaces_nonParameterized() { | 1810 void test_getInterfaces_nonParameterized() { |
| 1812 // | 1811 // |
| 1813 // class C implements A, B | 1812 // class C implements A, B |
| 1814 // | 1813 // |
| 1815 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 1814 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 1816 InterfaceType typeA = classA.type; | 1815 InterfaceType typeA = classA.type; |
| 1817 ClassElementImpl classB = ElementFactory.classElement2("B", []); | 1816 ClassElementImpl classB = ElementFactory.classElement2("B", []); |
| 1818 InterfaceType typeB = classB.type; | 1817 InterfaceType typeB = classB.type; |
| 1819 ClassElementImpl classC = ElementFactory.classElement2("C", []); | 1818 ClassElementImpl classC = ElementFactory.classElement2("C", []); |
| 1820 classC.interfaces = <InterfaceType> [typeA, typeB]; | 1819 classC.interfaces = <InterfaceType> [typeA, typeB]; |
| 1821 List<InterfaceType> interfaces = classC.type.interfaces; | 1820 List<InterfaceType> interfaces = classC.type.interfaces; |
| 1822 EngineTestCase.assertLength(2, interfaces); | 1821 EngineTestCase.assertLength(2, interfaces); |
| 1823 if (identical(interfaces[0], typeA)) { | 1822 if (identical(interfaces[0], typeA)) { |
| 1824 JUnitTestCase.assertSame(typeB, interfaces[1]); | 1823 expect(interfaces[1], same(typeB)); |
| 1825 } else { | 1824 } else { |
| 1826 JUnitTestCase.assertSame(typeB, interfaces[0]); | 1825 expect(interfaces[0], same(typeB)); |
| 1827 JUnitTestCase.assertSame(typeA, interfaces[1]); | 1826 expect(interfaces[1], same(typeA)); |
| 1828 } | 1827 } |
| 1829 } | 1828 } |
| 1830 | 1829 |
| 1831 void test_getInterfaces_parameterized() { | 1830 void test_getInterfaces_parameterized() { |
| 1832 // | 1831 // |
| 1833 // class A<E> | 1832 // class A<E> |
| 1834 // class B<F> implements A<F> | 1833 // class B<F> implements A<F> |
| 1835 // | 1834 // |
| 1836 ClassElementImpl classA = ElementFactory.classElement2("A", ["E"]); | 1835 ClassElementImpl classA = ElementFactory.classElement2("A", ["E"]); |
| 1837 ClassElementImpl classB = ElementFactory.classElement2("B", ["F"]); | 1836 ClassElementImpl classB = ElementFactory.classElement2("B", ["F"]); |
| 1838 InterfaceType typeB = classB.type; | 1837 InterfaceType typeB = classB.type; |
| 1839 InterfaceTypeImpl typeAF = new InterfaceTypeImpl.con1(classA); | 1838 InterfaceTypeImpl typeAF = new InterfaceTypeImpl.con1(classA); |
| 1840 typeAF.typeArguments = <DartType> [typeB.typeArguments[0]]; | 1839 typeAF.typeArguments = <DartType> [typeB.typeArguments[0]]; |
| 1841 classB.interfaces = <InterfaceType> [typeAF]; | 1840 classB.interfaces = <InterfaceType> [typeAF]; |
| 1842 // | 1841 // |
| 1843 // B<I> | 1842 // B<I> |
| 1844 // | 1843 // |
| 1845 InterfaceType typeI = ElementFactory.classElement2("I", []).type; | 1844 InterfaceType typeI = ElementFactory.classElement2("I", []).type; |
| 1846 InterfaceTypeImpl typeBI = new InterfaceTypeImpl.con1(classB); | 1845 InterfaceTypeImpl typeBI = new InterfaceTypeImpl.con1(classB); |
| 1847 typeBI.typeArguments = <DartType> [typeI]; | 1846 typeBI.typeArguments = <DartType> [typeI]; |
| 1848 List<InterfaceType> interfaces = typeBI.interfaces; | 1847 List<InterfaceType> interfaces = typeBI.interfaces; |
| 1849 EngineTestCase.assertLength(1, interfaces); | 1848 EngineTestCase.assertLength(1, interfaces); |
| 1850 InterfaceType result = interfaces[0]; | 1849 InterfaceType result = interfaces[0]; |
| 1851 JUnitTestCase.assertSame(classA, result.element); | 1850 expect(result.element, same(classA)); |
| 1852 JUnitTestCase.assertSame(typeI, result.typeArguments[0]); | 1851 expect(result.typeArguments[0], same(typeI)); |
| 1853 } | 1852 } |
| 1854 | 1853 |
| 1855 void test_getLeastUpperBound_directInterfaceCase() { | 1854 void test_getLeastUpperBound_directInterfaceCase() { |
| 1856 // | 1855 // |
| 1857 // class A | 1856 // class A |
| 1858 // class B implements A | 1857 // class B implements A |
| 1859 // class C implements B | 1858 // class C implements B |
| 1860 // | 1859 // |
| 1861 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 1860 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 1862 ClassElementImpl classB = ElementFactory.classElement2("B", []); | 1861 ClassElementImpl classB = ElementFactory.classElement2("B", []); |
| 1863 ClassElementImpl classC = ElementFactory.classElement2("C", []); | 1862 ClassElementImpl classC = ElementFactory.classElement2("C", []); |
| 1864 InterfaceType typeA = classA.type; | 1863 InterfaceType typeA = classA.type; |
| 1865 InterfaceType typeB = classB.type; | 1864 InterfaceType typeB = classB.type; |
| 1866 InterfaceType typeC = classC.type; | 1865 InterfaceType typeC = classC.type; |
| 1867 classB.interfaces = <InterfaceType> [typeA]; | 1866 classB.interfaces = <InterfaceType> [typeA]; |
| 1868 classC.interfaces = <InterfaceType> [typeB]; | 1867 classC.interfaces = <InterfaceType> [typeB]; |
| 1869 JUnitTestCase.assertEquals(typeB, typeB.getLeastUpperBound(typeC)); | 1868 expect(typeB.getLeastUpperBound(typeC), typeB); |
| 1870 JUnitTestCase.assertEquals(typeB, typeC.getLeastUpperBound(typeB)); | 1869 expect(typeC.getLeastUpperBound(typeB), typeB); |
| 1871 } | 1870 } |
| 1872 | 1871 |
| 1873 void test_getLeastUpperBound_directSubclassCase() { | 1872 void test_getLeastUpperBound_directSubclassCase() { |
| 1874 // | 1873 // |
| 1875 // class A | 1874 // class A |
| 1876 // class B extends A | 1875 // class B extends A |
| 1877 // class C extends B | 1876 // class C extends B |
| 1878 // | 1877 // |
| 1879 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 1878 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 1880 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); | 1879 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); |
| 1881 ClassElementImpl classC = ElementFactory.classElement("C", classB.type, []); | 1880 ClassElementImpl classC = ElementFactory.classElement("C", classB.type, []); |
| 1882 InterfaceType typeB = classB.type; | 1881 InterfaceType typeB = classB.type; |
| 1883 InterfaceType typeC = classC.type; | 1882 InterfaceType typeC = classC.type; |
| 1884 JUnitTestCase.assertEquals(typeB, typeB.getLeastUpperBound(typeC)); | 1883 expect(typeB.getLeastUpperBound(typeC), typeB); |
| 1885 JUnitTestCase.assertEquals(typeB, typeC.getLeastUpperBound(typeB)); | 1884 expect(typeC.getLeastUpperBound(typeB), typeB); |
| 1886 } | 1885 } |
| 1887 | 1886 |
| 1888 void test_getLeastUpperBound_functionType() { | 1887 void test_getLeastUpperBound_functionType() { |
| 1889 DartType interfaceType = ElementFactory.classElement2("A", []).type; | 1888 DartType interfaceType = ElementFactory.classElement2("A", []).type; |
| 1890 FunctionTypeImpl functionType = new FunctionTypeImpl.con1(new FunctionElemen
tImpl.forNode(AstFactory.identifier3("f"))); | 1889 FunctionTypeImpl functionType = new FunctionTypeImpl.con1(new FunctionElemen
tImpl.forNode(AstFactory.identifier3("f"))); |
| 1891 JUnitTestCase.assertNull(interfaceType.getLeastUpperBound(functionType)); | 1890 expect(interfaceType.getLeastUpperBound(functionType), isNull); |
| 1892 } | 1891 } |
| 1893 | 1892 |
| 1894 void test_getLeastUpperBound_mixinCase() { | 1893 void test_getLeastUpperBound_mixinCase() { |
| 1895 // | 1894 // |
| 1896 // class A | 1895 // class A |
| 1897 // class B extends A | 1896 // class B extends A |
| 1898 // class C extends A | 1897 // class C extends A |
| 1899 // class D extends B with M, N, O, P | 1898 // class D extends B with M, N, O, P |
| 1900 // | 1899 // |
| 1901 ClassElement classA = ElementFactory.classElement2("A", []); | 1900 ClassElement classA = ElementFactory.classElement2("A", []); |
| 1902 ClassElement classB = ElementFactory.classElement("B", classA.type, []); | 1901 ClassElement classB = ElementFactory.classElement("B", classA.type, []); |
| 1903 ClassElement classC = ElementFactory.classElement("C", classA.type, []); | 1902 ClassElement classC = ElementFactory.classElement("C", classA.type, []); |
| 1904 ClassElementImpl classD = ElementFactory.classElement("D", classB.type, []); | 1903 ClassElementImpl classD = ElementFactory.classElement("D", classB.type, []); |
| 1905 InterfaceType typeA = classA.type; | 1904 InterfaceType typeA = classA.type; |
| 1906 InterfaceType typeC = classC.type; | 1905 InterfaceType typeC = classC.type; |
| 1907 InterfaceType typeD = classD.type; | 1906 InterfaceType typeD = classD.type; |
| 1908 classD.mixins = <InterfaceType> [ | 1907 classD.mixins = <InterfaceType> [ |
| 1909 ElementFactory.classElement2("M", []).type, | 1908 ElementFactory.classElement2("M", []).type, |
| 1910 ElementFactory.classElement2("N", []).type, | 1909 ElementFactory.classElement2("N", []).type, |
| 1911 ElementFactory.classElement2("O", []).type, | 1910 ElementFactory.classElement2("O", []).type, |
| 1912 ElementFactory.classElement2("P", []).type]; | 1911 ElementFactory.classElement2("P", []).type]; |
| 1913 JUnitTestCase.assertEquals(typeA, typeD.getLeastUpperBound(typeC)); | 1912 expect(typeD.getLeastUpperBound(typeC), typeA); |
| 1914 JUnitTestCase.assertEquals(typeA, typeC.getLeastUpperBound(typeD)); | 1913 expect(typeC.getLeastUpperBound(typeD), typeA); |
| 1915 } | 1914 } |
| 1916 | 1915 |
| 1917 void test_getLeastUpperBound_null() { | 1916 void test_getLeastUpperBound_null() { |
| 1918 DartType interfaceType = ElementFactory.classElement2("A", []).type; | 1917 DartType interfaceType = ElementFactory.classElement2("A", []).type; |
| 1919 JUnitTestCase.assertNull(interfaceType.getLeastUpperBound(null)); | 1918 expect(interfaceType.getLeastUpperBound(null), isNull); |
| 1920 } | 1919 } |
| 1921 | 1920 |
| 1922 void test_getLeastUpperBound_object() { | 1921 void test_getLeastUpperBound_object() { |
| 1923 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 1922 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 1924 ClassElementImpl classB = ElementFactory.classElement2("B", []); | 1923 ClassElementImpl classB = ElementFactory.classElement2("B", []); |
| 1925 InterfaceType typeA = classA.type; | 1924 InterfaceType typeA = classA.type; |
| 1926 InterfaceType typeB = classB.type; | 1925 InterfaceType typeB = classB.type; |
| 1927 DartType typeObject = typeA.element.supertype; | 1926 DartType typeObject = typeA.element.supertype; |
| 1928 // assert that object does not have a super type | 1927 // assert that object does not have a super type |
| 1929 JUnitTestCase.assertNull((typeObject.element as ClassElement).supertype); | 1928 expect((typeObject.element as ClassElement).supertype, isNull); |
| 1930 // assert that both A and B have the same super type of Object | 1929 // assert that both A and B have the same super type of Object |
| 1931 JUnitTestCase.assertEquals(typeObject, typeB.element.supertype); | 1930 expect(typeB.element.supertype, typeObject); |
| 1932 // finally, assert that the only least upper bound of A and B is Object | 1931 // finally, assert that the only least upper bound of A and B is Object |
| 1933 JUnitTestCase.assertEquals(typeObject, typeA.getLeastUpperBound(typeB)); | 1932 expect(typeA.getLeastUpperBound(typeB), typeObject); |
| 1934 } | 1933 } |
| 1935 | 1934 |
| 1936 void test_getLeastUpperBound_self() { | 1935 void test_getLeastUpperBound_self() { |
| 1937 ClassElement classA = ElementFactory.classElement2("A", []); | 1936 ClassElement classA = ElementFactory.classElement2("A", []); |
| 1938 InterfaceType typeA = classA.type; | 1937 InterfaceType typeA = classA.type; |
| 1939 JUnitTestCase.assertEquals(typeA, typeA.getLeastUpperBound(typeA)); | 1938 expect(typeA.getLeastUpperBound(typeA), typeA); |
| 1940 } | 1939 } |
| 1941 | 1940 |
| 1942 void test_getLeastUpperBound_sharedSuperclass1() { | 1941 void test_getLeastUpperBound_sharedSuperclass1() { |
| 1943 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 1942 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 1944 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); | 1943 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); |
| 1945 ClassElementImpl classC = ElementFactory.classElement("C", classA.type, []); | 1944 ClassElementImpl classC = ElementFactory.classElement("C", classA.type, []); |
| 1946 InterfaceType typeA = classA.type; | 1945 InterfaceType typeA = classA.type; |
| 1947 InterfaceType typeB = classB.type; | 1946 InterfaceType typeB = classB.type; |
| 1948 InterfaceType typeC = classC.type; | 1947 InterfaceType typeC = classC.type; |
| 1949 JUnitTestCase.assertEquals(typeA, typeB.getLeastUpperBound(typeC)); | 1948 expect(typeB.getLeastUpperBound(typeC), typeA); |
| 1950 JUnitTestCase.assertEquals(typeA, typeC.getLeastUpperBound(typeB)); | 1949 expect(typeC.getLeastUpperBound(typeB), typeA); |
| 1951 } | 1950 } |
| 1952 | 1951 |
| 1953 void test_getLeastUpperBound_sharedSuperclass2() { | 1952 void test_getLeastUpperBound_sharedSuperclass2() { |
| 1954 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 1953 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 1955 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); | 1954 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); |
| 1956 ClassElementImpl classC = ElementFactory.classElement("C", classA.type, []); | 1955 ClassElementImpl classC = ElementFactory.classElement("C", classA.type, []); |
| 1957 ClassElementImpl classD = ElementFactory.classElement("D", classC.type, []); | 1956 ClassElementImpl classD = ElementFactory.classElement("D", classC.type, []); |
| 1958 InterfaceType typeA = classA.type; | 1957 InterfaceType typeA = classA.type; |
| 1959 InterfaceType typeB = classB.type; | 1958 InterfaceType typeB = classB.type; |
| 1960 InterfaceType typeD = classD.type; | 1959 InterfaceType typeD = classD.type; |
| 1961 JUnitTestCase.assertEquals(typeA, typeB.getLeastUpperBound(typeD)); | 1960 expect(typeB.getLeastUpperBound(typeD), typeA); |
| 1962 JUnitTestCase.assertEquals(typeA, typeD.getLeastUpperBound(typeB)); | 1961 expect(typeD.getLeastUpperBound(typeB), typeA); |
| 1963 } | 1962 } |
| 1964 | 1963 |
| 1965 void test_getLeastUpperBound_sharedSuperclass3() { | 1964 void test_getLeastUpperBound_sharedSuperclass3() { |
| 1966 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 1965 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 1967 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); | 1966 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); |
| 1968 ClassElementImpl classC = ElementFactory.classElement("C", classB.type, []); | 1967 ClassElementImpl classC = ElementFactory.classElement("C", classB.type, []); |
| 1969 ClassElementImpl classD = ElementFactory.classElement("D", classB.type, []); | 1968 ClassElementImpl classD = ElementFactory.classElement("D", classB.type, []); |
| 1970 InterfaceType typeB = classB.type; | 1969 InterfaceType typeB = classB.type; |
| 1971 InterfaceType typeC = classC.type; | 1970 InterfaceType typeC = classC.type; |
| 1972 InterfaceType typeD = classD.type; | 1971 InterfaceType typeD = classD.type; |
| 1973 JUnitTestCase.assertEquals(typeB, typeC.getLeastUpperBound(typeD)); | 1972 expect(typeC.getLeastUpperBound(typeD), typeB); |
| 1974 JUnitTestCase.assertEquals(typeB, typeD.getLeastUpperBound(typeC)); | 1973 expect(typeD.getLeastUpperBound(typeC), typeB); |
| 1975 } | 1974 } |
| 1976 | 1975 |
| 1977 void test_getLeastUpperBound_sharedSuperclass4() { | 1976 void test_getLeastUpperBound_sharedSuperclass4() { |
| 1978 ClassElement classA = ElementFactory.classElement2("A", []); | 1977 ClassElement classA = ElementFactory.classElement2("A", []); |
| 1979 ClassElement classA2 = ElementFactory.classElement2("A2", []); | 1978 ClassElement classA2 = ElementFactory.classElement2("A2", []); |
| 1980 ClassElement classA3 = ElementFactory.classElement2("A3", []); | 1979 ClassElement classA3 = ElementFactory.classElement2("A3", []); |
| 1981 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); | 1980 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); |
| 1982 ClassElementImpl classC = ElementFactory.classElement("C", classA.type, []); | 1981 ClassElementImpl classC = ElementFactory.classElement("C", classA.type, []); |
| 1983 InterfaceType typeA = classA.type; | 1982 InterfaceType typeA = classA.type; |
| 1984 InterfaceType typeA2 = classA2.type; | 1983 InterfaceType typeA2 = classA2.type; |
| 1985 InterfaceType typeA3 = classA3.type; | 1984 InterfaceType typeA3 = classA3.type; |
| 1986 InterfaceType typeB = classB.type; | 1985 InterfaceType typeB = classB.type; |
| 1987 InterfaceType typeC = classC.type; | 1986 InterfaceType typeC = classC.type; |
| 1988 classB.interfaces = <InterfaceType> [typeA2]; | 1987 classB.interfaces = <InterfaceType> [typeA2]; |
| 1989 classC.interfaces = <InterfaceType> [typeA3]; | 1988 classC.interfaces = <InterfaceType> [typeA3]; |
| 1990 JUnitTestCase.assertEquals(typeA, typeB.getLeastUpperBound(typeC)); | 1989 expect(typeB.getLeastUpperBound(typeC), typeA); |
| 1991 JUnitTestCase.assertEquals(typeA, typeC.getLeastUpperBound(typeB)); | 1990 expect(typeC.getLeastUpperBound(typeB), typeA); |
| 1992 } | 1991 } |
| 1993 | 1992 |
| 1994 void test_getLeastUpperBound_sharedSuperinterface1() { | 1993 void test_getLeastUpperBound_sharedSuperinterface1() { |
| 1995 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 1994 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 1996 ClassElementImpl classB = ElementFactory.classElement2("B", []); | 1995 ClassElementImpl classB = ElementFactory.classElement2("B", []); |
| 1997 ClassElementImpl classC = ElementFactory.classElement2("C", []); | 1996 ClassElementImpl classC = ElementFactory.classElement2("C", []); |
| 1998 InterfaceType typeA = classA.type; | 1997 InterfaceType typeA = classA.type; |
| 1999 InterfaceType typeB = classB.type; | 1998 InterfaceType typeB = classB.type; |
| 2000 InterfaceType typeC = classC.type; | 1999 InterfaceType typeC = classC.type; |
| 2001 classB.interfaces = <InterfaceType> [typeA]; | 2000 classB.interfaces = <InterfaceType> [typeA]; |
| 2002 classC.interfaces = <InterfaceType> [typeA]; | 2001 classC.interfaces = <InterfaceType> [typeA]; |
| 2003 JUnitTestCase.assertEquals(typeA, typeB.getLeastUpperBound(typeC)); | 2002 expect(typeB.getLeastUpperBound(typeC), typeA); |
| 2004 JUnitTestCase.assertEquals(typeA, typeC.getLeastUpperBound(typeB)); | 2003 expect(typeC.getLeastUpperBound(typeB), typeA); |
| 2005 } | 2004 } |
| 2006 | 2005 |
| 2007 void test_getLeastUpperBound_sharedSuperinterface2() { | 2006 void test_getLeastUpperBound_sharedSuperinterface2() { |
| 2008 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 2007 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 2009 ClassElementImpl classB = ElementFactory.classElement2("B", []); | 2008 ClassElementImpl classB = ElementFactory.classElement2("B", []); |
| 2010 ClassElementImpl classC = ElementFactory.classElement2("C", []); | 2009 ClassElementImpl classC = ElementFactory.classElement2("C", []); |
| 2011 ClassElementImpl classD = ElementFactory.classElement2("D", []); | 2010 ClassElementImpl classD = ElementFactory.classElement2("D", []); |
| 2012 InterfaceType typeA = classA.type; | 2011 InterfaceType typeA = classA.type; |
| 2013 InterfaceType typeB = classB.type; | 2012 InterfaceType typeB = classB.type; |
| 2014 InterfaceType typeC = classC.type; | 2013 InterfaceType typeC = classC.type; |
| 2015 InterfaceType typeD = classD.type; | 2014 InterfaceType typeD = classD.type; |
| 2016 classB.interfaces = <InterfaceType> [typeA]; | 2015 classB.interfaces = <InterfaceType> [typeA]; |
| 2017 classC.interfaces = <InterfaceType> [typeA]; | 2016 classC.interfaces = <InterfaceType> [typeA]; |
| 2018 classD.interfaces = <InterfaceType> [typeC]; | 2017 classD.interfaces = <InterfaceType> [typeC]; |
| 2019 JUnitTestCase.assertEquals(typeA, typeB.getLeastUpperBound(typeD)); | 2018 expect(typeB.getLeastUpperBound(typeD), typeA); |
| 2020 JUnitTestCase.assertEquals(typeA, typeD.getLeastUpperBound(typeB)); | 2019 expect(typeD.getLeastUpperBound(typeB), typeA); |
| 2021 } | 2020 } |
| 2022 | 2021 |
| 2023 void test_getLeastUpperBound_sharedSuperinterface3() { | 2022 void test_getLeastUpperBound_sharedSuperinterface3() { |
| 2024 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 2023 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 2025 ClassElementImpl classB = ElementFactory.classElement2("B", []); | 2024 ClassElementImpl classB = ElementFactory.classElement2("B", []); |
| 2026 ClassElementImpl classC = ElementFactory.classElement2("C", []); | 2025 ClassElementImpl classC = ElementFactory.classElement2("C", []); |
| 2027 ClassElementImpl classD = ElementFactory.classElement2("D", []); | 2026 ClassElementImpl classD = ElementFactory.classElement2("D", []); |
| 2028 InterfaceType typeA = classA.type; | 2027 InterfaceType typeA = classA.type; |
| 2029 InterfaceType typeB = classB.type; | 2028 InterfaceType typeB = classB.type; |
| 2030 InterfaceType typeC = classC.type; | 2029 InterfaceType typeC = classC.type; |
| 2031 InterfaceType typeD = classD.type; | 2030 InterfaceType typeD = classD.type; |
| 2032 classB.interfaces = <InterfaceType> [typeA]; | 2031 classB.interfaces = <InterfaceType> [typeA]; |
| 2033 classC.interfaces = <InterfaceType> [typeB]; | 2032 classC.interfaces = <InterfaceType> [typeB]; |
| 2034 classD.interfaces = <InterfaceType> [typeB]; | 2033 classD.interfaces = <InterfaceType> [typeB]; |
| 2035 JUnitTestCase.assertEquals(typeB, typeC.getLeastUpperBound(typeD)); | 2034 expect(typeC.getLeastUpperBound(typeD), typeB); |
| 2036 JUnitTestCase.assertEquals(typeB, typeD.getLeastUpperBound(typeC)); | 2035 expect(typeD.getLeastUpperBound(typeC), typeB); |
| 2037 } | 2036 } |
| 2038 | 2037 |
| 2039 void test_getLeastUpperBound_sharedSuperinterface4() { | 2038 void test_getLeastUpperBound_sharedSuperinterface4() { |
| 2040 ClassElement classA = ElementFactory.classElement2("A", []); | 2039 ClassElement classA = ElementFactory.classElement2("A", []); |
| 2041 ClassElement classA2 = ElementFactory.classElement2("A2", []); | 2040 ClassElement classA2 = ElementFactory.classElement2("A2", []); |
| 2042 ClassElement classA3 = ElementFactory.classElement2("A3", []); | 2041 ClassElement classA3 = ElementFactory.classElement2("A3", []); |
| 2043 ClassElementImpl classB = ElementFactory.classElement2("B", []); | 2042 ClassElementImpl classB = ElementFactory.classElement2("B", []); |
| 2044 ClassElementImpl classC = ElementFactory.classElement2("C", []); | 2043 ClassElementImpl classC = ElementFactory.classElement2("C", []); |
| 2045 InterfaceType typeA = classA.type; | 2044 InterfaceType typeA = classA.type; |
| 2046 InterfaceType typeA2 = classA2.type; | 2045 InterfaceType typeA2 = classA2.type; |
| 2047 InterfaceType typeA3 = classA3.type; | 2046 InterfaceType typeA3 = classA3.type; |
| 2048 InterfaceType typeB = classB.type; | 2047 InterfaceType typeB = classB.type; |
| 2049 InterfaceType typeC = classC.type; | 2048 InterfaceType typeC = classC.type; |
| 2050 classB.interfaces = <InterfaceType> [typeA, typeA2]; | 2049 classB.interfaces = <InterfaceType> [typeA, typeA2]; |
| 2051 classC.interfaces = <InterfaceType> [typeA, typeA3]; | 2050 classC.interfaces = <InterfaceType> [typeA, typeA3]; |
| 2052 JUnitTestCase.assertEquals(typeA, typeB.getLeastUpperBound(typeC)); | 2051 expect(typeB.getLeastUpperBound(typeC), typeA); |
| 2053 JUnitTestCase.assertEquals(typeA, typeC.getLeastUpperBound(typeB)); | 2052 expect(typeC.getLeastUpperBound(typeB), typeA); |
| 2054 } | 2053 } |
| 2055 | 2054 |
| 2056 void test_getLeastUpperBound_twoComparables() { | 2055 void test_getLeastUpperBound_twoComparables() { |
| 2057 InterfaceType string = _typeProvider.stringType; | 2056 InterfaceType string = _typeProvider.stringType; |
| 2058 InterfaceType num = _typeProvider.numType; | 2057 InterfaceType num = _typeProvider.numType; |
| 2059 JUnitTestCase.assertEquals(_typeProvider.objectType, string.getLeastUpperBou
nd(num)); | 2058 expect(string.getLeastUpperBound(num), _typeProvider.objectType); |
| 2060 } | 2059 } |
| 2061 | 2060 |
| 2062 void test_getLeastUpperBound_typeParameters_different() { | 2061 void test_getLeastUpperBound_typeParameters_different() { |
| 2063 // | 2062 // |
| 2064 // class List<int> | 2063 // class List<int> |
| 2065 // class List<double> | 2064 // class List<double> |
| 2066 // | 2065 // |
| 2067 InterfaceType listType = _typeProvider.listType; | 2066 InterfaceType listType = _typeProvider.listType; |
| 2068 InterfaceType intType = _typeProvider.intType; | 2067 InterfaceType intType = _typeProvider.intType; |
| 2069 InterfaceType doubleType = _typeProvider.doubleType; | 2068 InterfaceType doubleType = _typeProvider.doubleType; |
| 2070 InterfaceType listOfIntType = listType.substitute4(<DartType> [intType]); | 2069 InterfaceType listOfIntType = listType.substitute4(<DartType> [intType]); |
| 2071 InterfaceType listOfDoubleType = listType.substitute4(<DartType> [doubleType
]); | 2070 InterfaceType listOfDoubleType = listType.substitute4(<DartType> [doubleType
]); |
| 2072 JUnitTestCase.assertEquals(_typeProvider.objectType, listOfIntType.getLeastU
pperBound(listOfDoubleType)); | 2071 expect(listOfIntType.getLeastUpperBound(listOfDoubleType), _typeProvider.obj
ectType); |
| 2073 } | 2072 } |
| 2074 | 2073 |
| 2075 void test_getLeastUpperBound_typeParameters_same() { | 2074 void test_getLeastUpperBound_typeParameters_same() { |
| 2076 // | 2075 // |
| 2077 // List<int> | 2076 // List<int> |
| 2078 // List<int> | 2077 // List<int> |
| 2079 // | 2078 // |
| 2080 InterfaceType listType = _typeProvider.listType; | 2079 InterfaceType listType = _typeProvider.listType; |
| 2081 InterfaceType intType = _typeProvider.intType; | 2080 InterfaceType intType = _typeProvider.intType; |
| 2082 InterfaceType listOfIntType = listType.substitute4(<DartType> [intType]); | 2081 InterfaceType listOfIntType = listType.substitute4(<DartType> [intType]); |
| 2083 JUnitTestCase.assertEquals(listOfIntType, listOfIntType.getLeastUpperBound(l
istOfIntType)); | 2082 expect(listOfIntType.getLeastUpperBound(listOfIntType), listOfIntType); |
| 2084 } | 2083 } |
| 2085 | 2084 |
| 2086 void test_getMethod_implemented() { | 2085 void test_getMethod_implemented() { |
| 2087 // | 2086 // |
| 2088 // class A { m() {} } | 2087 // class A { m() {} } |
| 2089 // | 2088 // |
| 2090 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 2089 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 2091 String methodName = "m"; | 2090 String methodName = "m"; |
| 2092 MethodElementImpl methodM = ElementFactory.methodElement(methodName, null, [
]); | 2091 MethodElementImpl methodM = ElementFactory.methodElement(methodName, null, [
]); |
| 2093 classA.methods = <MethodElement> [methodM]; | 2092 classA.methods = <MethodElement> [methodM]; |
| 2094 InterfaceType typeA = classA.type; | 2093 InterfaceType typeA = classA.type; |
| 2095 JUnitTestCase.assertSame(methodM, typeA.getMethod(methodName)); | 2094 expect(typeA.getMethod(methodName), same(methodM)); |
| 2096 } | 2095 } |
| 2097 | 2096 |
| 2098 void test_getMethod_parameterized() { | 2097 void test_getMethod_parameterized() { |
| 2099 // | 2098 // |
| 2100 // class A<E> { E m(E p) {} } | 2099 // class A<E> { E m(E p) {} } |
| 2101 // | 2100 // |
| 2102 ClassElementImpl classA = ElementFactory.classElement2("A", ["E"]); | 2101 ClassElementImpl classA = ElementFactory.classElement2("A", ["E"]); |
| 2103 DartType typeE = classA.type.typeArguments[0]; | 2102 DartType typeE = classA.type.typeArguments[0]; |
| 2104 String methodName = "m"; | 2103 String methodName = "m"; |
| 2105 MethodElementImpl methodM = ElementFactory.methodElement(methodName, typeE,
[typeE]); | 2104 MethodElementImpl methodM = ElementFactory.methodElement(methodName, typeE,
[typeE]); |
| 2106 classA.methods = <MethodElement> [methodM]; | 2105 classA.methods = <MethodElement> [methodM]; |
| 2107 (methodM.type as FunctionTypeImpl).typeArguments = classA.type.typeArguments
; | 2106 (methodM.type as FunctionTypeImpl).typeArguments = classA.type.typeArguments
; |
| 2108 // | 2107 // |
| 2109 // A<I> | 2108 // A<I> |
| 2110 // | 2109 // |
| 2111 InterfaceType typeI = ElementFactory.classElement2("I", []).type; | 2110 InterfaceType typeI = ElementFactory.classElement2("I", []).type; |
| 2112 InterfaceTypeImpl typeAI = new InterfaceTypeImpl.con1(classA); | 2111 InterfaceTypeImpl typeAI = new InterfaceTypeImpl.con1(classA); |
| 2113 typeAI.typeArguments = <DartType> [typeI]; | 2112 typeAI.typeArguments = <DartType> [typeI]; |
| 2114 MethodElement method = typeAI.getMethod(methodName); | 2113 MethodElement method = typeAI.getMethod(methodName); |
| 2115 JUnitTestCase.assertNotNull(method); | 2114 expect(method, isNotNull); |
| 2116 FunctionType methodType = method.type; | 2115 FunctionType methodType = method.type; |
| 2117 JUnitTestCase.assertSame(typeI, methodType.returnType); | 2116 expect(methodType.returnType, same(typeI)); |
| 2118 List<DartType> parameterTypes = methodType.normalParameterTypes; | 2117 List<DartType> parameterTypes = methodType.normalParameterTypes; |
| 2119 EngineTestCase.assertLength(1, parameterTypes); | 2118 EngineTestCase.assertLength(1, parameterTypes); |
| 2120 JUnitTestCase.assertSame(typeI, parameterTypes[0]); | 2119 expect(parameterTypes[0], same(typeI)); |
| 2121 } | 2120 } |
| 2122 | 2121 |
| 2123 void test_getMethod_unimplemented() { | 2122 void test_getMethod_unimplemented() { |
| 2124 // | 2123 // |
| 2125 // class A {} | 2124 // class A {} |
| 2126 // | 2125 // |
| 2127 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 2126 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 2128 InterfaceType typeA = classA.type; | 2127 InterfaceType typeA = classA.type; |
| 2129 JUnitTestCase.assertNull(typeA.getMethod("m")); | 2128 expect(typeA.getMethod("m"), isNull); |
| 2130 } | 2129 } |
| 2131 | 2130 |
| 2132 void test_getMethods() { | 2131 void test_getMethods() { |
| 2133 ClassElementImpl typeElement = ElementFactory.classElement2("A", []); | 2132 ClassElementImpl typeElement = ElementFactory.classElement2("A", []); |
| 2134 MethodElementImpl methodOne = ElementFactory.methodElement("one", null, []); | 2133 MethodElementImpl methodOne = ElementFactory.methodElement("one", null, []); |
| 2135 MethodElementImpl methodTwo = ElementFactory.methodElement("two", null, []); | 2134 MethodElementImpl methodTwo = ElementFactory.methodElement("two", null, []); |
| 2136 typeElement.methods = <MethodElement> [methodOne, methodTwo]; | 2135 typeElement.methods = <MethodElement> [methodOne, methodTwo]; |
| 2137 InterfaceTypeImpl type = new InterfaceTypeImpl.con1(typeElement); | 2136 InterfaceTypeImpl type = new InterfaceTypeImpl.con1(typeElement); |
| 2138 JUnitTestCase.assertEquals(2, type.methods.length); | 2137 expect(type.methods.length, 2); |
| 2139 } | 2138 } |
| 2140 | 2139 |
| 2141 void test_getMethods_empty() { | 2140 void test_getMethods_empty() { |
| 2142 ClassElementImpl typeElement = ElementFactory.classElement2("A", []); | 2141 ClassElementImpl typeElement = ElementFactory.classElement2("A", []); |
| 2143 InterfaceTypeImpl type = new InterfaceTypeImpl.con1(typeElement); | 2142 InterfaceTypeImpl type = new InterfaceTypeImpl.con1(typeElement); |
| 2144 JUnitTestCase.assertEquals(0, type.methods.length); | 2143 expect(type.methods.length, 0); |
| 2145 } | 2144 } |
| 2146 | 2145 |
| 2147 void test_getMixins_nonParameterized() { | 2146 void test_getMixins_nonParameterized() { |
| 2148 // | 2147 // |
| 2149 // class C extends Object with A, B | 2148 // class C extends Object with A, B |
| 2150 // | 2149 // |
| 2151 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 2150 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 2152 InterfaceType typeA = classA.type; | 2151 InterfaceType typeA = classA.type; |
| 2153 ClassElementImpl classB = ElementFactory.classElement2("B", []); | 2152 ClassElementImpl classB = ElementFactory.classElement2("B", []); |
| 2154 InterfaceType typeB = classB.type; | 2153 InterfaceType typeB = classB.type; |
| 2155 ClassElementImpl classC = ElementFactory.classElement2("C", []); | 2154 ClassElementImpl classC = ElementFactory.classElement2("C", []); |
| 2156 classC.mixins = <InterfaceType> [typeA, typeB]; | 2155 classC.mixins = <InterfaceType> [typeA, typeB]; |
| 2157 List<InterfaceType> interfaces = classC.type.mixins; | 2156 List<InterfaceType> interfaces = classC.type.mixins; |
| 2158 EngineTestCase.assertLength(2, interfaces); | 2157 EngineTestCase.assertLength(2, interfaces); |
| 2159 if (identical(interfaces[0], typeA)) { | 2158 if (identical(interfaces[0], typeA)) { |
| 2160 JUnitTestCase.assertSame(typeB, interfaces[1]); | 2159 expect(interfaces[1], same(typeB)); |
| 2161 } else { | 2160 } else { |
| 2162 JUnitTestCase.assertSame(typeB, interfaces[0]); | 2161 expect(interfaces[0], same(typeB)); |
| 2163 JUnitTestCase.assertSame(typeA, interfaces[1]); | 2162 expect(interfaces[1], same(typeA)); |
| 2164 } | 2163 } |
| 2165 } | 2164 } |
| 2166 | 2165 |
| 2167 void test_getMixins_parameterized() { | 2166 void test_getMixins_parameterized() { |
| 2168 // | 2167 // |
| 2169 // class A<E> | 2168 // class A<E> |
| 2170 // class B<F> extends Object with A<F> | 2169 // class B<F> extends Object with A<F> |
| 2171 // | 2170 // |
| 2172 ClassElementImpl classA = ElementFactory.classElement2("A", ["E"]); | 2171 ClassElementImpl classA = ElementFactory.classElement2("A", ["E"]); |
| 2173 ClassElementImpl classB = ElementFactory.classElement2("B", ["F"]); | 2172 ClassElementImpl classB = ElementFactory.classElement2("B", ["F"]); |
| 2174 InterfaceType typeB = classB.type; | 2173 InterfaceType typeB = classB.type; |
| 2175 InterfaceTypeImpl typeAF = new InterfaceTypeImpl.con1(classA); | 2174 InterfaceTypeImpl typeAF = new InterfaceTypeImpl.con1(classA); |
| 2176 typeAF.typeArguments = <DartType> [typeB.typeArguments[0]]; | 2175 typeAF.typeArguments = <DartType> [typeB.typeArguments[0]]; |
| 2177 classB.mixins = <InterfaceType> [typeAF]; | 2176 classB.mixins = <InterfaceType> [typeAF]; |
| 2178 // | 2177 // |
| 2179 // B<I> | 2178 // B<I> |
| 2180 // | 2179 // |
| 2181 InterfaceType typeI = ElementFactory.classElement2("I", []).type; | 2180 InterfaceType typeI = ElementFactory.classElement2("I", []).type; |
| 2182 InterfaceTypeImpl typeBI = new InterfaceTypeImpl.con1(classB); | 2181 InterfaceTypeImpl typeBI = new InterfaceTypeImpl.con1(classB); |
| 2183 typeBI.typeArguments = <DartType> [typeI]; | 2182 typeBI.typeArguments = <DartType> [typeI]; |
| 2184 List<InterfaceType> interfaces = typeBI.mixins; | 2183 List<InterfaceType> interfaces = typeBI.mixins; |
| 2185 EngineTestCase.assertLength(1, interfaces); | 2184 EngineTestCase.assertLength(1, interfaces); |
| 2186 InterfaceType result = interfaces[0]; | 2185 InterfaceType result = interfaces[0]; |
| 2187 JUnitTestCase.assertSame(classA, result.element); | 2186 expect(result.element, same(classA)); |
| 2188 JUnitTestCase.assertSame(typeI, result.typeArguments[0]); | 2187 expect(result.typeArguments[0], same(typeI)); |
| 2189 } | 2188 } |
| 2190 | 2189 |
| 2191 void test_getSetter_implemented() { | 2190 void test_getSetter_implemented() { |
| 2192 // | 2191 // |
| 2193 // class A { s() {} } | 2192 // class A { s() {} } |
| 2194 // | 2193 // |
| 2195 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 2194 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 2196 String setterName = "s"; | 2195 String setterName = "s"; |
| 2197 PropertyAccessorElement setterS = ElementFactory.setterElement(setterName, f
alse, null); | 2196 PropertyAccessorElement setterS = ElementFactory.setterElement(setterName, f
alse, null); |
| 2198 classA.accessors = <PropertyAccessorElement> [setterS]; | 2197 classA.accessors = <PropertyAccessorElement> [setterS]; |
| 2199 InterfaceType typeA = classA.type; | 2198 InterfaceType typeA = classA.type; |
| 2200 JUnitTestCase.assertSame(setterS, typeA.getSetter(setterName)); | 2199 expect(typeA.getSetter(setterName), same(setterS)); |
| 2201 } | 2200 } |
| 2202 | 2201 |
| 2203 void test_getSetter_parameterized() { | 2202 void test_getSetter_parameterized() { |
| 2204 // | 2203 // |
| 2205 // class A<E> { set s(E p) {} } | 2204 // class A<E> { set s(E p) {} } |
| 2206 // | 2205 // |
| 2207 ClassElementImpl classA = ElementFactory.classElement2("A", ["E"]); | 2206 ClassElementImpl classA = ElementFactory.classElement2("A", ["E"]); |
| 2208 DartType typeE = classA.type.typeArguments[0]; | 2207 DartType typeE = classA.type.typeArguments[0]; |
| 2209 String setterName = "s"; | 2208 String setterName = "s"; |
| 2210 PropertyAccessorElement setterS = ElementFactory.setterElement(setterName, f
alse, typeE); | 2209 PropertyAccessorElement setterS = ElementFactory.setterElement(setterName, f
alse, typeE); |
| 2211 classA.accessors = <PropertyAccessorElement> [setterS]; | 2210 classA.accessors = <PropertyAccessorElement> [setterS]; |
| 2212 (setterS.type as FunctionTypeImpl).typeArguments = classA.type.typeArguments
; | 2211 (setterS.type as FunctionTypeImpl).typeArguments = classA.type.typeArguments
; |
| 2213 // | 2212 // |
| 2214 // A<I> | 2213 // A<I> |
| 2215 // | 2214 // |
| 2216 InterfaceType typeI = ElementFactory.classElement2("I", []).type; | 2215 InterfaceType typeI = ElementFactory.classElement2("I", []).type; |
| 2217 InterfaceTypeImpl typeAI = new InterfaceTypeImpl.con1(classA); | 2216 InterfaceTypeImpl typeAI = new InterfaceTypeImpl.con1(classA); |
| 2218 typeAI.typeArguments = <DartType> [typeI]; | 2217 typeAI.typeArguments = <DartType> [typeI]; |
| 2219 PropertyAccessorElement setter = typeAI.getSetter(setterName); | 2218 PropertyAccessorElement setter = typeAI.getSetter(setterName); |
| 2220 JUnitTestCase.assertNotNull(setter); | 2219 expect(setter, isNotNull); |
| 2221 FunctionType setterType = setter.type; | 2220 FunctionType setterType = setter.type; |
| 2222 List<DartType> parameterTypes = setterType.normalParameterTypes; | 2221 List<DartType> parameterTypes = setterType.normalParameterTypes; |
| 2223 EngineTestCase.assertLength(1, parameterTypes); | 2222 EngineTestCase.assertLength(1, parameterTypes); |
| 2224 JUnitTestCase.assertSame(typeI, parameterTypes[0]); | 2223 expect(parameterTypes[0], same(typeI)); |
| 2225 } | 2224 } |
| 2226 | 2225 |
| 2227 void test_getSetter_unimplemented() { | 2226 void test_getSetter_unimplemented() { |
| 2228 // | 2227 // |
| 2229 // class A {} | 2228 // class A {} |
| 2230 // | 2229 // |
| 2231 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 2230 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 2232 InterfaceType typeA = classA.type; | 2231 InterfaceType typeA = classA.type; |
| 2233 JUnitTestCase.assertNull(typeA.getSetter("s")); | 2232 expect(typeA.getSetter("s"), isNull); |
| 2234 } | 2233 } |
| 2235 | 2234 |
| 2236 void test_getSuperclass_nonParameterized() { | 2235 void test_getSuperclass_nonParameterized() { |
| 2237 // | 2236 // |
| 2238 // class B extends A | 2237 // class B extends A |
| 2239 // | 2238 // |
| 2240 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 2239 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 2241 InterfaceType typeA = classA.type; | 2240 InterfaceType typeA = classA.type; |
| 2242 ClassElementImpl classB = ElementFactory.classElement("B", typeA, []); | 2241 ClassElementImpl classB = ElementFactory.classElement("B", typeA, []); |
| 2243 InterfaceType typeB = classB.type; | 2242 InterfaceType typeB = classB.type; |
| 2244 JUnitTestCase.assertSame(typeA, typeB.superclass); | 2243 expect(typeB.superclass, same(typeA)); |
| 2245 } | 2244 } |
| 2246 | 2245 |
| 2247 void test_getSuperclass_parameterized() { | 2246 void test_getSuperclass_parameterized() { |
| 2248 // | 2247 // |
| 2249 // class A<E> | 2248 // class A<E> |
| 2250 // class B<F> extends A<F> | 2249 // class B<F> extends A<F> |
| 2251 // | 2250 // |
| 2252 ClassElementImpl classA = ElementFactory.classElement2("A", ["E"]); | 2251 ClassElementImpl classA = ElementFactory.classElement2("A", ["E"]); |
| 2253 ClassElementImpl classB = ElementFactory.classElement2("B", ["F"]); | 2252 ClassElementImpl classB = ElementFactory.classElement2("B", ["F"]); |
| 2254 InterfaceType typeB = classB.type; | 2253 InterfaceType typeB = classB.type; |
| 2255 InterfaceTypeImpl typeAF = new InterfaceTypeImpl.con1(classA); | 2254 InterfaceTypeImpl typeAF = new InterfaceTypeImpl.con1(classA); |
| 2256 typeAF.typeArguments = <DartType> [typeB.typeArguments[0]]; | 2255 typeAF.typeArguments = <DartType> [typeB.typeArguments[0]]; |
| 2257 classB.supertype = typeAF; | 2256 classB.supertype = typeAF; |
| 2258 // | 2257 // |
| 2259 // B<I> | 2258 // B<I> |
| 2260 // | 2259 // |
| 2261 InterfaceType typeI = ElementFactory.classElement2("I", []).type; | 2260 InterfaceType typeI = ElementFactory.classElement2("I", []).type; |
| 2262 InterfaceTypeImpl typeBI = new InterfaceTypeImpl.con1(classB); | 2261 InterfaceTypeImpl typeBI = new InterfaceTypeImpl.con1(classB); |
| 2263 typeBI.typeArguments = <DartType> [typeI]; | 2262 typeBI.typeArguments = <DartType> [typeI]; |
| 2264 InterfaceType superclass = typeBI.superclass; | 2263 InterfaceType superclass = typeBI.superclass; |
| 2265 JUnitTestCase.assertSame(classA, superclass.element); | 2264 expect(superclass.element, same(classA)); |
| 2266 JUnitTestCase.assertSame(typeI, superclass.typeArguments[0]); | 2265 expect(superclass.typeArguments[0], same(typeI)); |
| 2267 } | 2266 } |
| 2268 | 2267 |
| 2269 void test_getTypeArguments_empty() { | 2268 void test_getTypeArguments_empty() { |
| 2270 InterfaceType type = ElementFactory.classElement2("A", []).type; | 2269 InterfaceType type = ElementFactory.classElement2("A", []).type; |
| 2271 EngineTestCase.assertLength(0, type.typeArguments); | 2270 EngineTestCase.assertLength(0, type.typeArguments); |
| 2272 } | 2271 } |
| 2273 | 2272 |
| 2274 void test_hashCode() { | 2273 void test_hashCode() { |
| 2275 ClassElement classA = ElementFactory.classElement2("A", []); | 2274 ClassElement classA = ElementFactory.classElement2("A", []); |
| 2276 InterfaceType typeA = classA.type; | 2275 InterfaceType typeA = classA.type; |
| 2277 JUnitTestCase.assertFalse(0 == typeA.hashCode); | 2276 expect(0 == typeA.hashCode, isFalse); |
| 2278 } | 2277 } |
| 2279 | 2278 |
| 2280 void test_isAssignableTo_typeVariables() { | 2279 void test_isAssignableTo_typeVariables() { |
| 2281 // | 2280 // |
| 2282 // class A<E> {} | 2281 // class A<E> {} |
| 2283 // class B<F, G> { | 2282 // class B<F, G> { |
| 2284 // A<F> af; | 2283 // A<F> af; |
| 2285 // f (A<G> ag) { | 2284 // f (A<G> ag) { |
| 2286 // af = ag; | 2285 // af = ag; |
| 2287 // } | 2286 // } |
| 2288 // } | 2287 // } |
| 2289 // | 2288 // |
| 2290 ClassElement classA = ElementFactory.classElement2("A", ["E"]); | 2289 ClassElement classA = ElementFactory.classElement2("A", ["E"]); |
| 2291 ClassElement classB = ElementFactory.classElement2("B", ["F", "G"]); | 2290 ClassElement classB = ElementFactory.classElement2("B", ["F", "G"]); |
| 2292 InterfaceTypeImpl typeAF = new InterfaceTypeImpl.con1(classA); | 2291 InterfaceTypeImpl typeAF = new InterfaceTypeImpl.con1(classA); |
| 2293 typeAF.typeArguments = <DartType> [classB.typeParameters[0].type]; | 2292 typeAF.typeArguments = <DartType> [classB.typeParameters[0].type]; |
| 2294 InterfaceTypeImpl typeAG = new InterfaceTypeImpl.con1(classA); | 2293 InterfaceTypeImpl typeAG = new InterfaceTypeImpl.con1(classA); |
| 2295 typeAG.typeArguments = <DartType> [classB.typeParameters[1].type]; | 2294 typeAG.typeArguments = <DartType> [classB.typeParameters[1].type]; |
| 2296 JUnitTestCase.assertFalse(typeAG.isAssignableTo(typeAF)); | 2295 expect(typeAG.isAssignableTo(typeAF), isFalse); |
| 2297 } | 2296 } |
| 2298 | 2297 |
| 2299 void test_isAssignableTo_void() { | 2298 void test_isAssignableTo_void() { |
| 2300 JUnitTestCase.assertFalse(VoidTypeImpl.instance.isAssignableTo(_typeProvider
.intType)); | 2299 expect(VoidTypeImpl.instance.isAssignableTo(_typeProvider.intType), isFalse)
; |
| 2301 } | 2300 } |
| 2302 | 2301 |
| 2303 void test_isDirectSupertypeOf_extends() { | 2302 void test_isDirectSupertypeOf_extends() { |
| 2304 ClassElement classA = ElementFactory.classElement2("A", []); | 2303 ClassElement classA = ElementFactory.classElement2("A", []); |
| 2305 ClassElement classB = ElementFactory.classElement("B", classA.type, []); | 2304 ClassElement classB = ElementFactory.classElement("B", classA.type, []); |
| 2306 InterfaceType typeA = classA.type; | 2305 InterfaceType typeA = classA.type; |
| 2307 InterfaceType typeB = classB.type; | 2306 InterfaceType typeB = classB.type; |
| 2308 JUnitTestCase.assertTrue(typeA.isDirectSupertypeOf(typeB)); | 2307 expect(typeA.isDirectSupertypeOf(typeB), isTrue); |
| 2309 } | 2308 } |
| 2310 | 2309 |
| 2311 void test_isDirectSupertypeOf_false() { | 2310 void test_isDirectSupertypeOf_false() { |
| 2312 ClassElement classA = ElementFactory.classElement2("A", []); | 2311 ClassElement classA = ElementFactory.classElement2("A", []); |
| 2313 ClassElement classB = ElementFactory.classElement2("B", []); | 2312 ClassElement classB = ElementFactory.classElement2("B", []); |
| 2314 ClassElement classC = ElementFactory.classElement("C", classB.type, []); | 2313 ClassElement classC = ElementFactory.classElement("C", classB.type, []); |
| 2315 InterfaceType typeA = classA.type; | 2314 InterfaceType typeA = classA.type; |
| 2316 InterfaceType typeC = classC.type; | 2315 InterfaceType typeC = classC.type; |
| 2317 JUnitTestCase.assertFalse(typeA.isDirectSupertypeOf(typeC)); | 2316 expect(typeA.isDirectSupertypeOf(typeC), isFalse); |
| 2318 } | 2317 } |
| 2319 | 2318 |
| 2320 void test_isDirectSupertypeOf_implements() { | 2319 void test_isDirectSupertypeOf_implements() { |
| 2321 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 2320 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 2322 ClassElementImpl classB = ElementFactory.classElement2("B", []); | 2321 ClassElementImpl classB = ElementFactory.classElement2("B", []); |
| 2323 InterfaceType typeA = classA.type; | 2322 InterfaceType typeA = classA.type; |
| 2324 InterfaceType typeB = classB.type; | 2323 InterfaceType typeB = classB.type; |
| 2325 classB.interfaces = <InterfaceType> [typeA]; | 2324 classB.interfaces = <InterfaceType> [typeA]; |
| 2326 JUnitTestCase.assertTrue(typeA.isDirectSupertypeOf(typeB)); | 2325 expect(typeA.isDirectSupertypeOf(typeB), isTrue); |
| 2327 } | 2326 } |
| 2328 | 2327 |
| 2329 void test_isDirectSupertypeOf_with() { | 2328 void test_isDirectSupertypeOf_with() { |
| 2330 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 2329 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 2331 ClassElementImpl classB = ElementFactory.classElement2("B", []); | 2330 ClassElementImpl classB = ElementFactory.classElement2("B", []); |
| 2332 InterfaceType typeA = classA.type; | 2331 InterfaceType typeA = classA.type; |
| 2333 InterfaceType typeB = classB.type; | 2332 InterfaceType typeB = classB.type; |
| 2334 classB.mixins = <InterfaceType> [typeA]; | 2333 classB.mixins = <InterfaceType> [typeA]; |
| 2335 JUnitTestCase.assertTrue(typeA.isDirectSupertypeOf(typeB)); | 2334 expect(typeA.isDirectSupertypeOf(typeB), isTrue); |
| 2336 } | 2335 } |
| 2337 | 2336 |
| 2338 void test_isMoreSpecificThan_bottom() { | 2337 void test_isMoreSpecificThan_bottom() { |
| 2339 DartType type = ElementFactory.classElement2("A", []).type; | 2338 DartType type = ElementFactory.classElement2("A", []).type; |
| 2340 JUnitTestCase.assertTrue(BottomTypeImpl.instance.isMoreSpecificThan(type)); | 2339 expect(BottomTypeImpl.instance.isMoreSpecificThan(type), isTrue); |
| 2341 } | 2340 } |
| 2342 | 2341 |
| 2343 void test_isMoreSpecificThan_covariance() { | 2342 void test_isMoreSpecificThan_covariance() { |
| 2344 ClassElement classA = ElementFactory.classElement2("A", ["E"]); | 2343 ClassElement classA = ElementFactory.classElement2("A", ["E"]); |
| 2345 ClassElement classI = ElementFactory.classElement2("I", []); | 2344 ClassElement classI = ElementFactory.classElement2("I", []); |
| 2346 ClassElement classJ = ElementFactory.classElement("J", classI.type, []); | 2345 ClassElement classJ = ElementFactory.classElement("J", classI.type, []); |
| 2347 InterfaceTypeImpl typeAI = new InterfaceTypeImpl.con1(classA); | 2346 InterfaceTypeImpl typeAI = new InterfaceTypeImpl.con1(classA); |
| 2348 InterfaceTypeImpl typeAJ = new InterfaceTypeImpl.con1(classA); | 2347 InterfaceTypeImpl typeAJ = new InterfaceTypeImpl.con1(classA); |
| 2349 typeAI.typeArguments = <DartType> [classI.type]; | 2348 typeAI.typeArguments = <DartType> [classI.type]; |
| 2350 typeAJ.typeArguments = <DartType> [classJ.type]; | 2349 typeAJ.typeArguments = <DartType> [classJ.type]; |
| 2351 JUnitTestCase.assertTrue(typeAJ.isMoreSpecificThan(typeAI)); | 2350 expect(typeAJ.isMoreSpecificThan(typeAI), isTrue); |
| 2352 JUnitTestCase.assertFalse(typeAI.isMoreSpecificThan(typeAJ)); | 2351 expect(typeAI.isMoreSpecificThan(typeAJ), isFalse); |
| 2353 } | 2352 } |
| 2354 | 2353 |
| 2355 void test_isMoreSpecificThan_directSupertype() { | 2354 void test_isMoreSpecificThan_directSupertype() { |
| 2356 ClassElement classA = ElementFactory.classElement2("A", []); | 2355 ClassElement classA = ElementFactory.classElement2("A", []); |
| 2357 ClassElement classB = ElementFactory.classElement("B", classA.type, []); | 2356 ClassElement classB = ElementFactory.classElement("B", classA.type, []); |
| 2358 InterfaceType typeA = classA.type; | 2357 InterfaceType typeA = classA.type; |
| 2359 InterfaceType typeB = classB.type; | 2358 InterfaceType typeB = classB.type; |
| 2360 JUnitTestCase.assertTrue(typeB.isMoreSpecificThan(typeA)); | 2359 expect(typeB.isMoreSpecificThan(typeA), isTrue); |
| 2361 // the opposite test tests a different branch in isMoreSpecificThan() | 2360 // the opposite test tests a different branch in isMoreSpecificThan() |
| 2362 JUnitTestCase.assertFalse(typeA.isMoreSpecificThan(typeB)); | 2361 expect(typeA.isMoreSpecificThan(typeB), isFalse); |
| 2363 } | 2362 } |
| 2364 | 2363 |
| 2365 void test_isMoreSpecificThan_dynamic() { | 2364 void test_isMoreSpecificThan_dynamic() { |
| 2366 InterfaceType type = ElementFactory.classElement2("A", []).type; | 2365 InterfaceType type = ElementFactory.classElement2("A", []).type; |
| 2367 JUnitTestCase.assertTrue(type.isMoreSpecificThan(DynamicTypeImpl.instance)); | 2366 expect(type.isMoreSpecificThan(DynamicTypeImpl.instance), isTrue); |
| 2368 } | 2367 } |
| 2369 | 2368 |
| 2370 void test_isMoreSpecificThan_generic() { | 2369 void test_isMoreSpecificThan_generic() { |
| 2371 ClassElement classA = ElementFactory.classElement2("A", ["E"]); | 2370 ClassElement classA = ElementFactory.classElement2("A", ["E"]); |
| 2372 ClassElement classB = ElementFactory.classElement2("B", []); | 2371 ClassElement classB = ElementFactory.classElement2("B", []); |
| 2373 DartType dynamicType = DynamicTypeImpl.instance; | 2372 DartType dynamicType = DynamicTypeImpl.instance; |
| 2374 InterfaceType typeAOfDynamic = classA.type.substitute4(<DartType> [dynamicTy
pe]); | 2373 InterfaceType typeAOfDynamic = classA.type.substitute4(<DartType> [dynamicTy
pe]); |
| 2375 InterfaceType typeAOfB = classA.type.substitute4(<DartType> [classB.type]); | 2374 InterfaceType typeAOfB = classA.type.substitute4(<DartType> [classB.type]); |
| 2376 JUnitTestCase.assertFalse(typeAOfDynamic.isMoreSpecificThan(typeAOfB)); | 2375 expect(typeAOfDynamic.isMoreSpecificThan(typeAOfB), isFalse); |
| 2377 JUnitTestCase.assertTrue(typeAOfB.isMoreSpecificThan(typeAOfDynamic)); | 2376 expect(typeAOfB.isMoreSpecificThan(typeAOfDynamic), isTrue); |
| 2378 } | 2377 } |
| 2379 | 2378 |
| 2380 void test_isMoreSpecificThan_self() { | 2379 void test_isMoreSpecificThan_self() { |
| 2381 InterfaceType type = ElementFactory.classElement2("A", []).type; | 2380 InterfaceType type = ElementFactory.classElement2("A", []).type; |
| 2382 JUnitTestCase.assertTrue(type.isMoreSpecificThan(type)); | 2381 expect(type.isMoreSpecificThan(type), isTrue); |
| 2383 } | 2382 } |
| 2384 | 2383 |
| 2385 void test_isMoreSpecificThan_transitive_interface() { | 2384 void test_isMoreSpecificThan_transitive_interface() { |
| 2386 // | 2385 // |
| 2387 // class A {} | 2386 // class A {} |
| 2388 // class B extends A {} | 2387 // class B extends A {} |
| 2389 // class C implements B {} | 2388 // class C implements B {} |
| 2390 // | 2389 // |
| 2391 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 2390 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 2392 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); | 2391 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); |
| 2393 ClassElementImpl classC = ElementFactory.classElement2("C", []); | 2392 ClassElementImpl classC = ElementFactory.classElement2("C", []); |
| 2394 classC.interfaces = <InterfaceType> [classB.type]; | 2393 classC.interfaces = <InterfaceType> [classB.type]; |
| 2395 InterfaceType typeA = classA.type; | 2394 InterfaceType typeA = classA.type; |
| 2396 InterfaceType typeC = classC.type; | 2395 InterfaceType typeC = classC.type; |
| 2397 JUnitTestCase.assertTrue(typeC.isMoreSpecificThan(typeA)); | 2396 expect(typeC.isMoreSpecificThan(typeA), isTrue); |
| 2398 } | 2397 } |
| 2399 | 2398 |
| 2400 void test_isMoreSpecificThan_transitive_mixin() { | 2399 void test_isMoreSpecificThan_transitive_mixin() { |
| 2401 // | 2400 // |
| 2402 // class A {} | 2401 // class A {} |
| 2403 // class B extends A {} | 2402 // class B extends A {} |
| 2404 // class C with B {} | 2403 // class C with B {} |
| 2405 // | 2404 // |
| 2406 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 2405 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 2407 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); | 2406 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); |
| 2408 ClassElementImpl classC = ElementFactory.classElement2("C", []); | 2407 ClassElementImpl classC = ElementFactory.classElement2("C", []); |
| 2409 classC.mixins = <InterfaceType> [classB.type]; | 2408 classC.mixins = <InterfaceType> [classB.type]; |
| 2410 InterfaceType typeA = classA.type; | 2409 InterfaceType typeA = classA.type; |
| 2411 InterfaceType typeC = classC.type; | 2410 InterfaceType typeC = classC.type; |
| 2412 JUnitTestCase.assertTrue(typeC.isMoreSpecificThan(typeA)); | 2411 expect(typeC.isMoreSpecificThan(typeA), isTrue); |
| 2413 } | 2412 } |
| 2414 | 2413 |
| 2415 void test_isMoreSpecificThan_transitive_recursive() { | 2414 void test_isMoreSpecificThan_transitive_recursive() { |
| 2416 // | 2415 // |
| 2417 // class A extends B {} | 2416 // class A extends B {} |
| 2418 // class B extends A {} | 2417 // class B extends A {} |
| 2419 // class C {} | 2418 // class C {} |
| 2420 // | 2419 // |
| 2421 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 2420 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 2422 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); | 2421 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); |
| 2423 ClassElementImpl classC = ElementFactory.classElement2("C", []); | 2422 ClassElementImpl classC = ElementFactory.classElement2("C", []); |
| 2424 InterfaceType typeA = classA.type; | 2423 InterfaceType typeA = classA.type; |
| 2425 InterfaceType typeC = classC.type; | 2424 InterfaceType typeC = classC.type; |
| 2426 classA.supertype = classB.type; | 2425 classA.supertype = classB.type; |
| 2427 JUnitTestCase.assertFalse(typeA.isMoreSpecificThan(typeC)); | 2426 expect(typeA.isMoreSpecificThan(typeC), isFalse); |
| 2428 } | 2427 } |
| 2429 | 2428 |
| 2430 void test_isMoreSpecificThan_transitive_superclass() { | 2429 void test_isMoreSpecificThan_transitive_superclass() { |
| 2431 // | 2430 // |
| 2432 // class A {} | 2431 // class A {} |
| 2433 // class B extends A {} | 2432 // class B extends A {} |
| 2434 // class C extends B {} | 2433 // class C extends B {} |
| 2435 // | 2434 // |
| 2436 ClassElement classA = ElementFactory.classElement2("A", []); | 2435 ClassElement classA = ElementFactory.classElement2("A", []); |
| 2437 ClassElement classB = ElementFactory.classElement("B", classA.type, []); | 2436 ClassElement classB = ElementFactory.classElement("B", classA.type, []); |
| 2438 ClassElement classC = ElementFactory.classElement("C", classB.type, []); | 2437 ClassElement classC = ElementFactory.classElement("C", classB.type, []); |
| 2439 InterfaceType typeA = classA.type; | 2438 InterfaceType typeA = classA.type; |
| 2440 InterfaceType typeC = classC.type; | 2439 InterfaceType typeC = classC.type; |
| 2441 JUnitTestCase.assertTrue(typeC.isMoreSpecificThan(typeA)); | 2440 expect(typeC.isMoreSpecificThan(typeA), isTrue); |
| 2442 } | 2441 } |
| 2443 | 2442 |
| 2444 void test_isMoreSpecificThan_typeParameterType() { | 2443 void test_isMoreSpecificThan_typeParameterType() { |
| 2445 // | 2444 // |
| 2446 // class A<E> {} | 2445 // class A<E> {} |
| 2447 // | 2446 // |
| 2448 ClassElement classA = ElementFactory.classElement2("A", ["E"]); | 2447 ClassElement classA = ElementFactory.classElement2("A", ["E"]); |
| 2449 InterfaceType typeA = classA.type; | 2448 InterfaceType typeA = classA.type; |
| 2450 TypeParameterType parameterType = classA.typeParameters[0].type; | 2449 TypeParameterType parameterType = classA.typeParameters[0].type; |
| 2451 DartType objectType = _typeProvider.objectType; | 2450 DartType objectType = _typeProvider.objectType; |
| 2452 JUnitTestCase.assertTrue(parameterType.isMoreSpecificThan(objectType)); | 2451 expect(parameterType.isMoreSpecificThan(objectType), isTrue); |
| 2453 JUnitTestCase.assertFalse(parameterType.isMoreSpecificThan(typeA)); | 2452 expect(parameterType.isMoreSpecificThan(typeA), isFalse); |
| 2454 } | 2453 } |
| 2455 | 2454 |
| 2456 void test_isMoreSpecificThan_typeParameterType_withBound() { | 2455 void test_isMoreSpecificThan_typeParameterType_withBound() { |
| 2457 // | 2456 // |
| 2458 // class A {} | 2457 // class A {} |
| 2459 // class B<E extends A> {} | 2458 // class B<E extends A> {} |
| 2460 // | 2459 // |
| 2461 ClassElement classA = ElementFactory.classElement2("A", []); | 2460 ClassElement classA = ElementFactory.classElement2("A", []); |
| 2462 InterfaceType typeA = classA.type; | 2461 InterfaceType typeA = classA.type; |
| 2463 ClassElementImpl classB = ElementFactory.classElement2("B", []); | 2462 ClassElementImpl classB = ElementFactory.classElement2("B", []); |
| 2464 TypeParameterElementImpl parameterEA = new TypeParameterElementImpl.forNode(
AstFactory.identifier3("E")); | 2463 TypeParameterElementImpl parameterEA = new TypeParameterElementImpl.forNode(
AstFactory.identifier3("E")); |
| 2465 TypeParameterType parameterAEType = new TypeParameterTypeImpl(parameterEA); | 2464 TypeParameterType parameterAEType = new TypeParameterTypeImpl(parameterEA); |
| 2466 parameterEA.bound = typeA; | 2465 parameterEA.bound = typeA; |
| 2467 parameterEA.type = parameterAEType; | 2466 parameterEA.type = parameterAEType; |
| 2468 classB.typeParameters = <TypeParameterElementImpl> [parameterEA]; | 2467 classB.typeParameters = <TypeParameterElementImpl> [parameterEA]; |
| 2469 JUnitTestCase.assertTrue(parameterAEType.isMoreSpecificThan(typeA)); | 2468 expect(parameterAEType.isMoreSpecificThan(typeA), isTrue); |
| 2470 } | 2469 } |
| 2471 | 2470 |
| 2472 void test_isSubtypeOf_directSubtype() { | 2471 void test_isSubtypeOf_directSubtype() { |
| 2473 ClassElement classA = ElementFactory.classElement2("A", []); | 2472 ClassElement classA = ElementFactory.classElement2("A", []); |
| 2474 ClassElement classB = ElementFactory.classElement("B", classA.type, []); | 2473 ClassElement classB = ElementFactory.classElement("B", classA.type, []); |
| 2475 InterfaceType typeA = classA.type; | 2474 InterfaceType typeA = classA.type; |
| 2476 InterfaceType typeB = classB.type; | 2475 InterfaceType typeB = classB.type; |
| 2477 JUnitTestCase.assertTrue(typeB.isSubtypeOf(typeA)); | 2476 expect(typeB.isSubtypeOf(typeA), isTrue); |
| 2478 JUnitTestCase.assertFalse(typeA.isSubtypeOf(typeB)); | 2477 expect(typeA.isSubtypeOf(typeB), isFalse); |
| 2479 } | 2478 } |
| 2480 | 2479 |
| 2481 void test_isSubtypeOf_dynamic() { | 2480 void test_isSubtypeOf_dynamic() { |
| 2482 ClassElement classA = ElementFactory.classElement2("A", []); | 2481 ClassElement classA = ElementFactory.classElement2("A", []); |
| 2483 InterfaceType typeA = classA.type; | 2482 InterfaceType typeA = classA.type; |
| 2484 DartType dynamicType = DynamicTypeImpl.instance; | 2483 DartType dynamicType = DynamicTypeImpl.instance; |
| 2485 JUnitTestCase.assertTrue(dynamicType.isSubtypeOf(typeA)); | 2484 expect(dynamicType.isSubtypeOf(typeA), isTrue); |
| 2486 JUnitTestCase.assertTrue(typeA.isSubtypeOf(dynamicType)); | 2485 expect(typeA.isSubtypeOf(dynamicType), isTrue); |
| 2487 } | 2486 } |
| 2488 | 2487 |
| 2489 void test_isSubtypeOf_function() { | 2488 void test_isSubtypeOf_function() { |
| 2490 // | 2489 // |
| 2491 // void f(String s) {} | 2490 // void f(String s) {} |
| 2492 // class A { | 2491 // class A { |
| 2493 // void call(String s) {} | 2492 // void call(String s) {} |
| 2494 // } | 2493 // } |
| 2495 // | 2494 // |
| 2496 InterfaceType stringType = _typeProvider.stringType; | 2495 InterfaceType stringType = _typeProvider.stringType; |
| 2497 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 2496 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 2498 classA.methods = <MethodElement> [ElementFactory.methodElement("call", VoidT
ypeImpl.instance, [stringType])]; | 2497 classA.methods = <MethodElement> [ElementFactory.methodElement("call", VoidT
ypeImpl.instance, [stringType])]; |
| 2499 FunctionType functionType = ElementFactory.functionElement5("f", <ClassEleme
nt> [stringType.element]).type; | 2498 FunctionType functionType = ElementFactory.functionElement5("f", <ClassEleme
nt> [stringType.element]).type; |
| 2500 JUnitTestCase.assertTrue(classA.type.isSubtypeOf(functionType)); | 2499 expect(classA.type.isSubtypeOf(functionType), isTrue); |
| 2501 } | 2500 } |
| 2502 | 2501 |
| 2503 void test_isSubtypeOf_generic() { | 2502 void test_isSubtypeOf_generic() { |
| 2504 ClassElement classA = ElementFactory.classElement2("A", ["E"]); | 2503 ClassElement classA = ElementFactory.classElement2("A", ["E"]); |
| 2505 ClassElement classB = ElementFactory.classElement2("B", []); | 2504 ClassElement classB = ElementFactory.classElement2("B", []); |
| 2506 DartType dynamicType = DynamicTypeImpl.instance; | 2505 DartType dynamicType = DynamicTypeImpl.instance; |
| 2507 InterfaceType typeAOfDynamic = classA.type.substitute4(<DartType> [dynamicTy
pe]); | 2506 InterfaceType typeAOfDynamic = classA.type.substitute4(<DartType> [dynamicTy
pe]); |
| 2508 InterfaceType typeAOfB = classA.type.substitute4(<DartType> [classB.type]); | 2507 InterfaceType typeAOfB = classA.type.substitute4(<DartType> [classB.type]); |
| 2509 JUnitTestCase.assertTrue(typeAOfDynamic.isSubtypeOf(typeAOfB)); | 2508 expect(typeAOfDynamic.isSubtypeOf(typeAOfB), isTrue); |
| 2510 JUnitTestCase.assertTrue(typeAOfB.isSubtypeOf(typeAOfDynamic)); | 2509 expect(typeAOfB.isSubtypeOf(typeAOfDynamic), isTrue); |
| 2511 } | 2510 } |
| 2512 | 2511 |
| 2513 void test_isSubtypeOf_interface() { | 2512 void test_isSubtypeOf_interface() { |
| 2514 ClassElement classA = ElementFactory.classElement2("A", []); | 2513 ClassElement classA = ElementFactory.classElement2("A", []); |
| 2515 ClassElement classB = ElementFactory.classElement("B", classA.type, []); | 2514 ClassElement classB = ElementFactory.classElement("B", classA.type, []); |
| 2516 ClassElementImpl classC = ElementFactory.classElement2("C", []); | 2515 ClassElementImpl classC = ElementFactory.classElement2("C", []); |
| 2517 InterfaceType typeObject = classA.supertype; | 2516 InterfaceType typeObject = classA.supertype; |
| 2518 InterfaceType typeA = classA.type; | 2517 InterfaceType typeA = classA.type; |
| 2519 InterfaceType typeB = classB.type; | 2518 InterfaceType typeB = classB.type; |
| 2520 InterfaceType typeC = classC.type; | 2519 InterfaceType typeC = classC.type; |
| 2521 classC.interfaces = <InterfaceType> [typeB]; | 2520 classC.interfaces = <InterfaceType> [typeB]; |
| 2522 JUnitTestCase.assertTrue(typeC.isSubtypeOf(typeB)); | 2521 expect(typeC.isSubtypeOf(typeB), isTrue); |
| 2523 JUnitTestCase.assertTrue(typeC.isSubtypeOf(typeObject)); | 2522 expect(typeC.isSubtypeOf(typeObject), isTrue); |
| 2524 JUnitTestCase.assertTrue(typeC.isSubtypeOf(typeA)); | 2523 expect(typeC.isSubtypeOf(typeA), isTrue); |
| 2525 JUnitTestCase.assertFalse(typeA.isSubtypeOf(typeC)); | 2524 expect(typeA.isSubtypeOf(typeC), isFalse); |
| 2526 } | 2525 } |
| 2527 | 2526 |
| 2528 void test_isSubtypeOf_mixins() { | 2527 void test_isSubtypeOf_mixins() { |
| 2529 // | 2528 // |
| 2530 // class A {} | 2529 // class A {} |
| 2531 // class B extends A {} | 2530 // class B extends A {} |
| 2532 // class C with B {} | 2531 // class C with B {} |
| 2533 // | 2532 // |
| 2534 ClassElement classA = ElementFactory.classElement2("A", []); | 2533 ClassElement classA = ElementFactory.classElement2("A", []); |
| 2535 ClassElement classB = ElementFactory.classElement("B", classA.type, []); | 2534 ClassElement classB = ElementFactory.classElement("B", classA.type, []); |
| 2536 ClassElementImpl classC = ElementFactory.classElement2("C", []); | 2535 ClassElementImpl classC = ElementFactory.classElement2("C", []); |
| 2537 InterfaceType typeObject = classA.supertype; | 2536 InterfaceType typeObject = classA.supertype; |
| 2538 InterfaceType typeA = classA.type; | 2537 InterfaceType typeA = classA.type; |
| 2539 InterfaceType typeB = classB.type; | 2538 InterfaceType typeB = classB.type; |
| 2540 InterfaceType typeC = classC.type; | 2539 InterfaceType typeC = classC.type; |
| 2541 classC.mixins = <InterfaceType> [typeB]; | 2540 classC.mixins = <InterfaceType> [typeB]; |
| 2542 JUnitTestCase.assertTrue(typeC.isSubtypeOf(typeB)); | 2541 expect(typeC.isSubtypeOf(typeB), isTrue); |
| 2543 JUnitTestCase.assertTrue(typeC.isSubtypeOf(typeObject)); | 2542 expect(typeC.isSubtypeOf(typeObject), isTrue); |
| 2544 JUnitTestCase.assertTrue(typeC.isSubtypeOf(typeA)); | 2543 expect(typeC.isSubtypeOf(typeA), isTrue); |
| 2545 JUnitTestCase.assertFalse(typeA.isSubtypeOf(typeC)); | 2544 expect(typeA.isSubtypeOf(typeC), isFalse); |
| 2546 } | 2545 } |
| 2547 | 2546 |
| 2548 void test_isSubtypeOf_object() { | 2547 void test_isSubtypeOf_object() { |
| 2549 ClassElement classA = ElementFactory.classElement2("A", []); | 2548 ClassElement classA = ElementFactory.classElement2("A", []); |
| 2550 InterfaceType typeA = classA.type; | 2549 InterfaceType typeA = classA.type; |
| 2551 InterfaceType typeObject = classA.supertype; | 2550 InterfaceType typeObject = classA.supertype; |
| 2552 JUnitTestCase.assertTrue(typeA.isSubtypeOf(typeObject)); | 2551 expect(typeA.isSubtypeOf(typeObject), isTrue); |
| 2553 JUnitTestCase.assertFalse(typeObject.isSubtypeOf(typeA)); | 2552 expect(typeObject.isSubtypeOf(typeA), isFalse); |
| 2554 } | 2553 } |
| 2555 | 2554 |
| 2556 void test_isSubtypeOf_self() { | 2555 void test_isSubtypeOf_self() { |
| 2557 ClassElement classA = ElementFactory.classElement2("A", []); | 2556 ClassElement classA = ElementFactory.classElement2("A", []); |
| 2558 InterfaceType typeA = classA.type; | 2557 InterfaceType typeA = classA.type; |
| 2559 JUnitTestCase.assertTrue(typeA.isSubtypeOf(typeA)); | 2558 expect(typeA.isSubtypeOf(typeA), isTrue); |
| 2560 } | 2559 } |
| 2561 | 2560 |
| 2562 void test_isSubtypeOf_transitive_recursive() { | 2561 void test_isSubtypeOf_transitive_recursive() { |
| 2563 // | 2562 // |
| 2564 // class A extends B {} | 2563 // class A extends B {} |
| 2565 // class B extends A {} | 2564 // class B extends A {} |
| 2566 // class C {} | 2565 // class C {} |
| 2567 // | 2566 // |
| 2568 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 2567 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 2569 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); | 2568 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); |
| 2570 ClassElementImpl classC = ElementFactory.classElement2("C", []); | 2569 ClassElementImpl classC = ElementFactory.classElement2("C", []); |
| 2571 InterfaceType typeA = classA.type; | 2570 InterfaceType typeA = classA.type; |
| 2572 InterfaceType typeC = classC.type; | 2571 InterfaceType typeC = classC.type; |
| 2573 classA.supertype = classB.type; | 2572 classA.supertype = classB.type; |
| 2574 JUnitTestCase.assertFalse(typeA.isSubtypeOf(typeC)); | 2573 expect(typeA.isSubtypeOf(typeC), isFalse); |
| 2575 } | 2574 } |
| 2576 | 2575 |
| 2577 void test_isSubtypeOf_transitive_superclass() { | 2576 void test_isSubtypeOf_transitive_superclass() { |
| 2578 ClassElement classA = ElementFactory.classElement2("A", []); | 2577 ClassElement classA = ElementFactory.classElement2("A", []); |
| 2579 ClassElement classB = ElementFactory.classElement("B", classA.type, []); | 2578 ClassElement classB = ElementFactory.classElement("B", classA.type, []); |
| 2580 ClassElement classC = ElementFactory.classElement("C", classB.type, []); | 2579 ClassElement classC = ElementFactory.classElement("C", classB.type, []); |
| 2581 InterfaceType typeA = classA.type; | 2580 InterfaceType typeA = classA.type; |
| 2582 InterfaceType typeC = classC.type; | 2581 InterfaceType typeC = classC.type; |
| 2583 JUnitTestCase.assertTrue(typeC.isSubtypeOf(typeA)); | 2582 expect(typeC.isSubtypeOf(typeA), isTrue); |
| 2584 JUnitTestCase.assertFalse(typeA.isSubtypeOf(typeC)); | 2583 expect(typeA.isSubtypeOf(typeC), isFalse); |
| 2585 } | 2584 } |
| 2586 | 2585 |
| 2587 void test_isSubtypeOf_typeArguments() { | 2586 void test_isSubtypeOf_typeArguments() { |
| 2588 DartType dynamicType = DynamicTypeImpl.instance; | 2587 DartType dynamicType = DynamicTypeImpl.instance; |
| 2589 ClassElement classA = ElementFactory.classElement2("A", ["E"]); | 2588 ClassElement classA = ElementFactory.classElement2("A", ["E"]); |
| 2590 ClassElement classI = ElementFactory.classElement2("I", []); | 2589 ClassElement classI = ElementFactory.classElement2("I", []); |
| 2591 ClassElement classJ = ElementFactory.classElement("J", classI.type, []); | 2590 ClassElement classJ = ElementFactory.classElement("J", classI.type, []); |
| 2592 ClassElement classK = ElementFactory.classElement2("K", []); | 2591 ClassElement classK = ElementFactory.classElement2("K", []); |
| 2593 InterfaceType typeA = classA.type; | 2592 InterfaceType typeA = classA.type; |
| 2594 InterfaceType typeA_dynamic = typeA.substitute4(<DartType> [dynamicType]); | 2593 InterfaceType typeA_dynamic = typeA.substitute4(<DartType> [dynamicType]); |
| 2595 InterfaceTypeImpl typeAI = new InterfaceTypeImpl.con1(classA); | 2594 InterfaceTypeImpl typeAI = new InterfaceTypeImpl.con1(classA); |
| 2596 InterfaceTypeImpl typeAJ = new InterfaceTypeImpl.con1(classA); | 2595 InterfaceTypeImpl typeAJ = new InterfaceTypeImpl.con1(classA); |
| 2597 InterfaceTypeImpl typeAK = new InterfaceTypeImpl.con1(classA); | 2596 InterfaceTypeImpl typeAK = new InterfaceTypeImpl.con1(classA); |
| 2598 typeAI.typeArguments = <DartType> [classI.type]; | 2597 typeAI.typeArguments = <DartType> [classI.type]; |
| 2599 typeAJ.typeArguments = <DartType> [classJ.type]; | 2598 typeAJ.typeArguments = <DartType> [classJ.type]; |
| 2600 typeAK.typeArguments = <DartType> [classK.type]; | 2599 typeAK.typeArguments = <DartType> [classK.type]; |
| 2601 // A<J> <: A<I> since J <: I | 2600 // A<J> <: A<I> since J <: I |
| 2602 JUnitTestCase.assertTrue(typeAJ.isSubtypeOf(typeAI)); | 2601 expect(typeAJ.isSubtypeOf(typeAI), isTrue); |
| 2603 JUnitTestCase.assertFalse(typeAI.isSubtypeOf(typeAJ)); | 2602 expect(typeAI.isSubtypeOf(typeAJ), isFalse); |
| 2604 // A<I> <: A<I> since I <: I | 2603 // A<I> <: A<I> since I <: I |
| 2605 JUnitTestCase.assertTrue(typeAI.isSubtypeOf(typeAI)); | 2604 expect(typeAI.isSubtypeOf(typeAI), isTrue); |
| 2606 // A <: A<I> and A <: A<J> | 2605 // A <: A<I> and A <: A<J> |
| 2607 JUnitTestCase.assertTrue(typeA_dynamic.isSubtypeOf(typeAI)); | 2606 expect(typeA_dynamic.isSubtypeOf(typeAI), isTrue); |
| 2608 JUnitTestCase.assertTrue(typeA_dynamic.isSubtypeOf(typeAJ)); | 2607 expect(typeA_dynamic.isSubtypeOf(typeAJ), isTrue); |
| 2609 // A<I> <: A and A<J> <: A | 2608 // A<I> <: A and A<J> <: A |
| 2610 JUnitTestCase.assertTrue(typeAI.isSubtypeOf(typeA_dynamic)); | 2609 expect(typeAI.isSubtypeOf(typeA_dynamic), isTrue); |
| 2611 JUnitTestCase.assertTrue(typeAJ.isSubtypeOf(typeA_dynamic)); | 2610 expect(typeAJ.isSubtypeOf(typeA_dynamic), isTrue); |
| 2612 // A<I> !<: A<K> and A<K> !<: A<I> | 2611 // A<I> !<: A<K> and A<K> !<: A<I> |
| 2613 JUnitTestCase.assertFalse(typeAI.isSubtypeOf(typeAK)); | 2612 expect(typeAI.isSubtypeOf(typeAK), isFalse); |
| 2614 JUnitTestCase.assertFalse(typeAK.isSubtypeOf(typeAI)); | 2613 expect(typeAK.isSubtypeOf(typeAI), isFalse); |
| 2615 } | 2614 } |
| 2616 | 2615 |
| 2617 void test_isSubtypeOf_typeParameter() { | 2616 void test_isSubtypeOf_typeParameter() { |
| 2618 // | 2617 // |
| 2619 // class A<E> {} | 2618 // class A<E> {} |
| 2620 // | 2619 // |
| 2621 ClassElement classA = ElementFactory.classElement2("A", ["E"]); | 2620 ClassElement classA = ElementFactory.classElement2("A", ["E"]); |
| 2622 InterfaceType typeA = classA.type; | 2621 InterfaceType typeA = classA.type; |
| 2623 TypeParameterType parameterType = classA.typeParameters[0].type; | 2622 TypeParameterType parameterType = classA.typeParameters[0].type; |
| 2624 JUnitTestCase.assertFalse(typeA.isSubtypeOf(parameterType)); | 2623 expect(typeA.isSubtypeOf(parameterType), isFalse); |
| 2625 } | 2624 } |
| 2626 | 2625 |
| 2627 void test_isSupertypeOf_directSupertype() { | 2626 void test_isSupertypeOf_directSupertype() { |
| 2628 ClassElement classA = ElementFactory.classElement2("A", []); | 2627 ClassElement classA = ElementFactory.classElement2("A", []); |
| 2629 ClassElement classB = ElementFactory.classElement("B", classA.type, []); | 2628 ClassElement classB = ElementFactory.classElement("B", classA.type, []); |
| 2630 InterfaceType typeA = classA.type; | 2629 InterfaceType typeA = classA.type; |
| 2631 InterfaceType typeB = classB.type; | 2630 InterfaceType typeB = classB.type; |
| 2632 JUnitTestCase.assertFalse(typeB.isSupertypeOf(typeA)); | 2631 expect(typeB.isSupertypeOf(typeA), isFalse); |
| 2633 JUnitTestCase.assertTrue(typeA.isSupertypeOf(typeB)); | 2632 expect(typeA.isSupertypeOf(typeB), isTrue); |
| 2634 } | 2633 } |
| 2635 | 2634 |
| 2636 void test_isSupertypeOf_dynamic() { | 2635 void test_isSupertypeOf_dynamic() { |
| 2637 ClassElement classA = ElementFactory.classElement2("A", []); | 2636 ClassElement classA = ElementFactory.classElement2("A", []); |
| 2638 InterfaceType typeA = classA.type; | 2637 InterfaceType typeA = classA.type; |
| 2639 DartType dynamicType = DynamicTypeImpl.instance; | 2638 DartType dynamicType = DynamicTypeImpl.instance; |
| 2640 JUnitTestCase.assertTrue(dynamicType.isSupertypeOf(typeA)); | 2639 expect(dynamicType.isSupertypeOf(typeA), isTrue); |
| 2641 JUnitTestCase.assertTrue(typeA.isSupertypeOf(dynamicType)); | 2640 expect(typeA.isSupertypeOf(dynamicType), isTrue); |
| 2642 } | 2641 } |
| 2643 | 2642 |
| 2644 void test_isSupertypeOf_indirectSupertype() { | 2643 void test_isSupertypeOf_indirectSupertype() { |
| 2645 ClassElement classA = ElementFactory.classElement2("A", []); | 2644 ClassElement classA = ElementFactory.classElement2("A", []); |
| 2646 ClassElement classB = ElementFactory.classElement("B", classA.type, []); | 2645 ClassElement classB = ElementFactory.classElement("B", classA.type, []); |
| 2647 ClassElement classC = ElementFactory.classElement("C", classB.type, []); | 2646 ClassElement classC = ElementFactory.classElement("C", classB.type, []); |
| 2648 InterfaceType typeA = classA.type; | 2647 InterfaceType typeA = classA.type; |
| 2649 InterfaceType typeC = classC.type; | 2648 InterfaceType typeC = classC.type; |
| 2650 JUnitTestCase.assertFalse(typeC.isSupertypeOf(typeA)); | 2649 expect(typeC.isSupertypeOf(typeA), isFalse); |
| 2651 JUnitTestCase.assertTrue(typeA.isSupertypeOf(typeC)); | 2650 expect(typeA.isSupertypeOf(typeC), isTrue); |
| 2652 } | 2651 } |
| 2653 | 2652 |
| 2654 void test_isSupertypeOf_interface() { | 2653 void test_isSupertypeOf_interface() { |
| 2655 ClassElement classA = ElementFactory.classElement2("A", []); | 2654 ClassElement classA = ElementFactory.classElement2("A", []); |
| 2656 ClassElement classB = ElementFactory.classElement("B", classA.type, []); | 2655 ClassElement classB = ElementFactory.classElement("B", classA.type, []); |
| 2657 ClassElementImpl classC = ElementFactory.classElement2("C", []); | 2656 ClassElementImpl classC = ElementFactory.classElement2("C", []); |
| 2658 InterfaceType typeObject = classA.supertype; | 2657 InterfaceType typeObject = classA.supertype; |
| 2659 InterfaceType typeA = classA.type; | 2658 InterfaceType typeA = classA.type; |
| 2660 InterfaceType typeB = classB.type; | 2659 InterfaceType typeB = classB.type; |
| 2661 InterfaceType typeC = classC.type; | 2660 InterfaceType typeC = classC.type; |
| 2662 classC.interfaces = <InterfaceType> [typeB]; | 2661 classC.interfaces = <InterfaceType> [typeB]; |
| 2663 JUnitTestCase.assertTrue(typeB.isSupertypeOf(typeC)); | 2662 expect(typeB.isSupertypeOf(typeC), isTrue); |
| 2664 JUnitTestCase.assertTrue(typeObject.isSupertypeOf(typeC)); | 2663 expect(typeObject.isSupertypeOf(typeC), isTrue); |
| 2665 JUnitTestCase.assertTrue(typeA.isSupertypeOf(typeC)); | 2664 expect(typeA.isSupertypeOf(typeC), isTrue); |
| 2666 JUnitTestCase.assertFalse(typeC.isSupertypeOf(typeA)); | 2665 expect(typeC.isSupertypeOf(typeA), isFalse); |
| 2667 } | 2666 } |
| 2668 | 2667 |
| 2669 void test_isSupertypeOf_mixins() { | 2668 void test_isSupertypeOf_mixins() { |
| 2670 // | 2669 // |
| 2671 // class A {} | 2670 // class A {} |
| 2672 // class B extends A {} | 2671 // class B extends A {} |
| 2673 // class C with B {} | 2672 // class C with B {} |
| 2674 // | 2673 // |
| 2675 ClassElement classA = ElementFactory.classElement2("A", []); | 2674 ClassElement classA = ElementFactory.classElement2("A", []); |
| 2676 ClassElement classB = ElementFactory.classElement("B", classA.type, []); | 2675 ClassElement classB = ElementFactory.classElement("B", classA.type, []); |
| 2677 ClassElementImpl classC = ElementFactory.classElement2("C", []); | 2676 ClassElementImpl classC = ElementFactory.classElement2("C", []); |
| 2678 InterfaceType typeObject = classA.supertype; | 2677 InterfaceType typeObject = classA.supertype; |
| 2679 InterfaceType typeA = classA.type; | 2678 InterfaceType typeA = classA.type; |
| 2680 InterfaceType typeB = classB.type; | 2679 InterfaceType typeB = classB.type; |
| 2681 InterfaceType typeC = classC.type; | 2680 InterfaceType typeC = classC.type; |
| 2682 classC.mixins = <InterfaceType> [typeB]; | 2681 classC.mixins = <InterfaceType> [typeB]; |
| 2683 JUnitTestCase.assertTrue(typeB.isSupertypeOf(typeC)); | 2682 expect(typeB.isSupertypeOf(typeC), isTrue); |
| 2684 JUnitTestCase.assertTrue(typeObject.isSupertypeOf(typeC)); | 2683 expect(typeObject.isSupertypeOf(typeC), isTrue); |
| 2685 JUnitTestCase.assertTrue(typeA.isSupertypeOf(typeC)); | 2684 expect(typeA.isSupertypeOf(typeC), isTrue); |
| 2686 JUnitTestCase.assertFalse(typeC.isSupertypeOf(typeA)); | 2685 expect(typeC.isSupertypeOf(typeA), isFalse); |
| 2687 } | 2686 } |
| 2688 | 2687 |
| 2689 void test_isSupertypeOf_object() { | 2688 void test_isSupertypeOf_object() { |
| 2690 ClassElement classA = ElementFactory.classElement2("A", []); | 2689 ClassElement classA = ElementFactory.classElement2("A", []); |
| 2691 InterfaceType typeA = classA.type; | 2690 InterfaceType typeA = classA.type; |
| 2692 InterfaceType typeObject = classA.supertype; | 2691 InterfaceType typeObject = classA.supertype; |
| 2693 JUnitTestCase.assertFalse(typeA.isSupertypeOf(typeObject)); | 2692 expect(typeA.isSupertypeOf(typeObject), isFalse); |
| 2694 JUnitTestCase.assertTrue(typeObject.isSupertypeOf(typeA)); | 2693 expect(typeObject.isSupertypeOf(typeA), isTrue); |
| 2695 } | 2694 } |
| 2696 | 2695 |
| 2697 void test_isSupertypeOf_self() { | 2696 void test_isSupertypeOf_self() { |
| 2698 ClassElement classA = ElementFactory.classElement2("A", []); | 2697 ClassElement classA = ElementFactory.classElement2("A", []); |
| 2699 InterfaceType typeA = classA.type; | 2698 InterfaceType typeA = classA.type; |
| 2700 JUnitTestCase.assertTrue(typeA.isSupertypeOf(typeA)); | 2699 expect(typeA.isSupertypeOf(typeA), isTrue); |
| 2701 } | 2700 } |
| 2702 | 2701 |
| 2703 void test_lookUpGetter_implemented() { | 2702 void test_lookUpGetter_implemented() { |
| 2704 // | 2703 // |
| 2705 // class A { g {} } | 2704 // class A { g {} } |
| 2706 // | 2705 // |
| 2707 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 2706 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 2708 String getterName = "g"; | 2707 String getterName = "g"; |
| 2709 PropertyAccessorElement getterG = ElementFactory.getterElement(getterName, f
alse, null); | 2708 PropertyAccessorElement getterG = ElementFactory.getterElement(getterName, f
alse, null); |
| 2710 classA.accessors = <PropertyAccessorElement> [getterG]; | 2709 classA.accessors = <PropertyAccessorElement> [getterG]; |
| 2711 InterfaceType typeA = classA.type; | 2710 InterfaceType typeA = classA.type; |
| 2712 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(),
"lib"); | 2711 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(),
"lib"); |
| 2713 CompilationUnitElement unit = library.definingCompilationUnit; | 2712 CompilationUnitElement unit = library.definingCompilationUnit; |
| 2714 (unit as CompilationUnitElementImpl).types = <ClassElement> [classA]; | 2713 (unit as CompilationUnitElementImpl).types = <ClassElement> [classA]; |
| 2715 JUnitTestCase.assertSame(getterG, typeA.lookUpGetter(getterName, library)); | 2714 expect(typeA.lookUpGetter(getterName, library), same(getterG)); |
| 2716 } | 2715 } |
| 2717 | 2716 |
| 2718 void test_lookUpGetter_inherited() { | 2717 void test_lookUpGetter_inherited() { |
| 2719 // | 2718 // |
| 2720 // class A { g {} } | 2719 // class A { g {} } |
| 2721 // class B extends A {} | 2720 // class B extends A {} |
| 2722 // | 2721 // |
| 2723 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 2722 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 2724 String getterName = "g"; | 2723 String getterName = "g"; |
| 2725 PropertyAccessorElement getterG = ElementFactory.getterElement(getterName, f
alse, null); | 2724 PropertyAccessorElement getterG = ElementFactory.getterElement(getterName, f
alse, null); |
| 2726 classA.accessors = <PropertyAccessorElement> [getterG]; | 2725 classA.accessors = <PropertyAccessorElement> [getterG]; |
| 2727 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); | 2726 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); |
| 2728 InterfaceType typeB = classB.type; | 2727 InterfaceType typeB = classB.type; |
| 2729 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(),
"lib"); | 2728 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(),
"lib"); |
| 2730 CompilationUnitElement unit = library.definingCompilationUnit; | 2729 CompilationUnitElement unit = library.definingCompilationUnit; |
| 2731 (unit as CompilationUnitElementImpl).types = <ClassElement> [classA, classB]
; | 2730 (unit as CompilationUnitElementImpl).types = <ClassElement> [classA, classB]
; |
| 2732 JUnitTestCase.assertSame(getterG, typeB.lookUpGetter(getterName, library)); | 2731 expect(typeB.lookUpGetter(getterName, library), same(getterG)); |
| 2733 } | 2732 } |
| 2734 | 2733 |
| 2735 void test_lookUpGetter_recursive() { | 2734 void test_lookUpGetter_recursive() { |
| 2736 // | 2735 // |
| 2737 // class A extends B {} | 2736 // class A extends B {} |
| 2738 // class B extends A {} | 2737 // class B extends A {} |
| 2739 // | 2738 // |
| 2740 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 2739 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 2741 InterfaceType typeA = classA.type; | 2740 InterfaceType typeA = classA.type; |
| 2742 ClassElementImpl classB = ElementFactory.classElement("B", typeA, []); | 2741 ClassElementImpl classB = ElementFactory.classElement("B", typeA, []); |
| 2743 classA.supertype = classB.type; | 2742 classA.supertype = classB.type; |
| 2744 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(),
"lib"); | 2743 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(),
"lib"); |
| 2745 CompilationUnitElement unit = library.definingCompilationUnit; | 2744 CompilationUnitElement unit = library.definingCompilationUnit; |
| 2746 (unit as CompilationUnitElementImpl).types = <ClassElement> [classA, classB]
; | 2745 (unit as CompilationUnitElementImpl).types = <ClassElement> [classA, classB]
; |
| 2747 JUnitTestCase.assertNull(typeA.lookUpGetter("g", library)); | 2746 expect(typeA.lookUpGetter("g", library), isNull); |
| 2748 } | 2747 } |
| 2749 | 2748 |
| 2750 void test_lookUpGetter_unimplemented() { | 2749 void test_lookUpGetter_unimplemented() { |
| 2751 // | 2750 // |
| 2752 // class A {} | 2751 // class A {} |
| 2753 // | 2752 // |
| 2754 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 2753 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 2755 InterfaceType typeA = classA.type; | 2754 InterfaceType typeA = classA.type; |
| 2756 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(),
"lib"); | 2755 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(),
"lib"); |
| 2757 CompilationUnitElement unit = library.definingCompilationUnit; | 2756 CompilationUnitElement unit = library.definingCompilationUnit; |
| 2758 (unit as CompilationUnitElementImpl).types = <ClassElement> [classA]; | 2757 (unit as CompilationUnitElementImpl).types = <ClassElement> [classA]; |
| 2759 JUnitTestCase.assertNull(typeA.lookUpGetter("g", library)); | 2758 expect(typeA.lookUpGetter("g", library), isNull); |
| 2760 } | 2759 } |
| 2761 | 2760 |
| 2762 void test_lookUpMethod_implemented() { | 2761 void test_lookUpMethod_implemented() { |
| 2763 // | 2762 // |
| 2764 // class A { m() {} } | 2763 // class A { m() {} } |
| 2765 // | 2764 // |
| 2766 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 2765 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 2767 String methodName = "m"; | 2766 String methodName = "m"; |
| 2768 MethodElementImpl methodM = ElementFactory.methodElement(methodName, null, [
]); | 2767 MethodElementImpl methodM = ElementFactory.methodElement(methodName, null, [
]); |
| 2769 classA.methods = <MethodElement> [methodM]; | 2768 classA.methods = <MethodElement> [methodM]; |
| 2770 InterfaceType typeA = classA.type; | 2769 InterfaceType typeA = classA.type; |
| 2771 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(),
"lib"); | 2770 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(),
"lib"); |
| 2772 CompilationUnitElement unit = library.definingCompilationUnit; | 2771 CompilationUnitElement unit = library.definingCompilationUnit; |
| 2773 (unit as CompilationUnitElementImpl).types = <ClassElement> [classA]; | 2772 (unit as CompilationUnitElementImpl).types = <ClassElement> [classA]; |
| 2774 JUnitTestCase.assertSame(methodM, typeA.lookUpMethod(methodName, library)); | 2773 expect(typeA.lookUpMethod(methodName, library), same(methodM)); |
| 2775 } | 2774 } |
| 2776 | 2775 |
| 2777 void test_lookUpMethod_inherited() { | 2776 void test_lookUpMethod_inherited() { |
| 2778 // | 2777 // |
| 2779 // class A { m() {} } | 2778 // class A { m() {} } |
| 2780 // class B extends A {} | 2779 // class B extends A {} |
| 2781 // | 2780 // |
| 2782 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 2781 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 2783 String methodName = "m"; | 2782 String methodName = "m"; |
| 2784 MethodElementImpl methodM = ElementFactory.methodElement(methodName, null, [
]); | 2783 MethodElementImpl methodM = ElementFactory.methodElement(methodName, null, [
]); |
| 2785 classA.methods = <MethodElement> [methodM]; | 2784 classA.methods = <MethodElement> [methodM]; |
| 2786 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); | 2785 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); |
| 2787 InterfaceType typeB = classB.type; | 2786 InterfaceType typeB = classB.type; |
| 2788 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(),
"lib"); | 2787 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(),
"lib"); |
| 2789 CompilationUnitElement unit = library.definingCompilationUnit; | 2788 CompilationUnitElement unit = library.definingCompilationUnit; |
| 2790 (unit as CompilationUnitElementImpl).types = <ClassElement> [classA, classB]
; | 2789 (unit as CompilationUnitElementImpl).types = <ClassElement> [classA, classB]
; |
| 2791 JUnitTestCase.assertSame(methodM, typeB.lookUpMethod(methodName, library)); | 2790 expect(typeB.lookUpMethod(methodName, library), same(methodM)); |
| 2792 } | 2791 } |
| 2793 | 2792 |
| 2794 void test_lookUpMethod_parameterized() { | 2793 void test_lookUpMethod_parameterized() { |
| 2795 // | 2794 // |
| 2796 // class A<E> { E m(E p) {} } | 2795 // class A<E> { E m(E p) {} } |
| 2797 // class B<F> extends A<F> {} | 2796 // class B<F> extends A<F> {} |
| 2798 // | 2797 // |
| 2799 ClassElementImpl classA = ElementFactory.classElement2("A", ["E"]); | 2798 ClassElementImpl classA = ElementFactory.classElement2("A", ["E"]); |
| 2800 DartType typeE = classA.type.typeArguments[0]; | 2799 DartType typeE = classA.type.typeArguments[0]; |
| 2801 String methodName = "m"; | 2800 String methodName = "m"; |
| 2802 MethodElementImpl methodM = ElementFactory.methodElement(methodName, typeE,
[typeE]); | 2801 MethodElementImpl methodM = ElementFactory.methodElement(methodName, typeE,
[typeE]); |
| 2803 classA.methods = <MethodElement> [methodM]; | 2802 classA.methods = <MethodElement> [methodM]; |
| 2804 (methodM.type as FunctionTypeImpl).typeArguments = classA.type.typeArguments
; | 2803 (methodM.type as FunctionTypeImpl).typeArguments = classA.type.typeArguments
; |
| 2805 ClassElementImpl classB = ElementFactory.classElement2("B", ["F"]); | 2804 ClassElementImpl classB = ElementFactory.classElement2("B", ["F"]); |
| 2806 InterfaceType typeB = classB.type; | 2805 InterfaceType typeB = classB.type; |
| 2807 InterfaceTypeImpl typeAF = new InterfaceTypeImpl.con1(classA); | 2806 InterfaceTypeImpl typeAF = new InterfaceTypeImpl.con1(classA); |
| 2808 typeAF.typeArguments = <DartType> [typeB.typeArguments[0]]; | 2807 typeAF.typeArguments = <DartType> [typeB.typeArguments[0]]; |
| 2809 classB.supertype = typeAF; | 2808 classB.supertype = typeAF; |
| 2810 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(),
"lib"); | 2809 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(),
"lib"); |
| 2811 CompilationUnitElement unit = library.definingCompilationUnit; | 2810 CompilationUnitElement unit = library.definingCompilationUnit; |
| 2812 (unit as CompilationUnitElementImpl).types = <ClassElement> [classA]; | 2811 (unit as CompilationUnitElementImpl).types = <ClassElement> [classA]; |
| 2813 // | 2812 // |
| 2814 // B<I> | 2813 // B<I> |
| 2815 // | 2814 // |
| 2816 InterfaceType typeI = ElementFactory.classElement2("I", []).type; | 2815 InterfaceType typeI = ElementFactory.classElement2("I", []).type; |
| 2817 InterfaceTypeImpl typeBI = new InterfaceTypeImpl.con1(classB); | 2816 InterfaceTypeImpl typeBI = new InterfaceTypeImpl.con1(classB); |
| 2818 typeBI.typeArguments = <DartType> [typeI]; | 2817 typeBI.typeArguments = <DartType> [typeI]; |
| 2819 MethodElement method = typeBI.lookUpMethod(methodName, library); | 2818 MethodElement method = typeBI.lookUpMethod(methodName, library); |
| 2820 JUnitTestCase.assertNotNull(method); | 2819 expect(method, isNotNull); |
| 2821 FunctionType methodType = method.type; | 2820 FunctionType methodType = method.type; |
| 2822 JUnitTestCase.assertSame(typeI, methodType.returnType); | 2821 expect(methodType.returnType, same(typeI)); |
| 2823 List<DartType> parameterTypes = methodType.normalParameterTypes; | 2822 List<DartType> parameterTypes = methodType.normalParameterTypes; |
| 2824 EngineTestCase.assertLength(1, parameterTypes); | 2823 EngineTestCase.assertLength(1, parameterTypes); |
| 2825 JUnitTestCase.assertSame(typeI, parameterTypes[0]); | 2824 expect(parameterTypes[0], same(typeI)); |
| 2826 } | 2825 } |
| 2827 | 2826 |
| 2828 void test_lookUpMethod_recursive() { | 2827 void test_lookUpMethod_recursive() { |
| 2829 // | 2828 // |
| 2830 // class A extends B {} | 2829 // class A extends B {} |
| 2831 // class B extends A {} | 2830 // class B extends A {} |
| 2832 // | 2831 // |
| 2833 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 2832 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 2834 InterfaceType typeA = classA.type; | 2833 InterfaceType typeA = classA.type; |
| 2835 ClassElementImpl classB = ElementFactory.classElement("B", typeA, []); | 2834 ClassElementImpl classB = ElementFactory.classElement("B", typeA, []); |
| 2836 classA.supertype = classB.type; | 2835 classA.supertype = classB.type; |
| 2837 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(),
"lib"); | 2836 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(),
"lib"); |
| 2838 CompilationUnitElement unit = library.definingCompilationUnit; | 2837 CompilationUnitElement unit = library.definingCompilationUnit; |
| 2839 (unit as CompilationUnitElementImpl).types = <ClassElement> [classA, classB]
; | 2838 (unit as CompilationUnitElementImpl).types = <ClassElement> [classA, classB]
; |
| 2840 JUnitTestCase.assertNull(typeA.lookUpMethod("m", library)); | 2839 expect(typeA.lookUpMethod("m", library), isNull); |
| 2841 } | 2840 } |
| 2842 | 2841 |
| 2843 void test_lookUpMethod_unimplemented() { | 2842 void test_lookUpMethod_unimplemented() { |
| 2844 // | 2843 // |
| 2845 // class A {} | 2844 // class A {} |
| 2846 // | 2845 // |
| 2847 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 2846 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 2848 InterfaceType typeA = classA.type; | 2847 InterfaceType typeA = classA.type; |
| 2849 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(),
"lib"); | 2848 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(),
"lib"); |
| 2850 CompilationUnitElement unit = library.definingCompilationUnit; | 2849 CompilationUnitElement unit = library.definingCompilationUnit; |
| 2851 (unit as CompilationUnitElementImpl).types = <ClassElement> [classA]; | 2850 (unit as CompilationUnitElementImpl).types = <ClassElement> [classA]; |
| 2852 JUnitTestCase.assertNull(typeA.lookUpMethod("m", library)); | 2851 expect(typeA.lookUpMethod("m", library), isNull); |
| 2853 } | 2852 } |
| 2854 | 2853 |
| 2855 void test_lookUpSetter_implemented() { | 2854 void test_lookUpSetter_implemented() { |
| 2856 // | 2855 // |
| 2857 // class A { s(x) {} } | 2856 // class A { s(x) {} } |
| 2858 // | 2857 // |
| 2859 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 2858 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 2860 String setterName = "s"; | 2859 String setterName = "s"; |
| 2861 PropertyAccessorElement setterS = ElementFactory.setterElement(setterName, f
alse, null); | 2860 PropertyAccessorElement setterS = ElementFactory.setterElement(setterName, f
alse, null); |
| 2862 classA.accessors = <PropertyAccessorElement> [setterS]; | 2861 classA.accessors = <PropertyAccessorElement> [setterS]; |
| 2863 InterfaceType typeA = classA.type; | 2862 InterfaceType typeA = classA.type; |
| 2864 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(),
"lib"); | 2863 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(),
"lib"); |
| 2865 CompilationUnitElement unit = library.definingCompilationUnit; | 2864 CompilationUnitElement unit = library.definingCompilationUnit; |
| 2866 (unit as CompilationUnitElementImpl).types = <ClassElement> [classA]; | 2865 (unit as CompilationUnitElementImpl).types = <ClassElement> [classA]; |
| 2867 JUnitTestCase.assertSame(setterS, typeA.lookUpSetter(setterName, library)); | 2866 expect(typeA.lookUpSetter(setterName, library), same(setterS)); |
| 2868 } | 2867 } |
| 2869 | 2868 |
| 2870 void test_lookUpSetter_inherited() { | 2869 void test_lookUpSetter_inherited() { |
| 2871 // | 2870 // |
| 2872 // class A { s(x) {} } | 2871 // class A { s(x) {} } |
| 2873 // class B extends A {} | 2872 // class B extends A {} |
| 2874 // | 2873 // |
| 2875 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 2874 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 2876 String setterName = "g"; | 2875 String setterName = "g"; |
| 2877 PropertyAccessorElement setterS = ElementFactory.setterElement(setterName, f
alse, null); | 2876 PropertyAccessorElement setterS = ElementFactory.setterElement(setterName, f
alse, null); |
| 2878 classA.accessors = <PropertyAccessorElement> [setterS]; | 2877 classA.accessors = <PropertyAccessorElement> [setterS]; |
| 2879 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); | 2878 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); |
| 2880 InterfaceType typeB = classB.type; | 2879 InterfaceType typeB = classB.type; |
| 2881 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(),
"lib"); | 2880 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(),
"lib"); |
| 2882 CompilationUnitElement unit = library.definingCompilationUnit; | 2881 CompilationUnitElement unit = library.definingCompilationUnit; |
| 2883 (unit as CompilationUnitElementImpl).types = <ClassElement> [classA, classB]
; | 2882 (unit as CompilationUnitElementImpl).types = <ClassElement> [classA, classB]
; |
| 2884 JUnitTestCase.assertSame(setterS, typeB.lookUpSetter(setterName, library)); | 2883 expect(typeB.lookUpSetter(setterName, library), same(setterS)); |
| 2885 } | 2884 } |
| 2886 | 2885 |
| 2887 void test_lookUpSetter_recursive() { | 2886 void test_lookUpSetter_recursive() { |
| 2888 // | 2887 // |
| 2889 // class A extends B {} | 2888 // class A extends B {} |
| 2890 // class B extends A {} | 2889 // class B extends A {} |
| 2891 // | 2890 // |
| 2892 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 2891 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 2893 InterfaceType typeA = classA.type; | 2892 InterfaceType typeA = classA.type; |
| 2894 ClassElementImpl classB = ElementFactory.classElement("B", typeA, []); | 2893 ClassElementImpl classB = ElementFactory.classElement("B", typeA, []); |
| 2895 classA.supertype = classB.type; | 2894 classA.supertype = classB.type; |
| 2896 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(),
"lib"); | 2895 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(),
"lib"); |
| 2897 CompilationUnitElement unit = library.definingCompilationUnit; | 2896 CompilationUnitElement unit = library.definingCompilationUnit; |
| 2898 (unit as CompilationUnitElementImpl).types = <ClassElement> [classA, classB]
; | 2897 (unit as CompilationUnitElementImpl).types = <ClassElement> [classA, classB]
; |
| 2899 JUnitTestCase.assertNull(typeA.lookUpSetter("s", library)); | 2898 expect(typeA.lookUpSetter("s", library), isNull); |
| 2900 } | 2899 } |
| 2901 | 2900 |
| 2902 void test_lookUpSetter_unimplemented() { | 2901 void test_lookUpSetter_unimplemented() { |
| 2903 // | 2902 // |
| 2904 // class A {} | 2903 // class A {} |
| 2905 // | 2904 // |
| 2906 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 2905 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 2907 InterfaceType typeA = classA.type; | 2906 InterfaceType typeA = classA.type; |
| 2908 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(),
"lib"); | 2907 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(),
"lib"); |
| 2909 CompilationUnitElement unit = library.definingCompilationUnit; | 2908 CompilationUnitElement unit = library.definingCompilationUnit; |
| 2910 (unit as CompilationUnitElementImpl).types = <ClassElement> [classA]; | 2909 (unit as CompilationUnitElementImpl).types = <ClassElement> [classA]; |
| 2911 JUnitTestCase.assertNull(typeA.lookUpSetter("s", library)); | 2910 expect(typeA.lookUpSetter("s", library), isNull); |
| 2912 } | 2911 } |
| 2913 | 2912 |
| 2914 void test_setTypeArguments() { | 2913 void test_setTypeArguments() { |
| 2915 InterfaceTypeImpl type = ElementFactory.classElement2("A", []).type as Inter
faceTypeImpl; | 2914 InterfaceTypeImpl type = ElementFactory.classElement2("A", []).type as Inter
faceTypeImpl; |
| 2916 List<DartType> typeArguments = <DartType> [ | 2915 List<DartType> typeArguments = <DartType> [ |
| 2917 ElementFactory.classElement2("B", []).type, | 2916 ElementFactory.classElement2("B", []).type, |
| 2918 ElementFactory.classElement2("C", []).type]; | 2917 ElementFactory.classElement2("C", []).type]; |
| 2919 type.typeArguments = typeArguments; | 2918 type.typeArguments = typeArguments; |
| 2920 JUnitTestCase.assertEquals(typeArguments, type.typeArguments); | 2919 expect(type.typeArguments, typeArguments); |
| 2921 } | 2920 } |
| 2922 | 2921 |
| 2923 void test_substitute_equal() { | 2922 void test_substitute_equal() { |
| 2924 ClassElement classAE = ElementFactory.classElement2("A", ["E"]); | 2923 ClassElement classAE = ElementFactory.classElement2("A", ["E"]); |
| 2925 InterfaceType typeAE = classAE.type; | 2924 InterfaceType typeAE = classAE.type; |
| 2926 InterfaceType argumentType = ElementFactory.classElement2("B", []).type; | 2925 InterfaceType argumentType = ElementFactory.classElement2("B", []).type; |
| 2927 List<DartType> args = [argumentType]; | 2926 List<DartType> args = [argumentType]; |
| 2928 List<DartType> params = [classAE.typeParameters[0].type]; | 2927 List<DartType> params = [classAE.typeParameters[0].type]; |
| 2929 InterfaceType typeAESubbed = typeAE.substitute2(args, params); | 2928 InterfaceType typeAESubbed = typeAE.substitute2(args, params); |
| 2930 JUnitTestCase.assertEquals(classAE, typeAESubbed.element); | 2929 expect(typeAESubbed.element, classAE); |
| 2931 List<DartType> resultArguments = typeAESubbed.typeArguments; | 2930 List<DartType> resultArguments = typeAESubbed.typeArguments; |
| 2932 EngineTestCase.assertLength(1, resultArguments); | 2931 EngineTestCase.assertLength(1, resultArguments); |
| 2933 JUnitTestCase.assertEquals(argumentType, resultArguments[0]); | 2932 expect(resultArguments[0], argumentType); |
| 2934 } | 2933 } |
| 2935 | 2934 |
| 2936 void test_substitute_exception() { | 2935 void test_substitute_exception() { |
| 2937 try { | 2936 try { |
| 2938 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 2937 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 2939 InterfaceTypeImpl type = new InterfaceTypeImpl.con1(classA); | 2938 InterfaceTypeImpl type = new InterfaceTypeImpl.con1(classA); |
| 2940 InterfaceType argumentType = ElementFactory.classElement2("B", []).type; | 2939 InterfaceType argumentType = ElementFactory.classElement2("B", []).type; |
| 2941 type.substitute2(<DartType> [argumentType], <DartType> []); | 2940 type.substitute2(<DartType> [argumentType], <DartType> []); |
| 2942 JUnitTestCase.fail("Expected to encounter exception, argument and paramete
r type array lengths not equal."); | 2941 fail("Expected to encounter exception, argument and parameter type array l
engths not equal."); |
| 2943 } catch (e) { | 2942 } catch (e) { |
| 2944 // Expected result | 2943 // Expected result |
| 2945 } | 2944 } |
| 2946 } | 2945 } |
| 2947 | 2946 |
| 2948 void test_substitute_notEqual() { | 2947 void test_substitute_notEqual() { |
| 2949 // The [test_substitute_equals] above has a slightly higher level implementa
tion. | 2948 // The [test_substitute_equals] above has a slightly higher level implementa
tion. |
| 2950 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 2949 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 2951 TypeParameterElementImpl parameterElement = new TypeParameterElementImpl.for
Node(AstFactory.identifier3("E")); | 2950 TypeParameterElementImpl parameterElement = new TypeParameterElementImpl.for
Node(AstFactory.identifier3("E")); |
| 2952 InterfaceTypeImpl type = new InterfaceTypeImpl.con1(classA); | 2951 InterfaceTypeImpl type = new InterfaceTypeImpl.con1(classA); |
| 2953 TypeParameterTypeImpl parameter = new TypeParameterTypeImpl(parameterElement
); | 2952 TypeParameterTypeImpl parameter = new TypeParameterTypeImpl(parameterElement
); |
| 2954 type.typeArguments = <DartType> [parameter]; | 2953 type.typeArguments = <DartType> [parameter]; |
| 2955 InterfaceType argumentType = ElementFactory.classElement2("B", []).type; | 2954 InterfaceType argumentType = ElementFactory.classElement2("B", []).type; |
| 2956 TypeParameterTypeImpl parameterType = new TypeParameterTypeImpl(new TypePara
meterElementImpl.forNode(AstFactory.identifier3("F"))); | 2955 TypeParameterTypeImpl parameterType = new TypeParameterTypeImpl(new TypePara
meterElementImpl.forNode(AstFactory.identifier3("F"))); |
| 2957 InterfaceType result = type.substitute2(<DartType> [argumentType], <DartType
> [parameterType]); | 2956 InterfaceType result = type.substitute2(<DartType> [argumentType], <DartType
> [parameterType]); |
| 2958 JUnitTestCase.assertEquals(classA, result.element); | 2957 expect(result.element, classA); |
| 2959 List<DartType> resultArguments = result.typeArguments; | 2958 List<DartType> resultArguments = result.typeArguments; |
| 2960 EngineTestCase.assertLength(1, resultArguments); | 2959 EngineTestCase.assertLength(1, resultArguments); |
| 2961 JUnitTestCase.assertEquals(parameter, resultArguments[0]); | 2960 expect(resultArguments[0], parameter); |
| 2962 } | 2961 } |
| 2963 } | 2962 } |
| 2964 | 2963 |
| 2965 class InterfaceTypeImpl_FunctionTypeImplTest_test_isSubtypeOf_baseCase_classFunc
tion extends InterfaceTypeImpl { | 2964 class InterfaceTypeImpl_FunctionTypeImplTest_test_isSubtypeOf_baseCase_classFunc
tion extends InterfaceTypeImpl { |
| 2966 InterfaceTypeImpl_FunctionTypeImplTest_test_isSubtypeOf_baseCase_classFunction
(ClassElement arg0) : super.con1(arg0); | 2965 InterfaceTypeImpl_FunctionTypeImplTest_test_isSubtypeOf_baseCase_classFunction
(ClassElement arg0) : super.con1(arg0); |
| 2967 | 2966 |
| 2968 @override | 2967 @override |
| 2969 bool get isDartCoreFunction => true; | 2968 bool get isDartCoreFunction => true; |
| 2970 } | 2969 } |
| 2971 | 2970 |
| 2972 class LibraryElementImplTest extends EngineTestCase { | 2971 class LibraryElementImplTest extends EngineTestCase { |
| 2973 void test_creation() { | 2972 void test_creation() { |
| 2974 JUnitTestCase.assertNotNull(new LibraryElementImpl.forNode(createAnalysisCon
text(), AstFactory.libraryIdentifier2(["l"]))); | 2973 expect(new LibraryElementImpl.forNode(createAnalysisContext(), AstFactory.li
braryIdentifier2(["l"])), isNotNull); |
| 2975 } | 2974 } |
| 2976 | 2975 |
| 2977 void test_getImportedLibraries() { | 2976 void test_getImportedLibraries() { |
| 2978 AnalysisContext context = createAnalysisContext(); | 2977 AnalysisContext context = createAnalysisContext(); |
| 2979 LibraryElementImpl library1 = ElementFactory.library(context, "l1"); | 2978 LibraryElementImpl library1 = ElementFactory.library(context, "l1"); |
| 2980 LibraryElementImpl library2 = ElementFactory.library(context, "l2"); | 2979 LibraryElementImpl library2 = ElementFactory.library(context, "l2"); |
| 2981 LibraryElementImpl library3 = ElementFactory.library(context, "l3"); | 2980 LibraryElementImpl library3 = ElementFactory.library(context, "l3"); |
| 2982 LibraryElementImpl library4 = ElementFactory.library(context, "l4"); | 2981 LibraryElementImpl library4 = ElementFactory.library(context, "l4"); |
| 2983 PrefixElement prefixA = new PrefixElementImpl.forNode(AstFactory.identifier3
("a")); | 2982 PrefixElement prefixA = new PrefixElementImpl.forNode(AstFactory.identifier3
("a")); |
| 2984 PrefixElement prefixB = new PrefixElementImpl.forNode(AstFactory.identifier3
("b")); | 2983 PrefixElement prefixB = new PrefixElementImpl.forNode(AstFactory.identifier3
("b")); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 3002 List<ImportElementImpl> imports = [ | 3001 List<ImportElementImpl> imports = [ |
| 3003 ElementFactory.importFor(ElementFactory.library(context, "l2"), null, []
), | 3002 ElementFactory.importFor(ElementFactory.library(context, "l2"), null, []
), |
| 3004 ElementFactory.importFor(ElementFactory.library(context, "l3"), null, []
), | 3003 ElementFactory.importFor(ElementFactory.library(context, "l3"), null, []
), |
| 3005 ElementFactory.importFor(ElementFactory.library(context, "l4"), prefixA,
[]), | 3004 ElementFactory.importFor(ElementFactory.library(context, "l4"), prefixA,
[]), |
| 3006 ElementFactory.importFor(ElementFactory.library(context, "l5"), prefixA,
[]), | 3005 ElementFactory.importFor(ElementFactory.library(context, "l5"), prefixA,
[]), |
| 3007 ElementFactory.importFor(ElementFactory.library(context, "l6"), prefixB,
[])]; | 3006 ElementFactory.importFor(ElementFactory.library(context, "l6"), prefixB,
[])]; |
| 3008 library.imports = imports; | 3007 library.imports = imports; |
| 3009 List<PrefixElement> prefixes = library.prefixes; | 3008 List<PrefixElement> prefixes = library.prefixes; |
| 3010 EngineTestCase.assertLength(2, prefixes); | 3009 EngineTestCase.assertLength(2, prefixes); |
| 3011 if (identical(prefixA, prefixes[0])) { | 3010 if (identical(prefixA, prefixes[0])) { |
| 3012 JUnitTestCase.assertSame(prefixB, prefixes[1]); | 3011 expect(prefixes[1], same(prefixB)); |
| 3013 } else { | 3012 } else { |
| 3014 JUnitTestCase.assertSame(prefixB, prefixes[0]); | 3013 expect(prefixes[0], same(prefixB)); |
| 3015 JUnitTestCase.assertSame(prefixA, prefixes[1]); | 3014 expect(prefixes[1], same(prefixA)); |
| 3016 } | 3015 } |
| 3017 } | 3016 } |
| 3018 | 3017 |
| 3019 void test_getUnits() { | 3018 void test_getUnits() { |
| 3020 AnalysisContext context = createAnalysisContext(); | 3019 AnalysisContext context = createAnalysisContext(); |
| 3021 LibraryElementImpl library = ElementFactory.library(context, "test"); | 3020 LibraryElementImpl library = ElementFactory.library(context, "test"); |
| 3022 CompilationUnitElement unitLib = library.definingCompilationUnit; | 3021 CompilationUnitElement unitLib = library.definingCompilationUnit; |
| 3023 CompilationUnitElementImpl unitA = ElementFactory.compilationUnit("unit_a.da
rt"); | 3022 CompilationUnitElementImpl unitA = ElementFactory.compilationUnit("unit_a.da
rt"); |
| 3024 CompilationUnitElementImpl unitB = ElementFactory.compilationUnit("unit_b.da
rt"); | 3023 CompilationUnitElementImpl unitB = ElementFactory.compilationUnit("unit_b.da
rt"); |
| 3025 library.parts = <CompilationUnitElement> [unitA, unitB]; | 3024 library.parts = <CompilationUnitElement> [unitA, unitB]; |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3084 LibraryElementImpl library = ElementFactory.library(context, "app"); | 3083 LibraryElementImpl library = ElementFactory.library(context, "app"); |
| 3085 EngineTestCase.assertEqualsIgnoreOrder(<LibraryElement> [library], library.v
isibleLibraries); | 3084 EngineTestCase.assertEqualsIgnoreOrder(<LibraryElement> [library], library.v
isibleLibraries); |
| 3086 } | 3085 } |
| 3087 | 3086 |
| 3088 void test_isUpToDate() { | 3087 void test_isUpToDate() { |
| 3089 AnalysisContext context = createAnalysisContext(); | 3088 AnalysisContext context = createAnalysisContext(); |
| 3090 context.sourceFactory = new SourceFactory([]); | 3089 context.sourceFactory = new SourceFactory([]); |
| 3091 LibraryElement library = ElementFactory.library(context, "foo"); | 3090 LibraryElement library = ElementFactory.library(context, "foo"); |
| 3092 context.setContents(library.definingCompilationUnit.source, "sdfsdff"); | 3091 context.setContents(library.definingCompilationUnit.source, "sdfsdff"); |
| 3093 // Assert that we are not up to date if the target has an old time stamp. | 3092 // Assert that we are not up to date if the target has an old time stamp. |
| 3094 JUnitTestCase.assertFalse(library.isUpToDate(0)); | 3093 expect(library.isUpToDate(0), isFalse); |
| 3095 // Assert that we are up to date with a target modification time in the futu
re. | 3094 // Assert that we are up to date with a target modification time in the futu
re. |
| 3096 JUnitTestCase.assertTrue(library.isUpToDate(JavaSystem.currentTimeMillis() +
1000)); | 3095 expect(library.isUpToDate(JavaSystem.currentTimeMillis() + 1000), isTrue); |
| 3097 } | 3096 } |
| 3098 | 3097 |
| 3099 void test_setImports() { | 3098 void test_setImports() { |
| 3100 AnalysisContext context = createAnalysisContext(); | 3099 AnalysisContext context = createAnalysisContext(); |
| 3101 LibraryElementImpl library = new LibraryElementImpl.forNode(context, AstFact
ory.libraryIdentifier2(["l1"])); | 3100 LibraryElementImpl library = new LibraryElementImpl.forNode(context, AstFact
ory.libraryIdentifier2(["l1"])); |
| 3102 List<ImportElementImpl> expectedImports = [ | 3101 List<ImportElementImpl> expectedImports = [ |
| 3103 ElementFactory.importFor(ElementFactory.library(context, "l2"), null, []
), | 3102 ElementFactory.importFor(ElementFactory.library(context, "l2"), null, []
), |
| 3104 ElementFactory.importFor(ElementFactory.library(context, "l3"), null, []
)]; | 3103 ElementFactory.importFor(ElementFactory.library(context, "l3"), null, []
)]; |
| 3105 library.imports = expectedImports; | 3104 library.imports = expectedImports; |
| 3106 List<ImportElement> actualImports = library.imports; | 3105 List<ImportElement> actualImports = library.imports; |
| 3107 EngineTestCase.assertLength(expectedImports.length, actualImports); | 3106 EngineTestCase.assertLength(expectedImports.length, actualImports); |
| 3108 for (int i = 0; i < actualImports.length; i++) { | 3107 for (int i = 0; i < actualImports.length; i++) { |
| 3109 JUnitTestCase.assertSame(expectedImports[i], actualImports[i]); | 3108 expect(actualImports[i], same(expectedImports[i])); |
| 3110 } | 3109 } |
| 3111 } | 3110 } |
| 3112 } | 3111 } |
| 3113 | 3112 |
| 3114 class MultiplyDefinedElementImplTest extends EngineTestCase { | 3113 class MultiplyDefinedElementImplTest extends EngineTestCase { |
| 3115 void test_fromElements_conflicting() { | 3114 void test_fromElements_conflicting() { |
| 3116 Element firstElement = ElementFactory.localVariableElement2("xx"); | 3115 Element firstElement = ElementFactory.localVariableElement2("xx"); |
| 3117 Element secondElement = ElementFactory.localVariableElement2("yy"); | 3116 Element secondElement = ElementFactory.localVariableElement2("yy"); |
| 3118 Element result = MultiplyDefinedElementImpl.fromElements(null, firstElement,
secondElement); | 3117 Element result = MultiplyDefinedElementImpl.fromElements(null, firstElement,
secondElement); |
| 3119 EngineTestCase.assertInstanceOf((obj) => obj is MultiplyDefinedElement, Mult
iplyDefinedElement, result); | 3118 EngineTestCase.assertInstanceOf((obj) => obj is MultiplyDefinedElement, Mult
iplyDefinedElement, result); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 3132 EngineTestCase.assertInstanceOf((obj) => obj is MultiplyDefinedElement, Mult
iplyDefinedElement, result); | 3131 EngineTestCase.assertInstanceOf((obj) => obj is MultiplyDefinedElement, Mult
iplyDefinedElement, result); |
| 3133 List<Element> elements = (result as MultiplyDefinedElement).conflictingEleme
nts; | 3132 List<Element> elements = (result as MultiplyDefinedElement).conflictingEleme
nts; |
| 3134 EngineTestCase.assertLength(3, elements); | 3133 EngineTestCase.assertLength(3, elements); |
| 3135 for (int i = 0; i < elements.length; i++) { | 3134 for (int i = 0; i < elements.length; i++) { |
| 3136 EngineTestCase.assertInstanceOf((obj) => obj is LocalVariableElement, Loca
lVariableElement, elements[i]); | 3135 EngineTestCase.assertInstanceOf((obj) => obj is LocalVariableElement, Loca
lVariableElement, elements[i]); |
| 3137 } | 3136 } |
| 3138 } | 3137 } |
| 3139 | 3138 |
| 3140 void test_fromElements_nonConflicting() { | 3139 void test_fromElements_nonConflicting() { |
| 3141 Element element = ElementFactory.localVariableElement2("xx"); | 3140 Element element = ElementFactory.localVariableElement2("xx"); |
| 3142 JUnitTestCase.assertSame(element, MultiplyDefinedElementImpl.fromElements(nu
ll, element, element)); | 3141 expect(MultiplyDefinedElementImpl.fromElements(null, element, element), same
(element)); |
| 3143 } | 3142 } |
| 3144 } | 3143 } |
| 3145 | 3144 |
| 3146 class TypeParameterTypeImplTest extends EngineTestCase { | 3145 class TypeParameterTypeImplTest extends EngineTestCase { |
| 3147 void test_creation() { | 3146 void test_creation() { |
| 3148 JUnitTestCase.assertNotNull(new TypeParameterTypeImpl(new TypeParameterEleme
ntImpl.forNode(AstFactory.identifier3("E")))); | 3147 expect(new TypeParameterTypeImpl(new TypeParameterElementImpl.forNode(AstFac
tory.identifier3("E"))), isNotNull); |
| 3149 } | 3148 } |
| 3150 | 3149 |
| 3151 void test_getElement() { | 3150 void test_getElement() { |
| 3152 TypeParameterElementImpl element = new TypeParameterElementImpl.forNode(AstF
actory.identifier3("E")); | 3151 TypeParameterElementImpl element = new TypeParameterElementImpl.forNode(AstF
actory.identifier3("E")); |
| 3153 TypeParameterTypeImpl type = new TypeParameterTypeImpl(element); | 3152 TypeParameterTypeImpl type = new TypeParameterTypeImpl(element); |
| 3154 JUnitTestCase.assertEquals(element, type.element); | 3153 expect(type.element, element); |
| 3155 } | 3154 } |
| 3156 | 3155 |
| 3157 void test_isMoreSpecificThan_typeArguments_dynamic() { | 3156 void test_isMoreSpecificThan_typeArguments_dynamic() { |
| 3158 TypeParameterElementImpl element = new TypeParameterElementImpl.forNode(AstF
actory.identifier3("E")); | 3157 TypeParameterElementImpl element = new TypeParameterElementImpl.forNode(AstF
actory.identifier3("E")); |
| 3159 TypeParameterTypeImpl type = new TypeParameterTypeImpl(element); | 3158 TypeParameterTypeImpl type = new TypeParameterTypeImpl(element); |
| 3160 // E << dynamic | 3159 // E << dynamic |
| 3161 JUnitTestCase.assertTrue(type.isMoreSpecificThan(DynamicTypeImpl.instance)); | 3160 expect(type.isMoreSpecificThan(DynamicTypeImpl.instance), isTrue); |
| 3162 } | 3161 } |
| 3163 | 3162 |
| 3164 void test_isMoreSpecificThan_typeArguments_object() { | 3163 void test_isMoreSpecificThan_typeArguments_object() { |
| 3165 TypeParameterElementImpl element = new TypeParameterElementImpl.forNode(AstF
actory.identifier3("E")); | 3164 TypeParameterElementImpl element = new TypeParameterElementImpl.forNode(AstF
actory.identifier3("E")); |
| 3166 TypeParameterTypeImpl type = new TypeParameterTypeImpl(element); | 3165 TypeParameterTypeImpl type = new TypeParameterTypeImpl(element); |
| 3167 // E << Object | 3166 // E << Object |
| 3168 JUnitTestCase.assertTrue(type.isMoreSpecificThan(ElementFactory.object.type)
); | 3167 expect(type.isMoreSpecificThan(ElementFactory.object.type), isTrue); |
| 3169 } | 3168 } |
| 3170 | 3169 |
| 3171 void test_isMoreSpecificThan_typeArguments_resursive() { | 3170 void test_isMoreSpecificThan_typeArguments_resursive() { |
| 3172 ClassElementImpl classS = ElementFactory.classElement2("A", []); | 3171 ClassElementImpl classS = ElementFactory.classElement2("A", []); |
| 3173 TypeParameterElementImpl typeParameterU = new TypeParameterElementImpl.forNo
de(AstFactory.identifier3("U")); | 3172 TypeParameterElementImpl typeParameterU = new TypeParameterElementImpl.forNo
de(AstFactory.identifier3("U")); |
| 3174 TypeParameterTypeImpl typeParameterTypeU = new TypeParameterTypeImpl(typePar
ameterU); | 3173 TypeParameterTypeImpl typeParameterTypeU = new TypeParameterTypeImpl(typePar
ameterU); |
| 3175 TypeParameterElementImpl typeParameterT = new TypeParameterElementImpl.forNo
de(AstFactory.identifier3("T")); | 3174 TypeParameterElementImpl typeParameterT = new TypeParameterElementImpl.forNo
de(AstFactory.identifier3("T")); |
| 3176 TypeParameterTypeImpl typeParameterTypeT = new TypeParameterTypeImpl(typePar
ameterT); | 3175 TypeParameterTypeImpl typeParameterTypeT = new TypeParameterTypeImpl(typePar
ameterT); |
| 3177 typeParameterT.bound = typeParameterTypeU; | 3176 typeParameterT.bound = typeParameterTypeU; |
| 3178 typeParameterU.bound = typeParameterTypeU; | 3177 typeParameterU.bound = typeParameterTypeU; |
| 3179 // <T extends U> and <U extends T> | 3178 // <T extends U> and <U extends T> |
| 3180 // T << S | 3179 // T << S |
| 3181 JUnitTestCase.assertFalse(typeParameterTypeT.isMoreSpecificThan(classS.type)
); | 3180 expect(typeParameterTypeT.isMoreSpecificThan(classS.type), isFalse); |
| 3182 } | 3181 } |
| 3183 | 3182 |
| 3184 void test_isMoreSpecificThan_typeArguments_self() { | 3183 void test_isMoreSpecificThan_typeArguments_self() { |
| 3185 TypeParameterElementImpl element = new TypeParameterElementImpl.forNode(AstF
actory.identifier3("E")); | 3184 TypeParameterElementImpl element = new TypeParameterElementImpl.forNode(AstF
actory.identifier3("E")); |
| 3186 TypeParameterTypeImpl type = new TypeParameterTypeImpl(element); | 3185 TypeParameterTypeImpl type = new TypeParameterTypeImpl(element); |
| 3187 // E << E | 3186 // E << E |
| 3188 JUnitTestCase.assertTrue(type.isMoreSpecificThan(type)); | 3187 expect(type.isMoreSpecificThan(type), isTrue); |
| 3189 } | 3188 } |
| 3190 | 3189 |
| 3191 void test_isMoreSpecificThan_typeArguments_transitivity_interfaceTypes() { | 3190 void test_isMoreSpecificThan_typeArguments_transitivity_interfaceTypes() { |
| 3192 // class A {} | 3191 // class A {} |
| 3193 // class B extends A {} | 3192 // class B extends A {} |
| 3194 // | 3193 // |
| 3195 ClassElement classA = ElementFactory.classElement2("A", []); | 3194 ClassElement classA = ElementFactory.classElement2("A", []); |
| 3196 ClassElement classB = ElementFactory.classElement("B", classA.type, []); | 3195 ClassElement classB = ElementFactory.classElement("B", classA.type, []); |
| 3197 InterfaceType typeA = classA.type; | 3196 InterfaceType typeA = classA.type; |
| 3198 InterfaceType typeB = classB.type; | 3197 InterfaceType typeB = classB.type; |
| 3199 TypeParameterElementImpl typeParameterT = new TypeParameterElementImpl.forNo
de(AstFactory.identifier3("T")); | 3198 TypeParameterElementImpl typeParameterT = new TypeParameterElementImpl.forNo
de(AstFactory.identifier3("T")); |
| 3200 typeParameterT.bound = typeB; | 3199 typeParameterT.bound = typeB; |
| 3201 TypeParameterTypeImpl typeParameterTypeT = new TypeParameterTypeImpl(typePar
ameterT); | 3200 TypeParameterTypeImpl typeParameterTypeT = new TypeParameterTypeImpl(typePar
ameterT); |
| 3202 // <T extends B> | 3201 // <T extends B> |
| 3203 // T << A | 3202 // T << A |
| 3204 JUnitTestCase.assertTrue(typeParameterTypeT.isMoreSpecificThan(typeA)); | 3203 expect(typeParameterTypeT.isMoreSpecificThan(typeA), isTrue); |
| 3205 } | 3204 } |
| 3206 | 3205 |
| 3207 void test_isMoreSpecificThan_typeArguments_transitivity_typeParameters() { | 3206 void test_isMoreSpecificThan_typeArguments_transitivity_typeParameters() { |
| 3208 ClassElementImpl classS = ElementFactory.classElement2("A", []); | 3207 ClassElementImpl classS = ElementFactory.classElement2("A", []); |
| 3209 TypeParameterElementImpl typeParameterU = new TypeParameterElementImpl.forNo
de(AstFactory.identifier3("U")); | 3208 TypeParameterElementImpl typeParameterU = new TypeParameterElementImpl.forNo
de(AstFactory.identifier3("U")); |
| 3210 typeParameterU.bound = classS.type; | 3209 typeParameterU.bound = classS.type; |
| 3211 TypeParameterTypeImpl typeParameterTypeU = new TypeParameterTypeImpl(typePar
ameterU); | 3210 TypeParameterTypeImpl typeParameterTypeU = new TypeParameterTypeImpl(typePar
ameterU); |
| 3212 TypeParameterElementImpl typeParameterT = new TypeParameterElementImpl.forNo
de(AstFactory.identifier3("T")); | 3211 TypeParameterElementImpl typeParameterT = new TypeParameterElementImpl.forNo
de(AstFactory.identifier3("T")); |
| 3213 typeParameterT.bound = typeParameterTypeU; | 3212 typeParameterT.bound = typeParameterTypeU; |
| 3214 TypeParameterTypeImpl typeParameterTypeT = new TypeParameterTypeImpl(typePar
ameterT); | 3213 TypeParameterTypeImpl typeParameterTypeT = new TypeParameterTypeImpl(typePar
ameterT); |
| 3215 // <T extends U> and <U extends S> | 3214 // <T extends U> and <U extends S> |
| 3216 // T << S | 3215 // T << S |
| 3217 JUnitTestCase.assertTrue(typeParameterTypeT.isMoreSpecificThan(classS.type))
; | 3216 expect(typeParameterTypeT.isMoreSpecificThan(classS.type), isTrue); |
| 3218 } | 3217 } |
| 3219 | 3218 |
| 3220 void test_isMoreSpecificThan_typeArguments_upperBound() { | 3219 void test_isMoreSpecificThan_typeArguments_upperBound() { |
| 3221 ClassElementImpl classS = ElementFactory.classElement2("A", []); | 3220 ClassElementImpl classS = ElementFactory.classElement2("A", []); |
| 3222 TypeParameterElementImpl typeParameterT = new TypeParameterElementImpl.forNo
de(AstFactory.identifier3("T")); | 3221 TypeParameterElementImpl typeParameterT = new TypeParameterElementImpl.forNo
de(AstFactory.identifier3("T")); |
| 3223 typeParameterT.bound = classS.type; | 3222 typeParameterT.bound = classS.type; |
| 3224 TypeParameterTypeImpl typeParameterTypeT = new TypeParameterTypeImpl(typePar
ameterT); | 3223 TypeParameterTypeImpl typeParameterTypeT = new TypeParameterTypeImpl(typePar
ameterT); |
| 3225 // <T extends S> | 3224 // <T extends S> |
| 3226 // T << S | 3225 // T << S |
| 3227 JUnitTestCase.assertTrue(typeParameterTypeT.isMoreSpecificThan(classS.type))
; | 3226 expect(typeParameterTypeT.isMoreSpecificThan(classS.type), isTrue); |
| 3228 } | 3227 } |
| 3229 | 3228 |
| 3230 void test_substitute_equal() { | 3229 void test_substitute_equal() { |
| 3231 TypeParameterElementImpl element = new TypeParameterElementImpl.forNode(AstF
actory.identifier3("E")); | 3230 TypeParameterElementImpl element = new TypeParameterElementImpl.forNode(AstF
actory.identifier3("E")); |
| 3232 TypeParameterTypeImpl type = new TypeParameterTypeImpl(element); | 3231 TypeParameterTypeImpl type = new TypeParameterTypeImpl(element); |
| 3233 InterfaceTypeImpl argument = new InterfaceTypeImpl.con1(new ClassElementImpl
.forNode(AstFactory.identifier3("A"))); | 3232 InterfaceTypeImpl argument = new InterfaceTypeImpl.con1(new ClassElementImpl
.forNode(AstFactory.identifier3("A"))); |
| 3234 TypeParameterTypeImpl parameter = new TypeParameterTypeImpl(element); | 3233 TypeParameterTypeImpl parameter = new TypeParameterTypeImpl(element); |
| 3235 JUnitTestCase.assertSame(argument, type.substitute2(<DartType> [argument], <
DartType> [parameter])); | 3234 expect(type.substitute2(<DartType> [argument], <DartType> [parameter]), same
(argument)); |
| 3236 } | 3235 } |
| 3237 | 3236 |
| 3238 void test_substitute_notEqual() { | 3237 void test_substitute_notEqual() { |
| 3239 TypeParameterTypeImpl type = new TypeParameterTypeImpl(new TypeParameterElem
entImpl.forNode(AstFactory.identifier3("E"))); | 3238 TypeParameterTypeImpl type = new TypeParameterTypeImpl(new TypeParameterElem
entImpl.forNode(AstFactory.identifier3("E"))); |
| 3240 InterfaceTypeImpl argument = new InterfaceTypeImpl.con1(new ClassElementImpl
.forNode(AstFactory.identifier3("A"))); | 3239 InterfaceTypeImpl argument = new InterfaceTypeImpl.con1(new ClassElementImpl
.forNode(AstFactory.identifier3("A"))); |
| 3241 TypeParameterTypeImpl parameter = new TypeParameterTypeImpl(new TypeParamete
rElementImpl.forNode(AstFactory.identifier3("F"))); | 3240 TypeParameterTypeImpl parameter = new TypeParameterTypeImpl(new TypeParamete
rElementImpl.forNode(AstFactory.identifier3("F"))); |
| 3242 JUnitTestCase.assertSame(type, type.substitute2(<DartType> [argument], <Dart
Type> [parameter])); | 3241 expect(type.substitute2(<DartType> [argument], <DartType> [parameter]), same
(type)); |
| 3243 } | 3242 } |
| 3244 } | 3243 } |
| 3245 | 3244 |
| 3246 class UnionTypeImplTest extends EngineTestCase { | 3245 class UnionTypeImplTest extends EngineTestCase { |
| 3247 ClassElement _classA; | 3246 ClassElement _classA; |
| 3248 | 3247 |
| 3249 InterfaceType _typeA; | 3248 InterfaceType _typeA; |
| 3250 | 3249 |
| 3251 ClassElement _classB; | 3250 ClassElement _classB; |
| 3252 | 3251 |
| 3253 InterfaceType _typeB; | 3252 InterfaceType _typeB; |
| 3254 | 3253 |
| 3255 DartType _uA; | 3254 DartType _uA; |
| 3256 | 3255 |
| 3257 DartType _uB; | 3256 DartType _uB; |
| 3258 | 3257 |
| 3259 DartType _uAB; | 3258 DartType _uAB; |
| 3260 | 3259 |
| 3261 DartType _uBA; | 3260 DartType _uBA; |
| 3262 | 3261 |
| 3263 List<DartType> _us; | 3262 List<DartType> _us; |
| 3264 | 3263 |
| 3265 void test_emptyUnionsNotAllowed() { | 3264 void test_emptyUnionsNotAllowed() { |
| 3266 try { | 3265 try { |
| 3267 UnionTypeImpl.union([]); | 3266 UnionTypeImpl.union([]); |
| 3268 } on IllegalArgumentException catch (e) { | 3267 } on IllegalArgumentException catch (e) { |
| 3269 return; | 3268 return; |
| 3270 } | 3269 } |
| 3271 JUnitTestCase.fail("Expected illegal argument exception."); | 3270 fail("Expected illegal argument exception."); |
| 3272 } | 3271 } |
| 3273 | 3272 |
| 3274 void test_equality_beingASubtypeOfAnElementIsNotSufficient() { | 3273 void test_equality_beingASubtypeOfAnElementIsNotSufficient() { |
| 3275 // Non-equal if some elements are different | 3274 // Non-equal if some elements are different |
| 3276 JUnitTestCase.assertFalse(_uAB == _uA); | 3275 expect(_uAB == _uA, isFalse); |
| 3277 } | 3276 } |
| 3278 | 3277 |
| 3279 void test_equality_insertionOrderDoesntMatter() { | 3278 void test_equality_insertionOrderDoesntMatter() { |
| 3280 // Insertion order doesn't matter, only sets of elements | 3279 // Insertion order doesn't matter, only sets of elements |
| 3281 JUnitTestCase.assertTrue(_uAB == _uBA); | 3280 expect(_uAB == _uBA, isTrue); |
| 3282 JUnitTestCase.assertTrue(_uBA == _uAB); | 3281 expect(_uBA == _uAB, isTrue); |
| 3283 } | 3282 } |
| 3284 | 3283 |
| 3285 void test_equality_reflexivity() { | 3284 void test_equality_reflexivity() { |
| 3286 for (DartType u in _us) { | 3285 for (DartType u in _us) { |
| 3287 JUnitTestCase.assertTrue(u == u); | 3286 expect(u == u, isTrue); |
| 3288 } | 3287 } |
| 3289 } | 3288 } |
| 3290 | 3289 |
| 3291 void test_equality_singletonsCollapse() { | 3290 void test_equality_singletonsCollapse() { |
| 3292 JUnitTestCase.assertTrue(_typeA == _uA); | 3291 expect(_typeA == _uA, isTrue); |
| 3293 JUnitTestCase.assertTrue(_uA == _typeA); | 3292 expect(_uA == _typeA, isTrue); |
| 3294 } | 3293 } |
| 3295 | 3294 |
| 3296 void test_isMoreSpecificThan_allElementsOnLHSAreSubtypesOfSomeElementOnRHS() { | 3295 void test_isMoreSpecificThan_allElementsOnLHSAreSubtypesOfSomeElementOnRHS() { |
| 3297 // Unions are subtypes when all elements are subtypes | 3296 // Unions are subtypes when all elements are subtypes |
| 3298 JUnitTestCase.assertTrue(_uAB.isMoreSpecificThan(_uA)); | 3297 expect(_uAB.isMoreSpecificThan(_uA), isTrue); |
| 3299 JUnitTestCase.assertTrue(_uAB.isMoreSpecificThan(_typeA)); | 3298 expect(_uAB.isMoreSpecificThan(_typeA), isTrue); |
| 3300 } | 3299 } |
| 3301 | 3300 |
| 3302 void test_isMoreSpecificThan_element() { | 3301 void test_isMoreSpecificThan_element() { |
| 3303 // Elements of union are sub types | 3302 // Elements of union are sub types |
| 3304 JUnitTestCase.assertTrue(_typeA.isMoreSpecificThan(_uAB)); | 3303 expect(_typeA.isMoreSpecificThan(_uAB), isTrue); |
| 3305 JUnitTestCase.assertTrue(_typeB.isMoreSpecificThan(_uAB)); | 3304 expect(_typeB.isMoreSpecificThan(_uAB), isTrue); |
| 3306 } | 3305 } |
| 3307 | 3306 |
| 3308 void test_isMoreSpecificThan_notSubtypeOfAnyElement() { | 3307 void test_isMoreSpecificThan_notSubtypeOfAnyElement() { |
| 3309 // Types that are not subtypes of elements are not subtypes | 3308 // Types that are not subtypes of elements are not subtypes |
| 3310 JUnitTestCase.assertFalse(_typeA.isMoreSpecificThan(_uB)); | 3309 expect(_typeA.isMoreSpecificThan(_uB), isFalse); |
| 3311 } | 3310 } |
| 3312 | 3311 |
| 3313 void test_isMoreSpecificThan_reflexivity() { | 3312 void test_isMoreSpecificThan_reflexivity() { |
| 3314 for (DartType u in _us) { | 3313 for (DartType u in _us) { |
| 3315 JUnitTestCase.assertTrue(u.isMoreSpecificThan(u)); | 3314 expect(u.isMoreSpecificThan(u), isTrue); |
| 3316 } | 3315 } |
| 3317 } | 3316 } |
| 3318 | 3317 |
| 3319 void test_isMoreSpecificThan_someElementOnLHSIsNotASubtypeOfAnyElementOnRHS()
{ | 3318 void test_isMoreSpecificThan_someElementOnLHSIsNotASubtypeOfAnyElementOnRHS()
{ |
| 3320 // Unions are subtypes when some element is a subtype | 3319 // Unions are subtypes when some element is a subtype |
| 3321 JUnitTestCase.assertTrue(_uAB.isMoreSpecificThan(_uB)); | 3320 expect(_uAB.isMoreSpecificThan(_uB), isTrue); |
| 3322 JUnitTestCase.assertTrue(_uAB.isMoreSpecificThan(_typeB)); | 3321 expect(_uAB.isMoreSpecificThan(_typeB), isTrue); |
| 3323 } | 3322 } |
| 3324 | 3323 |
| 3325 void test_isMoreSpecificThan_subtypeOfSomeElement() { | 3324 void test_isMoreSpecificThan_subtypeOfSomeElement() { |
| 3326 // Subtypes of elements are sub types | 3325 // Subtypes of elements are sub types |
| 3327 JUnitTestCase.assertTrue(_typeB.isMoreSpecificThan(_uA)); | 3326 expect(_typeB.isMoreSpecificThan(_uA), isTrue); |
| 3328 } | 3327 } |
| 3329 | 3328 |
| 3330 void test_isSubtypeOf_allElementsOnLHSAreSubtypesOfSomeElementOnRHS() { | 3329 void test_isSubtypeOf_allElementsOnLHSAreSubtypesOfSomeElementOnRHS() { |
| 3331 // Unions are subtypes when all elements are subtypes | 3330 // Unions are subtypes when all elements are subtypes |
| 3332 JUnitTestCase.assertTrue(_uAB.isSubtypeOf(_uA)); | 3331 expect(_uAB.isSubtypeOf(_uA), isTrue); |
| 3333 JUnitTestCase.assertTrue(_uAB.isSubtypeOf(_typeA)); | 3332 expect(_uAB.isSubtypeOf(_typeA), isTrue); |
| 3334 } | 3333 } |
| 3335 | 3334 |
| 3336 void test_isSubtypeOf_element() { | 3335 void test_isSubtypeOf_element() { |
| 3337 // Elements of union are sub types | 3336 // Elements of union are sub types |
| 3338 JUnitTestCase.assertTrue(_typeA.isSubtypeOf(_uAB)); | 3337 expect(_typeA.isSubtypeOf(_uAB), isTrue); |
| 3339 JUnitTestCase.assertTrue(_typeB.isSubtypeOf(_uAB)); | 3338 expect(_typeB.isSubtypeOf(_uAB), isTrue); |
| 3340 } | 3339 } |
| 3341 | 3340 |
| 3342 void test_isSubtypeOf_notSubtypeOfAnyElement() { | 3341 void test_isSubtypeOf_notSubtypeOfAnyElement() { |
| 3343 // Types that are not subtypes of elements are not subtypes | 3342 // Types that are not subtypes of elements are not subtypes |
| 3344 JUnitTestCase.assertFalse(_typeA.isSubtypeOf(_uB)); | 3343 expect(_typeA.isSubtypeOf(_uB), isFalse); |
| 3345 } | 3344 } |
| 3346 | 3345 |
| 3347 void test_isSubtypeOf_reflexivity() { | 3346 void test_isSubtypeOf_reflexivity() { |
| 3348 for (DartType u in _us) { | 3347 for (DartType u in _us) { |
| 3349 JUnitTestCase.assertTrue(u.isSubtypeOf(u)); | 3348 expect(u.isSubtypeOf(u), isTrue); |
| 3350 } | 3349 } |
| 3351 } | 3350 } |
| 3352 | 3351 |
| 3353 void test_isSubtypeOf_someElementOnLHSIsNotASubtypeOfAnyElementOnRHS() { | 3352 void test_isSubtypeOf_someElementOnLHSIsNotASubtypeOfAnyElementOnRHS() { |
| 3354 // Unions are subtypes when some element is a subtype | 3353 // Unions are subtypes when some element is a subtype |
| 3355 JUnitTestCase.assertTrue(_uAB.isSubtypeOf(_uB)); | 3354 expect(_uAB.isSubtypeOf(_uB), isTrue); |
| 3356 JUnitTestCase.assertTrue(_uAB.isSubtypeOf(_typeB)); | 3355 expect(_uAB.isSubtypeOf(_typeB), isTrue); |
| 3357 } | 3356 } |
| 3358 | 3357 |
| 3359 void test_isSubtypeOf_subtypeOfSomeElement() { | 3358 void test_isSubtypeOf_subtypeOfSomeElement() { |
| 3360 // Subtypes of elements are sub types | 3359 // Subtypes of elements are sub types |
| 3361 JUnitTestCase.assertTrue(_typeB.isSubtypeOf(_uA)); | 3360 expect(_typeB.isSubtypeOf(_uA), isTrue); |
| 3362 } | 3361 } |
| 3363 | 3362 |
| 3364 void test_nestedUnionsCollapse() { | 3363 void test_nestedUnionsCollapse() { |
| 3365 UnionType u = UnionTypeImpl.union([_uAB, _typeA]) as UnionType; | 3364 UnionType u = UnionTypeImpl.union([_uAB, _typeA]) as UnionType; |
| 3366 for (DartType t in u.elements) { | 3365 for (DartType t in u.elements) { |
| 3367 if (t is UnionType) { | 3366 if (t is UnionType) { |
| 3368 JUnitTestCase.fail("Expected only non-union types but found $t!"); | 3367 fail("Expected only non-union types but found $t!"); |
| 3369 } | 3368 } |
| 3370 } | 3369 } |
| 3371 } | 3370 } |
| 3372 | 3371 |
| 3373 void test_noLossage() { | 3372 void test_noLossage() { |
| 3374 UnionType u = UnionTypeImpl.union([_typeA, _typeB, _typeB, _typeA, _typeB, _
typeB]) as UnionType; | 3373 UnionType u = UnionTypeImpl.union([_typeA, _typeB, _typeB, _typeA, _typeB, _
typeB]) as UnionType; |
| 3375 Set<DartType> elements = u.elements; | 3374 Set<DartType> elements = u.elements; |
| 3376 JUnitTestCase.assertTrue(elements.contains(_typeA)); | 3375 expect(elements.contains(_typeA), isTrue); |
| 3377 JUnitTestCase.assertTrue(elements.contains(_typeB)); | 3376 expect(elements.contains(_typeB), isTrue); |
| 3378 JUnitTestCase.assertTrue(elements.length == 2); | 3377 expect(elements.length == 2, isTrue); |
| 3379 } | 3378 } |
| 3380 | 3379 |
| 3381 void test_substitute() { | 3380 void test_substitute() { |
| 3382 // Based on [InterfaceTypeImplTest.test_substitute_equal]. | 3381 // Based on [InterfaceTypeImplTest.test_substitute_equal]. |
| 3383 ClassElement classAE = ElementFactory.classElement2("A", ["E"]); | 3382 ClassElement classAE = ElementFactory.classElement2("A", ["E"]); |
| 3384 InterfaceType typeAE = classAE.type; | 3383 InterfaceType typeAE = classAE.type; |
| 3385 List<DartType> args = [_typeB]; | 3384 List<DartType> args = [_typeB]; |
| 3386 List<DartType> params = [classAE.typeParameters[0].type]; | 3385 List<DartType> params = [classAE.typeParameters[0].type]; |
| 3387 DartType typeAESubbed = typeAE.substitute2(args, params); | 3386 DartType typeAESubbed = typeAE.substitute2(args, params); |
| 3388 JUnitTestCase.assertFalse(typeAE == typeAESubbed); | 3387 expect(typeAE == typeAESubbed, isFalse); |
| 3389 JUnitTestCase.assertEquals(UnionTypeImpl.union([_typeA, typeAE]).substitute2
(args, params), UnionTypeImpl.union([_typeA, typeAESubbed])); | 3388 expect(UnionTypeImpl.union([_typeA, typeAESubbed]), UnionTypeImpl.union([_ty
peA, typeAE]).substitute2(args, params)); |
| 3390 } | 3389 } |
| 3391 | 3390 |
| 3392 void test_toString_pair() { | 3391 void test_toString_pair() { |
| 3393 String s = _uAB.toString(); | 3392 String s = _uAB.toString(); |
| 3394 JUnitTestCase.assertTrue(s == "{A,B}" || s == "{B,A}"); | 3393 expect(s == "{A,B}" || s == "{B,A}", isTrue); |
| 3395 JUnitTestCase.assertEquals(s, _uAB.displayName); | 3394 expect(_uAB.displayName, s); |
| 3396 } | 3395 } |
| 3397 | 3396 |
| 3398 void test_toString_singleton() { | 3397 void test_toString_singleton() { |
| 3399 // Singleton unions collapse to the the single type. | 3398 // Singleton unions collapse to the the single type. |
| 3400 JUnitTestCase.assertEquals("A", _uA.toString()); | 3399 expect(_uA.toString(), "A"); |
| 3401 } | 3400 } |
| 3402 | 3401 |
| 3403 void test_unionTypeIsLessSpecificThan_function() { | 3402 void test_unionTypeIsLessSpecificThan_function() { |
| 3404 // Based on [FunctionTypeImplTest.test_isAssignableTo_normalAndPositionalArg
s]. | 3403 // Based on [FunctionTypeImplTest.test_isAssignableTo_normalAndPositionalArg
s]. |
| 3405 ClassElement a = ElementFactory.classElement2("A", []); | 3404 ClassElement a = ElementFactory.classElement2("A", []); |
| 3406 FunctionType t = ElementFactory.functionElement6("t", null, <ClassElement> [
a]).type; | 3405 FunctionType t = ElementFactory.functionElement6("t", null, <ClassElement> [
a]).type; |
| 3407 DartType uAT = UnionTypeImpl.union([_uA, t]); | 3406 DartType uAT = UnionTypeImpl.union([_uA, t]); |
| 3408 JUnitTestCase.assertTrue(t.isMoreSpecificThan(uAT)); | 3407 expect(t.isMoreSpecificThan(uAT), isTrue); |
| 3409 JUnitTestCase.assertFalse(t.isMoreSpecificThan(_uAB)); | 3408 expect(t.isMoreSpecificThan(_uAB), isFalse); |
| 3410 } | 3409 } |
| 3411 | 3410 |
| 3412 void test_unionTypeIsSuperTypeOf_function() { | 3411 void test_unionTypeIsSuperTypeOf_function() { |
| 3413 // Based on [FunctionTypeImplTest.test_isAssignableTo_normalAndPositionalArg
s]. | 3412 // Based on [FunctionTypeImplTest.test_isAssignableTo_normalAndPositionalArg
s]. |
| 3414 ClassElement a = ElementFactory.classElement2("A", []); | 3413 ClassElement a = ElementFactory.classElement2("A", []); |
| 3415 FunctionType t = ElementFactory.functionElement6("t", null, <ClassElement> [
a]).type; | 3414 FunctionType t = ElementFactory.functionElement6("t", null, <ClassElement> [
a]).type; |
| 3416 DartType uAT = UnionTypeImpl.union([_uA, t]); | 3415 DartType uAT = UnionTypeImpl.union([_uA, t]); |
| 3417 JUnitTestCase.assertTrue(t.isSubtypeOf(uAT)); | 3416 expect(t.isSubtypeOf(uAT), isTrue); |
| 3418 JUnitTestCase.assertFalse(t.isSubtypeOf(_uAB)); | 3417 expect(t.isSubtypeOf(_uAB), isFalse); |
| 3419 } | 3418 } |
| 3420 | 3419 |
| 3421 @override | 3420 @override |
| 3422 void setUp() { | 3421 void setUp() { |
| 3423 super.setUp(); | 3422 super.setUp(); |
| 3424 _classA = ElementFactory.classElement2("A", []); | 3423 _classA = ElementFactory.classElement2("A", []); |
| 3425 _typeA = _classA.type; | 3424 _typeA = _classA.type; |
| 3426 _classB = ElementFactory.classElement("B", _typeA, []); | 3425 _classB = ElementFactory.classElement("B", _typeA, []); |
| 3427 _typeB = _classB.type; | 3426 _typeB = _classB.type; |
| 3428 _uA = UnionTypeImpl.union([_typeA]); | 3427 _uA = UnionTypeImpl.union([_typeA]); |
| 3429 _uB = UnionTypeImpl.union([_typeB]); | 3428 _uB = UnionTypeImpl.union([_typeB]); |
| 3430 _uAB = UnionTypeImpl.union([_typeA, _typeB]); | 3429 _uAB = UnionTypeImpl.union([_typeA, _typeB]); |
| 3431 _uBA = UnionTypeImpl.union([_typeB, _typeA]); | 3430 _uBA = UnionTypeImpl.union([_typeB, _typeA]); |
| 3432 _us = <DartType> [_uA, _uB, _uAB, _uBA]; | 3431 _us = <DartType> [_uA, _uB, _uAB, _uBA]; |
| 3433 } | 3432 } |
| 3434 } | 3433 } |
| 3435 | 3434 |
| 3436 class VoidTypeImplTest extends EngineTestCase { | 3435 class VoidTypeImplTest extends EngineTestCase { |
| 3437 /** | 3436 /** |
| 3438 * Reference {code VoidTypeImpl.getInstance()}. | 3437 * Reference {code VoidTypeImpl.getInstance()}. |
| 3439 */ | 3438 */ |
| 3440 DartType _voidType = VoidTypeImpl.instance; | 3439 DartType _voidType = VoidTypeImpl.instance; |
| 3441 | 3440 |
| 3442 void test_isMoreSpecificThan_void_A() { | 3441 void test_isMoreSpecificThan_void_A() { |
| 3443 ClassElement classA = ElementFactory.classElement2("A", []); | 3442 ClassElement classA = ElementFactory.classElement2("A", []); |
| 3444 JUnitTestCase.assertFalse(_voidType.isMoreSpecificThan(classA.type)); | 3443 expect(_voidType.isMoreSpecificThan(classA.type), isFalse); |
| 3445 } | 3444 } |
| 3446 | 3445 |
| 3447 void test_isMoreSpecificThan_void_dynamic() { | 3446 void test_isMoreSpecificThan_void_dynamic() { |
| 3448 JUnitTestCase.assertTrue(_voidType.isMoreSpecificThan(DynamicTypeImpl.instan
ce)); | 3447 expect(_voidType.isMoreSpecificThan(DynamicTypeImpl.instance), isTrue); |
| 3449 } | 3448 } |
| 3450 | 3449 |
| 3451 void test_isMoreSpecificThan_void_void() { | 3450 void test_isMoreSpecificThan_void_void() { |
| 3452 JUnitTestCase.assertTrue(_voidType.isMoreSpecificThan(_voidType)); | 3451 expect(_voidType.isMoreSpecificThan(_voidType), isTrue); |
| 3453 } | 3452 } |
| 3454 | 3453 |
| 3455 void test_isSubtypeOf_void_A() { | 3454 void test_isSubtypeOf_void_A() { |
| 3456 ClassElement classA = ElementFactory.classElement2("A", []); | 3455 ClassElement classA = ElementFactory.classElement2("A", []); |
| 3457 JUnitTestCase.assertFalse(_voidType.isSubtypeOf(classA.type)); | 3456 expect(_voidType.isSubtypeOf(classA.type), isFalse); |
| 3458 } | 3457 } |
| 3459 | 3458 |
| 3460 void test_isSubtypeOf_void_dynamic() { | 3459 void test_isSubtypeOf_void_dynamic() { |
| 3461 JUnitTestCase.assertTrue(_voidType.isSubtypeOf(DynamicTypeImpl.instance)); | 3460 expect(_voidType.isSubtypeOf(DynamicTypeImpl.instance), isTrue); |
| 3462 } | 3461 } |
| 3463 | 3462 |
| 3464 void test_isSubtypeOf_void_void() { | 3463 void test_isSubtypeOf_void_void() { |
| 3465 JUnitTestCase.assertTrue(_voidType.isSubtypeOf(_voidType)); | 3464 expect(_voidType.isSubtypeOf(_voidType), isTrue); |
| 3466 } | 3465 } |
| 3467 | 3466 |
| 3468 void test_isVoid() { | 3467 void test_isVoid() { |
| 3469 JUnitTestCase.assertTrue(_voidType.isVoid); | 3468 expect(_voidType.isVoid, isTrue); |
| 3470 } | 3469 } |
| 3471 } | 3470 } |
| 3472 | 3471 |
| 3473 main() { | 3472 main() { |
| 3474 _ut.groupSep = ' | '; | 3473 groupSep = ' | '; |
| 3475 runReflectiveTests(AngularPropertyKindTest); | 3474 runReflectiveTests(AngularPropertyKindTest); |
| 3476 runReflectiveTests(ElementKindTest); | 3475 runReflectiveTests(ElementKindTest); |
| 3477 runReflectiveTests(FunctionTypeImplTest); | 3476 runReflectiveTests(FunctionTypeImplTest); |
| 3478 runReflectiveTests(InterfaceTypeImplTest); | 3477 runReflectiveTests(InterfaceTypeImplTest); |
| 3479 runReflectiveTests(TypeParameterTypeImplTest); | 3478 runReflectiveTests(TypeParameterTypeImplTest); |
| 3480 runReflectiveTests(UnionTypeImplTest); | 3479 runReflectiveTests(UnionTypeImplTest); |
| 3481 runReflectiveTests(VoidTypeImplTest); | 3480 runReflectiveTests(VoidTypeImplTest); |
| 3482 runReflectiveTests(ClassElementImplTest); | 3481 runReflectiveTests(ClassElementImplTest); |
| 3483 runReflectiveTests(CompilationUnitElementImplTest); | 3482 runReflectiveTests(CompilationUnitElementImplTest); |
| 3484 runReflectiveTests(ElementLocationImplTest); | 3483 runReflectiveTests(ElementLocationImplTest); |
| 3485 runReflectiveTests(ElementImplTest); | 3484 runReflectiveTests(ElementImplTest); |
| 3486 runReflectiveTests(HtmlElementImplTest); | 3485 runReflectiveTests(HtmlElementImplTest); |
| 3487 runReflectiveTests(LibraryElementImplTest); | 3486 runReflectiveTests(LibraryElementImplTest); |
| 3488 runReflectiveTests(MultiplyDefinedElementImplTest); | 3487 runReflectiveTests(MultiplyDefinedElementImplTest); |
| 3489 } | 3488 } |
| OLD | NEW |