| 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 24 matching lines...) Expand all Loading... |
| 35 runReflectiveTests(BuildCompilationUnitElementTaskTest); | 35 runReflectiveTests(BuildCompilationUnitElementTaskTest); |
| 36 runReflectiveTests(BuildDirectiveElementsTaskTest); | 36 runReflectiveTests(BuildDirectiveElementsTaskTest); |
| 37 runReflectiveTests(BuildEnumMemberElementsTaskTest); | 37 runReflectiveTests(BuildEnumMemberElementsTaskTest); |
| 38 runReflectiveTests(BuildExportSourceClosureTaskTest); | 38 runReflectiveTests(BuildExportSourceClosureTaskTest); |
| 39 runReflectiveTests(BuildExportNamespaceTaskTest); | 39 runReflectiveTests(BuildExportNamespaceTaskTest); |
| 40 runReflectiveTests(BuildFunctionTypeAliasesTaskTest); | 40 runReflectiveTests(BuildFunctionTypeAliasesTaskTest); |
| 41 runReflectiveTests(BuildLibraryConstructorsTaskTest); | 41 runReflectiveTests(BuildLibraryConstructorsTaskTest); |
| 42 runReflectiveTests(BuildLibraryElementTaskTest); | 42 runReflectiveTests(BuildLibraryElementTaskTest); |
| 43 runReflectiveTests(BuildPublicNamespaceTaskTest); | 43 runReflectiveTests(BuildPublicNamespaceTaskTest); |
| 44 runReflectiveTests(BuildTypeProviderTaskTest); | 44 runReflectiveTests(BuildTypeProviderTaskTest); |
| 45 runReflectiveTests(GenerateHintsTaskTest); |
| 45 runReflectiveTests(ParseDartTaskTest); | 46 runReflectiveTests(ParseDartTaskTest); |
| 46 runReflectiveTests(ResolveUnitTypeNamesTaskTest); | 47 runReflectiveTests(ResolveUnitTypeNamesTaskTest); |
| 47 runReflectiveTests(ResolveLibraryTypeNamesTaskTest); | 48 runReflectiveTests(ResolveLibraryTypeNamesTaskTest); |
| 48 runReflectiveTests(ResolveReferencesTaskTest); | 49 runReflectiveTests(ResolveReferencesTaskTest); |
| 49 runReflectiveTests(ResolveVariableReferencesTaskTest); | 50 runReflectiveTests(ResolveVariableReferencesTaskTest); |
| 50 runReflectiveTests(ScanDartTaskTest); | 51 runReflectiveTests(ScanDartTaskTest); |
| 51 runReflectiveTests(VerifyUnitTaskTest); | 52 runReflectiveTests(VerifyUnitTaskTest); |
| 52 } | 53 } |
| 53 | 54 |
| 54 @reflectiveTest | 55 @reflectiveTest |
| (...skipping 1012 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1067 // validate | 1068 // validate |
| 1068 TypeProvider typeProvider = outputs[TYPE_PROVIDER]; | 1069 TypeProvider typeProvider = outputs[TYPE_PROVIDER]; |
| 1069 expect(typeProvider, isNotNull); | 1070 expect(typeProvider, isNotNull); |
| 1070 expect(typeProvider.boolType, isNotNull); | 1071 expect(typeProvider.boolType, isNotNull); |
| 1071 expect(typeProvider.intType, isNotNull); | 1072 expect(typeProvider.intType, isNotNull); |
| 1072 expect(typeProvider.futureType, isNotNull); | 1073 expect(typeProvider.futureType, isNotNull); |
| 1073 } | 1074 } |
| 1074 } | 1075 } |
| 1075 | 1076 |
| 1076 @reflectiveTest | 1077 @reflectiveTest |
| 1078 class GenerateHintsTaskTest extends _AbstractDartTaskTest { |
| 1079 test_perform_bestPractices_missingReturn() { |
| 1080 Source source = _newSource('/test.dart', ''' |
| 1081 int main() { |
| 1082 } |
| 1083 '''); |
| 1084 LibraryUnitTarget target = new LibraryUnitTarget(source, source); |
| 1085 _computeResult(target, HINTS); |
| 1086 expect(task, new isInstanceOf<GenerateHintsTask>()); |
| 1087 // validate |
| 1088 _fillErrorListener(HINTS); |
| 1089 errorListener.assertErrorsWithCodes(<ErrorCode>[HintCode.MISSING_RETURN]); |
| 1090 } |
| 1091 |
| 1092 test_perform_dart2js() { |
| 1093 // TODO(scheglov) There is a bug - we need to finish building |
| 1094 // TypeProvider hierarchies before validating "expr is CoreType". |
| 1095 // Source source = _newSource('/test.dart', ''' |
| 1096 //main(p) { |
| 1097 // if (p is double) { |
| 1098 // print('double'); |
| 1099 // } |
| 1100 //} |
| 1101 //'''); |
| 1102 // LibraryUnitTarget target = new LibraryUnitTarget(source, source); |
| 1103 // _computeResult(target, HINTS); |
| 1104 // expect(task, new isInstanceOf<GenerateHintsTask>()); |
| 1105 // // validate |
| 1106 // _fillErrorListener(HINTS); |
| 1107 // errorListener.assertErrorsWithCodes(<ErrorCode>[HintCode.IS_DOUBLE]); |
| 1108 } |
| 1109 |
| 1110 test_perform_deadCode() { |
| 1111 Source source = _newSource('/test.dart', ''' |
| 1112 main() { |
| 1113 if (false) { |
| 1114 print('how?'); |
| 1115 } |
| 1116 } |
| 1117 '''); |
| 1118 LibraryUnitTarget target = new LibraryUnitTarget(source, source); |
| 1119 _computeResult(target, HINTS); |
| 1120 expect(task, new isInstanceOf<GenerateHintsTask>()); |
| 1121 // validate |
| 1122 _fillErrorListener(HINTS); |
| 1123 errorListener.assertErrorsWithCodes(<ErrorCode>[HintCode.DEAD_CODE]); |
| 1124 } |
| 1125 |
| 1126 test_perform_overrideVerifier() { |
| 1127 Source source = _newSource('/test.dart', ''' |
| 1128 class A {} |
| 1129 class B { |
| 1130 @override |
| 1131 m() {} |
| 1132 } |
| 1133 '''); |
| 1134 LibraryUnitTarget target = new LibraryUnitTarget(source, source); |
| 1135 _computeResult(target, HINTS); |
| 1136 expect(task, new isInstanceOf<GenerateHintsTask>()); |
| 1137 // validate |
| 1138 _fillErrorListener(HINTS); |
| 1139 errorListener.assertErrorsWithCodes( |
| 1140 <ErrorCode>[HintCode.OVERRIDE_ON_NON_OVERRIDING_METHOD]); |
| 1141 } |
| 1142 |
| 1143 test_perform_todo() { |
| 1144 Source source = _newSource('/test.dart', ''' |
| 1145 main() { |
| 1146 // TODO(developer) foo bar |
| 1147 } |
| 1148 '''); |
| 1149 LibraryUnitTarget target = new LibraryUnitTarget(source, source); |
| 1150 _computeResult(target, HINTS); |
| 1151 expect(task, new isInstanceOf<GenerateHintsTask>()); |
| 1152 // validate |
| 1153 _fillErrorListener(HINTS); |
| 1154 errorListener.assertErrorsWithCodes(<ErrorCode>[TodoCode.TODO]); |
| 1155 } |
| 1156 } |
| 1157 |
| 1158 @reflectiveTest |
| 1077 class ParseDartTaskTest extends _AbstractDartTaskTest { | 1159 class ParseDartTaskTest extends _AbstractDartTaskTest { |
| 1078 test_buildInputs() { | 1160 test_buildInputs() { |
| 1079 Map<String, TaskInput> inputs = ParseDartTask.buildInputs(emptySource); | 1161 Map<String, TaskInput> inputs = ParseDartTask.buildInputs(emptySource); |
| 1080 expect(inputs, isNotNull); | 1162 expect(inputs, isNotNull); |
| 1081 expect(inputs.keys, unorderedEquals([ | 1163 expect(inputs.keys, unorderedEquals([ |
| 1082 ParseDartTask.LINE_INFO_INPUT_NAME, | 1164 ParseDartTask.LINE_INFO_INPUT_NAME, |
| 1083 ParseDartTask.TOKEN_STREAM_INPUT_NAME | 1165 ParseDartTask.TOKEN_STREAM_INPUT_NAME |
| 1084 ])); | 1166 ])); |
| 1085 } | 1167 } |
| 1086 | 1168 |
| (...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1487 taskManager.addTaskDescriptor(ScanDartTask.DESCRIPTOR); | 1569 taskManager.addTaskDescriptor(ScanDartTask.DESCRIPTOR); |
| 1488 taskManager.addTaskDescriptor(ParseDartTask.DESCRIPTOR); | 1570 taskManager.addTaskDescriptor(ParseDartTask.DESCRIPTOR); |
| 1489 taskManager.addTaskDescriptor(BuildClassConstructorsTask.DESCRIPTOR); | 1571 taskManager.addTaskDescriptor(BuildClassConstructorsTask.DESCRIPTOR); |
| 1490 taskManager.addTaskDescriptor(BuildCompilationUnitElementTask.DESCRIPTOR); | 1572 taskManager.addTaskDescriptor(BuildCompilationUnitElementTask.DESCRIPTOR); |
| 1491 taskManager.addTaskDescriptor(BuildLibraryConstructorsTask.DESCRIPTOR); | 1573 taskManager.addTaskDescriptor(BuildLibraryConstructorsTask.DESCRIPTOR); |
| 1492 taskManager.addTaskDescriptor(BuildLibraryElementTask.DESCRIPTOR); | 1574 taskManager.addTaskDescriptor(BuildLibraryElementTask.DESCRIPTOR); |
| 1493 taskManager.addTaskDescriptor(BuildPublicNamespaceTask.DESCRIPTOR); | 1575 taskManager.addTaskDescriptor(BuildPublicNamespaceTask.DESCRIPTOR); |
| 1494 taskManager.addTaskDescriptor(BuildDirectiveElementsTask.DESCRIPTOR); | 1576 taskManager.addTaskDescriptor(BuildDirectiveElementsTask.DESCRIPTOR); |
| 1495 taskManager.addTaskDescriptor(BuildExportSourceClosureTask.DESCRIPTOR); | 1577 taskManager.addTaskDescriptor(BuildExportSourceClosureTask.DESCRIPTOR); |
| 1496 taskManager.addTaskDescriptor(BuildExportNamespaceTask.DESCRIPTOR); | 1578 taskManager.addTaskDescriptor(BuildExportNamespaceTask.DESCRIPTOR); |
| 1497 taskManager.addTaskDescriptor(BuildTypeProviderTask.DESCRIPTOR); | |
| 1498 taskManager.addTaskDescriptor(BuildEnumMemberElementsTask.DESCRIPTOR); | 1579 taskManager.addTaskDescriptor(BuildEnumMemberElementsTask.DESCRIPTOR); |
| 1499 taskManager.addTaskDescriptor(BuildFunctionTypeAliasesTask.DESCRIPTOR); | 1580 taskManager.addTaskDescriptor(BuildFunctionTypeAliasesTask.DESCRIPTOR); |
| 1581 taskManager.addTaskDescriptor(BuildTypeProviderTask.DESCRIPTOR); |
| 1582 taskManager.addTaskDescriptor(GenerateHintsTask.DESCRIPTOR); |
| 1500 taskManager.addTaskDescriptor(ResolveUnitTypeNamesTask.DESCRIPTOR); | 1583 taskManager.addTaskDescriptor(ResolveUnitTypeNamesTask.DESCRIPTOR); |
| 1501 taskManager.addTaskDescriptor(ResolveLibraryTypeNamesTask.DESCRIPTOR); | 1584 taskManager.addTaskDescriptor(ResolveLibraryTypeNamesTask.DESCRIPTOR); |
| 1502 taskManager.addTaskDescriptor(ResolveReferencesTask.DESCRIPTOR); | 1585 taskManager.addTaskDescriptor(ResolveReferencesTask.DESCRIPTOR); |
| 1503 taskManager.addTaskDescriptor(ResolveVariableReferencesTask.DESCRIPTOR); | 1586 taskManager.addTaskDescriptor(ResolveVariableReferencesTask.DESCRIPTOR); |
| 1504 taskManager.addTaskDescriptor(VerifyUnitTask.DESCRIPTOR); | 1587 taskManager.addTaskDescriptor(VerifyUnitTask.DESCRIPTOR); |
| 1505 // prepare AnalysisDriver | 1588 // prepare AnalysisDriver |
| 1506 analysisDriver = new AnalysisDriver(taskManager, context); | 1589 analysisDriver = new AnalysisDriver(taskManager, context); |
| 1507 } | 1590 } |
| 1508 | 1591 |
| 1509 void _computeResult(AnalysisTarget target, ResultDescriptor result) { | 1592 void _computeResult(AnalysisTarget target, ResultDescriptor result) { |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1554 return entryMap.putIfAbsent(target, () => new CacheEntry()); | 1637 return entryMap.putIfAbsent(target, () => new CacheEntry()); |
| 1555 } | 1638 } |
| 1556 | 1639 |
| 1557 TimestampedData<String> getContents(Source source) => source.contents; | 1640 TimestampedData<String> getContents(Source source) => source.contents; |
| 1558 | 1641 |
| 1559 noSuchMethod(Invocation invocation) { | 1642 noSuchMethod(Invocation invocation) { |
| 1560 print('noSuchMethod: ${invocation.memberName}'); | 1643 print('noSuchMethod: ${invocation.memberName}'); |
| 1561 return super.noSuchMethod(invocation); | 1644 return super.noSuchMethod(invocation); |
| 1562 } | 1645 } |
| 1563 } | 1646 } |
| OLD | NEW |