Chromium Code Reviews| Index: pkg/analysis_server/test/services/correction/fix_test.dart |
| diff --git a/pkg/analysis_server/test/services/correction/fix_test.dart b/pkg/analysis_server/test/services/correction/fix_test.dart |
| index e62784207e308870bf1727b42bbcf61c22c20127..4608f6bd7520e5829a91554aae5ed2c2e35684f3 100644 |
| --- a/pkg/analysis_server/test/services/correction/fix_test.dart |
| +++ b/pkg/analysis_server/test/services/correction/fix_test.dart |
| @@ -1736,6 +1736,71 @@ main() { |
| '''); |
| } |
| + void test_illegalAsyncReturnType_asyncLibrary_import() { |
| + errorFilter = (AnalysisError error) { |
| + return error.errorCode == StaticTypeWarningCode.ILLEGAL_ASYNC_RETURN_TYPE; |
| + }; |
| + resolveTestUnit(''' |
| +library main; |
| +int main() async { |
| +} |
| +'''); |
| + assertHasFix(FixKind.REPLACE_RETURN_TYPE_FUTURE, ''' |
| +library main; |
| +import 'dart:async'; |
| +Future<int> main() async { |
| +} |
| +'''); |
| + } |
| + |
| + void test_illegalAsyncReturnType_asyncLibrary_usePrefix() { |
| + errorFilter = (AnalysisError error) { |
| + return error.errorCode == StaticTypeWarningCode.ILLEGAL_ASYNC_RETURN_TYPE; |
| + }; |
| + resolveTestUnit(''' |
| +import 'dart:async' as al; |
| +int main() async { |
| +} |
| +'''); |
| + assertHasFix(FixKind.REPLACE_RETURN_TYPE_FUTURE, ''' |
| +import 'dart:async' as al; |
| +al.Future<int> main() async { |
| +} |
| +'''); |
| + } |
| + |
| + void test_illegalAsyncReturnType_complexTypeName() { |
| + errorFilter = (AnalysisError error) { |
| + return error.errorCode == StaticTypeWarningCode.ILLEGAL_ASYNC_RETURN_TYPE; |
| + }; |
| + resolveTestUnit(''' |
| +import 'dart:async'; |
| +List<int> main() async { |
| +} |
| +'''); |
| + assertHasFix(FixKind.REPLACE_RETURN_TYPE_FUTURE, ''' |
| +import 'dart:async'; |
| +Future<List<int>> main() async { |
| +} |
| +'''); |
| + } |
| + |
| + void test_illegalAsyncReturnType_void() { |
|
Brian Wilkerson
2015/03/09 21:05:35
Perhaps a test case containing:
import 'dart:asyn
scheglov
2015/03/09 21:34:37
Well, we don't report any error in this case.
So,
|
| + errorFilter = (AnalysisError error) { |
| + return error.errorCode == StaticTypeWarningCode.ILLEGAL_ASYNC_RETURN_TYPE; |
| + }; |
| + resolveTestUnit(''' |
| +import 'dart:async'; |
| +void main() async { |
| +} |
| +'''); |
| + assertHasFix(FixKind.REPLACE_RETURN_TYPE_FUTURE, ''' |
| +import 'dart:async'; |
| +Future main() async { |
| +} |
| +'''); |
| + } |
| + |
| void test_importLibraryPackage_withClass() { |
| _configureMyPkg(''' |
| library my_lib; |