| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library test.src.task.dart_test; | 5 library test.src.task.dart_test; |
| 6 | 6 |
| 7 import 'package:analyzer/src/context/cache.dart'; | 7 import 'package:analyzer/src/context/cache.dart'; |
| 8 import 'package:analyzer/src/generated/ast.dart'; | 8 import 'package:analyzer/src/generated/ast.dart'; |
| 9 import 'package:analyzer/src/generated/constant.dart'; | 9 import 'package:analyzer/src/generated/constant.dart'; |
| 10 import 'package:analyzer/src/generated/element.dart'; | 10 import 'package:analyzer/src/generated/element.dart'; |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 isInstanceOf isResolveVariableReferencesTask = | 120 isInstanceOf isResolveVariableReferencesTask = |
| 121 new isInstanceOf<ResolveVariableReferencesTask>(); | 121 new isInstanceOf<ResolveVariableReferencesTask>(); |
| 122 isInstanceOf isScanDartTask = new isInstanceOf<ScanDartTask>(); | 122 isInstanceOf isScanDartTask = new isInstanceOf<ScanDartTask>(); |
| 123 isInstanceOf isVerifyUnitTask = new isInstanceOf<VerifyUnitTask>(); | 123 isInstanceOf isVerifyUnitTask = new isInstanceOf<VerifyUnitTask>(); |
| 124 | 124 |
| 125 @reflectiveTest | 125 @reflectiveTest |
| 126 class BuildCompilationUnitElementTaskTest extends _AbstractDartTaskTest { | 126 class BuildCompilationUnitElementTaskTest extends _AbstractDartTaskTest { |
| 127 Source source; | 127 Source source; |
| 128 LibrarySpecificUnit target; | 128 LibrarySpecificUnit target; |
| 129 | 129 |
| 130 test_buildInputs() { | |
| 131 LibrarySpecificUnit target = | |
| 132 new LibrarySpecificUnit(emptySource, emptySource); | |
| 133 Map<String, TaskInput> inputs = | |
| 134 BuildCompilationUnitElementTask.buildInputs(target); | |
| 135 expect(inputs, isNotNull); | |
| 136 expect( | |
| 137 inputs.keys, | |
| 138 unorderedEquals( | |
| 139 [BuildCompilationUnitElementTask.PARSED_UNIT_INPUT_NAME])); | |
| 140 } | |
| 141 | |
| 142 test_constructor() { | |
| 143 BuildCompilationUnitElementTask task = | |
| 144 new BuildCompilationUnitElementTask(context, emptySource); | |
| 145 expect(task, isNotNull); | |
| 146 expect(task.context, context); | |
| 147 expect(task.target, emptySource); | |
| 148 } | |
| 149 | |
| 150 test_createTask() { | |
| 151 BuildCompilationUnitElementTask task = | |
| 152 BuildCompilationUnitElementTask.createTask(context, emptySource); | |
| 153 expect(task, isNotNull); | |
| 154 expect(task.context, context); | |
| 155 expect(task.target, emptySource); | |
| 156 } | |
| 157 | |
| 158 test_description() { | |
| 159 BuildCompilationUnitElementTask task = | |
| 160 new BuildCompilationUnitElementTask(null, emptySource); | |
| 161 expect(task.description, isNotNull); | |
| 162 } | |
| 163 | |
| 164 test_descriptor() { | |
| 165 TaskDescriptor descriptor = BuildCompilationUnitElementTask.DESCRIPTOR; | |
| 166 expect(descriptor, isNotNull); | |
| 167 } | |
| 168 | |
| 169 test_perform_find_constants() { | 130 test_perform_find_constants() { |
| 170 _performBuildTask(''' | 131 _performBuildTask(''' |
| 171 const x = 1; | 132 const x = 1; |
| 172 class C { | 133 class C { |
| 173 static const y = 1; | 134 static const y = 1; |
| 174 const C([p = 1]); | 135 const C([p = 1]); |
| 175 } | 136 } |
| 176 @x | 137 @x |
| 177 f() { | 138 f() { |
| 178 const z = 1; | 139 const z = 1; |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 void _performBuildTask(String content) { | 198 void _performBuildTask(String content) { |
| 238 source = newSource('/test.dart', content); | 199 source = newSource('/test.dart', content); |
| 239 target = new LibrarySpecificUnit(source, source); | 200 target = new LibrarySpecificUnit(source, source); |
| 240 computeResult(target, RESOLVED_UNIT1, | 201 computeResult(target, RESOLVED_UNIT1, |
| 241 matcher: isBuildCompilationUnitElementTask); | 202 matcher: isBuildCompilationUnitElementTask); |
| 242 } | 203 } |
| 243 } | 204 } |
| 244 | 205 |
| 245 @reflectiveTest | 206 @reflectiveTest |
| 246 class BuildDirectiveElementsTaskTest extends _AbstractDartTaskTest { | 207 class BuildDirectiveElementsTaskTest extends _AbstractDartTaskTest { |
| 247 test_constructor() { | |
| 248 BuildDirectiveElementsTask task = | |
| 249 new BuildDirectiveElementsTask(context, emptySource); | |
| 250 expect(task, isNotNull); | |
| 251 expect(task.context, context); | |
| 252 expect(task.target, emptySource); | |
| 253 } | |
| 254 | |
| 255 test_createTask() { | |
| 256 BuildDirectiveElementsTask task = | |
| 257 BuildDirectiveElementsTask.createTask(context, emptySource); | |
| 258 expect(task, isNotNull); | |
| 259 expect(task.context, context); | |
| 260 expect(task.target, emptySource); | |
| 261 } | |
| 262 | |
| 263 test_description() { | |
| 264 BuildDirectiveElementsTask task = | |
| 265 new BuildDirectiveElementsTask(null, emptySource); | |
| 266 expect(task.description, isNotNull); | |
| 267 } | |
| 268 | |
| 269 test_descriptor() { | |
| 270 TaskDescriptor descriptor = BuildDirectiveElementsTask.DESCRIPTOR; | |
| 271 expect(descriptor, isNotNull); | |
| 272 } | |
| 273 | |
| 274 test_perform() { | 208 test_perform() { |
| 275 List<Source> sources = newSources({ | 209 List<Source> sources = newSources({ |
| 276 '/libA.dart': ''' | 210 '/libA.dart': ''' |
| 277 library libA; | 211 library libA; |
| 278 import 'libB.dart'; | 212 import 'libB.dart'; |
| 279 export 'libC.dart'; | 213 export 'libC.dart'; |
| 280 ''', | 214 ''', |
| 281 '/libB.dart': ''' | 215 '/libB.dart': ''' |
| 282 library libB; | 216 library libB; |
| 283 ''', | 217 ''', |
| (...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 691 | 625 |
| 692 @reflectiveTest | 626 @reflectiveTest |
| 693 class BuildLibraryElementTaskTest extends _AbstractDartTaskTest { | 627 class BuildLibraryElementTaskTest extends _AbstractDartTaskTest { |
| 694 Source librarySource; | 628 Source librarySource; |
| 695 CompilationUnit libraryUnit; | 629 CompilationUnit libraryUnit; |
| 696 CompilationUnitElement libraryUnitElement; | 630 CompilationUnitElement libraryUnitElement; |
| 697 List<CompilationUnit> partUnits; | 631 List<CompilationUnit> partUnits; |
| 698 | 632 |
| 699 LibraryElement libraryElement; | 633 LibraryElement libraryElement; |
| 700 | 634 |
| 701 test_constructor() { | |
| 702 BuildLibraryElementTask task = | |
| 703 new BuildLibraryElementTask(context, emptySource); | |
| 704 expect(task, isNotNull); | |
| 705 expect(task.context, context); | |
| 706 expect(task.target, emptySource); | |
| 707 } | |
| 708 | |
| 709 test_createTask() { | |
| 710 BuildLibraryElementTask task = | |
| 711 BuildLibraryElementTask.createTask(context, emptySource); | |
| 712 expect(task, isNotNull); | |
| 713 expect(task.context, context); | |
| 714 expect(task.target, emptySource); | |
| 715 } | |
| 716 | |
| 717 test_description() { | |
| 718 BuildLibraryElementTask task = | |
| 719 new BuildLibraryElementTask(null, emptySource); | |
| 720 expect(task.description, isNotNull); | |
| 721 } | |
| 722 | |
| 723 test_descriptor() { | |
| 724 TaskDescriptor descriptor = BuildLibraryElementTask.DESCRIPTOR; | |
| 725 expect(descriptor, isNotNull); | |
| 726 } | |
| 727 | |
| 728 test_perform() { | 635 test_perform() { |
| 729 _performBuildTask({ | 636 _performBuildTask({ |
| 730 '/lib.dart': ''' | 637 '/lib.dart': ''' |
| 731 library lib; | 638 library lib; |
| 732 part 'part1.dart'; | 639 part 'part1.dart'; |
| 733 part 'part2.dart'; | 640 part 'part2.dart'; |
| 734 ''', | 641 ''', |
| 735 '/part1.dart': ''' | 642 '/part1.dart': ''' |
| 736 part of lib; | 643 part of lib; |
| 737 ''', | 644 ''', |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 952 .getValue(RESOLVED_UNIT1); | 859 .getValue(RESOLVED_UNIT1); |
| 953 libraryUnitElement = libraryUnit.element; | 860 libraryUnitElement = libraryUnit.element; |
| 954 librarySource = libraryUnitElement.source; | 861 librarySource = libraryUnitElement.source; |
| 955 libraryElement = outputs[LIBRARY_ELEMENT1]; | 862 libraryElement = outputs[LIBRARY_ELEMENT1]; |
| 956 partUnits = task.inputs[BuildLibraryElementTask.PARTS_UNIT_INPUT]; | 863 partUnits = task.inputs[BuildLibraryElementTask.PARTS_UNIT_INPUT]; |
| 957 } | 864 } |
| 958 } | 865 } |
| 959 | 866 |
| 960 @reflectiveTest | 867 @reflectiveTest |
| 961 class BuildPublicNamespaceTaskTest extends _AbstractDartTaskTest { | 868 class BuildPublicNamespaceTaskTest extends _AbstractDartTaskTest { |
| 962 test_buildInputs() { | |
| 963 Map<String, TaskInput> inputs = | |
| 964 BuildPublicNamespaceTask.buildInputs(emptySource); | |
| 965 expect(inputs, isNotNull); | |
| 966 expect( | |
| 967 inputs.keys, unorderedEquals([BuildPublicNamespaceTask.LIBRARY_INPUT])); | |
| 968 } | |
| 969 | |
| 970 test_constructor() { | |
| 971 BuildPublicNamespaceTask task = | |
| 972 new BuildPublicNamespaceTask(context, emptySource); | |
| 973 expect(task, isNotNull); | |
| 974 expect(task.context, context); | |
| 975 expect(task.target, emptySource); | |
| 976 } | |
| 977 | |
| 978 test_createTask() { | |
| 979 BuildPublicNamespaceTask task = | |
| 980 BuildPublicNamespaceTask.createTask(context, emptySource); | |
| 981 expect(task, isNotNull); | |
| 982 expect(task.context, context); | |
| 983 expect(task.target, emptySource); | |
| 984 } | |
| 985 | |
| 986 test_description() { | |
| 987 BuildPublicNamespaceTask task = | |
| 988 new BuildPublicNamespaceTask(null, emptySource); | |
| 989 expect(task.description, isNotNull); | |
| 990 } | |
| 991 | |
| 992 test_descriptor() { | |
| 993 TaskDescriptor descriptor = BuildPublicNamespaceTask.DESCRIPTOR; | |
| 994 expect(descriptor, isNotNull); | |
| 995 } | |
| 996 | |
| 997 test_perform() { | 869 test_perform() { |
| 998 List<Source> sources = newSources({ | 870 List<Source> sources = newSources({ |
| 999 '/lib.dart': ''' | 871 '/lib.dart': ''' |
| 1000 library lib; | 872 library lib; |
| 1001 part 'part.dart'; | 873 part 'part.dart'; |
| 1002 a() {} | 874 a() {} |
| 1003 _b() {} | 875 _b() {} |
| 1004 ''', | 876 ''', |
| 1005 '/part.dart': ''' | 877 '/part.dart': ''' |
| 1006 part of lib; | 878 part of lib; |
| (...skipping 562 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1569 matcher: isComputeInferableStaticVariableDependenciesTask); | 1441 matcher: isComputeInferableStaticVariableDependenciesTask); |
| 1570 expect(outputs, hasLength(1)); | 1442 expect(outputs, hasLength(1)); |
| 1571 List<VariableElement> dependencies = | 1443 List<VariableElement> dependencies = |
| 1572 outputs[INFERABLE_STATIC_VARIABLE_DEPENDENCIES]; | 1444 outputs[INFERABLE_STATIC_VARIABLE_DEPENDENCIES]; |
| 1573 expect(dependencies, unorderedEquals([elementB])); | 1445 expect(dependencies, unorderedEquals([elementB])); |
| 1574 } | 1446 } |
| 1575 } | 1447 } |
| 1576 | 1448 |
| 1577 @reflectiveTest | 1449 @reflectiveTest |
| 1578 class ContainingLibrariesTaskTest extends _AbstractDartTaskTest { | 1450 class ContainingLibrariesTaskTest extends _AbstractDartTaskTest { |
| 1579 test_buildInputs() { | |
| 1580 Map<String, TaskInput> inputs = | |
| 1581 ContainingLibrariesTask.buildInputs(emptySource); | |
| 1582 expect(inputs, isNotNull); | |
| 1583 expect(inputs, isEmpty); | |
| 1584 } | |
| 1585 | |
| 1586 test_constructor() { | |
| 1587 ContainingLibrariesTask task = | |
| 1588 new ContainingLibrariesTask(context, emptySource); | |
| 1589 expect(task, isNotNull); | |
| 1590 expect(task.context, context); | |
| 1591 expect(task.target, emptySource); | |
| 1592 } | |
| 1593 | |
| 1594 test_createTask() { | |
| 1595 ContainingLibrariesTask task = | |
| 1596 ContainingLibrariesTask.createTask(context, emptySource); | |
| 1597 expect(task, isNotNull); | |
| 1598 expect(task.context, context); | |
| 1599 expect(task.target, emptySource); | |
| 1600 } | |
| 1601 | |
| 1602 test_description() { | |
| 1603 ContainingLibrariesTask task = | |
| 1604 new ContainingLibrariesTask(null, emptySource); | |
| 1605 expect(task.description, isNotNull); | |
| 1606 } | |
| 1607 | |
| 1608 test_descriptor() { | |
| 1609 TaskDescriptor descriptor = ContainingLibrariesTask.DESCRIPTOR; | |
| 1610 expect(descriptor, isNotNull); | |
| 1611 } | |
| 1612 | |
| 1613 test_perform_definingCompilationUnit() { | 1451 test_perform_definingCompilationUnit() { |
| 1614 AnalysisTarget library = newSource('/test.dart', 'library test;'); | 1452 AnalysisTarget library = newSource('/test.dart', 'library test;'); |
| 1615 computeResult(library, INCLUDED_PARTS); | 1453 computeResult(library, INCLUDED_PARTS); |
| 1616 computeResult(library, CONTAINING_LIBRARIES, | 1454 computeResult(library, CONTAINING_LIBRARIES, |
| 1617 matcher: isContainingLibrariesTask); | 1455 matcher: isContainingLibrariesTask); |
| 1618 expect(outputs, hasLength(1)); | 1456 expect(outputs, hasLength(1)); |
| 1619 List<Source> containingLibraries = outputs[CONTAINING_LIBRARIES]; | 1457 List<Source> containingLibraries = outputs[CONTAINING_LIBRARIES]; |
| 1620 expect(containingLibraries, unorderedEquals([library])); | 1458 expect(containingLibraries, unorderedEquals([library])); |
| 1621 } | 1459 } |
| 1622 | 1460 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1645 computeResult(part, CONTAINING_LIBRARIES, | 1483 computeResult(part, CONTAINING_LIBRARIES, |
| 1646 matcher: isContainingLibrariesTask); | 1484 matcher: isContainingLibrariesTask); |
| 1647 expect(outputs, hasLength(1)); | 1485 expect(outputs, hasLength(1)); |
| 1648 List<Source> containingLibraries = outputs[CONTAINING_LIBRARIES]; | 1486 List<Source> containingLibraries = outputs[CONTAINING_LIBRARIES]; |
| 1649 expect(containingLibraries, unorderedEquals([library])); | 1487 expect(containingLibraries, unorderedEquals([library])); |
| 1650 } | 1488 } |
| 1651 } | 1489 } |
| 1652 | 1490 |
| 1653 @reflectiveTest | 1491 @reflectiveTest |
| 1654 class DartErrorsTaskTest extends _AbstractDartTaskTest { | 1492 class DartErrorsTaskTest extends _AbstractDartTaskTest { |
| 1655 test_buildInputs() { | |
| 1656 Map<String, TaskInput> inputs = DartErrorsTask.buildInputs(emptySource); | |
| 1657 expect(inputs, isNotNull); | |
| 1658 expect( | |
| 1659 inputs.keys, | |
| 1660 unorderedEquals([ | |
| 1661 DartErrorsTask.BUILD_DIRECTIVES_ERRORS_INPUT, | |
| 1662 DartErrorsTask.BUILD_LIBRARY_ERRORS_INPUT, | |
| 1663 DartErrorsTask.PARSE_ERRORS_INPUT, | |
| 1664 DartErrorsTask.SCAN_ERRORS_INPUT, | |
| 1665 DartErrorsTask.LIBRARY_UNIT_ERRORS_INPUT | |
| 1666 ])); | |
| 1667 } | |
| 1668 | |
| 1669 test_constructor() { | |
| 1670 DartErrorsTask task = new DartErrorsTask(context, emptySource); | |
| 1671 expect(task, isNotNull); | |
| 1672 expect(task.context, context); | |
| 1673 expect(task.target, emptySource); | |
| 1674 } | |
| 1675 | |
| 1676 test_createTask() { | |
| 1677 DartErrorsTask task = DartErrorsTask.createTask(context, emptySource); | |
| 1678 expect(task, isNotNull); | |
| 1679 expect(task.context, context); | |
| 1680 expect(task.target, emptySource); | |
| 1681 } | |
| 1682 | |
| 1683 test_description() { | |
| 1684 DartErrorsTask task = new DartErrorsTask(null, emptySource); | |
| 1685 expect(task.description, isNotNull); | |
| 1686 } | |
| 1687 | |
| 1688 test_descriptor() { | |
| 1689 TaskDescriptor descriptor = DartErrorsTask.DESCRIPTOR; | |
| 1690 expect(descriptor, isNotNull); | |
| 1691 } | |
| 1692 | |
| 1693 test_perform_definingCompilationUnit() { | 1493 test_perform_definingCompilationUnit() { |
| 1694 AnalysisTarget library = | 1494 AnalysisTarget library = |
| 1695 newSource('/test.dart', 'library test; import "dart:math";'); | 1495 newSource('/test.dart', 'library test; import "dart:math";'); |
| 1696 computeResult(library, INCLUDED_PARTS); | 1496 computeResult(library, INCLUDED_PARTS); |
| 1697 computeResult(library, DART_ERRORS, matcher: isDartErrorsTask); | 1497 computeResult(library, DART_ERRORS, matcher: isDartErrorsTask); |
| 1698 expect(outputs, hasLength(1)); | 1498 expect(outputs, hasLength(1)); |
| 1699 List<AnalysisError> errors = outputs[DART_ERRORS]; | 1499 List<AnalysisError> errors = outputs[DART_ERRORS]; |
| 1700 expect(errors, hasLength(1)); | 1500 expect(errors, hasLength(1)); |
| 1701 } | 1501 } |
| 1702 | 1502 |
| (...skipping 591 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2294 bool ready = outputs[LIBRARY_ERRORS_READY]; | 2094 bool ready = outputs[LIBRARY_ERRORS_READY]; |
| 2295 expect(ready, isTrue); | 2095 expect(ready, isTrue); |
| 2296 expect(context.getErrors(library).errors, hasLength(1)); | 2096 expect(context.getErrors(library).errors, hasLength(1)); |
| 2297 expect(context.getErrors(part1).errors, hasLength(1)); | 2097 expect(context.getErrors(part1).errors, hasLength(1)); |
| 2298 expect(context.getErrors(part2).errors, hasLength(1)); | 2098 expect(context.getErrors(part2).errors, hasLength(1)); |
| 2299 } | 2099 } |
| 2300 } | 2100 } |
| 2301 | 2101 |
| 2302 @reflectiveTest | 2102 @reflectiveTest |
| 2303 class LibraryUnitErrorsTaskTest extends _AbstractDartTaskTest { | 2103 class LibraryUnitErrorsTaskTest extends _AbstractDartTaskTest { |
| 2304 test_constructor() { | |
| 2305 LibraryUnitErrorsTask task = | |
| 2306 new LibraryUnitErrorsTask(context, emptySource); | |
| 2307 expect(task, isNotNull); | |
| 2308 expect(task.context, context); | |
| 2309 expect(task.target, emptySource); | |
| 2310 } | |
| 2311 | |
| 2312 test_createTask() { | |
| 2313 LibraryUnitErrorsTask task = | |
| 2314 LibraryUnitErrorsTask.createTask(context, emptySource); | |
| 2315 expect(task, isNotNull); | |
| 2316 expect(task.context, context); | |
| 2317 expect(task.target, emptySource); | |
| 2318 } | |
| 2319 | |
| 2320 test_description() { | |
| 2321 LibraryUnitErrorsTask task = new LibraryUnitErrorsTask(null, emptySource); | |
| 2322 expect(task.description, isNotNull); | |
| 2323 } | |
| 2324 | |
| 2325 test_descriptor() { | |
| 2326 TaskDescriptor descriptor = LibraryUnitErrorsTask.DESCRIPTOR; | |
| 2327 expect(descriptor, isNotNull); | |
| 2328 } | |
| 2329 | |
| 2330 test_perform_definingCompilationUnit() { | 2104 test_perform_definingCompilationUnit() { |
| 2331 AnalysisTarget library = | 2105 AnalysisTarget library = |
| 2332 newSource('/test.dart', 'library test; import "dart:math";'); | 2106 newSource('/test.dart', 'library test; import "dart:math";'); |
| 2333 computeResult( | 2107 computeResult( |
| 2334 new LibrarySpecificUnit(library, library), LIBRARY_UNIT_ERRORS, | 2108 new LibrarySpecificUnit(library, library), LIBRARY_UNIT_ERRORS, |
| 2335 matcher: isLibraryUnitErrorsTask); | 2109 matcher: isLibraryUnitErrorsTask); |
| 2336 expect(outputs, hasLength(1)); | 2110 expect(outputs, hasLength(1)); |
| 2337 List<AnalysisError> errors = outputs[LIBRARY_UNIT_ERRORS]; | 2111 List<AnalysisError> errors = outputs[LIBRARY_UNIT_ERRORS]; |
| 2338 expect(errors, hasLength(1)); | 2112 expect(errors, hasLength(1)); |
| 2339 } | 2113 } |
| 2340 | 2114 |
| 2341 test_perform_partInSingleLibrary() { | 2115 test_perform_partInSingleLibrary() { |
| 2342 AnalysisTarget library = | 2116 AnalysisTarget library = |
| 2343 newSource('/lib.dart', 'library test; part "part.dart";'); | 2117 newSource('/lib.dart', 'library test; part "part.dart";'); |
| 2344 AnalysisTarget part = newSource('/part.dart', 'part of test;'); | 2118 AnalysisTarget part = newSource('/part.dart', 'part of test;'); |
| 2345 computeResult(new LibrarySpecificUnit(library, part), LIBRARY_UNIT_ERRORS, | 2119 computeResult(new LibrarySpecificUnit(library, part), LIBRARY_UNIT_ERRORS, |
| 2346 matcher: isLibraryUnitErrorsTask); | 2120 matcher: isLibraryUnitErrorsTask); |
| 2347 expect(outputs, hasLength(1)); | 2121 expect(outputs, hasLength(1)); |
| 2348 List<AnalysisError> errors = outputs[LIBRARY_UNIT_ERRORS]; | 2122 List<AnalysisError> errors = outputs[LIBRARY_UNIT_ERRORS]; |
| 2349 expect(errors, hasLength(0)); | 2123 expect(errors, hasLength(0)); |
| 2350 } | 2124 } |
| 2351 } | 2125 } |
| 2352 | 2126 |
| 2353 @reflectiveTest | 2127 @reflectiveTest |
| 2354 class ParseDartTaskTest extends _AbstractDartTaskTest { | 2128 class ParseDartTaskTest extends _AbstractDartTaskTest { |
| 2355 Source source; | 2129 Source source; |
| 2356 | 2130 |
| 2357 test_buildInputs() { | |
| 2358 Map<String, TaskInput> inputs = ParseDartTask.buildInputs(emptySource); | |
| 2359 expect(inputs, isNotNull); | |
| 2360 expect( | |
| 2361 inputs.keys, | |
| 2362 unorderedEquals([ | |
| 2363 ParseDartTask.LINE_INFO_INPUT_NAME, | |
| 2364 ParseDartTask.MODIFICATION_TIME_INPUT_NAME, | |
| 2365 ParseDartTask.TOKEN_STREAM_INPUT_NAME | |
| 2366 ])); | |
| 2367 } | |
| 2368 | |
| 2369 test_constructor() { | |
| 2370 ParseDartTask task = new ParseDartTask(context, emptySource); | |
| 2371 expect(task, isNotNull); | |
| 2372 expect(task.context, context); | |
| 2373 expect(task.target, emptySource); | |
| 2374 } | |
| 2375 | |
| 2376 test_createTask() { | |
| 2377 ParseDartTask task = ParseDartTask.createTask(context, emptySource); | |
| 2378 expect(task, isNotNull); | |
| 2379 expect(task.context, context); | |
| 2380 expect(task.target, emptySource); | |
| 2381 } | |
| 2382 | |
| 2383 test_description() { | |
| 2384 ParseDartTask task = new ParseDartTask(null, emptySource); | |
| 2385 expect(task.description, isNotNull); | |
| 2386 } | |
| 2387 | |
| 2388 test_descriptor() { | |
| 2389 TaskDescriptor descriptor = ParseDartTask.DESCRIPTOR; | |
| 2390 expect(descriptor, isNotNull); | |
| 2391 } | |
| 2392 | |
| 2393 test_perform() { | 2131 test_perform() { |
| 2394 _performParseTask(r''' | 2132 _performParseTask(r''' |
| 2395 part of lib; | 2133 part of lib; |
| 2396 class B {}'''); | 2134 class B {}'''); |
| 2397 expect(outputs, hasLength(8)); | 2135 expect(outputs, hasLength(8)); |
| 2398 expect(outputs[EXPLICITLY_IMPORTED_LIBRARIES], hasLength(0)); | 2136 expect(outputs[EXPLICITLY_IMPORTED_LIBRARIES], hasLength(0)); |
| 2399 expect(outputs[EXPORTED_LIBRARIES], hasLength(0)); | 2137 expect(outputs[EXPORTED_LIBRARIES], hasLength(0)); |
| 2400 _assertHasCore(outputs[IMPORTED_LIBRARIES], 1); | 2138 _assertHasCore(outputs[IMPORTED_LIBRARIES], 1); |
| 2401 expect(outputs[INCLUDED_PARTS], hasLength(0)); | 2139 expect(outputs[INCLUDED_PARTS], hasLength(0)); |
| 2402 expect(outputs[PARSE_ERRORS], hasLength(0)); | 2140 expect(outputs[PARSE_ERRORS], hasLength(0)); |
| (...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2849 FunctionElement main = unit.element.functions[0]; | 2587 FunctionElement main = unit.element.functions[0]; |
| 2850 expectMutated(main.parameters[0], isFalse, isFalse); | 2588 expectMutated(main.parameters[0], isFalse, isFalse); |
| 2851 expectMutated(main.parameters[1], isFalse, isTrue); | 2589 expectMutated(main.parameters[1], isFalse, isTrue); |
| 2852 expectMutated(main.parameters[2], isTrue, isTrue); | 2590 expectMutated(main.parameters[2], isTrue, isTrue); |
| 2853 expectMutated(main.parameters[3], isTrue, isTrue); | 2591 expectMutated(main.parameters[3], isTrue, isTrue); |
| 2854 } | 2592 } |
| 2855 } | 2593 } |
| 2856 | 2594 |
| 2857 @reflectiveTest | 2595 @reflectiveTest |
| 2858 class ScanDartTaskTest extends _AbstractDartTaskTest { | 2596 class ScanDartTaskTest extends _AbstractDartTaskTest { |
| 2859 test_buildInputs() { | |
| 2860 Map<String, TaskInput> inputs = ScanDartTask.buildInputs(emptySource); | |
| 2861 expect(inputs, isNotNull); | |
| 2862 expect(inputs.keys, unorderedEquals([ScanDartTask.CONTENT_INPUT_NAME])); | |
| 2863 } | |
| 2864 | |
| 2865 test_constructor() { | |
| 2866 ScanDartTask task = new ScanDartTask(context, emptySource); | |
| 2867 expect(task, isNotNull); | |
| 2868 expect(task.context, context); | |
| 2869 expect(task.target, emptySource); | |
| 2870 } | |
| 2871 | |
| 2872 test_createTask() { | |
| 2873 ScanDartTask task = ScanDartTask.createTask(context, emptySource); | |
| 2874 expect(task, isNotNull); | |
| 2875 expect(task.context, context); | |
| 2876 expect(task.target, emptySource); | |
| 2877 } | |
| 2878 | |
| 2879 test_description() { | |
| 2880 ScanDartTask task = new ScanDartTask(null, emptySource); | |
| 2881 expect(task.description, isNotNull); | |
| 2882 } | |
| 2883 | |
| 2884 test_descriptor() { | |
| 2885 TaskDescriptor descriptor = ScanDartTask.DESCRIPTOR; | |
| 2886 expect(descriptor, isNotNull); | |
| 2887 } | |
| 2888 | |
| 2889 test_perform_errors() { | 2597 test_perform_errors() { |
| 2890 _performScanTask('import "'); | 2598 _performScanTask('import "'); |
| 2891 expect(outputs, hasLength(3)); | 2599 expect(outputs, hasLength(3)); |
| 2892 expect(outputs[LINE_INFO], isNotNull); | 2600 expect(outputs[LINE_INFO], isNotNull); |
| 2893 expect(outputs[SCAN_ERRORS], hasLength(1)); | 2601 expect(outputs[SCAN_ERRORS], hasLength(1)); |
| 2894 expect(outputs[TOKEN_STREAM], isNotNull); | 2602 expect(outputs[TOKEN_STREAM], isNotNull); |
| 2895 } | 2603 } |
| 2896 | 2604 |
| 2897 test_perform_noErrors() { | 2605 test_perform_noErrors() { |
| 2898 _performScanTask('class A {}'); | 2606 _performScanTask('class A {}'); |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3123 /** | 2831 /** |
| 3124 * Fill [errorListener] with [result] errors in the current [task]. | 2832 * Fill [errorListener] with [result] errors in the current [task]. |
| 3125 */ | 2833 */ |
| 3126 void _fillErrorListener(ResultDescriptor<List<AnalysisError>> result) { | 2834 void _fillErrorListener(ResultDescriptor<List<AnalysisError>> result) { |
| 3127 List<AnalysisError> errors = task.outputs[result]; | 2835 List<AnalysisError> errors = task.outputs[result]; |
| 3128 expect(errors, isNotNull, reason: result.name); | 2836 expect(errors, isNotNull, reason: result.name); |
| 3129 errorListener = new GatheringErrorListener(); | 2837 errorListener = new GatheringErrorListener(); |
| 3130 errorListener.addAll(errors); | 2838 errorListener.addAll(errors); |
| 3131 } | 2839 } |
| 3132 } | 2840 } |
| OLD | NEW |