| OLD | NEW |
| 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 3044 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3055 test_redirectToNonClass_undefinedIdentifier() async { | 3055 test_redirectToNonClass_undefinedIdentifier() async { |
| 3056 Source source = addSource(r''' | 3056 Source source = addSource(r''' |
| 3057 class B { | 3057 class B { |
| 3058 factory B() = A; | 3058 factory B() = A; |
| 3059 }'''); | 3059 }'''); |
| 3060 await computeAnalysisResult(source); | 3060 await computeAnalysisResult(source); |
| 3061 assertErrors(source, [StaticWarningCode.REDIRECT_TO_NON_CLASS]); | 3061 assertErrors(source, [StaticWarningCode.REDIRECT_TO_NON_CLASS]); |
| 3062 verify([source]); | 3062 verify([source]); |
| 3063 } | 3063 } |
| 3064 | 3064 |
| 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 |
| 3065 test_returnWithoutValue_async() async { | 3075 test_returnWithoutValue_async() async { |
| 3066 Source source = addSource(''' | 3076 Source source = addSource(''' |
| 3067 import 'dart:async'; | 3077 import 'dart:async'; |
| 3068 Future<int> f() async { | 3078 Future<int> f() async { |
| 3069 return; | 3079 return; |
| 3070 } | 3080 } |
| 3071 '''); | 3081 '''); |
| 3072 await computeAnalysisResult(source); | 3082 await computeAnalysisResult(source); |
| 3073 assertErrors(source, [StaticWarningCode.RETURN_WITHOUT_VALUE]); | 3083 assertErrors(source, [StaticWarningCode.RETURN_WITHOUT_VALUE]); |
| 3074 verify([source]); | 3084 verify([source]); |
| (...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3717 | 3727 |
| 3718 test_voidReturnForGetter() async { | 3728 test_voidReturnForGetter() async { |
| 3719 Source source = addSource(r''' | 3729 Source source = addSource(r''' |
| 3720 class S { | 3730 class S { |
| 3721 void get value {} | 3731 void get value {} |
| 3722 }'''); | 3732 }'''); |
| 3723 await computeAnalysisResult(source); | 3733 await computeAnalysisResult(source); |
| 3724 assertErrors(source, [StaticWarningCode.VOID_RETURN_FOR_GETTER]); | 3734 assertErrors(source, [StaticWarningCode.VOID_RETURN_FOR_GETTER]); |
| 3725 } | 3735 } |
| 3726 } | 3736 } |
| OLD | NEW |