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

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

Issue 1422793002: Use LIBRARY_SPECIFIC_UNITS instead of UNITS. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 2 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
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 2781 matching lines...) Expand 10 before | Expand all | Expand 10 after
2792 } 2792 }
2793 2793
2794 @reflectiveTest 2794 @reflectiveTest
2795 class ParseDartTaskTest extends _AbstractDartTaskTest { 2795 class ParseDartTaskTest extends _AbstractDartTaskTest {
2796 Source source; 2796 Source source;
2797 2797
2798 test_perform() { 2798 test_perform() {
2799 _performParseTask(r''' 2799 _performParseTask(r'''
2800 part of lib; 2800 part of lib;
2801 class B {}'''); 2801 class B {}''');
2802 expect(outputs, hasLength(8)); 2802 expect(outputs, hasLength(9));
2803 expect(outputs[EXPLICITLY_IMPORTED_LIBRARIES], hasLength(0)); 2803 expect(outputs[EXPLICITLY_IMPORTED_LIBRARIES], hasLength(0));
2804 expect(outputs[EXPORTED_LIBRARIES], hasLength(0)); 2804 expect(outputs[EXPORTED_LIBRARIES], hasLength(0));
2805 _assertHasCore(outputs[IMPORTED_LIBRARIES], 1); 2805 _assertHasCore(outputs[IMPORTED_LIBRARIES], 1);
2806 expect(outputs[INCLUDED_PARTS], hasLength(0)); 2806 expect(outputs[INCLUDED_PARTS], hasLength(0));
2807 expect(outputs[LIBRARY_SPECIFIC_UNITS], hasLength(1));
2807 expect(outputs[PARSE_ERRORS], hasLength(0)); 2808 expect(outputs[PARSE_ERRORS], hasLength(0));
2808 expect(outputs[PARSED_UNIT], isNotNull); 2809 expect(outputs[PARSED_UNIT], isNotNull);
2809 expect(outputs[SOURCE_KIND], SourceKind.PART); 2810 expect(outputs[SOURCE_KIND], SourceKind.PART);
2810 expect(outputs[UNITS], hasLength(1)); 2811 expect(outputs[UNITS], hasLength(1));
2811 } 2812 }
2812 2813
2813 test_perform_computeSourceKind_noDirectives_hasContainingLibrary() { 2814 test_perform_computeSourceKind_noDirectives_hasContainingLibrary() {
2814 // Parse "lib.dart" to let the context know that "test.dart" is included. 2815 // Parse "lib.dart" to let the context know that "test.dart" is included.
2815 computeResult( 2816 computeResult(
2816 newSource( 2817 newSource(
2817 '/lib.dart', 2818 '/lib.dart',
2818 r''' 2819 r'''
2819 library lib; 2820 library lib;
2820 part 'test.dart'; 2821 part 'test.dart';
2821 '''), 2822 '''),
2822 PARSED_UNIT); 2823 PARSED_UNIT);
2823 // If there are no the "part of" directive, then it is not a part. 2824 // If there are no the "part of" directive, then it is not a part.
2824 _performParseTask(''); 2825 _performParseTask('');
2825 expect(outputs[SOURCE_KIND], SourceKind.LIBRARY); 2826 expect(outputs[SOURCE_KIND], SourceKind.LIBRARY);
2826 } 2827 }
2827 2828
2828 test_perform_computeSourceKind_noDirectives_noContainingLibrary() { 2829 test_perform_computeSourceKind_noDirectives_noContainingLibrary() {
2829 _performParseTask(''); 2830 _performParseTask('');
2830 expect(outputs[SOURCE_KIND], SourceKind.LIBRARY); 2831 expect(outputs[SOURCE_KIND], SourceKind.LIBRARY);
2831 } 2832 }
2832 2833
2833 test_perform_doesNotExist() { 2834 test_perform_doesNotExist() {
2834 _performParseTask(null); 2835 _performParseTask(null);
2835 expect(outputs, hasLength(8)); 2836 expect(outputs, hasLength(9));
2836 expect(outputs[EXPLICITLY_IMPORTED_LIBRARIES], hasLength(0)); 2837 expect(outputs[EXPLICITLY_IMPORTED_LIBRARIES], hasLength(0));
2837 expect(outputs[EXPORTED_LIBRARIES], hasLength(0)); 2838 expect(outputs[EXPORTED_LIBRARIES], hasLength(0));
2838 _assertHasCore(outputs[IMPORTED_LIBRARIES], 1); 2839 _assertHasCore(outputs[IMPORTED_LIBRARIES], 1);
2839 expect(outputs[INCLUDED_PARTS], hasLength(0)); 2840 expect(outputs[INCLUDED_PARTS], hasLength(0));
2841 expect(outputs[LIBRARY_SPECIFIC_UNITS], hasLength(1));
2840 expect(outputs[PARSE_ERRORS], hasLength(0)); 2842 expect(outputs[PARSE_ERRORS], hasLength(0));
2841 expect(outputs[PARSED_UNIT], isNotNull); 2843 expect(outputs[PARSED_UNIT], isNotNull);
2842 expect(outputs[SOURCE_KIND], SourceKind.UNKNOWN); 2844 expect(outputs[SOURCE_KIND], SourceKind.UNKNOWN);
2843 expect(outputs[UNITS], hasLength(1)); 2845 expect(outputs[UNITS], hasLength(1));
2844 } 2846 }
2845 2847
2846 test_perform_invalidDirectives() { 2848 test_perform_invalidDirectives() {
2847 _performParseTask(r''' 2849 _performParseTask(r'''
2848 library lib; 2850 library lib;
2849 import '/does/not/exist.dart'; 2851 import '/does/not/exist.dart';
2850 import '://invaliduri.dart'; 2852 import '://invaliduri.dart';
2851 export '${a}lib3.dart'; 2853 export '${a}lib3.dart';
2852 part 'part.dart'; 2854 part 'part.dart';
2853 class A {}'''); 2855 class A {}''');
2854 expect(outputs, hasLength(8)); 2856 expect(outputs, hasLength(9));
2855 expect(outputs[EXPLICITLY_IMPORTED_LIBRARIES], hasLength(1)); 2857 expect(outputs[EXPLICITLY_IMPORTED_LIBRARIES], hasLength(1));
2856 expect(outputs[EXPORTED_LIBRARIES], hasLength(0)); 2858 expect(outputs[EXPORTED_LIBRARIES], hasLength(0));
2857 _assertHasCore(outputs[IMPORTED_LIBRARIES], 2); 2859 _assertHasCore(outputs[IMPORTED_LIBRARIES], 2);
2858 expect(outputs[INCLUDED_PARTS], hasLength(1)); 2860 expect(outputs[INCLUDED_PARTS], hasLength(1));
2861 expect(outputs[LIBRARY_SPECIFIC_UNITS], hasLength(2));
2859 expect(outputs[PARSE_ERRORS], hasLength(2)); 2862 expect(outputs[PARSE_ERRORS], hasLength(2));
2860 expect(outputs[PARSED_UNIT], isNotNull); 2863 expect(outputs[PARSED_UNIT], isNotNull);
2861 expect(outputs[SOURCE_KIND], SourceKind.LIBRARY); 2864 expect(outputs[SOURCE_KIND], SourceKind.LIBRARY);
2862 expect(outputs[UNITS], hasLength(2)); 2865 expect(outputs[UNITS], hasLength(2));
2863 } 2866 }
2864 2867
2865 test_perform_library() { 2868 test_perform_library() {
2866 _performParseTask(r''' 2869 _performParseTask(r'''
2867 library lib; 2870 library lib;
2868 import 'lib2.dart'; 2871 import 'lib2.dart';
2869 export 'lib3.dart'; 2872 export 'lib3.dart';
2870 part 'part.dart'; 2873 part 'part.dart';
2871 class A {'''); 2874 class A {''');
2872 expect(outputs, hasLength(8)); 2875 expect(outputs, hasLength(9));
2873 expect(outputs[EXPLICITLY_IMPORTED_LIBRARIES], hasLength(1)); 2876 expect(outputs[EXPLICITLY_IMPORTED_LIBRARIES], hasLength(1));
2874 expect(outputs[EXPORTED_LIBRARIES], hasLength(1)); 2877 expect(outputs[EXPORTED_LIBRARIES], hasLength(1));
2875 _assertHasCore(outputs[IMPORTED_LIBRARIES], 2); 2878 _assertHasCore(outputs[IMPORTED_LIBRARIES], 2);
2876 expect(outputs[INCLUDED_PARTS], hasLength(1)); 2879 expect(outputs[INCLUDED_PARTS], hasLength(1));
2880 expect(outputs[LIBRARY_SPECIFIC_UNITS], hasLength(2));
2877 expect(outputs[PARSE_ERRORS], hasLength(1)); 2881 expect(outputs[PARSE_ERRORS], hasLength(1));
2878 expect(outputs[PARSED_UNIT], isNotNull); 2882 expect(outputs[PARSED_UNIT], isNotNull);
2879 expect(outputs[SOURCE_KIND], SourceKind.LIBRARY); 2883 expect(outputs[SOURCE_KIND], SourceKind.LIBRARY);
2880 expect(outputs[UNITS], hasLength(2)); 2884 expect(outputs[UNITS], hasLength(2));
2881 } 2885 }
2882 2886
2883 test_perform_library_selfReferenceAsPart() { 2887 test_perform_library_selfReferenceAsPart() {
2884 _performParseTask(r''' 2888 _performParseTask(r'''
2885 library lib; 2889 library lib;
2886 part 'test.dart'; 2890 part 'test.dart';
2887 '''); 2891 ''');
2888 expect(outputs[INCLUDED_PARTS], unorderedEquals(<Source>[source])); 2892 expect(outputs[INCLUDED_PARTS], unorderedEquals(<Source>[source]));
2889 } 2893 }
2890 2894
2891 test_perform_part() { 2895 test_perform_part() {
2892 _performParseTask(r''' 2896 _performParseTask(r'''
2893 part of lib; 2897 part of lib;
2894 class B {}'''); 2898 class B {}''');
2895 expect(outputs, hasLength(8)); 2899 expect(outputs, hasLength(9));
2896 expect(outputs[EXPLICITLY_IMPORTED_LIBRARIES], hasLength(0)); 2900 expect(outputs[EXPLICITLY_IMPORTED_LIBRARIES], hasLength(0));
2897 expect(outputs[EXPORTED_LIBRARIES], hasLength(0)); 2901 expect(outputs[EXPORTED_LIBRARIES], hasLength(0));
2898 _assertHasCore(outputs[IMPORTED_LIBRARIES], 1); 2902 _assertHasCore(outputs[IMPORTED_LIBRARIES], 1);
2899 expect(outputs[INCLUDED_PARTS], hasLength(0)); 2903 expect(outputs[INCLUDED_PARTS], hasLength(0));
2904 expect(outputs[LIBRARY_SPECIFIC_UNITS], hasLength(1));
2900 expect(outputs[PARSE_ERRORS], hasLength(0)); 2905 expect(outputs[PARSE_ERRORS], hasLength(0));
2901 expect(outputs[PARSED_UNIT], isNotNull); 2906 expect(outputs[PARSED_UNIT], isNotNull);
2902 expect(outputs[SOURCE_KIND], SourceKind.PART); 2907 expect(outputs[SOURCE_KIND], SourceKind.PART);
2903 expect(outputs[UNITS], hasLength(1)); 2908 expect(outputs[UNITS], hasLength(1));
2904 } 2909 }
2905 2910
2906 void _performParseTask(String content) { 2911 void _performParseTask(String content) {
2907 source = newSource('/test.dart', content); 2912 source = newSource('/test.dart', content);
2908 computeResult(source, PARSED_UNIT, matcher: isParseDartTask); 2913 computeResult(source, PARSED_UNIT, matcher: isParseDartTask);
2909 } 2914 }
(...skipping 1502 matching lines...) Expand 10 before | Expand all | Expand 10 after
4412 /** 4417 /**
4413 * Fill [errorListener] with [result] errors in the current [task]. 4418 * Fill [errorListener] with [result] errors in the current [task].
4414 */ 4419 */
4415 void _fillErrorListener(ResultDescriptor<List<AnalysisError>> result) { 4420 void _fillErrorListener(ResultDescriptor<List<AnalysisError>> result) {
4416 List<AnalysisError> errors = task.outputs[result]; 4421 List<AnalysisError> errors = task.outputs[result];
4417 expect(errors, isNotNull, reason: result.name); 4422 expect(errors, isNotNull, reason: result.name);
4418 errorListener = new GatheringErrorListener(); 4423 errorListener = new GatheringErrorListener();
4419 errorListener.addAll(errors); 4424 errorListener.addAll(errors);
4420 } 4425 }
4421 } 4426 }
OLDNEW
« pkg/analyzer/lib/src/task/dart.dart ('K') | « pkg/analyzer/lib/task/model.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698