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

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

Issue 1131953004: Create a task in the new task model to compute constant dependencies. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 7 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 | Annotate | Revision Log
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/element.dart'; 9 import 'package:analyzer/src/generated/element.dart';
10 import 'package:analyzer/src/generated/error.dart'; 10 import 'package:analyzer/src/generated/error.dart';
(...skipping 15 matching lines...) Expand all
26 runReflectiveTests(BuildCompilationUnitElementTaskTest); 26 runReflectiveTests(BuildCompilationUnitElementTaskTest);
27 runReflectiveTests(BuildDirectiveElementsTaskTest); 27 runReflectiveTests(BuildDirectiveElementsTaskTest);
28 runReflectiveTests(BuildEnumMemberElementsTaskTest); 28 runReflectiveTests(BuildEnumMemberElementsTaskTest);
29 runReflectiveTests(BuildSourceClosuresTaskTest); 29 runReflectiveTests(BuildSourceClosuresTaskTest);
30 runReflectiveTests(BuildExportNamespaceTaskTest); 30 runReflectiveTests(BuildExportNamespaceTaskTest);
31 runReflectiveTests(BuildFunctionTypeAliasesTaskTest); 31 runReflectiveTests(BuildFunctionTypeAliasesTaskTest);
32 runReflectiveTests(BuildLibraryConstructorsTaskTest); 32 runReflectiveTests(BuildLibraryConstructorsTaskTest);
33 runReflectiveTests(BuildLibraryElementTaskTest); 33 runReflectiveTests(BuildLibraryElementTaskTest);
34 runReflectiveTests(BuildPublicNamespaceTaskTest); 34 runReflectiveTests(BuildPublicNamespaceTaskTest);
35 runReflectiveTests(BuildTypeProviderTaskTest); 35 runReflectiveTests(BuildTypeProviderTaskTest);
36 runReflectiveTests(ComputeConstantDependenciesTaskTest);
36 runReflectiveTests(ContainingLibrariesTaskTest); 37 runReflectiveTests(ContainingLibrariesTaskTest);
37 runReflectiveTests(DartErrorsTaskTest); 38 runReflectiveTests(DartErrorsTaskTest);
38 runReflectiveTests(GatherUsedImportedElementsTaskTest); 39 runReflectiveTests(GatherUsedImportedElementsTaskTest);
39 runReflectiveTests(GatherUsedLocalElementsTaskTest); 40 runReflectiveTests(GatherUsedLocalElementsTaskTest);
40 runReflectiveTests(GenerateHintsTaskTest); 41 runReflectiveTests(GenerateHintsTaskTest);
41 runReflectiveTests(LibraryUnitErrorsTaskTest); 42 runReflectiveTests(LibraryUnitErrorsTaskTest);
42 runReflectiveTests(ParseDartTaskTest); 43 runReflectiveTests(ParseDartTaskTest);
43 runReflectiveTests(ResolveUnitTypeNamesTaskTest); 44 runReflectiveTests(ResolveUnitTypeNamesTaskTest);
44 runReflectiveTests(ResolveLibraryTypeNamesTaskTest); 45 runReflectiveTests(ResolveLibraryTypeNamesTaskTest);
45 runReflectiveTests(ResolveReferencesTaskTest); 46 runReflectiveTests(ResolveReferencesTaskTest);
(...skipping 1134 matching lines...) Expand 10 before | Expand all | Expand 10 after
1180 // validate 1181 // validate
1181 TypeProvider typeProvider = outputs[TYPE_PROVIDER]; 1182 TypeProvider typeProvider = outputs[TYPE_PROVIDER];
1182 expect(typeProvider, isNotNull); 1183 expect(typeProvider, isNotNull);
1183 expect(typeProvider.boolType, isNotNull); 1184 expect(typeProvider.boolType, isNotNull);
1184 expect(typeProvider.intType, isNotNull); 1185 expect(typeProvider.intType, isNotNull);
1185 expect(typeProvider.futureType, isNotNull); 1186 expect(typeProvider.futureType, isNotNull);
1186 } 1187 }
1187 } 1188 }
1188 1189
1189 @reflectiveTest 1190 @reflectiveTest
1191 class ComputeConstantDependenciesTaskTest extends _AbstractDartTaskTest {
1192 test_perform() {
1193 Source source = newSource('/test.dart', '''
1194 const x = y;
1195 const y = 1;
1196 ''');
1197 // First compute the library element for the source.
1198 _computeResult(source, LIBRARY_ELEMENT1);
1199 LibraryElement libraryElement = outputs[LIBRARY_ELEMENT1];
1200 // Find the elements for the constant x and y.
Brian Wilkerson 2015/05/07 22:46:59 "constant" --> "constants"
Paul Berry 2015/05/08 00:24:35 Done.
1201 List<PropertyAccessorElement> accessors =
1202 libraryElement.definingCompilationUnit.accessors;
1203 Element x = accessors.firstWhere((PropertyAccessorElement accessor) =>
1204 accessor.isGetter && accessor.name == 'x').variable;
1205 Element y = accessors.firstWhere((PropertyAccessorElement accessor) =>
1206 accessor.isGetter && accessor.name == 'y').variable;
1207 // Now compute the dependencies for x, and check that it is the list [y].
1208 _computeResult(x, CONSTANT_DEPENDENCIES);
1209 expect(outputs[CONSTANT_DEPENDENCIES], [y]);
1210 }
1211 }
1212
1213 @reflectiveTest
1190 class ContainingLibrariesTaskTest extends _AbstractDartTaskTest { 1214 class ContainingLibrariesTaskTest extends _AbstractDartTaskTest {
1191 test_buildInputs() { 1215 test_buildInputs() {
1192 Map<String, TaskInput> inputs = 1216 Map<String, TaskInput> inputs =
1193 ContainingLibrariesTask.buildInputs(emptySource); 1217 ContainingLibrariesTask.buildInputs(emptySource);
1194 expect(inputs, isNotNull); 1218 expect(inputs, isNotNull);
1195 expect(inputs, isEmpty); 1219 expect(inputs, isEmpty);
1196 } 1220 }
1197 1221
1198 test_constructor() { 1222 test_constructor() {
1199 ContainingLibrariesTask task = 1223 ContainingLibrariesTask task =
(...skipping 943 matching lines...) Expand 10 before | Expand all | Expand 10 after
2143 /** 2167 /**
2144 * Fill [errorListener] with [result] errors in the current [task]. 2168 * Fill [errorListener] with [result] errors in the current [task].
2145 */ 2169 */
2146 void _fillErrorListener(ResultDescriptor<List<AnalysisError>> result) { 2170 void _fillErrorListener(ResultDescriptor<List<AnalysisError>> result) {
2147 List<AnalysisError> errors = task.outputs[result]; 2171 List<AnalysisError> errors = task.outputs[result];
2148 expect(errors, isNotNull, reason: result.name); 2172 expect(errors, isNotNull, reason: result.name);
2149 errorListener = new GatheringErrorListener(); 2173 errorListener = new GatheringErrorListener();
2150 errorListener.addAll(errors); 2174 errorListener.addAll(errors);
2151 } 2175 }
2152 } 2176 }
OLDNEW
« pkg/analyzer/lib/src/task/dart.dart ('K') | « pkg/analyzer/test/generated/all_the_rest_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698