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

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

Issue 2021613002: Compare error names in strong_mode_test ignoring order. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 6 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1777 matching lines...) Expand 10 before | Expand all | Expand 10 after
1788 String f/*<S>*/(/*=S*/ x) => null; 1788 String f/*<S>*/(/*=S*/ x) => null;
1789 }'''); 1789 }''');
1790 // TODO(jmesserly): we can't use assertErrors because STRONG_MODE_* errors 1790 // TODO(jmesserly): we can't use assertErrors because STRONG_MODE_* errors
1791 // from CodeChecker don't have working equality. 1791 // from CodeChecker don't have working equality.
1792 List<AnalysisError> errors = analysisContext2.computeErrors(source); 1792 List<AnalysisError> errors = analysisContext2.computeErrors(source);
1793 1793
1794 // Sort errors by name. 1794 // Sort errors by name.
1795 errors.sort((AnalysisError e1, AnalysisError e2) => 1795 errors.sort((AnalysisError e1, AnalysisError e2) =>
1796 e1.errorCode.name.compareTo(e2.errorCode.name)); 1796 e1.errorCode.name.compareTo(e2.errorCode.name));
1797 1797
1798 expect(errors.map((e) => e.errorCode.name), [ 1798 expect(
1799 'INVALID_METHOD_OVERRIDE_RETURN_TYPE', 1799 errors.map((e) => e.errorCode.name),
1800 'STRONG_MODE_INVALID_METHOD_OVERRIDE' 1800 unorderedEquals([
1801 ]); 1801 'INVALID_METHOD_OVERRIDE_RETURN_TYPE',
1802 'STRONG_MODE_INVALID_METHOD_OVERRIDE'
1803 ]));
1802 expect(errors[0].message, contains('Iterable<S>'), 1804 expect(errors[0].message, contains('Iterable<S>'),
1803 reason: 'errors should be in terms of the type parameters ' 1805 reason: 'errors should be in terms of the type parameters '
1804 'at the error location'); 1806 'at the error location');
1805 verify([source]); 1807 verify([source]);
1806 } 1808 }
1807 1809
1808 void test_genericMethod_override_invalidTypeParamBounds() { 1810 void test_genericMethod_override_invalidTypeParamBounds() {
1809 Source source = addSource(r''' 1811 Source source = addSource(r'''
1810 class A {} 1812 class A {}
1811 class B extends A {} 1813 class B extends A {}
1812 class C { 1814 class C {
1813 /*=T*/ f/*<T extends A>*/(/*=T*/ x) => null; 1815 /*=T*/ f/*<T extends A>*/(/*=T*/ x) => null;
1814 } 1816 }
1815 class D extends C { 1817 class D extends C {
1816 /*=T*/ f/*<T extends B>*/(/*=T*/ x) => null; 1818 /*=T*/ f/*<T extends B>*/(/*=T*/ x) => null;
1817 }'''); 1819 }''');
1818 // TODO(jmesserly): this is modified code from assertErrors, which we can't 1820 // TODO(jmesserly): this is modified code from assertErrors, which we can't
1819 // use directly because STRONG_MODE_* errors don't have working equality. 1821 // use directly because STRONG_MODE_* errors don't have working equality.
1820 List<AnalysisError> errors = analysisContext2.computeErrors(source); 1822 List<AnalysisError> errors = analysisContext2.computeErrors(source);
1821 List errorNames = errors.map((e) => e.errorCode.name).toList();
1822 expect(errorNames, hasLength(2));
1823 expect(errorNames, contains('STRONG_MODE_INVALID_METHOD_OVERRIDE'));
1824 expect( 1823 expect(
1825 errorNames, contains('INVALID_METHOD_OVERRIDE_TYPE_PARAMETER_BOUND')); 1824 errors.map((e) => e.errorCode.name),
1825 unorderedEquals([
1826 'INVALID_METHOD_OVERRIDE_TYPE_PARAMETER_BOUND',
1827 'STRONG_MODE_INVALID_METHOD_OVERRIDE'
1828 ]));
1826 verify([source]); 1829 verify([source]);
1827 } 1830 }
1828 1831
1829 void test_genericMethod_override_invalidTypeParamCount() { 1832 void test_genericMethod_override_invalidTypeParamCount() {
1830 Source source = addSource(r''' 1833 Source source = addSource(r'''
1831 class C { 1834 class C {
1832 /*=T*/ f/*<T>*/(/*=T*/ x) => null; 1835 /*=T*/ f/*<T>*/(/*=T*/ x) => null;
1833 } 1836 }
1834 class D extends C { 1837 class D extends C {
1835 /*=S*/ f/*<T, S>*/(/*=T*/ x) => null; 1838 /*=S*/ f/*<T, S>*/(/*=T*/ x) => null;
1836 }'''); 1839 }''');
1837 // TODO(jmesserly): we can't use assertErrors because STRONG_MODE_* errors 1840 // TODO(jmesserly): we can't use assertErrors because STRONG_MODE_* errors
1838 // from CodeChecker don't have working equality. 1841 // from CodeChecker don't have working equality.
1839 List<AnalysisError> errors = analysisContext2.computeErrors(source); 1842 List<AnalysisError> errors = analysisContext2.computeErrors(source);
1840 expect(errors.map((e) => e.errorCode.name), [ 1843 expect(
1841 'STRONG_MODE_INVALID_METHOD_OVERRIDE', 1844 errors.map((e) => e.errorCode.name),
1842 'INVALID_METHOD_OVERRIDE_TYPE_PARAMETERS' 1845 unorderedEquals([
1843 ]); 1846 'STRONG_MODE_INVALID_METHOD_OVERRIDE',
1847 'INVALID_METHOD_OVERRIDE_TYPE_PARAMETERS'
1848 ]));
1844 verify([source]); 1849 verify([source]);
1845 } 1850 }
1846 1851
1847 void test_genericMethod_propagatedType_promotion() { 1852 void test_genericMethod_propagatedType_promotion() {
1848 // Regression test for: 1853 // Regression test for:
1849 // https://github.com/dart-lang/sdk/issues/25340 1854 // https://github.com/dart-lang/sdk/issues/25340
1850 1855
1851 // Note, after https://github.com/dart-lang/sdk/issues/25486 the original 1856 // Note, after https://github.com/dart-lang/sdk/issues/25486 the original
1852 // example won't work, as we now compute a static type and therefore discard 1857 // example won't work, as we now compute a static type and therefore discard
1853 // the propagated type. So a new test was created that doesn't run under 1858 // 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
2303 main() { 2308 main() {
2304 var v = x; 2309 var v = x;
2305 v; // marker 2310 v; // marker
2306 } 2311 }
2307 int x = 3; 2312 int x = 3;
2308 '''; 2313 ''';
2309 assertPropagatedAssignedType(code, typeProvider.intType, null); 2314 assertPropagatedAssignedType(code, typeProvider.intType, null);
2310 assertTypeOfMarkedExpression(code, typeProvider.intType, null); 2315 assertTypeOfMarkedExpression(code, typeProvider.intType, null);
2311 } 2316 }
2312 } 2317 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698