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

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

Issue 2813553006: Split error code to ease future improvements (Closed)
Patch Set: Created 3 years, 8 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 | « pkg/analyzer/test/generated/compile_time_error_code_test.dart ('k') | 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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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.static_warning_code_test; 5 library analyzer.test.generated.static_warning_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/source_io.dart'; 10 import 'package:analyzer/src/generated/source_io.dart';
(...skipping 1310 matching lines...) Expand 10 before | Expand all | Expand 10 after
1321 test_extraPositionalArguments_functionExpression() async { 1321 test_extraPositionalArguments_functionExpression() async {
1322 Source source = addSource(r''' 1322 Source source = addSource(r'''
1323 main() { 1323 main() {
1324 (int x) {} (0, 1); 1324 (int x) {} (0, 1);
1325 }'''); 1325 }''');
1326 await computeAnalysisResult(source); 1326 await computeAnalysisResult(source);
1327 assertErrors(source, [StaticWarningCode.EXTRA_POSITIONAL_ARGUMENTS]); 1327 assertErrors(source, [StaticWarningCode.EXTRA_POSITIONAL_ARGUMENTS]);
1328 verify([source]); 1328 verify([source]);
1329 } 1329 }
1330 1330
1331 test_extraPositionalArgumentsCouldBeNamed() async {
1332 Source source = addSource(r'''
1333 f({x, y}) {}
1334 main() {
1335 f(0, 1, '2');
1336 }''');
1337 await computeAnalysisResult(source);
1338 assertErrors(
1339 source, [StaticWarningCode.EXTRA_POSITIONAL_ARGUMENTS_COULD_BE_NAMED]);
1340 verify([source]);
1341 }
1342
1343 test_extraPositionalArgumentsCouldBeNamed_functionExpression() async {
1344 Source source = addSource(r'''
1345 main() {
1346 (int x, {int y}) {} (0, 1);
1347 }''');
1348 await computeAnalysisResult(source);
1349 assertErrors(
1350 source, [StaticWarningCode.EXTRA_POSITIONAL_ARGUMENTS_COULD_BE_NAMED]);
1351 verify([source]);
1352 }
1353
1331 test_fieldInitializedInInitializerAndDeclaration_final() async { 1354 test_fieldInitializedInInitializerAndDeclaration_final() async {
1332 Source source = addSource(r''' 1355 Source source = addSource(r'''
1333 class A { 1356 class A {
1334 final int x = 0; 1357 final int x = 0;
1335 A() : x = 1 {} 1358 A() : x = 1 {}
1336 }'''); 1359 }''');
1337 await computeAnalysisResult(source); 1360 await computeAnalysisResult(source);
1338 assertErrors(source, 1361 assertErrors(source,
1339 [StaticWarningCode.FIELD_INITIALIZED_IN_INITIALIZER_AND_DECLARATION]); 1362 [StaticWarningCode.FIELD_INITIALIZED_IN_INITIALIZER_AND_DECLARATION]);
1340 verify([source]); 1363 verify([source]);
(...skipping 1714 matching lines...) Expand 10 before | Expand all | Expand 10 after
3055 test_redirectToNonClass_undefinedIdentifier() async { 3078 test_redirectToNonClass_undefinedIdentifier() async {
3056 Source source = addSource(r''' 3079 Source source = addSource(r'''
3057 class B { 3080 class B {
3058 factory B() = A; 3081 factory B() = A;
3059 }'''); 3082 }''');
3060 await computeAnalysisResult(source); 3083 await computeAnalysisResult(source);
3061 assertErrors(source, [StaticWarningCode.REDIRECT_TO_NON_CLASS]); 3084 assertErrors(source, [StaticWarningCode.REDIRECT_TO_NON_CLASS]);
3062 verify([source]); 3085 verify([source]);
3063 } 3086 }
3064 3087
3065 test_returnWithoutValue_Null() async {
3066 // Test that block bodied functions with return type Null and an empty
3067 // return cause a static warning.
3068 Source source = addSource(r'''
3069 Null f() {return;}
3070 ''');
3071 await computeAnalysisResult(source);
3072 assertErrors(source, [StaticWarningCode.RETURN_WITHOUT_VALUE]);
3073 }
3074
3075 test_returnWithoutValue_async() async { 3088 test_returnWithoutValue_async() async {
3076 Source source = addSource(''' 3089 Source source = addSource('''
3077 import 'dart:async'; 3090 import 'dart:async';
3078 Future<int> f() async { 3091 Future<int> f() async {
3079 return; 3092 return;
3080 } 3093 }
3081 '''); 3094 ''');
3082 await computeAnalysisResult(source); 3095 await computeAnalysisResult(source);
3083 assertErrors(source, [StaticWarningCode.RETURN_WITHOUT_VALUE]); 3096 assertErrors(source, [StaticWarningCode.RETURN_WITHOUT_VALUE]);
3084 verify([source]); 3097 verify([source]);
(...skipping 28 matching lines...) Expand all
3113 if (x < 0) { 3126 if (x < 0) {
3114 return 1; 3127 return 1;
3115 } 3128 }
3116 return; 3129 return;
3117 }'''); 3130 }''');
3118 await computeAnalysisResult(source); 3131 await computeAnalysisResult(source);
3119 assertErrors(source, [StaticWarningCode.RETURN_WITHOUT_VALUE]); 3132 assertErrors(source, [StaticWarningCode.RETURN_WITHOUT_VALUE]);
3120 verify([source]); 3133 verify([source]);
3121 } 3134 }
3122 3135
3136 test_returnWithoutValue_Null() async {
3137 // Test that block bodied functions with return type Null and an empty
3138 // return cause a static warning.
3139 Source source = addSource(r'''
3140 Null f() {return;}
3141 ''');
3142 await computeAnalysisResult(source);
3143 assertErrors(source, [StaticWarningCode.RETURN_WITHOUT_VALUE]);
3144 }
3145
3123 test_staticAccessToInstanceMember_method_invocation() async { 3146 test_staticAccessToInstanceMember_method_invocation() async {
3124 Source source = addSource(r''' 3147 Source source = addSource(r'''
3125 class A { 3148 class A {
3126 m() {} 3149 m() {}
3127 } 3150 }
3128 main() { 3151 main() {
3129 A.m(); 3152 A.m();
3130 }'''); 3153 }''');
3131 await computeAnalysisResult(source); 3154 await computeAnalysisResult(source);
3132 assertErrors(source, [StaticWarningCode.STATIC_ACCESS_TO_INSTANCE_MEMBER]); 3155 assertErrors(source, [StaticWarningCode.STATIC_ACCESS_TO_INSTANCE_MEMBER]);
(...skipping 594 matching lines...) Expand 10 before | Expand all | Expand 10 after
3727 3750
3728 test_voidReturnForGetter() async { 3751 test_voidReturnForGetter() async {
3729 Source source = addSource(r''' 3752 Source source = addSource(r'''
3730 class S { 3753 class S {
3731 void get value {} 3754 void get value {}
3732 }'''); 3755 }''');
3733 await computeAnalysisResult(source); 3756 await computeAnalysisResult(source);
3734 assertErrors(source, [StaticWarningCode.VOID_RETURN_FOR_GETTER]); 3757 assertErrors(source, [StaticWarningCode.VOID_RETURN_FOR_GETTER]);
3735 } 3758 }
3736 } 3759 }
OLDNEW
« no previous file with comments | « pkg/analyzer/test/generated/compile_time_error_code_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698