Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(508)

Side by Side Diff: pkg/analyzer/test/src/task/dart_test.dart

Issue 1167773002: Record SourceKind.UNKNOWN for not existing sources. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « pkg/analyzer/lib/src/task/dart.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
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 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/task/dart.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698