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

Unified Diff: pkg/analysis_server/test/services/completion/dart/local_reference_contributor_test.dart

Issue 2722253002: Calculate default args for local reference completions. (Closed)
Patch Set: Cleanup; added test. 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
« no previous file with comments | « pkg/analysis_server/test/services/completion/dart/completion_contributor_util.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/completion/dart/local_reference_contributor_test.dart
diff --git a/pkg/analysis_server/test/services/completion/dart/local_reference_contributor_test.dart b/pkg/analysis_server/test/services/completion/dart/local_reference_contributor_test.dart
index 45624f2c583401a1984a2b65a1a8095e2d8e14a3..15b37b29dc1222f2b9e75f5372ccfc2b725c3040 100644
--- a/pkg/analysis_server/test/services/completion/dart/local_reference_contributor_test.dart
+++ b/pkg/analysis_server/test/services/completion/dart/local_reference_contributor_test.dart
@@ -4597,4 +4597,68 @@ class LocalReferenceContributorTest_Driver
extends LocalReferenceContributorTest {
@override
bool get enableNewAnalysisDriver => true;
+
+ test_ArgDefaults_function() async {
+ addTestSource('''
+bool hasLength(int expected, bool b) => false;
+void main() {h^}''');
+ await computeSuggestions();
+
+ assertSuggestFunction('hasLength', 'bool',
+ relevance: DART_RELEVANCE_LOCAL_FUNCTION,
+ defaultArgListString: 'expected, b');
+ }
+
+ test_ArgDefaults_function_none() async {
+ addTestSource('''
+bool hasLength() => false;
+void main() {h^}''');
+ await computeSuggestions();
+
+ assertSuggestFunction('hasLength', 'bool',
+ relevance: DART_RELEVANCE_LOCAL_FUNCTION, defaultArgListString: null);
+ }
+
+ test_ArgDefaults_function_with_optional_positional() async {
+ _addMetaPackageSource();
+ addTestSource('''
+import 'package:meta/meta.dart';
+
+bool foo(int bar, [bool boo, int baz]) => false;
+void main() {h^}''');
+ await computeSuggestions();
+
+ assertSuggestFunction('foo', 'bool',
+ relevance: DART_RELEVANCE_LOCAL_FUNCTION, defaultArgListString: 'bar');
+ }
+
+ test_ArgDefaults_function_with_required_named() async {
+ _addMetaPackageSource();
+ addTestSource('''
+import 'package:meta/meta.dart';
+
+bool foo(int bar, {bool boo, @required int baz}) => false;
+void main() {h^}''');
+ await computeSuggestions();
+
+ assertSuggestFunction('foo', 'bool',
+ relevance: DART_RELEVANCE_LOCAL_FUNCTION,
+ defaultArgListString: 'bar, baz: null');
+ }
+
+ void _addMetaPackageSource() {
+ addPackageSource(
+ 'meta',
+ 'meta.dart',
+ r'''
+library meta;
+
+const Required required = const Required();
+
+class Required {
+ final String reason;
+ const Required([this.reason]);
+}
+''');
+ }
}
« no previous file with comments | « pkg/analysis_server/test/services/completion/dart/completion_contributor_util.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698