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

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

Issue 2246293002: remove duplicate checking for overrides (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: fix Created 4 years, 4 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 'package:analyzer/dart/ast/ast.dart'; 7 import 'package:analyzer/dart/ast/ast.dart';
8 import 'package:analyzer/dart/element/element.dart'; 8 import 'package:analyzer/dart/element/element.dart';
9 import 'package:analyzer/dart/element/type.dart'; 9 import 'package:analyzer/dart/element/type.dart';
10 import 'package:analyzer/src/dart/element/element.dart'; 10 import 'package:analyzer/src/dart/element/element.dart';
(...skipping 1761 matching lines...) Expand 10 before | Expand all | Expand 10 after
1772 } 1772 }
1773 1773
1774 void test_genericMethod_override_invalidReturnType() { 1774 void test_genericMethod_override_invalidReturnType() {
1775 Source source = addSource(r''' 1775 Source source = addSource(r'''
1776 class C { 1776 class C {
1777 Iterable/*<T>*/ f/*<T>*/(/*=T*/ x) => null; 1777 Iterable/*<T>*/ f/*<T>*/(/*=T*/ x) => null;
1778 } 1778 }
1779 class D extends C { 1779 class D extends C {
1780 String f/*<S>*/(/*=S*/ x) => null; 1780 String f/*<S>*/(/*=S*/ x) => null;
1781 }'''); 1781 }''');
1782 // TODO(jmesserly): we can't use assertErrors because STRONG_MODE_* errors 1782 assertErrors(source, [StrongModeCode.INVALID_METHOD_OVERRIDE]);
1783 // from CodeChecker don't have working equality.
1784 List<AnalysisError> errors = analysisContext2.computeErrors(source);
1785
1786 // Sort errors by name.
1787 errors.sort((AnalysisError e1, AnalysisError e2) =>
1788 e1.errorCode.name.compareTo(e2.errorCode.name));
1789
1790 expect(
1791 errors.map((e) => e.errorCode.name),
1792 unorderedEquals([
1793 'INVALID_METHOD_OVERRIDE_RETURN_TYPE',
1794 'STRONG_MODE_INVALID_METHOD_OVERRIDE'
1795 ]));
1796 expect(errors[0].message, contains('Iterable<S>'),
1797 reason: 'errors should be in terms of the type parameters '
1798 'at the error location');
1799 verify([source]); 1783 verify([source]);
1800 } 1784 }
1801 1785
1802 void test_genericMethod_override_invalidTypeParamBounds() { 1786 void test_genericMethod_override_invalidTypeParamBounds() {
1803 Source source = addSource(r''' 1787 Source source = addSource(r'''
1804 class A {} 1788 class A {}
1805 class B extends A {} 1789 class B extends A {}
1806 class C { 1790 class C {
1807 /*=T*/ f/*<T extends A>*/(/*=T*/ x) => null; 1791 /*=T*/ f/*<T extends A>*/(/*=T*/ x) => null;
1808 } 1792 }
1809 class D extends C { 1793 class D extends C {
1810 /*=T*/ f/*<T extends B>*/(/*=T*/ x) => null; 1794 /*=T*/ f/*<T extends B>*/(/*=T*/ x) => null;
1811 }'''); 1795 }''');
1812 // TODO(jmesserly): this is modified code from assertErrors, which we can't 1796 assertErrors(source, [StrongModeCode.INVALID_METHOD_OVERRIDE]);
1813 // use directly because STRONG_MODE_* errors don't have working equality.
1814 List<AnalysisError> errors = analysisContext2.computeErrors(source);
1815 expect(
1816 errors.map((e) => e.errorCode.name),
1817 unorderedEquals([
1818 'INVALID_METHOD_OVERRIDE_TYPE_PARAMETER_BOUND',
1819 'STRONG_MODE_INVALID_METHOD_OVERRIDE'
1820 ]));
1821 verify([source]); 1797 verify([source]);
1822 } 1798 }
1823 1799
1824 void test_genericMethod_override_invalidTypeParamCount() { 1800 void test_genericMethod_override_invalidTypeParamCount() {
1825 Source source = addSource(r''' 1801 Source source = addSource(r'''
1826 class C { 1802 class C {
1827 /*=T*/ f/*<T>*/(/*=T*/ x) => null; 1803 /*=T*/ f/*<T>*/(/*=T*/ x) => null;
1828 } 1804 }
1829 class D extends C { 1805 class D extends C {
1830 /*=S*/ f/*<T, S>*/(/*=T*/ x) => null; 1806 /*=S*/ f/*<T, S>*/(/*=T*/ x) => null;
1831 }'''); 1807 }''');
1832 // TODO(jmesserly): we can't use assertErrors because STRONG_MODE_* errors 1808 assertErrors(source, [StrongModeCode.INVALID_METHOD_OVERRIDE]);
1833 // from CodeChecker don't have working equality.
1834 List<AnalysisError> errors = analysisContext2.computeErrors(source);
1835 expect(
1836 errors.map((e) => e.errorCode.name),
1837 unorderedEquals([
1838 'STRONG_MODE_INVALID_METHOD_OVERRIDE',
1839 'INVALID_METHOD_OVERRIDE_TYPE_PARAMETERS'
1840 ]));
1841 verify([source]); 1809 verify([source]);
1842 } 1810 }
1843 1811
1844 void test_genericMethod_propagatedType_promotion() { 1812 void test_genericMethod_propagatedType_promotion() {
1845 // Regression test for: 1813 // Regression test for:
1846 // https://github.com/dart-lang/sdk/issues/25340 1814 // https://github.com/dart-lang/sdk/issues/25340
1847 1815
1848 // Note, after https://github.com/dart-lang/sdk/issues/25486 the original 1816 // Note, after https://github.com/dart-lang/sdk/issues/25486 the original
1849 // example won't work, as we now compute a static type and therefore discard 1817 // example won't work, as we now compute a static type and therefore discard
1850 // the propagated type. So a new test was created that doesn't run under 1818 // the propagated type. So a new test was created that doesn't run under
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after
2300 main() { 2268 main() {
2301 var v = x; 2269 var v = x;
2302 v; // marker 2270 v; // marker
2303 } 2271 }
2304 int x = 3; 2272 int x = 3;
2305 '''; 2273 ''';
2306 assertPropagatedAssignedType(code, typeProvider.intType, null); 2274 assertPropagatedAssignedType(code, typeProvider.intType, null);
2307 assertTypeOfMarkedExpression(code, typeProvider.intType, null); 2275 assertTypeOfMarkedExpression(code, typeProvider.intType, null);
2308 } 2276 }
2309 } 2277 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/generated/error_verifier.dart ('k') | pkg/analyzer/test/src/task/strong/checker_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698