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

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

Issue 1555233002: Encode number of type parameters in prelinked summary. (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 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 * Verify that the given [typeRef] represents a reference to a type declared 297 * Verify that the given [typeRef] represents a reference to a type declared
298 * in a file reachable via [absoluteUri] and [relativeUri], having name 298 * in a file reachable via [absoluteUri] and [relativeUri], having name
299 * [expectedName]. If [expectedPrefix] is supplied, verify that the type is 299 * [expectedName]. If [expectedPrefix] is supplied, verify that the type is
300 * reached via the given prefix. If [allowTypeParameters] is true, allow the 300 * reached via the given prefix. If [allowTypeParameters] is true, allow the
301 * type reference to supply type parameters. [expectedKind] is the kind of 301 * type reference to supply type parameters. [expectedKind] is the kind of
302 * object referenced. [prelinkedSourceUnit] and [unlinkedSourceUnit] refer 302 * object referenced. [prelinkedSourceUnit] and [unlinkedSourceUnit] refer
303 * to the compilation unit within which the [typeRef] appears; if not 303 * to the compilation unit within which the [typeRef] appears; if not
304 * specified they are assumed to refer to the defining compilation unit. 304 * specified they are assumed to refer to the defining compilation unit.
305 * [expectedTargetUnit] is the index of the compilation unit in which the 305 * [expectedTargetUnit] is the index of the compilation unit in which the
306 * target of the [typeRef] is expected to appear; if not specified it is 306 * target of the [typeRef] is expected to appear; if not specified it is
307 * assumed to be the defining compilation unit. 307 * assumed to be the defining compilation unit. [numTypeParameters] is the
308 * number of type parameters of the thing being referred to.
308 */ 309 */
309 void checkTypeRef(UnlinkedTypeRef typeRef, String absoluteUri, 310 void checkTypeRef(UnlinkedTypeRef typeRef, String absoluteUri,
310 String relativeUri, String expectedName, 311 String relativeUri, String expectedName,
311 {String expectedPrefix, 312 {String expectedPrefix,
312 bool allowTypeParameters: false, 313 bool allowTypeParameters: false,
313 PrelinkedReferenceKind expectedKind: PrelinkedReferenceKind.classOrEnum, 314 PrelinkedReferenceKind expectedKind: PrelinkedReferenceKind.classOrEnum,
314 int expectedTargetUnit: 0, 315 int expectedTargetUnit: 0,
315 PrelinkedUnit prelinkedSourceUnit, 316 PrelinkedUnit prelinkedSourceUnit,
316 UnlinkedUnit unlinkedSourceUnit}) { 317 UnlinkedUnit unlinkedSourceUnit,
318 int numTypeParameters: 0}) {
317 prelinkedSourceUnit ??= definingUnit; 319 prelinkedSourceUnit ??= definingUnit;
318 unlinkedSourceUnit ??= unlinkedUnits[0]; 320 unlinkedSourceUnit ??= unlinkedUnits[0];
319 expect(typeRef, new isInstanceOf<UnlinkedTypeRef>()); 321 expect(typeRef, new isInstanceOf<UnlinkedTypeRef>());
320 expect(typeRef.paramReference, 0); 322 expect(typeRef.paramReference, 0);
321 int index = typeRef.reference; 323 int index = typeRef.reference;
322 UnlinkedReference reference = unlinkedSourceUnit.references[index]; 324 UnlinkedReference reference = unlinkedSourceUnit.references[index];
323 PrelinkedReference referenceResolution = 325 PrelinkedReference referenceResolution =
324 prelinkedSourceUnit.references[index]; 326 prelinkedSourceUnit.references[index];
325 if (index == 0) { 327 if (index == 0) {
326 // Index 0 is reserved for "dynamic". 328 // Index 0 is reserved for "dynamic".
(...skipping 15 matching lines...) Expand all
342 } 344 }
343 if (checkAstDerivedData) { 345 if (checkAstDerivedData) {
344 if (expectedPrefix == null) { 346 if (expectedPrefix == null) {
345 expect(reference.prefixReference, 0); 347 expect(reference.prefixReference, 0);
346 } else { 348 } else {
347 checkPrefix(reference.prefixReference, expectedPrefix); 349 checkPrefix(reference.prefixReference, expectedPrefix);
348 } 350 }
349 } 351 }
350 expect(referenceResolution.kind, expectedKind); 352 expect(referenceResolution.kind, expectedKind);
351 expect(referenceResolution.unit, expectedTargetUnit); 353 expect(referenceResolution.unit, expectedTargetUnit);
354 expect(referenceResolution.numTypeParameters, numTypeParameters);
352 } 355 }
353 356
354 /** 357 /**
355 * Verify that the given [typeRef] represents a reference to an unresolved 358 * Verify that the given [typeRef] represents a reference to an unresolved
356 * type. 359 * type.
357 */ 360 */
358 void checkUnresolvedTypeRef( 361 void checkUnresolvedTypeRef(
359 UnlinkedTypeRef typeRef, String expectedPrefix, String expectedName) { 362 UnlinkedTypeRef typeRef, String expectedPrefix, String expectedName) {
360 // When serializing from the element model, unresolved type refs lose their 363 // When serializing from the element model, unresolved type refs lose their
361 // name. 364 // name.
(...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after
840 test_class_non_alias_flag() { 843 test_class_non_alias_flag() {
841 UnlinkedClass cls = serializeClassText('class C {}'); 844 UnlinkedClass cls = serializeClassText('class C {}');
842 expect(cls.isMixinApplication, false); 845 expect(cls.isMixinApplication, false);
843 } 846 }
844 847
845 test_class_private() { 848 test_class_private() {
846 serializeClassText('class _C {}', '_C'); 849 serializeClassText('class _C {}', '_C');
847 expect(unlinkedUnits[0].publicNamespace.names, isEmpty); 850 expect(unlinkedUnits[0].publicNamespace.names, isEmpty);
848 } 851 }
849 852
853 test_class_reference_generic() {
Brian Wilkerson 2016/01/04 23:20:46 Does this, or should this, also apply to generic m
Paul Berry 2016/01/04 23:34:04 Not at the moment, because all this CL deals with
854 UnlinkedTypeRef typeRef =
855 serializeTypeText('C', otherDeclarations: 'class C<D, E> {}');
856 checkTypeRef(typeRef, null, null, 'C', numTypeParameters: 2);
857 }
858
859 test_class_reference_generic_imported() {
860 addNamedSource('/lib.dart', 'class C<D, E> {}');
861 UnlinkedTypeRef typeRef =
862 serializeTypeText('C', otherDeclarations: 'import "lib.dart";');
863 checkTypeRef(typeRef, absUri('/lib.dart'), 'lib.dart', 'C',
864 numTypeParameters: 2);
865 }
866
850 test_class_superclass() { 867 test_class_superclass() {
851 UnlinkedClass cls = serializeClassText('class C {}'); 868 UnlinkedClass cls = serializeClassText('class C {}');
852 expect(cls.supertype, isNull); 869 expect(cls.supertype, isNull);
853 expect(cls.hasNoSupertype, isFalse); 870 expect(cls.hasNoSupertype, isFalse);
854 } 871 }
855 872
856 test_class_superclass_explicit() { 873 test_class_superclass_explicit() {
857 UnlinkedClass cls = serializeClassText('class C extends D {} class D {}'); 874 UnlinkedClass cls = serializeClassText('class C extends D {} class D {}');
858 expect(cls.supertype, isNotNull); 875 expect(cls.supertype, isNotNull);
859 checkTypeRef(cls.supertype, null, null, 'D'); 876 checkTypeRef(cls.supertype, null, null, 'D');
860 expect(cls.hasNoSupertype, isFalse); 877 expect(cls.hasNoSupertype, isFalse);
861 } 878 }
862 879
863 test_class_type_param_bound() { 880 test_class_type_param_bound() {
864 UnlinkedClass cls = serializeClassText('class C<T extends List> {}'); 881 UnlinkedClass cls = serializeClassText('class C<T extends List> {}');
865 expect(cls.typeParameters, hasLength(1)); 882 expect(cls.typeParameters, hasLength(1));
866 expect(cls.typeParameters[0].name, 'T'); 883 expect(cls.typeParameters[0].name, 'T');
867 expect(cls.typeParameters[0].bound, isNotNull); 884 expect(cls.typeParameters[0].bound, isNotNull);
868 checkTypeRef(cls.typeParameters[0].bound, 'dart:core', 'dart:core', 'List', 885 checkTypeRef(cls.typeParameters[0].bound, 'dart:core', 'dart:core', 'List',
869 allowTypeParameters: true); 886 allowTypeParameters: true, numTypeParameters: 1);
870 } 887 }
871 888
872 test_class_type_param_f_bound() { 889 test_class_type_param_f_bound() {
873 UnlinkedClass cls = serializeClassText('class C<T, U extends List<T>> {}'); 890 UnlinkedClass cls = serializeClassText('class C<T, U extends List<T>> {}');
874 UnlinkedTypeRef typeArgument = cls.typeParameters[1].bound.typeArguments[0]; 891 UnlinkedTypeRef typeArgument = cls.typeParameters[1].bound.typeArguments[0];
875 checkParamTypeRef(typeArgument, 2); 892 checkParamTypeRef(typeArgument, 2);
876 } 893 }
877 894
878 test_class_type_param_f_bound_self_ref() { 895 test_class_type_param_f_bound_self_ref() {
879 UnlinkedClass cls = serializeClassText('class C<T, U extends List<U>> {}'); 896 UnlinkedClass cls = serializeClassText('class C<T, U extends List<U>> {}');
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
1093 test_constructor_return_type() { 1110 test_constructor_return_type() {
1094 UnlinkedExecutable executable = findExecutable('', 1111 UnlinkedExecutable executable = findExecutable('',
1095 executables: serializeClassText('class C { C(); }').executables); 1112 executables: serializeClassText('class C { C(); }').executables);
1096 checkTypeRef(executable.returnType, null, null, 'C'); 1113 checkTypeRef(executable.returnType, null, null, 'C');
1097 } 1114 }
1098 1115
1099 test_constructor_return_type_parameterized() { 1116 test_constructor_return_type_parameterized() {
1100 UnlinkedExecutable executable = findExecutable('', 1117 UnlinkedExecutable executable = findExecutable('',
1101 executables: serializeClassText('class C<T, U> { C(); }').executables); 1118 executables: serializeClassText('class C<T, U> { C(); }').executables);
1102 checkTypeRef(executable.returnType, null, null, 'C', 1119 checkTypeRef(executable.returnType, null, null, 'C',
1103 allowTypeParameters: true); 1120 allowTypeParameters: true, numTypeParameters: 2);
1104 expect(executable.returnType.typeArguments, hasLength(2)); 1121 expect(executable.returnType.typeArguments, hasLength(2));
1105 { 1122 {
1106 UnlinkedTypeRef typeRef = executable.returnType.typeArguments[0]; 1123 UnlinkedTypeRef typeRef = executable.returnType.typeArguments[0];
1107 checkParamTypeRef(typeRef, 2); 1124 checkParamTypeRef(typeRef, 2);
1108 } 1125 }
1109 { 1126 {
1110 UnlinkedTypeRef typeRef = executable.returnType.typeArguments[1]; 1127 UnlinkedTypeRef typeRef = executable.returnType.typeArguments[1];
1111 checkParamTypeRef(typeRef, 1); 1128 checkParamTypeRef(typeRef, 1);
1112 } 1129 }
1113 } 1130 }
(...skipping 757 matching lines...) Expand 10 before | Expand all | Expand 10 after
1871 serializeLibraryText('import "dart:async" as a; a.Future v;'); 1888 serializeLibraryText('import "dart:async" as a; a.Future v;');
1872 expect(unlinkedUnits[0].publicNamespace.names, hasLength(2)); 1889 expect(unlinkedUnits[0].publicNamespace.names, hasLength(2));
1873 expect(unlinkedUnits[0].publicNamespace.names[0].name, 'v'); 1890 expect(unlinkedUnits[0].publicNamespace.names[0].name, 'v');
1874 expect(unlinkedUnits[0].publicNamespace.names[1].name, 'v='); 1891 expect(unlinkedUnits[0].publicNamespace.names[1].name, 'v=');
1875 } 1892 }
1876 1893
1877 test_import_prefix_reference() { 1894 test_import_prefix_reference() {
1878 UnlinkedVariable variable = 1895 UnlinkedVariable variable =
1879 serializeVariableText('import "dart:async" as a; a.Future v;'); 1896 serializeVariableText('import "dart:async" as a; a.Future v;');
1880 checkTypeRef(variable.type, 'dart:async', 'dart:async', 'Future', 1897 checkTypeRef(variable.type, 'dart:async', 'dart:async', 'Future',
1881 expectedPrefix: 'a'); 1898 expectedPrefix: 'a', numTypeParameters: 1);
1882 } 1899 }
1883 1900
1884 test_import_reference() { 1901 test_import_reference() {
1885 UnlinkedVariable variable = 1902 UnlinkedVariable variable =
1886 serializeVariableText('import "dart:async"; Future v;'); 1903 serializeVariableText('import "dart:async"; Future v;');
1887 checkTypeRef(variable.type, 'dart:async', 'dart:async', 'Future'); 1904 checkTypeRef(variable.type, 'dart:async', 'dart:async', 'Future',
1905 numTypeParameters: 1);
1888 } 1906 }
1889 1907
1890 test_import_reference_merged_no_prefix() { 1908 test_import_reference_merged_no_prefix() {
1891 serializeLibraryText(''' 1909 serializeLibraryText('''
1892 import "dart:async" show Future; 1910 import "dart:async" show Future;
1893 import "dart:async" show Stream; 1911 import "dart:async" show Stream;
1894 1912
1895 Future f; 1913 Future f;
1896 Stream s; 1914 Stream s;
1897 '''); 1915 ''');
1898 checkTypeRef(findVariable('f').type, 'dart:async', 'dart:async', 'Future'); 1916 checkTypeRef(findVariable('f').type, 'dart:async', 'dart:async', 'Future',
1899 checkTypeRef(findVariable('s').type, 'dart:async', 'dart:async', 'Stream'); 1917 numTypeParameters: 1);
1918 checkTypeRef(findVariable('s').type, 'dart:async', 'dart:async', 'Stream',
1919 numTypeParameters: 1);
1900 } 1920 }
1901 1921
1902 test_import_reference_merged_prefixed() { 1922 test_import_reference_merged_prefixed() {
1903 serializeLibraryText(''' 1923 serializeLibraryText('''
1904 import "dart:async" as a show Future; 1924 import "dart:async" as a show Future;
1905 import "dart:async" as a show Stream; 1925 import "dart:async" as a show Stream;
1906 1926
1907 a.Future f; 1927 a.Future f;
1908 a.Stream s; 1928 a.Stream s;
1909 '''); 1929 ''');
1910 checkTypeRef(findVariable('f').type, 'dart:async', 'dart:async', 'Future', 1930 checkTypeRef(findVariable('f').type, 'dart:async', 'dart:async', 'Future',
1911 expectedPrefix: 'a'); 1931 expectedPrefix: 'a', numTypeParameters: 1);
1912 checkTypeRef(findVariable('s').type, 'dart:async', 'dart:async', 'Stream', 1932 checkTypeRef(findVariable('s').type, 'dart:async', 'dart:async', 'Stream',
1913 expectedPrefix: 'a'); 1933 expectedPrefix: 'a', numTypeParameters: 1);
1914 } 1934 }
1915 1935
1916 test_import_show_order() { 1936 test_import_show_order() {
1917 String libraryText = 1937 String libraryText =
1918 'import "dart:async" show Future, Stream; Future x; Stream y;'; 1938 'import "dart:async" show Future, Stream; Future x; Stream y;';
1919 serializeLibraryText(libraryText); 1939 serializeLibraryText(libraryText);
1920 // Second import is the implicit import of dart:core 1940 // Second import is the implicit import of dart:core
1921 expect(unlinkedUnits[0].imports, hasLength(2)); 1941 expect(unlinkedUnits[0].imports, hasLength(2));
1922 expect(unlinkedUnits[0].imports[0].combinators, hasLength(1)); 1942 expect(unlinkedUnits[0].imports[0].combinators, hasLength(1));
1923 expect(unlinkedUnits[0].imports[0].combinators[0].shows, hasLength(2)); 1943 expect(unlinkedUnits[0].imports[0].combinators[0].shows, hasLength(2));
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
1966 addNamedSource('/a.dart', 'part of foo; class C {}'); 1986 addNamedSource('/a.dart', 'part of foo; class C {}');
1967 serializeLibraryText('library foo; part "a.dart";'); 1987 serializeLibraryText('library foo; part "a.dart";');
1968 expect(unlinkedUnits[0].publicNamespace.names, isEmpty); 1988 expect(unlinkedUnits[0].publicNamespace.names, isEmpty);
1969 expect(unlinkedUnits[1].publicNamespace.names, hasLength(1)); 1989 expect(unlinkedUnits[1].publicNamespace.names, hasLength(1));
1970 expect(unlinkedUnits[1].publicNamespace.names[0].name, 'C'); 1990 expect(unlinkedUnits[1].publicNamespace.names[0].name, 'C');
1971 } 1991 }
1972 1992
1973 test_type_arguments_explicit() { 1993 test_type_arguments_explicit() {
1974 UnlinkedTypeRef typeRef = serializeTypeText('List<int>'); 1994 UnlinkedTypeRef typeRef = serializeTypeText('List<int>');
1975 checkTypeRef(typeRef, 'dart:core', 'dart:core', 'List', 1995 checkTypeRef(typeRef, 'dart:core', 'dart:core', 'List',
1976 allowTypeParameters: true); 1996 allowTypeParameters: true, numTypeParameters: 1);
1977 expect(typeRef.typeArguments, hasLength(1)); 1997 expect(typeRef.typeArguments, hasLength(1));
1978 checkTypeRef(typeRef.typeArguments[0], 'dart:core', 'dart:core', 'int'); 1998 checkTypeRef(typeRef.typeArguments[0], 'dart:core', 'dart:core', 'int');
1979 } 1999 }
1980 2000
1981 test_type_arguments_explicit_dynamic() { 2001 test_type_arguments_explicit_dynamic() {
1982 UnlinkedTypeRef typeRef = serializeTypeText('List<dynamic>'); 2002 UnlinkedTypeRef typeRef = serializeTypeText('List<dynamic>');
1983 checkTypeRef(typeRef, 'dart:core', 'dart:core', 'List', 2003 checkTypeRef(typeRef, 'dart:core', 'dart:core', 'List',
1984 allowTypeParameters: true); 2004 allowTypeParameters: true, numTypeParameters: 1);
1985 expect(typeRef.typeArguments, isEmpty); 2005 expect(typeRef.typeArguments, isEmpty);
1986 } 2006 }
1987 2007
1988 test_type_arguments_explicit_dynamic_typedef() { 2008 test_type_arguments_explicit_dynamic_typedef() {
1989 UnlinkedTypeRef typeRef = 2009 UnlinkedTypeRef typeRef =
1990 serializeTypeText('F<dynamic>', otherDeclarations: 'typedef T F<T>();'); 2010 serializeTypeText('F<dynamic>', otherDeclarations: 'typedef T F<T>();');
1991 checkTypeRef(typeRef, null, null, 'F', 2011 checkTypeRef(typeRef, null, null, 'F',
1992 allowTypeParameters: true, 2012 allowTypeParameters: true,
1993 expectedKind: PrelinkedReferenceKind.typedef); 2013 expectedKind: PrelinkedReferenceKind.typedef,
2014 numTypeParameters: 1);
1994 expect(typeRef.typeArguments, isEmpty); 2015 expect(typeRef.typeArguments, isEmpty);
1995 } 2016 }
1996 2017
1997 test_type_arguments_explicit_typedef() { 2018 test_type_arguments_explicit_typedef() {
1998 UnlinkedTypeRef typeRef = 2019 UnlinkedTypeRef typeRef =
1999 serializeTypeText('F<int>', otherDeclarations: 'typedef T F<T>();'); 2020 serializeTypeText('F<int>', otherDeclarations: 'typedef T F<T>();');
2000 checkTypeRef(typeRef, null, null, 'F', 2021 checkTypeRef(typeRef, null, null, 'F',
2001 allowTypeParameters: true, 2022 allowTypeParameters: true,
2002 expectedKind: PrelinkedReferenceKind.typedef); 2023 expectedKind: PrelinkedReferenceKind.typedef,
2024 numTypeParameters: 1);
2003 expect(typeRef.typeArguments, hasLength(1)); 2025 expect(typeRef.typeArguments, hasLength(1));
2004 checkTypeRef(typeRef.typeArguments[0], 'dart:core', 'dart:core', 'int'); 2026 checkTypeRef(typeRef.typeArguments[0], 'dart:core', 'dart:core', 'int');
2005 } 2027 }
2006 2028
2007 test_type_arguments_implicit() { 2029 test_type_arguments_implicit() {
2008 UnlinkedTypeRef typeRef = serializeTypeText('List'); 2030 UnlinkedTypeRef typeRef = serializeTypeText('List');
2009 checkTypeRef(typeRef, 'dart:core', 'dart:core', 'List', 2031 checkTypeRef(typeRef, 'dart:core', 'dart:core', 'List',
2010 allowTypeParameters: true); 2032 allowTypeParameters: true, numTypeParameters: 1);
2011 expect(typeRef.typeArguments, isEmpty); 2033 expect(typeRef.typeArguments, isEmpty);
2012 } 2034 }
2013 2035
2014 test_type_arguments_implicit_typedef() { 2036 test_type_arguments_implicit_typedef() {
2015 UnlinkedTypeRef typeRef = 2037 UnlinkedTypeRef typeRef =
2016 serializeTypeText('F', otherDeclarations: 'typedef T F<T>();'); 2038 serializeTypeText('F', otherDeclarations: 'typedef T F<T>();');
2017 checkTypeRef(typeRef, null, null, 'F', 2039 checkTypeRef(typeRef, null, null, 'F',
2018 allowTypeParameters: true, 2040 allowTypeParameters: true,
2019 expectedKind: PrelinkedReferenceKind.typedef); 2041 expectedKind: PrelinkedReferenceKind.typedef,
2042 numTypeParameters: 1);
2020 expect(typeRef.typeArguments, isEmpty); 2043 expect(typeRef.typeArguments, isEmpty);
2021 } 2044 }
2022 2045
2023 test_type_arguments_order() { 2046 test_type_arguments_order() {
2024 UnlinkedTypeRef typeRef = serializeTypeText('Map<int, Object>'); 2047 UnlinkedTypeRef typeRef = serializeTypeText('Map<int, Object>');
2025 checkTypeRef(typeRef, 'dart:core', 'dart:core', 'Map', 2048 checkTypeRef(typeRef, 'dart:core', 'dart:core', 'Map',
2026 allowTypeParameters: true); 2049 allowTypeParameters: true, numTypeParameters: 2);
2027 expect(typeRef.typeArguments, hasLength(2)); 2050 expect(typeRef.typeArguments, hasLength(2));
2028 checkTypeRef(typeRef.typeArguments[0], 'dart:core', 'dart:core', 'int'); 2051 checkTypeRef(typeRef.typeArguments[0], 'dart:core', 'dart:core', 'int');
2029 checkTypeRef(typeRef.typeArguments[1], 'dart:core', 'dart:core', 'Object'); 2052 checkTypeRef(typeRef.typeArguments[1], 'dart:core', 'dart:core', 'Object');
2030 } 2053 }
2031 2054
2032 test_type_dynamic() { 2055 test_type_dynamic() {
2033 checkDynamicTypeRef(serializeTypeText('dynamic')); 2056 checkDynamicTypeRef(serializeTypeText('dynamic'));
2034 } 2057 }
2035 2058
2036 test_type_reference_from_part() { 2059 test_type_reference_from_part() {
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
2190 expect(type.parameters, hasLength(2)); 2213 expect(type.parameters, hasLength(2));
2191 expect(type.parameters[0].name, 'x'); 2214 expect(type.parameters[0].name, 'x');
2192 expect(type.parameters[1].name, 'y'); 2215 expect(type.parameters[1].name, 'y');
2193 } 2216 }
2194 2217
2195 test_typedef_private() { 2218 test_typedef_private() {
2196 serializeTypedefText('typedef _F();', '_F'); 2219 serializeTypedefText('typedef _F();', '_F');
2197 expect(unlinkedUnits[0].publicNamespace.names, isEmpty); 2220 expect(unlinkedUnits[0].publicNamespace.names, isEmpty);
2198 } 2221 }
2199 2222
2223 test_typedef_reference_generic() {
2224 UnlinkedTypeRef typeRef =
2225 serializeTypeText('F', otherDeclarations: 'typedef void F<A, B>();');
2226 checkTypeRef(typeRef, null, null, 'F',
2227 numTypeParameters: 2, expectedKind: PrelinkedReferenceKind.typedef);
2228 }
2229
2230 test_typedef_reference_generic_imported() {
2231 addNamedSource('/lib.dart', 'typedef void F<A, B>();');
2232 UnlinkedTypeRef typeRef =
2233 serializeTypeText('F', otherDeclarations: 'import "lib.dart";');
2234 checkTypeRef(typeRef, absUri('/lib.dart'), 'lib.dart', 'F',
2235 numTypeParameters: 2, expectedKind: PrelinkedReferenceKind.typedef);
2236 }
2237
2200 test_typedef_return_type_explicit() { 2238 test_typedef_return_type_explicit() {
2201 UnlinkedTypedef type = serializeTypedefText('typedef int F();'); 2239 UnlinkedTypedef type = serializeTypedefText('typedef int F();');
2202 checkTypeRef(type.returnType, 'dart:core', 'dart:core', 'int'); 2240 checkTypeRef(type.returnType, 'dart:core', 'dart:core', 'int');
2203 } 2241 }
2204 2242
2205 test_typedef_type_param_in_parameter() { 2243 test_typedef_type_param_in_parameter() {
2206 UnlinkedTypedef type = serializeTypedefText('typedef F<T>(T t);'); 2244 UnlinkedTypedef type = serializeTypedefText('typedef F<T>(T t);');
2207 checkParamTypeRef(type.parameters[0].type, 1); 2245 checkParamTypeRef(type.parameters[0].type, 1);
2208 } 2246 }
2209 2247
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
2310 UnlinkedVariable variable = 2348 UnlinkedVariable variable =
2311 serializeVariableText('int i;', variableName: 'i'); 2349 serializeVariableText('int i;', variableName: 'i');
2312 checkTypeRef(variable.type, 'dart:core', 'dart:core', 'int'); 2350 checkTypeRef(variable.type, 'dart:core', 'dart:core', 'int');
2313 } 2351 }
2314 2352
2315 test_varible_private() { 2353 test_varible_private() {
2316 serializeVariableText('int _i;', variableName: '_i'); 2354 serializeVariableText('int _i;', variableName: '_i');
2317 expect(unlinkedUnits[0].publicNamespace.names, isEmpty); 2355 expect(unlinkedUnits[0].publicNamespace.names, isEmpty);
2318 } 2356 }
2319 } 2357 }
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