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 analyzer.test.src.summary.summary_common; | 5 library analyzer.test.src.summary.summary_common; |
6 | 6 |
7 import 'package:analyzer/analyzer.dart'; | 7 import 'package:analyzer/analyzer.dart'; |
8 import 'package:analyzer/dart/ast/ast.dart'; | 8 import 'package:analyzer/dart/ast/ast.dart'; |
9 import 'package:analyzer/error/listener.dart'; | 9 import 'package:analyzer/error/listener.dart'; |
10 import 'package:analyzer/src/dart/scanner/reader.dart'; | 10 import 'package:analyzer/src/dart/scanner/reader.dart'; |
(...skipping 6437 matching lines...) Loading... |
6448 } | 6448 } |
6449 | 6449 |
6450 test_export_typedef() { | 6450 test_export_typedef() { |
6451 addNamedSource('/a.dart', 'typedef F();'); | 6451 addNamedSource('/a.dart', 'typedef F();'); |
6452 serializeLibraryText('export "a.dart";'); | 6452 serializeLibraryText('export "a.dart";'); |
6453 expect(linked.exportNames, hasLength(1)); | 6453 expect(linked.exportNames, hasLength(1)); |
6454 checkExportName( | 6454 checkExportName( |
6455 linked.exportNames[0], absUri('/a.dart'), 'F', ReferenceKind.typedef); | 6455 linked.exportNames[0], absUri('/a.dart'), 'F', ReferenceKind.typedef); |
6456 } | 6456 } |
6457 | 6457 |
| 6458 test_export_typedef_genericFunction() { |
| 6459 addNamedSource('/a.dart', 'typedef F<S> = S Function<T>(T x);'); |
| 6460 serializeLibraryText('export "a.dart";'); |
| 6461 expect(linked.exportNames, hasLength(1)); |
| 6462 checkExportName(linked.exportNames[0], absUri('/a.dart'), 'F', |
| 6463 ReferenceKind.genericFunctionTypedef); |
| 6464 } |
| 6465 |
6458 test_export_uri() { | 6466 test_export_uri() { |
6459 addNamedSource('/a.dart', 'library my.lib;'); | 6467 addNamedSource('/a.dart', 'library my.lib;'); |
6460 String uriString = '"a.dart"'; | 6468 String uriString = '"a.dart"'; |
6461 String libraryText = 'export $uriString;'; | 6469 String libraryText = 'export $uriString;'; |
6462 serializeLibraryText(libraryText); | 6470 serializeLibraryText(libraryText); |
6463 var unlinkedExports = unlinkedUnits[0].publicNamespace.exports; | 6471 var unlinkedExports = unlinkedUnits[0].publicNamespace.exports; |
6464 expect(unlinkedExports, hasLength(1)); | 6472 expect(unlinkedExports, hasLength(1)); |
6465 expect(unlinkedExports[0].uri, 'a.dart'); | 6473 expect(unlinkedExports[0].uri, 'a.dart'); |
6466 expect(unlinkedExports[0].configurations, isEmpty); | 6474 expect(unlinkedExports[0].configurations, isEmpty); |
6467 } | 6475 } |
(...skipping 3660 matching lines...) Loading... |
10128 // Extra comment so doc comment offset != 0 | 10136 // Extra comment so doc comment offset != 0 |
10129 /** | 10137 /** |
10130 * Docs | 10138 * Docs |
10131 */ | 10139 */ |
10132 typedef F();'''; | 10140 typedef F();'''; |
10133 UnlinkedTypedef typedef = serializeTypedefText(text); | 10141 UnlinkedTypedef typedef = serializeTypedefText(text); |
10134 expect(typedef.documentationComment, isNotNull); | 10142 expect(typedef.documentationComment, isNotNull); |
10135 checkDocumentationComment(typedef.documentationComment, text); | 10143 checkDocumentationComment(typedef.documentationComment, text); |
10136 } | 10144 } |
10137 | 10145 |
| 10146 test_typedef_genericFunction_reference() { |
| 10147 EntityRef typeRef = serializeTypeText('F', |
| 10148 otherDeclarations: 'typedef F<S> = S Function<T>(T x);'); |
| 10149 checkTypeRef(typeRef, null, 'F', |
| 10150 numTypeParameters: 1, |
| 10151 expectedKind: ReferenceKind.genericFunctionTypedef); |
| 10152 } |
| 10153 |
| 10154 test_typedef_genericFunction_typeNames() { |
| 10155 UnlinkedTypedef typedef = |
| 10156 serializeTypedefText('typedef F<S> = S Function(int x, String y);'); |
| 10157 expect(typedef.style, TypedefStyle.genericFunctionType); |
| 10158 expect(typedef.typeParameters, hasLength(1)); |
| 10159 expect(typedef.typeParameters[0].name, 'S'); |
| 10160 expect(typedef.parameters, isEmpty); |
| 10161 |
| 10162 EntityRef genericFunction = typedef.returnType; |
| 10163 expect(genericFunction.entityKind, EntityRefKind.genericFunctionType); |
| 10164 expect(genericFunction.typeParameters, isEmpty); |
| 10165 |
| 10166 List<UnlinkedParam> functionParameters = genericFunction.syntheticParams; |
| 10167 expect(functionParameters, hasLength(2)); |
| 10168 expect(functionParameters[0].name, 'x'); |
| 10169 expect(functionParameters[1].name, 'y'); |
| 10170 checkLinkedTypeRef(functionParameters[0].type, 'dart:core', 'int'); |
| 10171 checkLinkedTypeRef(functionParameters[1].type, 'dart:core', 'String'); |
| 10172 |
| 10173 checkParamTypeRef(genericFunction.syntheticReturnType, 1); |
| 10174 } |
| 10175 |
| 10176 test_typedef_genericFunction_typeParameters() { |
| 10177 UnlinkedTypedef typedef = |
| 10178 serializeTypedefText('typedef F<S> = S Function<T1, T2>(T1 x, T2 y);'); |
| 10179 expect(typedef.style, TypedefStyle.genericFunctionType); |
| 10180 expect(typedef.typeParameters, hasLength(1)); |
| 10181 expect(typedef.typeParameters[0].name, 'S'); |
| 10182 expect(typedef.parameters, isEmpty); |
| 10183 |
| 10184 EntityRef genericFunction = typedef.returnType; |
| 10185 expect(genericFunction.entityKind, EntityRefKind.genericFunctionType); |
| 10186 |
| 10187 expect(genericFunction.typeParameters, hasLength(2)); |
| 10188 expect(genericFunction.typeParameters[0].name, 'T1'); |
| 10189 expect(genericFunction.typeParameters[1].name, 'T2'); |
| 10190 |
| 10191 expect(genericFunction.syntheticParams, hasLength(2)); |
| 10192 expect(genericFunction.syntheticParams[0].name, 'x'); |
| 10193 expect(genericFunction.syntheticParams[1].name, 'y'); |
| 10194 checkParamTypeRef(genericFunction.syntheticParams[0].type, 2); |
| 10195 checkParamTypeRef(genericFunction.syntheticParams[1].type, 1); |
| 10196 |
| 10197 checkParamTypeRef(genericFunction.syntheticReturnType, 3); |
| 10198 } |
| 10199 |
10138 test_typedef_name() { | 10200 test_typedef_name() { |
10139 String text = 'typedef F();'; | 10201 String text = 'typedef F();'; |
10140 UnlinkedTypedef type = serializeTypedefText(text); | 10202 UnlinkedTypedef type = serializeTypedefText(text); |
10141 expect(type.name, 'F'); | 10203 expect(type.name, 'F'); |
10142 if (includeInformative) { | 10204 if (includeInformative) { |
10143 expect(type.nameOffset, text.indexOf('F')); | 10205 expect(type.nameOffset, text.indexOf('F')); |
10144 } | 10206 } |
10145 expect(unlinkedUnits[0].publicNamespace.names, hasLength(1)); | 10207 expect(unlinkedUnits[0].publicNamespace.names, hasLength(1)); |
10146 expect( | 10208 expect( |
10147 unlinkedUnits[0].publicNamespace.names[0].kind, ReferenceKind.typedef); | 10209 unlinkedUnits[0].publicNamespace.names[0].kind, ReferenceKind.typedef); |
(...skipping 496 matching lines...) Loading... |
10644 */ | 10706 */ |
10645 class _PrefixExpectation { | 10707 class _PrefixExpectation { |
10646 final ReferenceKind kind; | 10708 final ReferenceKind kind; |
10647 final String name; | 10709 final String name; |
10648 final String absoluteUri; | 10710 final String absoluteUri; |
10649 final int numTypeParameters; | 10711 final int numTypeParameters; |
10650 | 10712 |
10651 _PrefixExpectation(this.kind, this.name, | 10713 _PrefixExpectation(this.kind, this.name, |
10652 {this.absoluteUri, this.numTypeParameters: 0}); | 10714 {this.absoluteUri, this.numTypeParameters: 0}); |
10653 } | 10715 } |
OLD | NEW |