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 b0258a3905902744a85baf598c0730b866d643ed..5244097290c6518adeacff56a2d9c881f6f79b62 100644 |
--- a/pkg/analysis_server/test/services/correction/fix_test.dart |
+++ b/pkg/analysis_server/test/services/correction/fix_test.dart |
@@ -463,40 +463,42 @@ main() { |
'''); |
List<AnalysisError> errors = context.computeErrors(testSource); |
expect(errors, hasLength(2)); |
- String message1 = "Expected to find ';'"; |
- String message2 = "Undefined name 'await'"; |
- expect(errors.map((e) => e.message), unorderedEquals([message1, message2])); |
- for (AnalysisError error in errors) { |
- if (error.message == message1) { |
- List<Fix> fixes = await _computeFixes(error); |
- expect(fixes, isEmpty); |
- } |
- if (error.message == message2) { |
- List<Fix> fixes = await _computeFixes(error); |
- // has exactly one fix |
- expect(fixes, hasLength(1)); |
- Fix fix = fixes[0]; |
- expect(fix.kind, DartFixKind.ADD_ASYNC); |
- // apply to "file" |
- List<SourceFileEdit> fileEdits = fix.change.edits; |
- expect(fileEdits, hasLength(1)); |
- resultCode = SourceEdit.applySequence(testCode, fileEdits[0].edits); |
- // verify |
- expect( |
- resultCode, |
- ''' |
+ errors.sort((a, b) => a.message.compareTo(b.message)); |
+ // No fix for ";". |
+ { |
+ AnalysisError error = errors[0]; |
+ expect(error.message, "Expected to find ';'"); |
+ List<Fix> fixes = await _computeFixes(error); |
+ expect(fixes, isEmpty); |
+ } |
+ // Has fix for "await". |
+ { |
+ AnalysisError error = errors[1]; |
+ expect(error.message, startsWith("Undefined name 'await';")); |
+ List<Fix> fixes = await _computeFixes(error); |
+ // has exactly one fix |
+ expect(fixes, hasLength(1)); |
+ Fix fix = fixes[0]; |
+ expect(fix.kind, DartFixKind.ADD_ASYNC); |
+ // apply to "file" |
+ List<SourceFileEdit> fileEdits = fix.change.edits; |
+ expect(fileEdits, hasLength(1)); |
+ resultCode = SourceEdit.applySequence(testCode, fileEdits[0].edits); |
+ // verify |
+ expect( |
+ resultCode, |
+ ''' |
foo() {} |
main() async { |
await foo(); |
} |
'''); |
- } |
} |
} |
test_addSync_expressionFunctionBody() async { |
errorFilter = (AnalysisError error) { |
- return error.errorCode == StaticWarningCode.UNDEFINED_IDENTIFIER; |
+ return error.errorCode == StaticWarningCode.UNDEFINED_IDENTIFIER_AWAIT; |
}; |
resolveTestUnit(''' |
foo() {} |
@@ -512,7 +514,7 @@ main() async => await foo(); |
test_addSync_returnFuture() async { |
errorFilter = (AnalysisError error) { |
- return error.errorCode == StaticWarningCode.UNDEFINED_IDENTIFIER; |
+ return error.errorCode == StaticWarningCode.UNDEFINED_IDENTIFIER_AWAIT; |
}; |
resolveTestUnit(''' |
foo() {} |
@@ -536,7 +538,7 @@ Future<int> main() async { |
test_addSync_returnFuture_alreadyFuture() async { |
errorFilter = (AnalysisError error) { |
- return error.errorCode == StaticWarningCode.UNDEFINED_IDENTIFIER; |
+ return error.errorCode == StaticWarningCode.UNDEFINED_IDENTIFIER_AWAIT; |
}; |
resolveTestUnit(''' |
import 'dart:async'; |
@@ -560,7 +562,7 @@ Future<int> main() async { |
test_addSync_returnFuture_dynamic() async { |
errorFilter = (AnalysisError error) { |
- return error.errorCode == StaticWarningCode.UNDEFINED_IDENTIFIER; |
+ return error.errorCode == StaticWarningCode.UNDEFINED_IDENTIFIER_AWAIT; |
}; |
resolveTestUnit(''' |
foo() {} |
@@ -582,7 +584,7 @@ dynamic main() async { |
test_addSync_returnFuture_noType() async { |
errorFilter = (AnalysisError error) { |
- return error.errorCode == StaticWarningCode.UNDEFINED_IDENTIFIER; |
+ return error.errorCode == StaticWarningCode.UNDEFINED_IDENTIFIER_AWAIT; |
}; |
resolveTestUnit(''' |
foo() {} |