| 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/file_system/file_system.dart'; | 7 import 'package:analyzer/file_system/file_system.dart'; |
| 8 import 'package:analyzer/file_system/memory_file_system.dart'; | 8 import 'package:analyzer/file_system/memory_file_system.dart'; |
| 9 import 'package:analyzer/src/context/cache.dart'; | 9 import 'package:analyzer/src/context/cache.dart'; |
| 10 import 'package:analyzer/src/generated/ast.dart'; | 10 import 'package:analyzer/src/generated/ast.dart'; |
| (...skipping 727 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 738 part 'part1.dart'; | 738 part 'part1.dart'; |
| 739 part 'part2.dart'; | 739 part 'part2.dart'; |
| 740 ''', | 740 ''', |
| 741 '/part1.dart': ''' | 741 '/part1.dart': ''' |
| 742 part of lib; | 742 part of lib; |
| 743 ''', | 743 ''', |
| 744 '/part2.dart': ''' | 744 '/part2.dart': ''' |
| 745 part of lib; | 745 part of lib; |
| 746 ''' | 746 ''' |
| 747 }); | 747 }); |
| 748 expect(outputs, hasLength(5)); | 748 expect(outputs, hasLength(4)); |
| 749 // simple outputs | 749 // simple outputs |
| 750 expect(outputs[BUILD_LIBRARY_ERRORS], isEmpty); | 750 expect(outputs[BUILD_LIBRARY_ERRORS], isEmpty); |
| 751 expect(outputs[IS_LAUNCHABLE], isFalse); | 751 expect(outputs[IS_LAUNCHABLE], isFalse); |
| 752 expect(outputs[HAS_HTML_IMPORT], isFalse); | |
| 753 // LibraryElement output | 752 // LibraryElement output |
| 754 expect(libraryElement, isNotNull); | 753 expect(libraryElement, isNotNull); |
| 755 expect(libraryElement.entryPoint, isNull); | 754 expect(libraryElement.entryPoint, isNull); |
| 756 expect(libraryElement.source, same(librarySource)); | 755 expect(libraryElement.source, same(librarySource)); |
| 757 expect(libraryElement.definingCompilationUnit, libraryUnitElement); | 756 expect(libraryElement.definingCompilationUnit, libraryUnitElement); |
| 758 expect(libraryElement.parts, | 757 expect(libraryElement.parts, |
| 759 unorderedEquals([partUnits[0].element, partUnits[1].element])); | 758 unorderedEquals([partUnits[0].element, partUnits[1].element])); |
| 760 // LibraryElement references | 759 // LibraryElement references |
| 761 expect((libraryUnit.directives[0] as LibraryDirective).element, | 760 expect((libraryUnit.directives[0] as LibraryDirective).element, |
| 762 same(libraryElement)); | 761 same(libraryElement)); |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 866 library lib; | 865 library lib; |
| 867 part 'part.dart'; | 866 part 'part.dart'; |
| 868 ''', | 867 ''', |
| 869 '/part.dart': ''' | 868 '/part.dart': ''' |
| 870 // no part of | 869 // no part of |
| 871 ''' | 870 ''' |
| 872 }); | 871 }); |
| 873 _assertErrorsWithCodes([CompileTimeErrorCode.PART_OF_NON_PART]); | 872 _assertErrorsWithCodes([CompileTimeErrorCode.PART_OF_NON_PART]); |
| 874 } | 873 } |
| 875 | 874 |
| 876 test_perform_hasHtmlImport() { | |
| 877 _performBuildTask({ | |
| 878 '/lib.dart': ''' | |
| 879 import 'dart:html'; | |
| 880 ''' | |
| 881 }); | |
| 882 expect(outputs[HAS_HTML_IMPORT], isTrue); | |
| 883 } | |
| 884 | |
| 885 test_perform_isLaunchable_inDefiningUnit() { | 875 test_perform_isLaunchable_inDefiningUnit() { |
| 886 _performBuildTask({ | 876 _performBuildTask({ |
| 887 '/lib.dart': ''' | 877 '/lib.dart': ''' |
| 888 library lib; | 878 library lib; |
| 889 main() { | 879 main() { |
| 890 } | 880 } |
| 891 ''' | 881 ''' |
| 892 }); | 882 }); |
| 893 expect(outputs[IS_LAUNCHABLE], isTrue); | 883 expect(outputs[IS_LAUNCHABLE], isTrue); |
| 894 expect(libraryElement.entryPoint, isNotNull); | 884 expect(libraryElement.entryPoint, isNotNull); |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1099 } | 1089 } |
| 1100 // d.dart | 1090 // d.dart |
| 1101 { | 1091 { |
| 1102 _computeResult(sourceD, IMPORT_SOURCE_CLOSURE); | 1092 _computeResult(sourceD, IMPORT_SOURCE_CLOSURE); |
| 1103 expect(task, new isInstanceOf<BuildSourceClosuresTask>()); | 1093 expect(task, new isInstanceOf<BuildSourceClosuresTask>()); |
| 1104 List<Source> closure = outputs[IMPORT_SOURCE_CLOSURE]; | 1094 List<Source> closure = outputs[IMPORT_SOURCE_CLOSURE]; |
| 1105 expect(closure, contains(sourceD)); | 1095 expect(closure, contains(sourceD)); |
| 1106 expect(closure, contains(coreSource)); | 1096 expect(closure, contains(coreSource)); |
| 1107 } | 1097 } |
| 1108 } | 1098 } |
| 1099 |
| 1100 test_perform_isClient_false() { |
| 1101 Source sourceA = _newSource('/a.dart', ''' |
| 1102 library lib_a; |
| 1103 import 'b.dart'; |
| 1104 '''); |
| 1105 _newSource('/b.dart', ''' |
| 1106 library lib_b; |
| 1107 '''); |
| 1108 _computeResult(sourceA, IS_CLIENT); |
| 1109 expect(task, new isInstanceOf<BuildSourceClosuresTask>()); |
| 1110 expect(outputs[IS_CLIENT], isFalse); |
| 1111 } |
| 1112 |
| 1113 test_perform_isClient_true_direct() { |
| 1114 Source sourceA = _newSource('/a.dart', ''' |
| 1115 library lib_a; |
| 1116 import 'dart:html'; |
| 1117 '''); |
| 1118 _computeResult(sourceA, IS_CLIENT); |
| 1119 expect(task, new isInstanceOf<BuildSourceClosuresTask>()); |
| 1120 expect(outputs[IS_CLIENT], isTrue); |
| 1121 } |
| 1122 |
| 1123 test_perform_isClient_true_indirect() { |
| 1124 Source sourceA = _newSource('/a.dart', ''' |
| 1125 library lib_a; |
| 1126 import 'b.dart'; |
| 1127 '''); |
| 1128 _newSource('/b.dart', ''' |
| 1129 library lib_b; |
| 1130 import 'dart:html'; |
| 1131 '''); |
| 1132 _computeResult(sourceA, IS_CLIENT); |
| 1133 expect(task, new isInstanceOf<BuildSourceClosuresTask>()); |
| 1134 expect(outputs[IS_CLIENT], isTrue); |
| 1135 } |
| 1109 } | 1136 } |
| 1110 | 1137 |
| 1111 @reflectiveTest | 1138 @reflectiveTest |
| 1112 class BuildTypeProviderTaskTest extends _AbstractDartTaskTest { | 1139 class BuildTypeProviderTaskTest extends _AbstractDartTaskTest { |
| 1113 test_perform() { | 1140 test_perform() { |
| 1114 _computeResult(AnalysisContextTarget.request, TYPE_PROVIDER); | 1141 _computeResult(AnalysisContextTarget.request, TYPE_PROVIDER); |
| 1115 expect(task, new isInstanceOf<BuildTypeProviderTask>()); | 1142 expect(task, new isInstanceOf<BuildTypeProviderTask>()); |
| 1116 // validate | 1143 // validate |
| 1117 TypeProvider typeProvider = outputs[TYPE_PROVIDER]; | 1144 TypeProvider typeProvider = outputs[TYPE_PROVIDER]; |
| 1118 expect(typeProvider, isNotNull); | 1145 expect(typeProvider, isNotNull); |
| (...skipping 683 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1802 return entryMap.putIfAbsent(target, () => new CacheEntry()); | 1829 return entryMap.putIfAbsent(target, () => new CacheEntry()); |
| 1803 } | 1830 } |
| 1804 | 1831 |
| 1805 TimestampedData<String> getContents(Source source) => source.contents; | 1832 TimestampedData<String> getContents(Source source) => source.contents; |
| 1806 | 1833 |
| 1807 noSuchMethod(Invocation invocation) { | 1834 noSuchMethod(Invocation invocation) { |
| 1808 print('noSuchMethod: ${invocation.memberName}'); | 1835 print('noSuchMethod: ${invocation.memberName}'); |
| 1809 return super.noSuchMethod(invocation); | 1836 return super.noSuchMethod(invocation); |
| 1810 } | 1837 } |
| 1811 } | 1838 } |
| OLD | NEW |