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

Side by Side Diff: pkg/analyzer/test/src/summary/summary_test.dart

Issue 1558353003: Add a count of type parameters to UnlinkedPublicName. (Closed) Base URL: git@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.summary.summary_test; 5 library analyzer.test.src.summary.summary_test;
6 6
7 import 'package:analyzer/dart/element/element.dart'; 7 import 'package:analyzer/dart/element/element.dart';
8 import 'package:analyzer/src/generated/ast.dart'; 8 import 'package:analyzer/src/generated/ast.dart';
9 import 'package:analyzer/src/generated/engine.dart'; 9 import 'package:analyzer/src/generated/engine.dart';
10 import 'package:analyzer/src/generated/error.dart'; 10 import 'package:analyzer/src/generated/error.dart';
(...skipping 703 matching lines...) Expand 10 before | Expand all | Expand 10 after
714 } 714 }
715 715
716 test_class_alias_concrete() { 716 test_class_alias_concrete() {
717 UnlinkedClass cls = 717 UnlinkedClass cls =
718 serializeClassText('class C = _D with _E; class _D {} class _E {}'); 718 serializeClassText('class C = _D with _E; class _D {} class _E {}');
719 expect(cls.isAbstract, false); 719 expect(cls.isAbstract, false);
720 expect(unlinkedUnits[0].publicNamespace.names, hasLength(1)); 720 expect(unlinkedUnits[0].publicNamespace.names, hasLength(1));
721 expect(unlinkedUnits[0].publicNamespace.names[0].kind, 721 expect(unlinkedUnits[0].publicNamespace.names[0].kind,
722 PrelinkedReferenceKind.classOrEnum); 722 PrelinkedReferenceKind.classOrEnum);
723 expect(unlinkedUnits[0].publicNamespace.names[0].name, 'C'); 723 expect(unlinkedUnits[0].publicNamespace.names[0].name, 'C');
724 expect(unlinkedUnits[0].publicNamespace.names[0].numTypeParameters, 0);
724 } 725 }
725 726
726 test_class_alias_flag() { 727 test_class_alias_flag() {
727 UnlinkedClass cls = 728 UnlinkedClass cls =
728 serializeClassText('class C = D with E; class D {} class E {}'); 729 serializeClassText('class C = D with E; class D {} class E {}');
729 expect(cls.isMixinApplication, true); 730 expect(cls.isMixinApplication, true);
730 } 731 }
731 732
733 test_class_alias_generic() {
734 serializeClassText('class C<A, B> = _D with _E; class _D {} class _E {}');
735 expect(unlinkedUnits[0].publicNamespace.names[0].numTypeParameters, 2);
736 }
737
732 test_class_alias_mixin_order() { 738 test_class_alias_mixin_order() {
733 UnlinkedClass cls = serializeClassText(''' 739 UnlinkedClass cls = serializeClassText('''
734 class C = D with E, F; 740 class C = D with E, F;
735 class D {} 741 class D {}
736 class E {} 742 class E {}
737 class F {} 743 class F {}
738 '''); 744 ''');
739 expect(cls.mixins, hasLength(2)); 745 expect(cls.mixins, hasLength(2));
740 checkTypeRef(cls.mixins[0], null, null, 'E'); 746 checkTypeRef(cls.mixins[0], null, null, 'E');
741 checkTypeRef(cls.mixins[1], null, null, 'F'); 747 checkTypeRef(cls.mixins[1], null, null, 'F');
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
780 expect(cls.hasNoSupertype, isFalse); 786 expect(cls.hasNoSupertype, isFalse);
781 } 787 }
782 788
783 test_class_concrete() { 789 test_class_concrete() {
784 UnlinkedClass cls = serializeClassText('class C {}'); 790 UnlinkedClass cls = serializeClassText('class C {}');
785 expect(cls.isAbstract, false); 791 expect(cls.isAbstract, false);
786 expect(unlinkedUnits[0].publicNamespace.names, hasLength(1)); 792 expect(unlinkedUnits[0].publicNamespace.names, hasLength(1));
787 expect(unlinkedUnits[0].publicNamespace.names[0].kind, 793 expect(unlinkedUnits[0].publicNamespace.names[0].kind,
788 PrelinkedReferenceKind.classOrEnum); 794 PrelinkedReferenceKind.classOrEnum);
789 expect(unlinkedUnits[0].publicNamespace.names[0].name, 'C'); 795 expect(unlinkedUnits[0].publicNamespace.names[0].name, 'C');
796 expect(unlinkedUnits[0].publicNamespace.names[0].numTypeParameters, 0);
790 } 797 }
791 798
792 test_class_interface() { 799 test_class_interface() {
793 UnlinkedClass cls = serializeClassText(''' 800 UnlinkedClass cls = serializeClassText('''
794 class C implements D {} 801 class C implements D {}
795 class D {} 802 class D {}
796 '''); 803 ''');
797 expect(cls.interfaces, hasLength(1)); 804 expect(cls.interfaces, hasLength(1));
798 checkTypeRef(cls.interfaces[0], null, null, 'D'); 805 checkTypeRef(cls.interfaces[0], null, null, 'D');
799 } 806 }
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
912 UnlinkedClass cls = serializeClassText('class C<T, U extends List<U>> {}'); 919 UnlinkedClass cls = serializeClassText('class C<T, U extends List<U>> {}');
913 UnlinkedTypeRef typeArgument = cls.typeParameters[1].bound.typeArguments[0]; 920 UnlinkedTypeRef typeArgument = cls.typeParameters[1].bound.typeArguments[0];
914 checkParamTypeRef(typeArgument, 1); 921 checkParamTypeRef(typeArgument, 1);
915 } 922 }
916 923
917 test_class_type_param_no_bound() { 924 test_class_type_param_no_bound() {
918 UnlinkedClass cls = serializeClassText('class C<T> {}'); 925 UnlinkedClass cls = serializeClassText('class C<T> {}');
919 expect(cls.typeParameters, hasLength(1)); 926 expect(cls.typeParameters, hasLength(1));
920 expect(cls.typeParameters[0].name, 'T'); 927 expect(cls.typeParameters[0].name, 'T');
921 expect(cls.typeParameters[0].bound, isNull); 928 expect(cls.typeParameters[0].bound, isNull);
929 expect(unlinkedUnits[0].publicNamespace.names[0].numTypeParameters, 1);
922 } 930 }
923 931
924 test_constructor() { 932 test_constructor() {
925 UnlinkedExecutable executable = findExecutable('', 933 UnlinkedExecutable executable = findExecutable('',
926 executables: serializeClassText('class C { C(); }').executables); 934 executables: serializeClassText('class C { C(); }').executables);
927 expect(executable.kind, UnlinkedExecutableKind.constructor); 935 expect(executable.kind, UnlinkedExecutableKind.constructor);
928 expect(executable.hasImplicitReturnType, isFalse); 936 expect(executable.hasImplicitReturnType, isFalse);
929 expect(executable.isExternal, isFalse); 937 expect(executable.isExternal, isFalse);
930 } 938 }
931 939
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
1241 1249
1242 test_enum() { 1250 test_enum() {
1243 UnlinkedEnum e = serializeEnumText('enum E { v1 }'); 1251 UnlinkedEnum e = serializeEnumText('enum E { v1 }');
1244 expect(e.name, 'E'); 1252 expect(e.name, 'E');
1245 expect(e.values, hasLength(1)); 1253 expect(e.values, hasLength(1));
1246 expect(e.values[0].name, 'v1'); 1254 expect(e.values[0].name, 'v1');
1247 expect(unlinkedUnits[0].publicNamespace.names, hasLength(1)); 1255 expect(unlinkedUnits[0].publicNamespace.names, hasLength(1));
1248 expect(unlinkedUnits[0].publicNamespace.names[0].kind, 1256 expect(unlinkedUnits[0].publicNamespace.names[0].kind,
1249 PrelinkedReferenceKind.classOrEnum); 1257 PrelinkedReferenceKind.classOrEnum);
1250 expect(unlinkedUnits[0].publicNamespace.names[0].name, 'E'); 1258 expect(unlinkedUnits[0].publicNamespace.names[0].name, 'E');
1259 expect(unlinkedUnits[0].publicNamespace.names[0].numTypeParameters, 0);
1251 } 1260 }
1252 1261
1253 test_enum_order() { 1262 test_enum_order() {
1254 UnlinkedEnum e = serializeEnumText('enum E { v1, v2 }'); 1263 UnlinkedEnum e = serializeEnumText('enum E { v1, v2 }');
1255 expect(e.values, hasLength(2)); 1264 expect(e.values, hasLength(2));
1256 expect(e.values[0].name, 'v1'); 1265 expect(e.values[0].name, 'v1');
1257 expect(e.values[1].name, 'v2'); 1266 expect(e.values[1].name, 'v2');
1258 } 1267 }
1259 1268
1260 test_enum_private() { 1269 test_enum_private() {
(...skipping 16 matching lines...) Expand all
1277 test_executable_function() { 1286 test_executable_function() {
1278 UnlinkedExecutable executable = serializeExecutableText('f() {}'); 1287 UnlinkedExecutable executable = serializeExecutableText('f() {}');
1279 expect(executable.kind, UnlinkedExecutableKind.functionOrMethod); 1288 expect(executable.kind, UnlinkedExecutableKind.functionOrMethod);
1280 expect(executable.hasImplicitReturnType, isTrue); 1289 expect(executable.hasImplicitReturnType, isTrue);
1281 checkDynamicTypeRef(executable.returnType); 1290 checkDynamicTypeRef(executable.returnType);
1282 expect(executable.isExternal, isFalse); 1291 expect(executable.isExternal, isFalse);
1283 expect(unlinkedUnits[0].publicNamespace.names, hasLength(1)); 1292 expect(unlinkedUnits[0].publicNamespace.names, hasLength(1));
1284 expect(unlinkedUnits[0].publicNamespace.names[0].kind, 1293 expect(unlinkedUnits[0].publicNamespace.names[0].kind,
1285 PrelinkedReferenceKind.other); 1294 PrelinkedReferenceKind.other);
1286 expect(unlinkedUnits[0].publicNamespace.names[0].name, 'f'); 1295 expect(unlinkedUnits[0].publicNamespace.names[0].name, 'f');
1296 expect(unlinkedUnits[0].publicNamespace.names[0].numTypeParameters, 0);
1287 } 1297 }
1288 1298
1289 test_executable_function_explicit_return() { 1299 test_executable_function_explicit_return() {
1290 UnlinkedExecutable executable = 1300 UnlinkedExecutable executable =
1291 serializeExecutableText('dynamic f() => null;'); 1301 serializeExecutableText('dynamic f() => null;');
1292 expect(executable.hasImplicitReturnType, isFalse); 1302 expect(executable.hasImplicitReturnType, isFalse);
1293 checkDynamicTypeRef(executable.returnType); 1303 checkDynamicTypeRef(executable.returnType);
1294 } 1304 }
1295 1305
1296 test_executable_function_external() { 1306 test_executable_function_external() {
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
1703 test_executable_type_param_f_bound_self_ref_method() { 1713 test_executable_type_param_f_bound_self_ref_method() {
1704 UnlinkedExecutable ex = 1714 UnlinkedExecutable ex =
1705 serializeMethodText('void f<T, U extends List<U>>() {}'); 1715 serializeMethodText('void f<T, U extends List<U>>() {}');
1706 UnlinkedTypeRef typeArgument = ex.typeParameters[1].bound.typeArguments[0]; 1716 UnlinkedTypeRef typeArgument = ex.typeParameters[1].bound.typeArguments[0];
1707 checkParamTypeRef(typeArgument, 1); 1717 checkParamTypeRef(typeArgument, 1);
1708 } 1718 }
1709 1719
1710 test_executable_type_param_in_parameter_function() { 1720 test_executable_type_param_in_parameter_function() {
1711 UnlinkedExecutable ex = serializeExecutableText('void f<T>(T t) {}'); 1721 UnlinkedExecutable ex = serializeExecutableText('void f<T>(T t) {}');
1712 checkParamTypeRef(ex.parameters[0].type, 1); 1722 checkParamTypeRef(ex.parameters[0].type, 1);
1723 expect(unlinkedUnits[0].publicNamespace.names[0].numTypeParameters, 1);
1713 } 1724 }
1714 1725
1715 test_executable_type_param_in_parameter_method() { 1726 test_executable_type_param_in_parameter_method() {
1716 UnlinkedExecutable ex = serializeMethodText('void f<T>(T t) {}'); 1727 UnlinkedExecutable ex = serializeMethodText('void f<T>(T t) {}');
1717 checkParamTypeRef(ex.parameters[0].type, 1); 1728 checkParamTypeRef(ex.parameters[0].type, 1);
1718 } 1729 }
1719 1730
1720 test_executable_type_param_in_return_type_function() { 1731 test_executable_type_param_in_return_type_function() {
1721 UnlinkedExecutable ex = serializeExecutableText('T f<T>() => null;'); 1732 UnlinkedExecutable ex = serializeExecutableText('T f<T>() => null;');
1722 checkParamTypeRef(ex.returnType, 1); 1733 checkParamTypeRef(ex.returnType, 1);
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after
2217 checkUnresolvedTypeRef(typeRef, null, 'Foo'); 2228 checkUnresolvedTypeRef(typeRef, null, 'Foo');
2218 } 2229 }
2219 2230
2220 test_typedef_name() { 2231 test_typedef_name() {
2221 UnlinkedTypedef type = serializeTypedefText('typedef F();'); 2232 UnlinkedTypedef type = serializeTypedefText('typedef F();');
2222 expect(type.name, 'F'); 2233 expect(type.name, 'F');
2223 expect(unlinkedUnits[0].publicNamespace.names, hasLength(1)); 2234 expect(unlinkedUnits[0].publicNamespace.names, hasLength(1));
2224 expect(unlinkedUnits[0].publicNamespace.names[0].kind, 2235 expect(unlinkedUnits[0].publicNamespace.names[0].kind,
2225 PrelinkedReferenceKind.typedef); 2236 PrelinkedReferenceKind.typedef);
2226 expect(unlinkedUnits[0].publicNamespace.names[0].name, 'F'); 2237 expect(unlinkedUnits[0].publicNamespace.names[0].name, 'F');
2238 expect(unlinkedUnits[0].publicNamespace.names[0].numTypeParameters, 0);
2227 } 2239 }
2228 2240
2229 test_typedef_param_none() { 2241 test_typedef_param_none() {
2230 UnlinkedTypedef type = serializeTypedefText('typedef F();'); 2242 UnlinkedTypedef type = serializeTypedefText('typedef F();');
2231 expect(type.parameters, isEmpty); 2243 expect(type.parameters, isEmpty);
2232 } 2244 }
2233 2245
2234 test_typedef_param_order() { 2246 test_typedef_param_order() {
2235 UnlinkedTypedef type = serializeTypedefText('typedef F(x, y);'); 2247 UnlinkedTypedef type = serializeTypedefText('typedef F(x, y);');
2236 expect(type.parameters, hasLength(2)); 2248 expect(type.parameters, hasLength(2));
(...skipping 22 matching lines...) Expand all
2259 } 2271 }
2260 2272
2261 test_typedef_return_type_explicit() { 2273 test_typedef_return_type_explicit() {
2262 UnlinkedTypedef type = serializeTypedefText('typedef int F();'); 2274 UnlinkedTypedef type = serializeTypedefText('typedef int F();');
2263 checkTypeRef(type.returnType, 'dart:core', 'dart:core', 'int'); 2275 checkTypeRef(type.returnType, 'dart:core', 'dart:core', 'int');
2264 } 2276 }
2265 2277
2266 test_typedef_type_param_in_parameter() { 2278 test_typedef_type_param_in_parameter() {
2267 UnlinkedTypedef type = serializeTypedefText('typedef F<T>(T t);'); 2279 UnlinkedTypedef type = serializeTypedefText('typedef F<T>(T t);');
2268 checkParamTypeRef(type.parameters[0].type, 1); 2280 checkParamTypeRef(type.parameters[0].type, 1);
2281 expect(unlinkedUnits[0].publicNamespace.names[0].numTypeParameters, 1);
2269 } 2282 }
2270 2283
2271 test_typedef_type_param_in_return_type() { 2284 test_typedef_type_param_in_return_type() {
2272 UnlinkedTypedef type = serializeTypedefText('typedef T F<T>();'); 2285 UnlinkedTypedef type = serializeTypedefText('typedef T F<T>();');
2273 checkParamTypeRef(type.returnType, 1); 2286 checkParamTypeRef(type.returnType, 1);
2274 } 2287 }
2275 2288
2276 test_typedef_type_param_none() { 2289 test_typedef_type_param_none() {
2277 UnlinkedTypedef type = serializeTypedefText('typedef F();'); 2290 UnlinkedTypedef type = serializeTypedefText('typedef F();');
2278 expect(type.typeParameters, isEmpty); 2291 expect(type.typeParameters, isEmpty);
2279 } 2292 }
2280 2293
2281 test_typedef_type_param_order() { 2294 test_typedef_type_param_order() {
2282 UnlinkedTypedef type = serializeTypedefText('typedef F<T, U>();'); 2295 UnlinkedTypedef type = serializeTypedefText('typedef F<T, U>();');
2283 expect(type.typeParameters, hasLength(2)); 2296 expect(type.typeParameters, hasLength(2));
2284 expect(type.typeParameters[0].name, 'T'); 2297 expect(type.typeParameters[0].name, 'T');
2285 expect(type.typeParameters[1].name, 'U'); 2298 expect(type.typeParameters[1].name, 'U');
2286 } 2299 }
2287 2300
2288 test_variable() { 2301 test_variable() {
2289 serializeVariableText('int i;', variableName: 'i'); 2302 serializeVariableText('int i;', variableName: 'i');
2290 expect(findExecutable('i'), isNull); 2303 expect(findExecutable('i'), isNull);
2291 expect(findExecutable('i='), isNull); 2304 expect(findExecutable('i='), isNull);
2292 expect(unlinkedUnits[0].publicNamespace.names, hasLength(2)); 2305 expect(unlinkedUnits[0].publicNamespace.names, hasLength(2));
2293 expect(unlinkedUnits[0].publicNamespace.names[0].kind, 2306 expect(unlinkedUnits[0].publicNamespace.names[0].kind,
2294 PrelinkedReferenceKind.other); 2307 PrelinkedReferenceKind.other);
2295 expect(unlinkedUnits[0].publicNamespace.names[0].name, 'i'); 2308 expect(unlinkedUnits[0].publicNamespace.names[0].name, 'i');
2309 expect(unlinkedUnits[0].publicNamespace.names[0].numTypeParameters, 0);
2296 expect(unlinkedUnits[0].publicNamespace.names[1].kind, 2310 expect(unlinkedUnits[0].publicNamespace.names[1].kind,
2297 PrelinkedReferenceKind.other); 2311 PrelinkedReferenceKind.other);
2298 expect(unlinkedUnits[0].publicNamespace.names[1].name, 'i='); 2312 expect(unlinkedUnits[0].publicNamespace.names[1].name, 'i=');
2313 expect(unlinkedUnits[0].publicNamespace.names[1].numTypeParameters, 0);
2299 } 2314 }
2300 2315
2301 test_variable_const() { 2316 test_variable_const() {
2302 UnlinkedVariable variable = 2317 UnlinkedVariable variable =
2303 serializeVariableText('const int i = 0;', variableName: 'i'); 2318 serializeVariableText('const int i = 0;', variableName: 'i');
2304 expect(variable.isConst, isTrue); 2319 expect(variable.isConst, isTrue);
2305 } 2320 }
2306 2321
2307 test_variable_explicit_dynamic() { 2322 test_variable_explicit_dynamic() {
2308 UnlinkedVariable variable = serializeVariableText('dynamic v;'); 2323 UnlinkedVariable variable = serializeVariableText('dynamic v;');
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
2371 UnlinkedVariable variable = 2386 UnlinkedVariable variable =
2372 serializeVariableText('int i;', variableName: 'i'); 2387 serializeVariableText('int i;', variableName: 'i');
2373 checkTypeRef(variable.type, 'dart:core', 'dart:core', 'int'); 2388 checkTypeRef(variable.type, 'dart:core', 'dart:core', 'int');
2374 } 2389 }
2375 2390
2376 test_varible_private() { 2391 test_varible_private() {
2377 serializeVariableText('int _i;', variableName: '_i'); 2392 serializeVariableText('int _i;', variableName: '_i');
2378 expect(unlinkedUnits[0].publicNamespace.names, isEmpty); 2393 expect(unlinkedUnits[0].publicNamespace.names, isEmpty);
2379 } 2394 }
2380 } 2395 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/summary/summarize_elements.dart ('k') | pkg/analyzer/tool/summary/idl.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698