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

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

Issue 2692983003: Add fix for missing @required params. (Closed)
Patch Set: Removed unneeded async. Created 3 years, 10 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
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 d6bd2db659c3a682a8e929ed8b544a6d3f96e969..070e85199631182962f54ec830af24a73fbff453 100644
--- a/pkg/analysis_server/test/services/correction/fix_test.dart
+++ b/pkg/analysis_server/test/services/correction/fix_test.dart
@@ -296,6 +296,65 @@ main() {
await assertNoFix(DartFixKind.ADD_MISSING_PARAMETER_POSITIONAL);
}
+ void _addMetaPackageSource() {
scheglov 2017/02/14 22:06:07 Please format and sort and files that you change i
pquitslund 2017/02/14 23:41:38 Whoops! I got confused by the "Rearrange Code" ac
+ addPackageSource('meta', 'meta.dart', r'''
+library meta;
+
+const Required required = const Required();
+
+class Required {
+ final String reason;
+ const Required([this.reason]);
+}
+''');
+ }
+
+ test_addMissingRequiredParam_single() async {
+ _addMetaPackageSource();
+
+ await resolveTestUnit('''
+import 'package:meta/meta.dart';
+
+test({@required int a}) {}
+main() {
+ test();
+}
+''');
+ await assertHasFix(
+ DartFixKind.ADD_MISSING_REQUIRED_PARAMETER,
+ '''
+import 'package:meta/meta.dart';
+
+test({@required int a}) {}
+main() {
+ test(a: null);
+}
+''');
+ }
+
+ test_addMissingRequiredParam_multiple() async {
scheglov 2017/02/14 22:06:07 This looks like "_hasOtherArgument" test. But yes,
pquitslund 2017/02/14 23:41:38 Acknowledged.
+ _addMetaPackageSource();
+
+ await resolveTestUnit('''
+import 'package:meta/meta.dart';
+
+test({@required int a, @required int b}) {}
+main() {
+ test(a: 3);
+}
+''');
+ await assertHasFix(
+ DartFixKind.ADD_MISSING_REQUIRED_PARAMETER,
+ '''
+import 'package:meta/meta.dart';
+
+test({@required int a, @required int b}) {}
+main() {
+ test(a: 3, b: null);
+}
+''');
+ }
+
test_addMissingParameter_function_positional_hasZero() async {
await resolveTestUnit('''
test() {}

Powered by Google App Engine
This is Rietveld 408576698