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

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

Issue 1924683002: Code completion bug fix, https://github.com/dart-lang/sdk/issues/26342, and test cleanup in variabl… (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: rebase with bleeding_edge Created 4 years, 8 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/completion/dart/variable_name_contributor.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/variable_name_contributor_test.dart
diff --git a/pkg/analysis_server/test/services/completion/dart/variable_name_contributor_test.dart b/pkg/analysis_server/test/services/completion/dart/variable_name_contributor_test.dart
index 72a4cab24ae375037db3be39ed00fcb1c58e5b05..6896850c3c96ba9af4aad88b9525a8d8b2bc1bc3 100644
--- a/pkg/analysis_server/test/services/completion/dart/variable_name_contributor_test.dart
+++ b/pkg/analysis_server/test/services/completion/dart/variable_name_contributor_test.dart
@@ -24,24 +24,24 @@ class VariableNameContributorTest extends DartCompletionContributorTest {
return new VariableNameContributor();
}
- test_ExpressionStatement_short() async {
+ test_ExpressionStatement_dont_suggest_type() async {
addTestSource('''
- f() { A ^ }
+ f() { a ^ }
''');
await computeSuggestions();
expect(replacementOffset, completionOffset);
expect(replacementLength, 0);
- assertSuggestName('a');
+ assertNotSuggested('a');
}
- test_ExpressionStatement_short_semicolon() async {
+ test_ExpressionStatement_dont_suggest_type_semicolon() async {
addTestSource('''
- f() { A ^; }
+ f() { a ^; }
''');
await computeSuggestions();
expect(replacementOffset, completionOffset);
expect(replacementLength, 0);
- assertSuggestName('a');
+ assertNotSuggested('a');
}
test_ExpressionStatement_long() async {
@@ -100,9 +100,9 @@ class VariableNameContributorTest extends DartCompletionContributorTest {
assertSuggestName('name');
}
- test_ExpressionStatement_top_level_short() async {
+ test_ExpressionStatement_short() async {
addTestSource('''
- A ^
+ f() { A ^ }
''');
await computeSuggestions();
expect(replacementOffset, completionOffset);
@@ -110,9 +110,9 @@ class VariableNameContributorTest extends DartCompletionContributorTest {
assertSuggestName('a');
}
- test_ExpressionStatement_top_level_short_semicolon() async {
+ test_ExpressionStatement_short_semicolon() async {
addTestSource('''
- A ^;
+ f() { A ^; }
''');
await computeSuggestions();
expect(replacementOffset, completionOffset);
@@ -120,7 +120,27 @@ class VariableNameContributorTest extends DartCompletionContributorTest {
assertSuggestName('a');
}
- test_ExpressionStatement_top_level_long() async {
+ test_TopLevelVariableDeclaration_dont_suggest_type() async {
+ addTestSource('''
+ a ^
+ ''');
+ await computeSuggestions();
+ expect(replacementOffset, completionOffset);
+ expect(replacementLength, 0);
+ assertNotSuggested('a');
+ }
+
+ test_TopLevelVariableDeclaration_dont_suggest_type_semicolon() async {
+ addTestSource('''
+ a ^;
+ ''');
+ await computeSuggestions();
+ expect(replacementOffset, completionOffset);
+ expect(replacementLength, 0);
+ assertNotSuggested('a');
+ }
+
+ test_TopLevelVariableDeclaration_long() async {
addTestSource('''
AbstractCrazyNonsenseClassName ^
''');
@@ -134,7 +154,7 @@ class VariableNameContributorTest extends DartCompletionContributorTest {
assertSuggestName('name');
}
- test_ExpressionStatement_top_level_long_semicolon() async {
+ test_TopLevelVariableDeclaration_long_semicolon() async {
addTestSource('''
AbstractCrazyNonsenseClassName ^;
''');
@@ -148,7 +168,35 @@ class VariableNameContributorTest extends DartCompletionContributorTest {
assertSuggestName('name');
}
- test_ExpressionStatement_top_level_prefixed() async {
+ test_TopLevelVariableDeclaration_partial() async {
+ addTestSource('''
+ AbstractCrazyNonsenseClassName abs^
+ ''');
+ await computeSuggestions();
+ expect(replacementOffset, completionOffset - 3);
+ expect(replacementLength, 3);
+ assertSuggestName('abstractCrazyNonsenseClassName');
+ assertSuggestName('crazyNonsenseClassName');
+ assertSuggestName('nonsenseClassName');
+ assertSuggestName('className');
+ assertSuggestName('name');
+ }
+
+ test_TopLevelVariableDeclaration_partial_semicolon() async {
+ addTestSource('''
+ AbstractCrazyNonsenseClassName abs^
+ ''');
+ await computeSuggestions();
+ expect(replacementOffset, completionOffset - 3);
+ expect(replacementLength, 3);
+ assertSuggestName('abstractCrazyNonsenseClassName');
+ assertSuggestName('crazyNonsenseClassName');
+ assertSuggestName('nonsenseClassName');
+ assertSuggestName('className');
+ assertSuggestName('name');
+ }
+
+ test_TopLevelVariableDeclaration_prefixed() async {
addTestSource('''
prefix.AbstractCrazyNonsenseClassName ^
''');
@@ -162,7 +210,7 @@ class VariableNameContributorTest extends DartCompletionContributorTest {
assertSuggestName('name');
}
- test_ExpressionStatement_top_level_prefixed_semicolon() async {
+ test_TopLevelVariableDeclaration_prefixed_semicolon() async {
addTestSource('''
prefix.AbstractCrazyNonsenseClassName ^;
''');
@@ -176,24 +224,23 @@ class VariableNameContributorTest extends DartCompletionContributorTest {
assertSuggestName('name');
}
- test_VariableDeclaration_short() async {
+ test_TopLevelVariableDeclaration_short() async {
addTestSource('''
- AAA a^
+ A ^
''');
await computeSuggestions();
- expect(replacementOffset, completionOffset-1);
- expect(replacementLength, 1);
- assertSuggestName('aaa');
+ expect(replacementOffset, completionOffset);
+ expect(replacementLength, 0);
+ assertSuggestName('a');
}
- test_VariableDeclaration_short_semicolon() async {
+ test_TopLevelVariableDeclaration_short_semicolon() async {
addTestSource('''
- AAA a^;
+ A ^;
''');
await computeSuggestions();
- expect(replacementOffset, completionOffset-1);
- expect(replacementLength, 1);
- assertSuggestName('aaa');
+ expect(replacementOffset, completionOffset);
+ expect(replacementLength, 0);
+ assertSuggestName('a');
}
-
}
« no previous file with comments | « pkg/analysis_server/lib/src/services/completion/dart/variable_name_contributor.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698