| 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 2159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2170 computeResult(new LibrarySpecificUnit(library, part), LIBRARY_UNIT_ERRORS); | 2170 computeResult(new LibrarySpecificUnit(library, part), LIBRARY_UNIT_ERRORS); |
| 2171 expect(task, new isInstanceOf<LibraryUnitErrorsTask>()); | 2171 expect(task, new isInstanceOf<LibraryUnitErrorsTask>()); |
| 2172 expect(outputs, hasLength(1)); | 2172 expect(outputs, hasLength(1)); |
| 2173 List<AnalysisError> errors = outputs[LIBRARY_UNIT_ERRORS]; | 2173 List<AnalysisError> errors = outputs[LIBRARY_UNIT_ERRORS]; |
| 2174 expect(errors, hasLength(0)); | 2174 expect(errors, hasLength(0)); |
| 2175 } | 2175 } |
| 2176 } | 2176 } |
| 2177 | 2177 |
| 2178 @reflectiveTest | 2178 @reflectiveTest |
| 2179 class ParseDartTaskTest extends _AbstractDartTaskTest { | 2179 class ParseDartTaskTest extends _AbstractDartTaskTest { |
| 2180 Source source; |
| 2181 |
| 2180 test_buildInputs() { | 2182 test_buildInputs() { |
| 2181 Map<String, TaskInput> inputs = ParseDartTask.buildInputs(emptySource); | 2183 Map<String, TaskInput> inputs = ParseDartTask.buildInputs(emptySource); |
| 2182 expect(inputs, isNotNull); | 2184 expect(inputs, isNotNull); |
| 2183 expect(inputs.keys, unorderedEquals([ | 2185 expect(inputs.keys, unorderedEquals([ |
| 2184 ParseDartTask.LINE_INFO_INPUT_NAME, | 2186 ParseDartTask.LINE_INFO_INPUT_NAME, |
| 2185 ParseDartTask.MODIFICATION_TIME_INPUT_NAME, | 2187 ParseDartTask.MODIFICATION_TIME_INPUT_NAME, |
| 2186 ParseDartTask.TOKEN_STREAM_INPUT_NAME | 2188 ParseDartTask.TOKEN_STREAM_INPUT_NAME |
| 2187 ])); | 2189 ])); |
| 2188 } | 2190 } |
| 2189 | 2191 |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2285 expect(outputs[EXPLICITLY_IMPORTED_LIBRARIES], hasLength(1)); | 2287 expect(outputs[EXPLICITLY_IMPORTED_LIBRARIES], hasLength(1)); |
| 2286 expect(outputs[EXPORTED_LIBRARIES], hasLength(1)); | 2288 expect(outputs[EXPORTED_LIBRARIES], hasLength(1)); |
| 2287 _assertHasCore(outputs[IMPORTED_LIBRARIES], 2); | 2289 _assertHasCore(outputs[IMPORTED_LIBRARIES], 2); |
| 2288 expect(outputs[INCLUDED_PARTS], hasLength(1)); | 2290 expect(outputs[INCLUDED_PARTS], hasLength(1)); |
| 2289 expect(outputs[PARSE_ERRORS], hasLength(1)); | 2291 expect(outputs[PARSE_ERRORS], hasLength(1)); |
| 2290 expect(outputs[PARSED_UNIT], isNotNull); | 2292 expect(outputs[PARSED_UNIT], isNotNull); |
| 2291 expect(outputs[SOURCE_KIND], SourceKind.LIBRARY); | 2293 expect(outputs[SOURCE_KIND], SourceKind.LIBRARY); |
| 2292 expect(outputs[UNITS], hasLength(2)); | 2294 expect(outputs[UNITS], hasLength(2)); |
| 2293 } | 2295 } |
| 2294 | 2296 |
| 2297 test_perform_library_selfReferenceAsPart() { |
| 2298 _performParseTask(r''' |
| 2299 library lib; |
| 2300 part 'test.dart'; |
| 2301 '''); |
| 2302 expect(outputs[INCLUDED_PARTS], unorderedEquals(<Source>[source])); |
| 2303 } |
| 2304 |
| 2295 test_perform_part() { | 2305 test_perform_part() { |
| 2296 _performParseTask(r''' | 2306 _performParseTask(r''' |
| 2297 part of lib; | 2307 part of lib; |
| 2298 class B {}'''); | 2308 class B {}'''); |
| 2299 expect(outputs, hasLength(8)); | 2309 expect(outputs, hasLength(8)); |
| 2300 expect(outputs[EXPLICITLY_IMPORTED_LIBRARIES], hasLength(0)); | 2310 expect(outputs[EXPLICITLY_IMPORTED_LIBRARIES], hasLength(0)); |
| 2301 expect(outputs[EXPORTED_LIBRARIES], hasLength(0)); | 2311 expect(outputs[EXPORTED_LIBRARIES], hasLength(0)); |
| 2302 _assertHasCore(outputs[IMPORTED_LIBRARIES], 1); | 2312 _assertHasCore(outputs[IMPORTED_LIBRARIES], 1); |
| 2303 expect(outputs[INCLUDED_PARTS], hasLength(0)); | 2313 expect(outputs[INCLUDED_PARTS], hasLength(0)); |
| 2304 expect(outputs[PARSE_ERRORS], hasLength(0)); | 2314 expect(outputs[PARSE_ERRORS], hasLength(0)); |
| 2305 expect(outputs[PARSED_UNIT], isNotNull); | 2315 expect(outputs[PARSED_UNIT], isNotNull); |
| 2306 expect(outputs[SOURCE_KIND], SourceKind.PART); | 2316 expect(outputs[SOURCE_KIND], SourceKind.PART); |
| 2307 expect(outputs[UNITS], hasLength(1)); | 2317 expect(outputs[UNITS], hasLength(1)); |
| 2308 } | 2318 } |
| 2309 | 2319 |
| 2310 void _performParseTask(String content) { | 2320 void _performParseTask(String content) { |
| 2311 AnalysisTarget target = newSource('/test.dart', content); | 2321 source = newSource('/test.dart', content); |
| 2312 computeResult(target, PARSED_UNIT); | 2322 computeResult(source, PARSED_UNIT); |
| 2313 expect(task, new isInstanceOf<ParseDartTask>()); | 2323 expect(task, new isInstanceOf<ParseDartTask>()); |
| 2314 } | 2324 } |
| 2315 | 2325 |
| 2316 static void _assertHasCore(List<Source> sources, int lenght) { | 2326 static void _assertHasCore(List<Source> sources, int lenght) { |
| 2317 expect(sources, hasLength(lenght)); | 2327 expect(sources, hasLength(lenght)); |
| 2318 expect(sources, contains(predicate((Source s) { | 2328 expect(sources, contains(predicate((Source s) { |
| 2319 return s.fullName.endsWith('core.dart'); | 2329 return s.fullName.endsWith('core.dart'); |
| 2320 }))); | 2330 }))); |
| 2321 } | 2331 } |
| 2322 } | 2332 } |
| (...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2719 /** | 2729 /** |
| 2720 * Fill [errorListener] with [result] errors in the current [task]. | 2730 * Fill [errorListener] with [result] errors in the current [task]. |
| 2721 */ | 2731 */ |
| 2722 void _fillErrorListener(ResultDescriptor<List<AnalysisError>> result) { | 2732 void _fillErrorListener(ResultDescriptor<List<AnalysisError>> result) { |
| 2723 List<AnalysisError> errors = task.outputs[result]; | 2733 List<AnalysisError> errors = task.outputs[result]; |
| 2724 expect(errors, isNotNull, reason: result.name); | 2734 expect(errors, isNotNull, reason: result.name); |
| 2725 errorListener = new GatheringErrorListener(); | 2735 errorListener = new GatheringErrorListener(); |
| 2726 errorListener.addAll(errors); | 2736 errorListener.addAll(errors); |
| 2727 } | 2737 } |
| 2728 } | 2738 } |
| OLD | NEW |