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

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

Issue 2643073002: Deprecate the use of `Function` as a class. (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.hint_code_test; 5 library analyzer.test.generated.hint_code_test;
6 6
7 import 'package:analyzer/error/error.dart'; 7 import 'package:analyzer/error/error.dart';
8 import 'package:analyzer/src/error/codes.dart'; 8 import 'package:analyzer/src/error/codes.dart';
9 import 'package:analyzer/src/generated/engine.dart'; 9 import 'package:analyzer/src/generated/engine.dart';
10 import 'package:analyzer/src/generated/parser.dart'; 10 import 'package:analyzer/src/generated/parser.dart';
(...skipping 926 matching lines...) Expand 10 before | Expand all | Expand 10 after
937 A.named() {} 937 A.named() {}
938 } 938 }
939 class B extends A { 939 class B extends A {
940 B() : super.named() {} 940 B() : super.named() {}
941 }'''); 941 }''');
942 await computeAnalysisResult(source); 942 await computeAnalysisResult(source);
943 assertErrors(source, [HintCode.DEPRECATED_MEMBER_USE]); 943 assertErrors(source, [HintCode.DEPRECATED_MEMBER_USE]);
944 verify([source]); 944 verify([source]);
945 } 945 }
946 946
947 test_deprecatedFunction_class() async {
948 Source source = addSource(r'''
949 class Function {}
950 ''');
951 await computeAnalysisResult(source);
952 assertErrors(source, [HintCode.DEPRECATED_FUNCTION_CLASS_DECLARATION]);
953 verify([source]);
954 }
955
956 test_deprecatedFunction_extends() async {
957 Source source = addSource(r'''
958 class A extends Function {}
959 ''');
960 await computeAnalysisResult(source);
961 assertErrors(source, [
962 HintCode.DEPRECATED_EXTENDS_FUNCTION,
963 StaticWarningCode.FUNCTION_WITHOUT_CALL
964 ]);
965 verify([source]);
966 }
967
968 test_deprecatedFunction_extends2() async {
969 Source source = addSource(r'''
970 class Function {}
971 class A extends Function {}
972 ''');
973 await computeAnalysisResult(source);
974 assertErrors(source, [
975 HintCode.DEPRECATED_FUNCTION_CLASS_DECLARATION,
976 HintCode.DEPRECATED_EXTENDS_FUNCTION
977 ]);
978 verify([source]);
979 }
980
981 test_deprecatedFunction_implements() async {
982 Source source = addSource(r'''
983 class A implements Function {}
984 ''');
985 await computeAnalysisResult(source);
986 assertErrors(source, [
987 HintCode.DEPRECATED_IMPLEMENTS_FUNCTION,
988 StaticWarningCode.FUNCTION_WITHOUT_CALL
989 ]);
990 verify([source]);
991 }
992
993 test_deprecatedFunction_implements2() async {
994 Source source = addSource(r'''
995 class Function {}
996 class A implements Function {}
997 ''');
998 await computeAnalysisResult(source);
999 assertErrors(source, [
1000 HintCode.DEPRECATED_FUNCTION_CLASS_DECLARATION,
1001 HintCode.DEPRECATED_IMPLEMENTS_FUNCTION
1002 ]);
1003 verify([source]);
1004 }
1005
1006 test_deprecatedFunction_mixin() async {
Brian Wilkerson 2017/01/19 18:16:05 Perhaps split this into two tests (one with and on
floitsch 2017/01/19 18:22:49 Done.
1007 Source source = addSource(r'''
1008 class Function {}
1009 class A extends Object with Function {}
1010 ''');
1011 await computeAnalysisResult(source);
1012 assertErrors(source, [
1013 HintCode.DEPRECATED_FUNCTION_CLASS_DECLARATION,
1014 HintCode.DEPRECATED_MIXIN_FUNCTION
1015 ]);
1016 verify([source]);
1017 }
1018
947 test_divisionOptimization_double() async { 1019 test_divisionOptimization_double() async {
948 Source source = addSource(r''' 1020 Source source = addSource(r'''
949 f(double x, double y) { 1021 f(double x, double y) {
950 var v = (x / y).toInt(); 1022 var v = (x / y).toInt();
951 }'''); 1023 }''');
952 await computeAnalysisResult(source); 1024 await computeAnalysisResult(source);
953 assertErrors(source, [HintCode.DIVISION_OPTIMIZATION]); 1025 assertErrors(source, [HintCode.DIVISION_OPTIMIZATION]);
954 verify([source]); 1026 verify([source]);
955 } 1027 }
956 1028
(...skipping 3076 matching lines...) Expand 10 before | Expand all | Expand 10 after
4033 n() { 4105 n() {
4034 var a = m(), b = m(); 4106 var a = m(), b = m();
4035 } 4107 }
4036 }'''); 4108 }''');
4037 await computeAnalysisResult(source); 4109 await computeAnalysisResult(source);
4038 assertErrors( 4110 assertErrors(
4039 source, [HintCode.USE_OF_VOID_RESULT, HintCode.USE_OF_VOID_RESULT]); 4111 source, [HintCode.USE_OF_VOID_RESULT, HintCode.USE_OF_VOID_RESULT]);
4040 verify([source]); 4112 verify([source]);
4041 } 4113 }
4042 } 4114 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698