Chromium Code Reviews| Index: pkg/analyzer/test/src/task/dart_test.dart |
| diff --git a/pkg/analyzer/test/src/task/dart_test.dart b/pkg/analyzer/test/src/task/dart_test.dart |
| index ff6418191292c5a847a6d2846fa86bb8143a148b..f631d3949c4004983386141a649ec59052add915 100644 |
| --- a/pkg/analyzer/test/src/task/dart_test.dart |
| +++ b/pkg/analyzer/test/src/task/dart_test.dart |
| @@ -40,6 +40,7 @@ main() { |
| runReflectiveTests(BuildTypeProviderTaskTest); |
| runReflectiveTests(ComputeConstantDependenciesTaskTest); |
| runReflectiveTests(ComputeConstantValueTaskTest); |
| + runReflectiveTests(ComputeInferableStaticVariableDependenciesTaskTest); |
| runReflectiveTests(ContainingLibrariesTaskTest); |
| runReflectiveTests(DartErrorsTaskTest); |
| runReflectiveTests(EvaluateUnitConstantsTaskTest); |
| @@ -63,15 +64,6 @@ class BuildCompilationUnitElementTaskTest extends _AbstractDartTaskTest { |
| Source source; |
| LibrarySpecificUnit target; |
| - /** |
| - * Enable strong mode in the current analysis context. |
| - */ |
| - void enableStrongMode() { |
| - AnalysisOptionsImpl options = context.analysisOptions; |
| - options.strongMode = true; |
| - context.analysisOptions = options; |
| - } |
| - |
| test_buildInputs() { |
| LibrarySpecificUnit target = |
| new LibrarySpecificUnit(emptySource, emptySource); |
| @@ -112,7 +104,6 @@ class BuildCompilationUnitElementTaskTest extends _AbstractDartTaskTest { |
| } |
| test_perform_find_constants_strong() { |
| - enableStrongMode(); |
| _performBuildTask(''' |
| const x = 1; |
| class C { |
| @@ -138,10 +129,8 @@ f() { |
| context, source, source, annotation), |
| unitElement.types[0].constructors[0].parameters[0] |
| ]; |
| - expect(outputs[CLASSES_IN_UNIT], hasLength(1)); |
| expect( |
| outputs[COMPILATION_UNIT_CONSTANTS].toSet(), expectedConstants.toSet()); |
| - expect(outputs[INFERABLE_STATIC_VARIABLES_IN_UNIT], hasLength(2)); |
| } |
| test_perform_find_constants_weak() { |
|
Paul Berry
2015/08/27 18:56:08
It looks like this test is now the same as the pre
Brian Wilkerson
2015/08/27 20:43:54
Done
|
| @@ -170,14 +159,11 @@ f() { |
| context, source, source, annotation), |
| unitElement.types[0].constructors[0].parameters[0] |
| ]; |
| - expect(outputs[CLASSES_IN_UNIT], hasLength(0)); |
| expect( |
| outputs[COMPILATION_UNIT_CONSTANTS].toSet(), expectedConstants.toSet()); |
| - expect(outputs[INFERABLE_STATIC_VARIABLES_IN_UNIT], hasLength(0)); |
| } |
| test_perform_library_strong() { |
| - enableStrongMode(); |
| _performBuildTask(r''' |
| library lib; |
| import 'lib2.dart'; |
| @@ -189,11 +175,9 @@ class A { |
| } |
| class B = Object with A; |
| '''); |
| - expect(outputs, hasLength(5)); |
| - expect(outputs[CLASSES_IN_UNIT], hasLength(2)); |
| + expect(outputs, hasLength(3)); |
| expect(outputs[COMPILATION_UNIT_CONSTANTS], isNotNull); |
| expect(outputs[COMPILATION_UNIT_ELEMENT], isNotNull); |
| - expect(outputs[INFERABLE_STATIC_VARIABLES_IN_UNIT], hasLength(2)); |
| expect(outputs[RESOLVED_UNIT1], isNotNull); |
| } |
| @@ -209,11 +193,9 @@ class A { |
| } |
| class B = Object with A; |
| '''); |
| - expect(outputs, hasLength(5)); |
| - expect(outputs[CLASSES_IN_UNIT], hasLength(0)); |
| + expect(outputs, hasLength(3)); |
| expect(outputs[COMPILATION_UNIT_CONSTANTS], isNotNull); |
| expect(outputs[COMPILATION_UNIT_ELEMENT], isNotNull); |
| - expect(outputs[INFERABLE_STATIC_VARIABLES_IN_UNIT], hasLength(0)); |
| expect(outputs[RESOLVED_UNIT1], isNotNull); |
| } |
| @@ -1556,6 +1538,32 @@ const x = 1; |
| } |
| @reflectiveTest |
| +class ComputeInferableStaticVariableDependenciesTaskTest |
| + extends _AbstractDartTaskTest { |
| + test_perform() { |
| + AnalysisTarget source = newSource( |
| + '/test.dart', |
| + ''' |
| +const a = b; |
| +const b = 0; |
| +'''); |
| + LibrarySpecificUnit target = new LibrarySpecificUnit(source, source); |
| + computeResult(target, RESOLVED_UNIT5); |
| + CompilationUnit unit = outputs[RESOLVED_UNIT5]; |
| + TopLevelVariableElement elementA = unit.element.topLevelVariables[0]; |
| + TopLevelVariableElement elementB = unit.element.topLevelVariables[1]; |
| + |
| + computeResult(elementA, INFERABLE_STATIC_VARIABLE_DEPENDENCIES); |
| + expect(task, |
| + new isInstanceOf<ComputeInferableStaticVariableDependenciesTask>()); |
| + expect(outputs, hasLength(1)); |
| + Set<VariableElement> dependencies = |
| + outputs[INFERABLE_STATIC_VARIABLE_DEPENDENCIES]; |
| + expect(dependencies, unorderedEquals([elementB])); |
| + } |
| +} |
| + |
| +@reflectiveTest |
| class ContainingLibrariesTaskTest extends _AbstractDartTaskTest { |
| test_buildInputs() { |
| Map<String, TaskInput> inputs = |
| @@ -2336,16 +2344,25 @@ class B {}'''); |
| @reflectiveTest |
| class PartiallyResolveReferencesTaskTest extends _AbstractDartTaskTest { |
| test_perform() { |
| + enableStrongMode(); |
| Source source = newSource( |
| '/test.dart', |
| ''' |
| int a = b; |
| int b = c; |
| +var d = 0; |
| +class A {} |
| +class C { |
| + static final f = ''; |
| + var g = 0; |
| +} |
| '''); |
| LibrarySpecificUnit target = new LibrarySpecificUnit(source, source); |
| computeResult(target, RESOLVED_UNIT5); |
| expect(task, new isInstanceOf<PartiallyResolveUnitReferencesTask>()); |
| // Test the outputs |
| + expect(outputs[CLASSES_IN_UNIT], hasLength(2)); |
| + expect(outputs[INFERABLE_STATIC_VARIABLES_IN_UNIT], hasLength(2)); |
| CompilationUnit unit = outputs[RESOLVED_UNIT5]; |
| expect(unit, same(outputs[RESOLVED_UNIT5])); |
| // Test the state of the AST |
| @@ -2386,6 +2403,8 @@ main() { |
| computeResult(new LibrarySpecificUnit(sourceC, sourceC), RESOLVED_UNIT5); |
| expect(task, new isInstanceOf<PartiallyResolveUnitReferencesTask>()); |
| // validate |
| + expect(outputs[CLASSES_IN_UNIT], hasLength(0)); |
| + expect(outputs[INFERABLE_STATIC_VARIABLES_IN_UNIT], hasLength(0)); |
| CompilationUnit unit = outputs[RESOLVED_UNIT5]; |
| expect(unit, isNotNull); |
| @@ -2901,6 +2920,15 @@ class _AbstractDartTaskTest extends AbstractContextTest { |
| source, [new ScriptFragment(97, 5, 36, scriptContent)]); |
| } |
| + /** |
| + * Enable strong mode in the current analysis context. |
| + */ |
| + void enableStrongMode() { |
| + AnalysisOptionsImpl options = context.analysisOptions; |
| + options.strongMode = true; |
| + context.analysisOptions = options; |
| + } |
| + |
| void setUp() { |
| super.setUp(); |
| emptySource = newSource('/test.dart'); |