| 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'; |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 runJUnitTest(__test, __test.test_hashCode_equal); | 125 runJUnitTest(__test, __test.test_hashCode_equal); |
| 126 }); | 126 }); |
| 127 _ut.test('test_hashCode_equalWithDifferentUriKind', () { | 127 _ut.test('test_hashCode_equalWithDifferentUriKind', () { |
| 128 final __test = new ElementLocationImplTest(); | 128 final __test = new ElementLocationImplTest(); |
| 129 runJUnitTest(__test, __test.test_hashCode_equalWithDifferentUriKind); | 129 runJUnitTest(__test, __test.test_hashCode_equalWithDifferentUriKind); |
| 130 }); | 130 }); |
| 131 }); | 131 }); |
| 132 } | 132 } |
| 133 } | 133 } |
| 134 | 134 |
| 135 class HtmlElementImplTest extends EngineTestCase { |
| 136 void test_equals_differentSource() { |
| 137 AnalysisContextImpl context = createAnalysisContext(); |
| 138 HtmlElementImpl elementA = ElementFactory.htmlUnit(context, "indexA.html"); |
| 139 HtmlElementImpl elementB = ElementFactory.htmlUnit(context, "indexB.html"); |
| 140 JUnitTestCase.assertFalse(elementA == elementB); |
| 141 } |
| 142 |
| 143 void test_equals_null() { |
| 144 AnalysisContextImpl context = createAnalysisContext(); |
| 145 HtmlElementImpl element = ElementFactory.htmlUnit(context, "index.html"); |
| 146 JUnitTestCase.assertFalse(element == null); |
| 147 } |
| 148 |
| 149 void test_equals_sameSource() { |
| 150 AnalysisContextImpl context = createAnalysisContext(); |
| 151 HtmlElementImpl elementA = ElementFactory.htmlUnit(context, "index.html"); |
| 152 HtmlElementImpl elementB = ElementFactory.htmlUnit(context, "index.html"); |
| 153 JUnitTestCase.assertTrue(elementA == elementB); |
| 154 } |
| 155 |
| 156 void test_equals_self() { |
| 157 AnalysisContextImpl context = createAnalysisContext(); |
| 158 HtmlElementImpl element = ElementFactory.htmlUnit(context, "index.html"); |
| 159 JUnitTestCase.assertTrue(element == element); |
| 160 } |
| 161 |
| 162 static dartSuite() { |
| 163 _ut.group('HtmlElementImplTest', () { |
| 164 _ut.test('test_equals_differentSource', () { |
| 165 final __test = new HtmlElementImplTest(); |
| 166 runJUnitTest(__test, __test.test_equals_differentSource); |
| 167 }); |
| 168 _ut.test('test_equals_null', () { |
| 169 final __test = new HtmlElementImplTest(); |
| 170 runJUnitTest(__test, __test.test_equals_null); |
| 171 }); |
| 172 _ut.test('test_equals_sameSource', () { |
| 173 final __test = new HtmlElementImplTest(); |
| 174 runJUnitTest(__test, __test.test_equals_sameSource); |
| 175 }); |
| 176 _ut.test('test_equals_self', () { |
| 177 final __test = new HtmlElementImplTest(); |
| 178 runJUnitTest(__test, __test.test_equals_self); |
| 179 }); |
| 180 }); |
| 181 } |
| 182 } |
| 183 |
| 135 class MultiplyDefinedElementImplTest extends EngineTestCase { | 184 class MultiplyDefinedElementImplTest extends EngineTestCase { |
| 136 void test_fromElements_conflicting() { | 185 void test_fromElements_conflicting() { |
| 137 Element firstElement = ElementFactory.localVariableElement2("xx"); | 186 Element firstElement = ElementFactory.localVariableElement2("xx"); |
| 138 Element secondElement = ElementFactory.localVariableElement2("yy"); | 187 Element secondElement = ElementFactory.localVariableElement2("yy"); |
| 139 Element result = MultiplyDefinedElementImpl.fromElements(null, firstElement,
secondElement); | 188 Element result = MultiplyDefinedElementImpl.fromElements(null, firstElement,
secondElement); |
| 140 EngineTestCase.assertInstanceOf(MultiplyDefinedElement, result); | 189 EngineTestCase.assertInstanceOf(MultiplyDefinedElement, result); |
| 141 List<Element> elements = (result as MultiplyDefinedElement).conflictingEleme
nts; | 190 List<Element> elements = (result as MultiplyDefinedElement).conflictingEleme
nts; |
| 142 EngineTestCase.assertLength(2, elements); | 191 EngineTestCase.assertLength(2, elements); |
| 143 for (int i = 0; i < elements.length; i++) { | 192 for (int i = 0; i < elements.length; i++) { |
| 144 EngineTestCase.assertInstanceOf(LocalVariableElement, elements[i]); | 193 EngineTestCase.assertInstanceOf(LocalVariableElement, elements[i]); |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 List<PrefixElement> prefixes = library.prefixes; | 270 List<PrefixElement> prefixes = library.prefixes; |
| 222 EngineTestCase.assertLength(2, prefixes); | 271 EngineTestCase.assertLength(2, prefixes); |
| 223 if (identical(prefixA, prefixes[0])) { | 272 if (identical(prefixA, prefixes[0])) { |
| 224 JUnitTestCase.assertSame(prefixB, prefixes[1]); | 273 JUnitTestCase.assertSame(prefixB, prefixes[1]); |
| 225 } else { | 274 } else { |
| 226 JUnitTestCase.assertSame(prefixB, prefixes[0]); | 275 JUnitTestCase.assertSame(prefixB, prefixes[0]); |
| 227 JUnitTestCase.assertSame(prefixA, prefixes[1]); | 276 JUnitTestCase.assertSame(prefixA, prefixes[1]); |
| 228 } | 277 } |
| 229 } | 278 } |
| 230 | 279 |
| 280 void test_getUnits() { |
| 281 AnalysisContext context = createAnalysisContext(); |
| 282 LibraryElementImpl library = ElementFactory.library(context, "test"); |
| 283 CompilationUnitElement unitLib = library.definingCompilationUnit; |
| 284 CompilationUnitElementImpl unitA = ElementFactory.compilationUnit(context, "
unit_a.dart"); |
| 285 CompilationUnitElementImpl unitB = ElementFactory.compilationUnit(context, "
unit_b.dart"); |
| 286 library.parts = <CompilationUnitElement> [unitA, unitB]; |
| 287 EngineTestCase.assertEqualsIgnoreOrder(<CompilationUnitElement> [unitLib, un
itA, unitB], library.units); |
| 288 } |
| 289 |
| 231 void test_getVisibleLibraries_cycle() { | 290 void test_getVisibleLibraries_cycle() { |
| 232 AnalysisContext context = createAnalysisContext(); | 291 AnalysisContext context = createAnalysisContext(); |
| 233 LibraryElementImpl library = ElementFactory.library(context, "app"); | 292 LibraryElementImpl library = ElementFactory.library(context, "app"); |
| 234 LibraryElementImpl libraryA = ElementFactory.library(context, "A"); | 293 LibraryElementImpl libraryA = ElementFactory.library(context, "A"); |
| 235 libraryA.imports = <ImportElementImpl> [ElementFactory.importFor(library, nu
ll, [])]; | 294 libraryA.imports = <ImportElementImpl> [ElementFactory.importFor(library, nu
ll, [])]; |
| 236 library.imports = <ImportElementImpl> [ElementFactory.importFor(libraryA, nu
ll, [])]; | 295 library.imports = <ImportElementImpl> [ElementFactory.importFor(libraryA, nu
ll, [])]; |
| 237 List<LibraryElement> libraries = library.visibleLibraries; | 296 List<LibraryElement> libraries = library.visibleLibraries; |
| 238 EngineTestCase.assertEqualsIgnoreOrder(<LibraryElement> [library, libraryA],
libraries); | 297 EngineTestCase.assertEqualsIgnoreOrder(<LibraryElement> [library, libraryA],
libraries); |
| 239 } | 298 } |
| 240 | 299 |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 runJUnitTest(__test, __test.test_creation); | 378 runJUnitTest(__test, __test.test_creation); |
| 320 }); | 379 }); |
| 321 _ut.test('test_getImportedLibraries', () { | 380 _ut.test('test_getImportedLibraries', () { |
| 322 final __test = new LibraryElementImplTest(); | 381 final __test = new LibraryElementImplTest(); |
| 323 runJUnitTest(__test, __test.test_getImportedLibraries); | 382 runJUnitTest(__test, __test.test_getImportedLibraries); |
| 324 }); | 383 }); |
| 325 _ut.test('test_getPrefixes', () { | 384 _ut.test('test_getPrefixes', () { |
| 326 final __test = new LibraryElementImplTest(); | 385 final __test = new LibraryElementImplTest(); |
| 327 runJUnitTest(__test, __test.test_getPrefixes); | 386 runJUnitTest(__test, __test.test_getPrefixes); |
| 328 }); | 387 }); |
| 388 _ut.test('test_getUnits', () { |
| 389 final __test = new LibraryElementImplTest(); |
| 390 runJUnitTest(__test, __test.test_getUnits); |
| 391 }); |
| 329 _ut.test('test_getVisibleLibraries_cycle', () { | 392 _ut.test('test_getVisibleLibraries_cycle', () { |
| 330 final __test = new LibraryElementImplTest(); | 393 final __test = new LibraryElementImplTest(); |
| 331 runJUnitTest(__test, __test.test_getVisibleLibraries_cycle); | 394 runJUnitTest(__test, __test.test_getVisibleLibraries_cycle); |
| 332 }); | 395 }); |
| 333 _ut.test('test_getVisibleLibraries_directExports', () { | 396 _ut.test('test_getVisibleLibraries_directExports', () { |
| 334 final __test = new LibraryElementImplTest(); | 397 final __test = new LibraryElementImplTest(); |
| 335 runJUnitTest(__test, __test.test_getVisibleLibraries_directExports); | 398 runJUnitTest(__test, __test.test_getVisibleLibraries_directExports); |
| 336 }); | 399 }); |
| 337 _ut.test('test_getVisibleLibraries_directImports', () { | 400 _ut.test('test_getVisibleLibraries_directImports', () { |
| 338 final __test = new LibraryElementImplTest(); | 401 final __test = new LibraryElementImplTest(); |
| (...skipping 2077 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2416 typeParameter.type = typeParameterTypes[i]; | 2479 typeParameter.type = typeParameterTypes[i]; |
| 2417 } | 2480 } |
| 2418 element.typeParameters = typeParameters; | 2481 element.typeParameters = typeParameters; |
| 2419 type.typeArguments = typeParameterTypes; | 2482 type.typeArguments = typeParameterTypes; |
| 2420 } | 2483 } |
| 2421 return element; | 2484 return element; |
| 2422 } | 2485 } |
| 2423 | 2486 |
| 2424 static ClassElementImpl classElement2(String typeName, List<String> parameterN
ames) => classElement(typeName, object.type, parameterNames); | 2487 static ClassElementImpl classElement2(String typeName, List<String> parameterN
ames) => classElement(typeName, object.type, parameterNames); |
| 2425 | 2488 |
| 2489 static CompilationUnitElementImpl compilationUnit(AnalysisContext context, Str
ing fileName) { |
| 2490 FileBasedSource source = new FileBasedSource.con1(context.sourceFactory.cont
entCache, FileUtilities2.createFile(fileName)); |
| 2491 CompilationUnitElementImpl unit = new CompilationUnitElementImpl(fileName); |
| 2492 unit.source = source; |
| 2493 return unit; |
| 2494 } |
| 2495 |
| 2426 static ConstructorElementImpl constructorElement(ClassElement definingClass, S
tring name, bool isConst, List<Type2> argumentTypes) { | 2496 static ConstructorElementImpl constructorElement(ClassElement definingClass, S
tring name, bool isConst, List<Type2> argumentTypes) { |
| 2427 Type2 type = definingClass.type; | 2497 Type2 type = definingClass.type; |
| 2428 ConstructorElementImpl constructor = new ConstructorElementImpl(name == null
? null : ASTFactory.identifier3(name)); | 2498 ConstructorElementImpl constructor = new ConstructorElementImpl(name == null
? null : ASTFactory.identifier3(name)); |
| 2429 constructor.const2 = isConst; | 2499 constructor.const2 = isConst; |
| 2430 int count = argumentTypes.length; | 2500 int count = argumentTypes.length; |
| 2431 List<ParameterElement> parameters = new List<ParameterElement>(count); | 2501 List<ParameterElement> parameters = new List<ParameterElement>(count); |
| 2432 for (int i = 0; i < count; i++) { | 2502 for (int i = 0; i < count; i++) { |
| 2433 ParameterElementImpl parameter = new ParameterElementImpl.con1(ASTFactory.
identifier3("a${i}")); | 2503 ParameterElementImpl parameter = new ParameterElementImpl.con1(ASTFactory.
identifier3("a${i}")); |
| 2434 parameter.type = argumentTypes[i]; | 2504 parameter.type = argumentTypes[i]; |
| 2435 parameter.parameterKind = ParameterKind.REQUIRED; | 2505 parameter.parameterKind = ParameterKind.REQUIRED; |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2576 getter.getter = true; | 2646 getter.getter = true; |
| 2577 getter.static = isStatic; | 2647 getter.static = isStatic; |
| 2578 getter.variable = field; | 2648 getter.variable = field; |
| 2579 getter.returnType = type; | 2649 getter.returnType = type; |
| 2580 field.getter = getter; | 2650 field.getter = getter; |
| 2581 FunctionTypeImpl getterType = new FunctionTypeImpl.con1(getter); | 2651 FunctionTypeImpl getterType = new FunctionTypeImpl.con1(getter); |
| 2582 getter.type = getterType; | 2652 getter.type = getterType; |
| 2583 return getter; | 2653 return getter; |
| 2584 } | 2654 } |
| 2585 | 2655 |
| 2656 static HtmlElementImpl htmlUnit(AnalysisContext context, String fileName) { |
| 2657 FileBasedSource source = new FileBasedSource.con1(context.sourceFactory.cont
entCache, FileUtilities2.createFile(fileName)); |
| 2658 HtmlElementImpl unit = new HtmlElementImpl(context, fileName); |
| 2659 unit.source = source; |
| 2660 return unit; |
| 2661 } |
| 2662 |
| 2586 static ImportElementImpl importFor(LibraryElement importedLibrary, PrefixEleme
nt prefix, List<NamespaceCombinator> combinators) { | 2663 static ImportElementImpl importFor(LibraryElement importedLibrary, PrefixEleme
nt prefix, List<NamespaceCombinator> combinators) { |
| 2587 ImportElementImpl spec = new ImportElementImpl(0); | 2664 ImportElementImpl spec = new ImportElementImpl(0); |
| 2588 spec.importedLibrary = importedLibrary; | 2665 spec.importedLibrary = importedLibrary; |
| 2589 spec.prefix = prefix; | 2666 spec.prefix = prefix; |
| 2590 spec.combinators = combinators; | 2667 spec.combinators = combinators; |
| 2591 return spec; | 2668 return spec; |
| 2592 } | 2669 } |
| 2593 | 2670 |
| 2594 static LibraryElementImpl library(AnalysisContext context, String libraryName)
{ | 2671 static LibraryElementImpl library(AnalysisContext context, String libraryName)
{ |
| 2595 String fileName = "/${libraryName}.dart"; | 2672 String fileName = "/${libraryName}.dart"; |
| 2596 FileBasedSource source = new FileBasedSource.con1(context.sourceFactory.cont
entCache, FileUtilities2.createFile(fileName)); | 2673 CompilationUnitElementImpl unit = compilationUnit(context, fileName); |
| 2597 CompilationUnitElementImpl unit = new CompilationUnitElementImpl(fileName); | |
| 2598 unit.source = source; | |
| 2599 LibraryElementImpl library = new LibraryElementImpl(context, ASTFactory.libr
aryIdentifier2([libraryName])); | 2674 LibraryElementImpl library = new LibraryElementImpl(context, ASTFactory.libr
aryIdentifier2([libraryName])); |
| 2600 library.definingCompilationUnit = unit; | 2675 library.definingCompilationUnit = unit; |
| 2601 return library; | 2676 return library; |
| 2602 } | 2677 } |
| 2603 | 2678 |
| 2604 static LocalVariableElementImpl localVariableElement(Identifier name) => new L
ocalVariableElementImpl(name); | 2679 static LocalVariableElementImpl localVariableElement(Identifier name) => new L
ocalVariableElementImpl(name); |
| 2605 | 2680 |
| 2606 static LocalVariableElementImpl localVariableElement2(String name) => new Loca
lVariableElementImpl(ASTFactory.identifier3(name)); | 2681 static LocalVariableElementImpl localVariableElement2(String name) => new Loca
lVariableElementImpl(ASTFactory.identifier3(name)); |
| 2607 | 2682 |
| 2608 static MethodElementImpl methodElement(String methodName, Type2 returnType, Li
st<Type2> argumentTypes) { | 2683 static MethodElementImpl methodElement(String methodName, Type2 returnType, Li
st<Type2> argumentTypes) { |
| (...skipping 1299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3908 main() { | 3983 main() { |
| 3909 ElementKindTest.dartSuite(); | 3984 ElementKindTest.dartSuite(); |
| 3910 AngularPropertyKindTest.dartSuite(); | 3985 AngularPropertyKindTest.dartSuite(); |
| 3911 FunctionTypeImplTest.dartSuite(); | 3986 FunctionTypeImplTest.dartSuite(); |
| 3912 InterfaceTypeImplTest.dartSuite(); | 3987 InterfaceTypeImplTest.dartSuite(); |
| 3913 TypeParameterTypeImplTest.dartSuite(); | 3988 TypeParameterTypeImplTest.dartSuite(); |
| 3914 VoidTypeImplTest.dartSuite(); | 3989 VoidTypeImplTest.dartSuite(); |
| 3915 ClassElementImplTest.dartSuite(); | 3990 ClassElementImplTest.dartSuite(); |
| 3916 ElementLocationImplTest.dartSuite(); | 3991 ElementLocationImplTest.dartSuite(); |
| 3917 ElementImplTest.dartSuite(); | 3992 ElementImplTest.dartSuite(); |
| 3993 HtmlElementImplTest.dartSuite(); |
| 3918 LibraryElementImplTest.dartSuite(); | 3994 LibraryElementImplTest.dartSuite(); |
| 3919 MultiplyDefinedElementImplTest.dartSuite(); | 3995 MultiplyDefinedElementImplTest.dartSuite(); |
| 3920 } | 3996 } |
| OLD | NEW |