| 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'; |
| 11 import 'package:analyzer/src/generated/engine.dart' show CacheState; | 11 import 'package:analyzer/src/generated/engine.dart' |
| 12 show AnalysisOptionsImpl, CacheState; |
| 12 import 'package:analyzer/src/generated/error.dart'; | 13 import 'package:analyzer/src/generated/error.dart'; |
| 13 import 'package:analyzer/src/generated/resolver.dart'; | 14 import 'package:analyzer/src/generated/resolver.dart'; |
| 14 import 'package:analyzer/src/generated/source.dart'; | 15 import 'package:analyzer/src/generated/source.dart'; |
| 15 import 'package:analyzer/src/task/dart.dart'; | 16 import 'package:analyzer/src/task/dart.dart'; |
| 16 import 'package:analyzer/task/dart.dart'; | 17 import 'package:analyzer/task/dart.dart'; |
| 17 import 'package:analyzer/task/general.dart'; | 18 import 'package:analyzer/task/general.dart'; |
| 18 import 'package:analyzer/task/model.dart'; | 19 import 'package:analyzer/task/model.dart'; |
| 19 import 'package:unittest/unittest.dart'; | 20 import 'package:unittest/unittest.dart'; |
| 20 | 21 |
| 21 import '../../generated/test_support.dart'; | 22 import '../../generated/test_support.dart'; |
| (...skipping 1869 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1891 } | 1892 } |
| 1892 '''); | 1893 '''); |
| 1893 LibrarySpecificUnit target = new LibrarySpecificUnit(source, source); | 1894 LibrarySpecificUnit target = new LibrarySpecificUnit(source, source); |
| 1894 _computeResult(target, HINTS); | 1895 _computeResult(target, HINTS); |
| 1895 expect(task, new isInstanceOf<GenerateHintsTask>()); | 1896 expect(task, new isInstanceOf<GenerateHintsTask>()); |
| 1896 // validate | 1897 // validate |
| 1897 _fillErrorListener(HINTS); | 1898 _fillErrorListener(HINTS); |
| 1898 errorListener.assertErrorsWithCodes(<ErrorCode>[HintCode.DEAD_CODE]); | 1899 errorListener.assertErrorsWithCodes(<ErrorCode>[HintCode.DEAD_CODE]); |
| 1899 } | 1900 } |
| 1900 | 1901 |
| 1902 test_perform_disabled() { |
| 1903 context.analysisOptions = |
| 1904 new AnalysisOptionsImpl.from(context.analysisOptions)..hint = false; |
| 1905 Source source = newSource('/test.dart', ''' |
| 1906 int main() { |
| 1907 } |
| 1908 '''); |
| 1909 LibrarySpecificUnit target = new LibrarySpecificUnit(source, source); |
| 1910 _computeResult(target, HINTS); |
| 1911 expect(task, new isInstanceOf<GenerateHintsTask>()); |
| 1912 // validate |
| 1913 _fillErrorListener(HINTS); |
| 1914 errorListener.assertNoErrors(); |
| 1915 } |
| 1916 |
| 1901 test_perform_imports_duplicateImport() { | 1917 test_perform_imports_duplicateImport() { |
| 1902 newSource('/a.dart', r''' | 1918 newSource('/a.dart', r''' |
| 1903 library lib_a; | 1919 library lib_a; |
| 1904 class A {} | 1920 class A {} |
| 1905 '''); | 1921 '''); |
| 1906 Source source = newSource('/test.dart', r''' | 1922 Source source = newSource('/test.dart', r''' |
| 1907 import 'a.dart'; | 1923 import 'a.dart'; |
| 1908 import 'a.dart'; | 1924 import 'a.dart'; |
| 1909 main() { | 1925 main() { |
| 1910 new A(); | 1926 new A(); |
| (...skipping 758 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2669 /** | 2685 /** |
| 2670 * Fill [errorListener] with [result] errors in the current [task]. | 2686 * Fill [errorListener] with [result] errors in the current [task]. |
| 2671 */ | 2687 */ |
| 2672 void _fillErrorListener(ResultDescriptor<List<AnalysisError>> result) { | 2688 void _fillErrorListener(ResultDescriptor<List<AnalysisError>> result) { |
| 2673 List<AnalysisError> errors = task.outputs[result]; | 2689 List<AnalysisError> errors = task.outputs[result]; |
| 2674 expect(errors, isNotNull, reason: result.name); | 2690 expect(errors, isNotNull, reason: result.name); |
| 2675 errorListener = new GatheringErrorListener(); | 2691 errorListener = new GatheringErrorListener(); |
| 2676 errorListener.addAll(errors); | 2692 errorListener.addAll(errors); |
| 2677 } | 2693 } |
| 2678 } | 2694 } |
| OLD | NEW |