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

Unified Diff: pkg/analysis_server/test/services/correction/fix_test.dart

Issue 987173002: Quick Fix for returning Future from 'async' functions. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analysis_server/lib/src/services/correction/fix_internal.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
« no previous file with comments | « pkg/analysis_server/lib/src/services/correction/fix_internal.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698