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

Side by Side Diff: pkg/analyzer/test/generated/strong_mode_test.dart

Issue 2640143007: Issue 28100. Implement new strong mode instantiate to bound rules in analyzer. (Closed)
Patch Set: Created 3 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) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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.generated.strong_mode_test; 5 library analyzer.test.generated.strong_mode_test;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:analyzer/dart/ast/ast.dart'; 9 import 'package:analyzer/dart/ast/ast.dart';
10 import 'package:analyzer/dart/ast/standard_resolution_map.dart'; 10 import 'package:analyzer/dart/ast/standard_resolution_map.dart';
(...skipping 1940 matching lines...) Expand 10 before | Expand all | Expand 10 after
1951 } 1951 }
1952 '''; 1952 ''';
1953 await resolveTestUnit(code, noErrors: false); 1953 await resolveTestUnit(code, noErrors: false);
1954 expectIdentifierType('ai', "A<dynamic>"); 1954 expectIdentifierType('ai', "A<dynamic>");
1955 expectIdentifierType('bi', "B<num>"); 1955 expectIdentifierType('bi', "B<num>");
1956 expectIdentifierType('ci', "C<int, B<int>, B<dynamic>>"); 1956 expectIdentifierType('ci', "C<int, B<int>, B<dynamic>>");
1957 expectIdentifierType('aa', "A<dynamic>"); 1957 expectIdentifierType('aa', "A<dynamic>");
1958 expectIdentifierType('bb', "B<num>"); 1958 expectIdentifierType('bb', "B<num>");
1959 expectIdentifierType('cc', "C<int, B<int>, B<dynamic>>"); 1959 expectIdentifierType('cc', "C<int, B<int>, B<dynamic>>");
1960 } 1960 }
1961 1961
Leaf 2017/01/20 20:31:53 Nice! Can you add a couple of tests for the gener
scheglov 2017/01/21 02:11:23 Done.
1962 test_instantiateToBounds_error_recursion() async {
1963 String code = r'''
1964 class C<T0 extends List<T1>, T1 extends List<T0>> {}
1965 C c;
1966 ''';
1967 await resolveTestUnit(code, noErrors: false);
1968 assertErrors(testSource, [StrongModeCode.UNABLE_INSTANTIATE_TO_BOUNDS]);
1969 expectIdentifierType('c;', 'C<dynamic, dynamic>');
1970 }
1971
1972 test_instantiateToBounds_error_recursion_self() async {
1973 String code = r'''
1974 class C<T extends C<T>> {}
1975 C c;
1976 ''';
1977 await resolveTestUnit(code, noErrors: false);
1978 assertErrors(testSource, [StrongModeCode.UNABLE_INSTANTIATE_TO_BOUNDS]);
1979 expectIdentifierType('c;', 'C<dynamic>');
1980 }
1981
1982 test_instantiateToBounds_error_recursion_self2() async {
1983 String code = r'''
1984 class A<E> {}
1985 class C<T extends A<T>> {}
1986 C c;
1987 ''';
1988 await resolveTestUnit(code, noErrors: false);
1989 assertErrors(testSource, [StrongModeCode.UNABLE_INSTANTIATE_TO_BOUNDS]);
1990 expectIdentifierType('c;', 'C<dynamic>');
1991 }
1992
1993 test_instantiateToBounds_ok_referenceOther_after() async {
1994 String code = r'''
1995 class C<T0 extends T1, T1 extends int> {}
1996 C c;
1997 ''';
1998 await resolveTestUnit(code);
1999 assertNoErrors(testSource);
2000 expectIdentifierType('c;', 'C<int, int>');
2001 }
2002
2003 test_instantiateToBounds_ok_referenceOther_after2() async {
2004 String code = r'''
2005 class C<T0 extends Map<T1, T1>, T1 extends int> {}
2006 C c;
2007 ''';
2008 await resolveTestUnit(code);
2009 assertNoErrors(testSource);
2010 expectIdentifierType('c;', 'C<Map<int, int>, int>');
2011 }
2012
2013 test_instantiateToBounds_ok_referenceOther_before() async {
2014 String code = r'''
2015 class C<T0 extends int, T1 extends T0> {}
2016 C c;
2017 ''';
2018 await resolveTestUnit(code);
2019 assertNoErrors(testSource);
2020 expectIdentifierType('c;', 'C<int, int>');
2021 }
2022
2023 test_instantiateToBounds_ok_referenceOther_multi() async {
2024 String code = r'''
2025 class C<T0 extends Map<T1, T2>, T1 extends List<T2>, T2 extends int> {}
2026 C c;
2027 ''';
2028 await resolveTestUnit(code);
2029 assertNoErrors(testSource);
2030 expectIdentifierType('c;', 'C<Map<List<int>, int>, List<int>, int>');
2031 }
2032
2033 test_instantiateToBounds_ok_simpleBounds() async {
2034 String code = r'''
2035 class A<T> {}
2036 class B<T extends num> {}
2037 class C<T extends List<int>> {}
2038
2039 void main() {
2040 A a;
2041 B b;
2042 C c;
2043 }
2044 ''';
2045 await resolveTestUnit(code);
2046 assertNoErrors(testSource);
2047 expectIdentifierType('a;', 'A<dynamic>');
2048 expectIdentifierType('b;', 'B<num>');
2049 expectIdentifierType('c;', 'C<List<int>>');
2050 }
2051
1962 test_notInstantiatedBound_direct() async { 2052 test_notInstantiatedBound_direct() async {
1963 String code = r''' 2053 String code = r'''
1964 class A<T> {} 2054 class A<T> {}
1965 class C<T extends A> {} 2055 class C<T extends A> {}
1966 '''; 2056 ''';
1967 await resolveTestUnit(code, noErrors: false); 2057 await resolveTestUnit(code, noErrors: false);
1968 assertErrors(testSource, [StrongModeCode.NOT_INSTANTIATED_BOUND]); 2058 assertErrors(testSource, [StrongModeCode.NOT_INSTANTIATED_BOUND]);
1969 } 2059 }
1970 2060
1971 test_notInstantiatedBound_indirect() async { 2061 test_notInstantiatedBound_indirect() async {
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after
2444 main() { 2534 main() {
2445 var v = x; 2535 var v = x;
2446 v; // marker 2536 v; // marker
2447 } 2537 }
2448 int x = 3; 2538 int x = 3;
2449 '''; 2539 ''';
2450 await assertPropagatedAssignedType(code, typeProvider.intType, null); 2540 await assertPropagatedAssignedType(code, typeProvider.intType, null);
2451 await assertTypeOfMarkedExpression(code, typeProvider.intType, null); 2541 await assertTypeOfMarkedExpression(code, typeProvider.intType, null);
2452 } 2542 }
2453 } 2543 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698