| 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/file_system/file_system.dart'; | 7 import 'package:analyzer/file_system/file_system.dart'; |
| 8 import 'package:analyzer/file_system/memory_file_system.dart'; | 8 import 'package:analyzer/file_system/memory_file_system.dart'; |
| 9 import 'package:analyzer/src/context/cache.dart'; | 9 import 'package:analyzer/src/context/cache.dart'; |
| 10 import 'package:analyzer/src/generated/ast.dart'; | 10 import 'package:analyzer/src/generated/ast.dart'; |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 TaskDescriptor descriptor = BuildCompilationUnitElementTask.DESCRIPTOR; | 83 TaskDescriptor descriptor = BuildCompilationUnitElementTask.DESCRIPTOR; |
| 84 expect(descriptor, isNotNull); | 84 expect(descriptor, isNotNull); |
| 85 } | 85 } |
| 86 | 86 |
| 87 test_perform_library() { | 87 test_perform_library() { |
| 88 _performBuildTask(r''' | 88 _performBuildTask(r''' |
| 89 library lib; | 89 library lib; |
| 90 import 'lib2.dart'; | 90 import 'lib2.dart'; |
| 91 export 'lib3.dart'; | 91 export 'lib3.dart'; |
| 92 part 'part.dart'; | 92 part 'part.dart'; |
| 93 class A {'''); | 93 class A {} |
| 94 expect(outputs, hasLength(2)); | 94 class B = Object with A; |
| 95 '''); |
| 96 expect(outputs, hasLength(3)); |
| 97 expect(outputs[CLASS_ELEMENTS], hasLength(2)); |
| 95 expect(outputs[COMPILATION_UNIT_ELEMENT], isNotNull); | 98 expect(outputs[COMPILATION_UNIT_ELEMENT], isNotNull); |
| 96 expect(outputs[RESOLVED_UNIT1], isNotNull); | 99 expect(outputs[RESOLVED_UNIT1], isNotNull); |
| 97 } | 100 } |
| 98 | 101 |
| 99 void _performBuildTask(String content) { | 102 void _performBuildTask(String content) { |
| 100 Source source = _newSource('/test.dart', content); | 103 Source source = _newSource('/test.dart', content); |
| 101 AnalysisTarget target = new LibraryUnitTarget(source, source); | 104 AnalysisTarget target = new LibraryUnitTarget(source, source); |
| 102 _computeResult(target, RESOLVED_UNIT1); | 105 _computeResult(target, RESOLVED_UNIT1); |
| 103 expect(task, new isInstanceOf<BuildCompilationUnitElementTask>()); | 106 expect(task, new isInstanceOf<BuildCompilationUnitElementTask>()); |
| 104 } | 107 } |
| (...skipping 823 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 928 | 931 |
| 929 test_descriptor() { | 932 test_descriptor() { |
| 930 TaskDescriptor descriptor = ParseDartTask.DESCRIPTOR; | 933 TaskDescriptor descriptor = ParseDartTask.DESCRIPTOR; |
| 931 expect(descriptor, isNotNull); | 934 expect(descriptor, isNotNull); |
| 932 } | 935 } |
| 933 | 936 |
| 934 test_perform() { | 937 test_perform() { |
| 935 _performParseTask(r''' | 938 _performParseTask(r''' |
| 936 part of lib; | 939 part of lib; |
| 937 class B {}'''); | 940 class B {}'''); |
| 938 expect(outputs, hasLength(6)); | 941 expect(outputs, hasLength(7)); |
| 939 expect(outputs[EXPORTED_LIBRARIES], hasLength(0)); | 942 expect(outputs[EXPORTED_LIBRARIES], hasLength(0)); |
| 940 _assertHasCore(outputs[IMPORTED_LIBRARIES], 1); | 943 _assertHasCore(outputs[IMPORTED_LIBRARIES], 1); |
| 941 expect(outputs[INCLUDED_PARTS], hasLength(0)); | 944 expect(outputs[INCLUDED_PARTS], hasLength(0)); |
| 942 expect(outputs[PARSE_ERRORS], hasLength(0)); | 945 expect(outputs[PARSE_ERRORS], hasLength(0)); |
| 943 expect(outputs[PARSED_UNIT], isNotNull); | 946 expect(outputs[PARSED_UNIT], isNotNull); |
| 944 expect(outputs[SOURCE_KIND], SourceKind.PART); | 947 expect(outputs[SOURCE_KIND], SourceKind.PART); |
| 948 expect(outputs[UNITS], hasLength(1)); |
| 945 } | 949 } |
| 946 | 950 |
| 947 test_perform_invalidDirectives() { | 951 test_perform_invalidDirectives() { |
| 948 _performParseTask(r''' | 952 _performParseTask(r''' |
| 949 library lib; | 953 library lib; |
| 950 import '/does/not/exist.dart'; | 954 import '/does/not/exist.dart'; |
| 951 import '://invaliduri.dart'; | 955 import '://invaliduri.dart'; |
| 952 export '${a}lib3.dart'; | 956 export '${a}lib3.dart'; |
| 953 part 'part.dart'; | 957 part 'part.dart'; |
| 954 class A {}'''); | 958 class A {}'''); |
| 955 expect(outputs, hasLength(6)); | 959 expect(outputs, hasLength(7)); |
| 956 expect(outputs[EXPORTED_LIBRARIES], hasLength(0)); | 960 expect(outputs[EXPORTED_LIBRARIES], hasLength(0)); |
| 957 _assertHasCore(outputs[IMPORTED_LIBRARIES], 2); | 961 _assertHasCore(outputs[IMPORTED_LIBRARIES], 2); |
| 958 expect(outputs[INCLUDED_PARTS], hasLength(1)); | 962 expect(outputs[INCLUDED_PARTS], hasLength(1)); |
| 959 expect(outputs[PARSE_ERRORS], hasLength(2)); | 963 expect(outputs[PARSE_ERRORS], hasLength(2)); |
| 960 expect(outputs[PARSED_UNIT], isNotNull); | 964 expect(outputs[PARSED_UNIT], isNotNull); |
| 961 expect(outputs[SOURCE_KIND], SourceKind.LIBRARY); | 965 expect(outputs[SOURCE_KIND], SourceKind.LIBRARY); |
| 966 expect(outputs[UNITS], hasLength(2)); |
| 962 } | 967 } |
| 963 | 968 |
| 964 test_perform_library() { | 969 test_perform_library() { |
| 965 _performParseTask(r''' | 970 _performParseTask(r''' |
| 966 library lib; | 971 library lib; |
| 967 import 'lib2.dart'; | 972 import 'lib2.dart'; |
| 968 export 'lib3.dart'; | 973 export 'lib3.dart'; |
| 969 part 'part.dart'; | 974 part 'part.dart'; |
| 970 class A {'''); | 975 class A {'''); |
| 971 expect(outputs, hasLength(6)); | 976 expect(outputs, hasLength(7)); |
| 972 expect(outputs[EXPORTED_LIBRARIES], hasLength(1)); | 977 expect(outputs[EXPORTED_LIBRARIES], hasLength(1)); |
| 973 _assertHasCore(outputs[IMPORTED_LIBRARIES], 2); | 978 _assertHasCore(outputs[IMPORTED_LIBRARIES], 2); |
| 974 expect(outputs[INCLUDED_PARTS], hasLength(1)); | 979 expect(outputs[INCLUDED_PARTS], hasLength(1)); |
| 975 expect(outputs[PARSE_ERRORS], hasLength(1)); | 980 expect(outputs[PARSE_ERRORS], hasLength(1)); |
| 976 expect(outputs[PARSED_UNIT], isNotNull); | 981 expect(outputs[PARSED_UNIT], isNotNull); |
| 977 expect(outputs[SOURCE_KIND], SourceKind.LIBRARY); | 982 expect(outputs[SOURCE_KIND], SourceKind.LIBRARY); |
| 983 expect(outputs[UNITS], hasLength(2)); |
| 978 } | 984 } |
| 979 | 985 |
| 980 void _performParseTask(String content) { | 986 void _performParseTask(String content) { |
| 981 AnalysisTarget target = _newSource('/test.dart', content); | 987 AnalysisTarget target = _newSource('/test.dart', content); |
| 982 _computeResult(target, PARSED_UNIT); | 988 _computeResult(target, PARSED_UNIT); |
| 983 expect(task, new isInstanceOf<ParseDartTask>()); | 989 expect(task, new isInstanceOf<ParseDartTask>()); |
| 984 } | 990 } |
| 985 | 991 |
| 986 static void _assertHasCore(List<Source> sources, int lenght) { | 992 static void _assertHasCore(List<Source> sources, int lenght) { |
| 987 expect(sources, hasLength(lenght)); | 993 expect(sources, hasLength(lenght)); |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1210 return entryMap.putIfAbsent(target, () => new CacheEntry()); | 1216 return entryMap.putIfAbsent(target, () => new CacheEntry()); |
| 1211 } | 1217 } |
| 1212 | 1218 |
| 1213 TimestampedData<String> getContents(Source source) => source.contents; | 1219 TimestampedData<String> getContents(Source source) => source.contents; |
| 1214 | 1220 |
| 1215 noSuchMethod(Invocation invocation) { | 1221 noSuchMethod(Invocation invocation) { |
| 1216 print('noSuchMethod: ${invocation.memberName}'); | 1222 print('noSuchMethod: ${invocation.memberName}'); |
| 1217 return super.noSuchMethod(invocation); | 1223 return super.noSuchMethod(invocation); |
| 1218 } | 1224 } |
| 1219 } | 1225 } |
| OLD | NEW |