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

Unified Diff: pkg/analysis_server/test/domain_completion_test.dart

Issue 2662973007: suggest catch and finally keywords (Closed)
Patch Set: merge 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/domain_completion_test.dart
diff --git a/pkg/analysis_server/test/domain_completion_test.dart b/pkg/analysis_server/test/domain_completion_test.dart
index 87b98c9c372df8c5b9fbc3260acfff95e38ac42a..31d853be150d33cc134205fc9485770aeeea1c1d 100644
--- a/pkg/analysis_server/test/domain_completion_test.dart
+++ b/pkg/analysis_server/test/domain_completion_test.dart
@@ -99,6 +99,76 @@ class CompletionDomainHandlerTest extends AbstractCompletionDomainTest {
expect(suggestions, hasLength(2));
}
+ test_catch() async {
+ addTestFile('main() {try {} ^}');
+ await getSuggestions();
+ assertHasResult(CompletionSuggestionKind.KEYWORD, 'on',
+ relevance: DART_RELEVANCE_KEYWORD);
+ assertHasResult(CompletionSuggestionKind.KEYWORD, 'catch',
+ relevance: DART_RELEVANCE_KEYWORD);
+ assertHasResult(CompletionSuggestionKind.KEYWORD, 'finally',
+ relevance: DART_RELEVANCE_KEYWORD);
+ expect(suggestions, hasLength(3));
+ }
+
+ test_catch2() async {
+ addTestFile('main() {try {} on Foo {} ^}');
+ await getSuggestions();
+ assertHasResult(CompletionSuggestionKind.KEYWORD, 'on',
+ relevance: DART_RELEVANCE_KEYWORD);
+ assertHasResult(CompletionSuggestionKind.KEYWORD, 'catch',
+ relevance: DART_RELEVANCE_KEYWORD);
+ assertHasResult(CompletionSuggestionKind.KEYWORD, 'finally',
+ relevance: DART_RELEVANCE_KEYWORD);
+ assertHasResult(CompletionSuggestionKind.KEYWORD, 'for',
+ relevance: DART_RELEVANCE_KEYWORD);
+ suggestions.firstWhere(
+ (CompletionSuggestion suggestion) =>
+ suggestion.kind != CompletionSuggestionKind.KEYWORD, orElse: () {
+ fail('Expected suggestions other than keyword suggestions');
+ });
+ }
+
+ test_catch3() async {
+ addTestFile('main() {try {} catch (e) {} finally {} ^}');
+ await getSuggestions();
+ assertNoResult('on');
+ assertNoResult('catch');
+ assertNoResult('finally');
+ assertHasResult(CompletionSuggestionKind.KEYWORD, 'for',
+ relevance: DART_RELEVANCE_KEYWORD);
+ suggestions.firstWhere(
+ (CompletionSuggestion suggestion) =>
+ suggestion.kind != CompletionSuggestionKind.KEYWORD, orElse: () {
+ fail('Expected suggestions other than keyword suggestions');
+ });
+ }
+
+ test_catch4() async {
+ addTestFile('main() {try {} finally {} ^}');
+ await getSuggestions();
+ assertNoResult('on');
+ assertNoResult('catch');
+ assertNoResult('finally');
+ assertHasResult(CompletionSuggestionKind.KEYWORD, 'for',
+ relevance: DART_RELEVANCE_KEYWORD);
+ suggestions.firstWhere(
+ (CompletionSuggestion suggestion) =>
+ suggestion.kind != CompletionSuggestionKind.KEYWORD, orElse: () {
+ fail('Expected suggestions other than keyword suggestions');
+ });
+ }
+
+ test_catch5() async {
+ addTestFile('main() {try {} ^ finally {}}');
+ await getSuggestions();
+ assertHasResult(CompletionSuggestionKind.KEYWORD, 'on',
+ relevance: DART_RELEVANCE_KEYWORD);
+ assertHasResult(CompletionSuggestionKind.KEYWORD, 'catch',
+ relevance: DART_RELEVANCE_KEYWORD);
+ expect(suggestions, hasLength(2));
+ }
+
test_html() {
testFile = '/project/web/test.html';
addTestFile('''

Powered by Google App Engine
This is Rietveld 408576698