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

Unified Diff: pkg/analysis_services/test/completion/keyword_computer_test.dart

Issue 461063002: add keyword suggestions (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: merge Created 6 years, 4 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_services/test/completion/keyword_computer_test.dart
diff --git a/pkg/analysis_services/test/completion/keyword_computer_test.dart b/pkg/analysis_services/test/completion/keyword_computer_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..49ad8418244fa658a750983a1798197b41023a02
--- /dev/null
+++ b/pkg/analysis_services/test/completion/keyword_computer_test.dart
@@ -0,0 +1,73 @@
+// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+library test.services.completion.dart.keyword;
+
+import 'package:analysis_services/completion/completion_suggestion.dart';
+import 'package:analysis_services/src/completion/keyword_computer.dart';
+import 'package:analysis_testing/reflective_tests.dart';
+import 'package:analyzer/src/generated/scanner.dart';
+import 'package:unittest/unittest.dart';
+
+import 'completion_test_util.dart';
+
+main() {
+ groupSep = ' | ';
+ runReflectiveTests(KeywordComputerTest);
+}
+
+@ReflectiveTestCase()
+class KeywordComputerTest extends AbstractCompletionTest {
+
+ void assertSuggestKeywords(List<String> names) {
+ Keyword.values.forEach((Keyword keyword) {
+ if (names.contains(keyword.syntax)) {
+ assertSuggest(CompletionSuggestionKind.KEYWORD, keyword.syntax);
+ } else {
+ assertNotSuggested(keyword.syntax);
+ }
+ });
+ }
+
+ @override
+ void setUp() {
+ super.setUp();
+ computer = new KeywordComputer();
+ }
+
+ test_class_extends() {
+ addTestSource('class A ^');
+ expect(computeFast(), isTrue);
+ assertSuggestKeywords(['extends', 'implements', 'with']);
+ }
+
+ test_class_extends_name() {
+ addTestSource('class A extends ^');
+ expect(computeFast(), isTrue);
+ assertSuggestKeywords([]);
+ }
+
+ test_class_name() {
+ addTestSource('class ^');
+ expect(computeFast(), isTrue);
+ assertSuggestKeywords([]);
+ }
+
+ test_empty() {
+ addTestSource('^');
+ expect(computeFast(), isTrue);
+ assertSuggestKeywords(
+ [
+ 'abstract',
+ 'class',
+ 'const',
+ 'export',
+ 'final',
+ 'import',
+ 'library',
+ 'part',
+ 'typedef',
+ 'var']);
+ }
+}
« no previous file with comments | « pkg/analysis_services/lib/src/completion/keyword_computer.dart ('k') | pkg/analysis_services/test/completion/test_all.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698