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 2075 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2086 } | 2086 } |
2087 } | 2087 } |
2088 | 2088 |
2089 @reflectiveTest | 2089 @reflectiveTest |
2090 class ParseDartTaskTest extends _AbstractDartTaskTest { | 2090 class ParseDartTaskTest extends _AbstractDartTaskTest { |
2091 test_buildInputs() { | 2091 test_buildInputs() { |
2092 Map<String, TaskInput> inputs = ParseDartTask.buildInputs(emptySource); | 2092 Map<String, TaskInput> inputs = ParseDartTask.buildInputs(emptySource); |
2093 expect(inputs, isNotNull); | 2093 expect(inputs, isNotNull); |
2094 expect(inputs.keys, unorderedEquals([ | 2094 expect(inputs.keys, unorderedEquals([ |
2095 ParseDartTask.LINE_INFO_INPUT_NAME, | 2095 ParseDartTask.LINE_INFO_INPUT_NAME, |
| 2096 ParseDartTask.MODIFICATION_TIME_INPUT_NAME, |
2096 ParseDartTask.TOKEN_STREAM_INPUT_NAME | 2097 ParseDartTask.TOKEN_STREAM_INPUT_NAME |
2097 ])); | 2098 ])); |
2098 } | 2099 } |
2099 | 2100 |
2100 test_constructor() { | 2101 test_constructor() { |
2101 ParseDartTask task = new ParseDartTask(context, emptySource); | 2102 ParseDartTask task = new ParseDartTask(context, emptySource); |
2102 expect(task, isNotNull); | 2103 expect(task, isNotNull); |
2103 expect(task.context, context); | 2104 expect(task.context, context); |
2104 expect(task.target, emptySource); | 2105 expect(task.target, emptySource); |
2105 } | 2106 } |
(...skipping 23 matching lines...) Expand all Loading... |
2129 expect(outputs[EXPLICITLY_IMPORTED_LIBRARIES], hasLength(0)); | 2130 expect(outputs[EXPLICITLY_IMPORTED_LIBRARIES], hasLength(0)); |
2130 expect(outputs[EXPORTED_LIBRARIES], hasLength(0)); | 2131 expect(outputs[EXPORTED_LIBRARIES], hasLength(0)); |
2131 _assertHasCore(outputs[IMPORTED_LIBRARIES], 1); | 2132 _assertHasCore(outputs[IMPORTED_LIBRARIES], 1); |
2132 expect(outputs[INCLUDED_PARTS], hasLength(0)); | 2133 expect(outputs[INCLUDED_PARTS], hasLength(0)); |
2133 expect(outputs[PARSE_ERRORS], hasLength(0)); | 2134 expect(outputs[PARSE_ERRORS], hasLength(0)); |
2134 expect(outputs[PARSED_UNIT], isNotNull); | 2135 expect(outputs[PARSED_UNIT], isNotNull); |
2135 expect(outputs[SOURCE_KIND], SourceKind.PART); | 2136 expect(outputs[SOURCE_KIND], SourceKind.PART); |
2136 expect(outputs[UNITS], hasLength(1)); | 2137 expect(outputs[UNITS], hasLength(1)); |
2137 } | 2138 } |
2138 | 2139 |
| 2140 test_perform_doesNotExist() { |
| 2141 _performParseTask(null); |
| 2142 expect(outputs, hasLength(8)); |
| 2143 expect(outputs[EXPLICITLY_IMPORTED_LIBRARIES], hasLength(0)); |
| 2144 expect(outputs[EXPORTED_LIBRARIES], hasLength(0)); |
| 2145 _assertHasCore(outputs[IMPORTED_LIBRARIES], 1); |
| 2146 expect(outputs[INCLUDED_PARTS], hasLength(0)); |
| 2147 expect(outputs[PARSE_ERRORS], hasLength(0)); |
| 2148 expect(outputs[PARSED_UNIT], isNotNull); |
| 2149 expect(outputs[SOURCE_KIND], SourceKind.UNKNOWN); |
| 2150 expect(outputs[UNITS], hasLength(1)); |
| 2151 } |
| 2152 |
2139 test_perform_invalidDirectives() { | 2153 test_perform_invalidDirectives() { |
2140 _performParseTask(r''' | 2154 _performParseTask(r''' |
2141 library lib; | 2155 library lib; |
2142 import '/does/not/exist.dart'; | 2156 import '/does/not/exist.dart'; |
2143 import '://invaliduri.dart'; | 2157 import '://invaliduri.dart'; |
2144 export '${a}lib3.dart'; | 2158 export '${a}lib3.dart'; |
2145 part 'part.dart'; | 2159 part 'part.dart'; |
2146 class A {}'''); | 2160 class A {}'''); |
2147 expect(outputs, hasLength(8)); | 2161 expect(outputs, hasLength(8)); |
2148 expect(outputs[EXPLICITLY_IMPORTED_LIBRARIES], hasLength(1)); | 2162 expect(outputs[EXPLICITLY_IMPORTED_LIBRARIES], hasLength(1)); |
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2534 /** | 2548 /** |
2535 * Fill [errorListener] with [result] errors in the current [task]. | 2549 * Fill [errorListener] with [result] errors in the current [task]. |
2536 */ | 2550 */ |
2537 void _fillErrorListener(ResultDescriptor<List<AnalysisError>> result) { | 2551 void _fillErrorListener(ResultDescriptor<List<AnalysisError>> result) { |
2538 List<AnalysisError> errors = task.outputs[result]; | 2552 List<AnalysisError> errors = task.outputs[result]; |
2539 expect(errors, isNotNull, reason: result.name); | 2553 expect(errors, isNotNull, reason: result.name); |
2540 errorListener = new GatheringErrorListener(); | 2554 errorListener = new GatheringErrorListener(); |
2541 errorListener.addAll(errors); | 2555 errorListener.addAll(errors); |
2542 } | 2556 } |
2543 } | 2557 } |
OLD | NEW |