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

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

Issue 454403003: local code completion suggestions (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: merge and address comments 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/local_computer_test.dart
diff --git a/pkg/analysis_services/test/completion/local_computer_test.dart b/pkg/analysis_services/test/completion/local_computer_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..deb81346271b9bd558a00e9edcddcf095616c244
--- /dev/null
+++ b/pkg/analysis_services/test/completion/local_computer_test.dart
@@ -0,0 +1,103 @@
+// 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.local;
+
+import 'package:analysis_services/src/completion/local_computer.dart';
+import 'package:analysis_testing/reflective_tests.dart';
+import 'package:unittest/unittest.dart';
+
+import 'completion_test_util.dart';
+
+main() {
+ groupSep = ' | ';
+ runReflectiveTests(LocalComputerTest);
+}
+
+@ReflectiveTestCase()
+class LocalComputerTest extends AbstractCompletionTest {
+
+ @override
+ void setUp() {
+ super.setUp();
+ computer = new LocalComputer();
+ }
+
+ test_block() {
+ addTestSource('class A {a() {var f; ^ var g;}}');
+ expect(computeFast(), isTrue);
+ assertSuggestVariable('f');
+ assertNotSuggested('g');
+ }
+
+ test_catch() {
+ addTestSource('class A {a() {try{} catch (e) {^}}}');
+ expect(computeFast(), isTrue);
+ assertSuggestParameter('e');
+ }
+
+ test_catch2() {
+ addTestSource('class A {a() {try{} catch (e, s) {^}}}');
+ expect(computeFast(), isTrue);
+ assertSuggestParameter('e');
+ assertSuggestParameter('s');
+ }
+
+ test_compilationUnit_declarations() {
+ addTestSource('class A {^} class B {} var T;');
+ expect(computeFast(), isTrue);
+ assertSuggestClass('A');
+ assertSuggestClass('B');
+ assertSuggestTopLevelVar('T');
+ }
+
+ test_compilationUnit_directives() {
+ addTestSource('import "boo.dart" as x; class A {^}');
+ expect(computeFast(), isTrue);
+ assertSuggestLibraryPrefix('x');
+ }
+
+ test_for() {
+ addTestSource('main(args) {for (int i; i < 10; ++i) {^}}');
+ expect(computeFast(), isTrue);
+ assertSuggestVariable('i');
+ }
+
+ test_forEach() {
+ addTestSource('main(args) {for (foo in bar) {^}}');
+ expect(computeFast(), isTrue);
+ assertSuggestVariable('foo');
+ }
+
+ test_function() {
+ addTestSource('main(args) {^}');
+ expect(computeFast(), isTrue);
+ assertSuggestFunction('main');
+ assertSuggestParameter('args');
+ }
+
+ test_members() {
+ addTestSource('class A {var f; a() {^} var g;}');
+ expect(computeFast(), isTrue);
+ assertSuggestMethodName('a');
+ assertSuggestField('f');
+ assertSuggestField('g');
+ }
+
+ test_methodParam_named() {
+ addTestSource('class A {a(x, {y: boo}) {^}}');
+ expect(computeFast(), isTrue);
+ assertSuggestMethodName('a');
+ assertSuggestParameter('x');
+ assertSuggestParameter('y');
+ }
+
+ test_methodParam_positional() {
+ addTestSource('class A {a(x, [y=1]) {^}}');
+ expect(computeFast(), isTrue);
+ assertSuggestMethodName('a');
+ assertSuggestParameter('x');
+ assertSuggestParameter('y');
+ }
+}
« no previous file with comments | « pkg/analysis_services/test/completion/completion_test_util.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