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

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

Issue 1686713002: Add support for redirectedConstructor to summaries. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 10 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 test.src.serialization.elements_test; 5 library test.src.serialization.elements_test;
6 6
7 import 'dart:convert'; 7 import 'dart:convert';
8 8
9 import 'package:analyzer/dart/ast/ast.dart'; 9 import 'package:analyzer/dart/ast/ast.dart';
10 import 'package:analyzer/dart/element/element.dart'; 10 import 'package:analyzer/dart/element/element.dart';
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 expect(r.elementAnnotation, isNull); 421 expect(r.elementAnnotation, isNull);
422 } else { 422 } else {
423 fail('Not implemented for ${r.runtimeType} vs. ${o.runtimeType}'); 423 fail('Not implemented for ${r.runtimeType} vs. ${o.runtimeType}');
424 } 424 }
425 } 425 }
426 } 426 }
427 427
428 void compareConstructorElements(ConstructorElementImpl resynthesized, 428 void compareConstructorElements(ConstructorElementImpl resynthesized,
429 ConstructorElementImpl original, String desc) { 429 ConstructorElementImpl original, String desc) {
430 compareExecutableElements(resynthesized, original, desc); 430 compareExecutableElements(resynthesized, original, desc);
431 compareConstAstLists(resynthesized.constantInitializers, 431 if (original.isConst) {
432 original.constantInitializers, desc); 432 compareConstAstLists(resynthesized.constantInitializers,
433 // TODO(paulberry): test redirectedConstructor 433 original.constantInitializers, desc);
434 }
435 if (original.redirectedConstructor == null) {
436 expect(resynthesized.redirectedConstructor, isNull, reason: desc);
437 } else {
438 compareElements(resynthesized.redirectedConstructor,
439 original.redirectedConstructor, desc);
440 }
434 } 441 }
435 442
436 void compareElementAnnotations(ElementAnnotationImpl resynthesized, 443 void compareElementAnnotations(ElementAnnotationImpl resynthesized,
437 ElementAnnotationImpl original, String desc) { 444 ElementAnnotationImpl original, String desc) {
438 expect(resynthesized.element, isNotNull, reason: desc); 445 expect(resynthesized.element, isNotNull, reason: desc);
439 expect(resynthesized.element.kind, original.element.kind, reason: desc); 446 expect(resynthesized.element.kind, original.element.kind, reason: desc);
440 expect(resynthesized.element.location, original.element.location, 447 expect(resynthesized.element.location, original.element.location,
441 reason: desc); 448 reason: desc);
442 expect(resynthesized.compilationUnit, isNotNull, reason: desc); 449 expect(resynthesized.compilationUnit, isNotNull, reason: desc);
443 expect(resynthesized.compilationUnit.location, 450 expect(resynthesized.compilationUnit.location,
(...skipping 1446 matching lines...) Expand 10 before | Expand all | Expand 10 after
1890 1897
1891 test_constructor_initializers_thisInvocation_unnamed() { 1898 test_constructor_initializers_thisInvocation_unnamed() {
1892 checkLibrary(''' 1899 checkLibrary('''
1893 class C { 1900 class C {
1894 const C.named() : this(1, 'bbb'); 1901 const C.named() : this(1, 'bbb');
1895 const C(int a, String b); 1902 const C(int a, String b);
1896 } 1903 }
1897 '''); 1904 ''');
1898 } 1905 }
1899 1906
1907 test_constructor_redirected_factory_named() {
1908 checkLibrary('''
1909 class C {
1910 factory C() = D.named;
1911 C._();
1912 }
1913 class D extends C {
1914 D.named() : super._();
1915 }
1916 ''');
1917 }
1918
1919 test_constructor_redirected_factory_named_imported() {
1920 addLibrarySource(
1921 '/foo.dart',
1922 '''
1923 import 'test.dart';
1924 class D extends C {
1925 D.named() : super._();
1926 }
1927 ''');
1928 checkLibrary('''
1929 import 'foo.dart';
1930 class C {
1931 factory C() = D.named;
1932 C._();
1933 }
1934 ''');
1935 }
1936
1937 test_constructor_redirected_factory_named_prefixed() {
1938 addLibrarySource(
1939 '/foo.dart',
1940 '''
1941 import 'test.dart';
1942 class D extends C {
1943 D.named() : super._();
1944 }
1945 ''');
1946 checkLibrary('''
1947 import 'foo.dart' as foo;
1948 class C {
1949 factory C() = foo.D.named;
1950 C._();
1951 }
1952 ''');
1953 }
1954
1955 test_constructor_redirected_factory_unnamed() {
1956 checkLibrary('''
1957 class C {
1958 factory C() = D;
1959 C._();
1960 }
1961 class D extends C {
1962 D() : super._();
1963 }
1964 ''');
1965 }
1966
1967 test_constructor_redirected_factory_unnamed_imported() {
1968 addLibrarySource(
1969 '/foo.dart',
1970 '''
1971 import 'test.dart';
1972 class D extends C {
1973 D() : super._();
1974 }
1975 ''');
1976 checkLibrary('''
1977 import 'foo.dart';
1978 class C {
1979 factory C() = D;
1980 C._();
1981 }
1982 ''');
1983 }
1984
1985 test_constructor_redirected_factory_unnamed_prefixed() {
1986 addLibrarySource(
1987 '/foo.dart',
1988 '''
1989 import 'test.dart';
1990 class D extends C {
1991 D() : super._();
1992 }
1993 ''');
1994 checkLibrary('''
1995 import 'foo.dart' as foo;
1996 class C {
1997 factory C() = foo.D;
1998 C._();
1999 }
2000 ''');
2001 }
2002
2003 test_constructor_redirected_thisInvocation_named() {
2004 checkLibrary('''
2005 class C {
2006 C.named();
2007 C() : this.named();
2008 }
2009 ''');
2010 }
2011
2012 test_constructor_redirected_thisInvocation_named_generic() {
2013 checkLibrary('''
2014 class C<T> {
2015 C.named();
2016 C() : this.named();
2017 }
2018 ''');
2019 }
2020
2021 test_constructor_redirected_thisInvocation_unnamed() {
2022 checkLibrary('''
2023 class C {
2024 C();
2025 C.named() : this();
2026 }
2027 ''');
2028 }
2029
2030 test_constructor_redirected_thisInvocation_unnamed_generic() {
2031 checkLibrary('''
2032 class C<T> {
2033 C();
2034 C.named() : this();
2035 }
2036 ''');
2037 }
2038
1900 test_core() { 2039 test_core() {
1901 String uri = 'dart:core'; 2040 String uri = 'dart:core';
1902 LibraryElementImpl original = 2041 LibraryElementImpl original =
1903 resolve2(analysisContext2.sourceFactory.forUri(uri)); 2042 resolve2(analysisContext2.sourceFactory.forUri(uri));
1904 LibraryElementImpl resynthesized = resynthesizeLibraryElement( 2043 LibraryElementImpl resynthesized = resynthesizeLibraryElement(
1905 encodeLibraryElement(original), uri, original); 2044 encodeLibraryElement(original), uri, original);
1906 checkLibraryElements(original, resynthesized); 2045 checkLibraryElements(original, resynthesized);
1907 } 2046 }
1908 2047
1909 test_enum_documented() { 2048 test_enum_documented() {
(...skipping 1096 matching lines...) Expand 10 before | Expand all | Expand 10 after
3006 fail('Unexpectedly tried to get unlinked summary for $uri'); 3145 fail('Unexpectedly tried to get unlinked summary for $uri');
3007 } 3146 }
3008 return serializedUnit; 3147 return serializedUnit;
3009 } 3148 }
3010 3149
3011 @override 3150 @override
3012 bool hasLibrarySummary(String uri) { 3151 bool hasLibrarySummary(String uri) {
3013 return true; 3152 return true;
3014 } 3153 }
3015 } 3154 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/summary/summarize_elements.dart ('k') | pkg/analyzer/test/src/summary/summary_common.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698