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

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

Issue 1602803002: Clean-up imports (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 years, 11 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 analyzer.test.src.task.dart_test; 5 library analyzer.test.src.task.dart_test;
6 6
7 import 'package:analyzer/dart/ast/ast.dart';
8 import 'package:analyzer/dart/ast/visitor.dart';
7 import 'package:analyzer/dart/element/element.dart'; 9 import 'package:analyzer/dart/element/element.dart';
8 import 'package:analyzer/dart/element/type.dart'; 10 import 'package:analyzer/dart/element/type.dart';
9 import 'package:analyzer/src/context/cache.dart'; 11 import 'package:analyzer/src/context/cache.dart';
10 import 'package:analyzer/src/dart/element/element.dart'; 12 import 'package:analyzer/src/dart/element/element.dart';
11 import 'package:analyzer/src/generated/ast.dart';
12 import 'package:analyzer/src/generated/constant.dart'; 13 import 'package:analyzer/src/generated/constant.dart';
13 import 'package:analyzer/src/generated/engine.dart' 14 import 'package:analyzer/src/generated/engine.dart'
14 show AnalysisOptions, AnalysisOptionsImpl, CacheState; 15 show AnalysisOptions, AnalysisOptionsImpl, CacheState;
15 import 'package:analyzer/src/generated/error.dart'; 16 import 'package:analyzer/src/generated/error.dart';
16 import 'package:analyzer/src/generated/resolver.dart'; 17 import 'package:analyzer/src/generated/resolver.dart';
17 import 'package:analyzer/src/generated/scanner.dart'; 18 import 'package:analyzer/src/generated/scanner.dart';
18 import 'package:analyzer/src/generated/sdk.dart'; 19 import 'package:analyzer/src/generated/sdk.dart';
19 import 'package:analyzer/src/generated/source.dart'; 20 import 'package:analyzer/src/generated/source.dart';
20 import 'package:analyzer/src/services/lint.dart'; 21 import 'package:analyzer/src/services/lint.dart';
21 import 'package:analyzer/src/task/dart.dart'; 22 import 'package:analyzer/src/task/dart.dart';
(...skipping 2992 matching lines...) Expand 10 before | Expand all | Expand 10 after
3014 expect(outputs[EXPORTED_LIBRARIES], hasLength(0)); 3015 expect(outputs[EXPORTED_LIBRARIES], hasLength(0));
3015 _assertHasCore(outputs[IMPORTED_LIBRARIES], 1); 3016 _assertHasCore(outputs[IMPORTED_LIBRARIES], 1);
3016 expect(outputs[INCLUDED_PARTS], hasLength(0)); 3017 expect(outputs[INCLUDED_PARTS], hasLength(0));
3017 expect(outputs[LIBRARY_SPECIFIC_UNITS], hasLength(1)); 3018 expect(outputs[LIBRARY_SPECIFIC_UNITS], hasLength(1));
3018 expect(outputs[PARSE_ERRORS], hasLength(0)); 3019 expect(outputs[PARSE_ERRORS], hasLength(0));
3019 expect(outputs[PARSED_UNIT], isNotNull); 3020 expect(outputs[PARSED_UNIT], isNotNull);
3020 expect(outputs[SOURCE_KIND], SourceKind.PART); 3021 expect(outputs[SOURCE_KIND], SourceKind.PART);
3021 expect(outputs[UNITS], hasLength(1)); 3022 expect(outputs[UNITS], hasLength(1));
3022 } 3023 }
3023 3024
3025 test_perform_computeSourceKind_noDirectives_hasContainingLibrary() {
3026 // Parse "lib.dart" to let the context know that "test.dart" is included.
3027 computeResult(
3028 newSource(
3029 '/lib.dart',
3030 r'''
3031 library lib;
3032 part 'test.dart';
3033 '''),
3034 PARSED_UNIT);
3035 // If there are no the "part of" directive, then it is not a part.
3036 _performParseTask('');
3037 expect(outputs[SOURCE_KIND], SourceKind.LIBRARY);
3038 }
3039
3040 test_perform_computeSourceKind_noDirectives_noContainingLibrary() {
3041 _performParseTask('');
3042 expect(outputs[SOURCE_KIND], SourceKind.LIBRARY);
3043 }
3044
3045 test_perform_doesNotExist() {
3046 _performParseTask(null);
3047 expect(outputs, hasLength(9));
3048 expect(outputs[EXPLICITLY_IMPORTED_LIBRARIES], hasLength(0));
3049 expect(outputs[EXPORTED_LIBRARIES], hasLength(0));
3050 _assertHasCore(outputs[IMPORTED_LIBRARIES], 1);
3051 expect(outputs[INCLUDED_PARTS], hasLength(0));
3052 expect(outputs[LIBRARY_SPECIFIC_UNITS], hasLength(1));
3053 expect(outputs[PARSE_ERRORS], hasLength(0));
3054 expect(outputs[PARSED_UNIT], isNotNull);
3055 expect(outputs[SOURCE_KIND], SourceKind.UNKNOWN);
3056 expect(outputs[UNITS], hasLength(1));
3057 }
3058
3024 test_perform_enableAsync_false() { 3059 test_perform_enableAsync_false() {
3025 AnalysisOptionsImpl options = new AnalysisOptionsImpl(); 3060 AnalysisOptionsImpl options = new AnalysisOptionsImpl();
3026 options.enableAsync = false; 3061 options.enableAsync = false;
3027 prepareAnalysisContext(options); 3062 prepareAnalysisContext(options);
3028 _performParseTask(r''' 3063 _performParseTask(r'''
3029 import 'dart:async'; 3064 import 'dart:async';
3030 class B {void foo() async {}}'''); 3065 class B {void foo() async {}}''');
3031 expect(outputs, hasLength(9)); 3066 expect(outputs, hasLength(9));
3032 expect(outputs[EXPLICITLY_IMPORTED_LIBRARIES], hasLength(1)); 3067 expect(outputs[EXPLICITLY_IMPORTED_LIBRARIES], hasLength(1));
3033 expect(outputs[EXPORTED_LIBRARIES], hasLength(0)); 3068 expect(outputs[EXPORTED_LIBRARIES], hasLength(0));
(...skipping 15 matching lines...) Expand all
3049 expect(outputs[EXPORTED_LIBRARIES], hasLength(0)); 3084 expect(outputs[EXPORTED_LIBRARIES], hasLength(0));
3050 _assertHasCore(outputs[IMPORTED_LIBRARIES], 2); 3085 _assertHasCore(outputs[IMPORTED_LIBRARIES], 2);
3051 expect(outputs[INCLUDED_PARTS], hasLength(0)); 3086 expect(outputs[INCLUDED_PARTS], hasLength(0));
3052 expect(outputs[LIBRARY_SPECIFIC_UNITS], hasLength(1)); 3087 expect(outputs[LIBRARY_SPECIFIC_UNITS], hasLength(1));
3053 expect(outputs[PARSE_ERRORS], hasLength(0)); 3088 expect(outputs[PARSE_ERRORS], hasLength(0));
3054 expect(outputs[PARSED_UNIT], isNotNull); 3089 expect(outputs[PARSED_UNIT], isNotNull);
3055 expect(outputs[SOURCE_KIND], SourceKind.LIBRARY); 3090 expect(outputs[SOURCE_KIND], SourceKind.LIBRARY);
3056 expect(outputs[UNITS], hasLength(1)); 3091 expect(outputs[UNITS], hasLength(1));
3057 } 3092 }
3058 3093
3059 test_perform_computeSourceKind_noDirectives_hasContainingLibrary() {
3060 // Parse "lib.dart" to let the context know that "test.dart" is included.
3061 computeResult(
3062 newSource(
3063 '/lib.dart',
3064 r'''
3065 library lib;
3066 part 'test.dart';
3067 '''),
3068 PARSED_UNIT);
3069 // If there are no the "part of" directive, then it is not a part.
3070 _performParseTask('');
3071 expect(outputs[SOURCE_KIND], SourceKind.LIBRARY);
3072 }
3073
3074 test_perform_computeSourceKind_noDirectives_noContainingLibrary() {
3075 _performParseTask('');
3076 expect(outputs[SOURCE_KIND], SourceKind.LIBRARY);
3077 }
3078
3079 test_perform_doesNotExist() {
3080 _performParseTask(null);
3081 expect(outputs, hasLength(9));
3082 expect(outputs[EXPLICITLY_IMPORTED_LIBRARIES], hasLength(0));
3083 expect(outputs[EXPORTED_LIBRARIES], hasLength(0));
3084 _assertHasCore(outputs[IMPORTED_LIBRARIES], 1);
3085 expect(outputs[INCLUDED_PARTS], hasLength(0));
3086 expect(outputs[LIBRARY_SPECIFIC_UNITS], hasLength(1));
3087 expect(outputs[PARSE_ERRORS], hasLength(0));
3088 expect(outputs[PARSED_UNIT], isNotNull);
3089 expect(outputs[SOURCE_KIND], SourceKind.UNKNOWN);
3090 expect(outputs[UNITS], hasLength(1));
3091 }
3092
3093 test_perform_flushTokenStream() { 3094 test_perform_flushTokenStream() {
3094 _performParseTask(r''' 3095 _performParseTask(r'''
3095 class Test {} 3096 class Test {}
3096 '''); 3097 ''');
3097 expect(analysisCache.getState(source, TOKEN_STREAM), CacheState.FLUSHED); 3098 expect(analysisCache.getState(source, TOKEN_STREAM), CacheState.FLUSHED);
3098 } 3099 }
3099 3100
3100 test_perform_invalidDirectives() { 3101 test_perform_invalidDirectives() {
3101 _performParseTask(r''' 3102 _performParseTask(r'''
3102 library lib; 3103 library lib;
(...skipping 1771 matching lines...) Expand 10 before | Expand all | Expand 10 after
4874 /** 4875 /**
4875 * Fill [errorListener] with [result] errors in the current [task]. 4876 * Fill [errorListener] with [result] errors in the current [task].
4876 */ 4877 */
4877 void _fillErrorListener(ResultDescriptor<List<AnalysisError>> result) { 4878 void _fillErrorListener(ResultDescriptor<List<AnalysisError>> result) {
4878 List<AnalysisError> errors = task.outputs[result]; 4879 List<AnalysisError> errors = task.outputs[result];
4879 expect(errors, isNotNull, reason: result.name); 4880 expect(errors, isNotNull, reason: result.name);
4880 errorListener = new GatheringErrorListener(); 4881 errorListener = new GatheringErrorListener();
4881 errorListener.addAll(errors); 4882 errorListener.addAll(errors);
4882 } 4883 }
4883 } 4884 }
OLDNEW
« no previous file with comments | « pkg/analyzer/test/src/summary/summary_test.dart ('k') | pkg/analyzer/test/src/task/dart_work_manager_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698