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

Side by Side Diff: pkg/analysis_services/test/completion/local_computer_test.dart

Issue 467233003: refactor and cleanup code completion (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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library test.services.completion.dart.local; 5 library test.services.completion.dart.local;
6 6
7 import 'package:analysis_services/src/completion/local_computer.dart'; 7 import 'package:analysis_services/src/completion/local_computer.dart';
8 import 'package:analysis_testing/reflective_tests.dart'; 8 import 'package:analysis_testing/reflective_tests.dart';
9 import 'package:unittest/unittest.dart'; 9 import 'package:unittest/unittest.dart';
10 10
11 import 'completion_test_util.dart'; 11 import 'completion_test_util.dart';
12 12
13 main() { 13 main() {
14 groupSep = ' | '; 14 groupSep = ' | ';
15 runReflectiveTests(LocalComputerTest); 15 runReflectiveTests(LocalComputerTest);
16 } 16 }
17 17
18 @ReflectiveTestCase() 18 @ReflectiveTestCase()
19 class LocalComputerTest extends AbstractCompletionTest { 19 class LocalComputerTest extends AbstractCompletionTest {
20 20
21 @override 21 @override
22 void setUp() { 22 void setUp() {
23 super.setUp(); 23 super.setUp();
24 computer = new LocalComputer(); 24 computer = new LocalComputer();
25 } 25 }
26 26
27 test_block() { 27 test_block() {
28 addTestSource('class A {a() {var f; {var x;} ^ var g;}}'); 28 addTestSource('class A {a() {var f; {var x;} ^ var g;}}');
29 expect(computeFast(), isTrue); 29 expect(computeFast(), isTrue);
30 assertSuggestVariable('f'); 30 assertSuggestLocalVariable('f');
31 assertNotSuggested('g'); 31 assertNotSuggested('g');
32 assertNotSuggested('x'); 32 assertNotSuggested('x');
33 } 33 }
34 34
35 test_catch() { 35 test_catch() {
36 addTestSource('class A {a() {try{} catch (e) {^}}}'); 36 addTestSource('class A {a() {try{} catch (e) {^}}}');
37 expect(computeFast(), isTrue); 37 expect(computeFast(), isTrue);
38 assertSuggestParameter('e'); 38 assertSuggestParameter('e');
39 } 39 }
40 40
(...skipping 29 matching lines...) Expand all
70 expect(computeFast(), isTrue); 70 expect(computeFast(), isTrue);
71 //TODO (danrubel) should not be suggested 71 //TODO (danrubel) should not be suggested
72 // but var ^ in this test 72 // but var ^ in this test
73 // parses differently than B ^ in test above 73 // parses differently than B ^ in test above
74 assertSuggestClass('A'); 74 assertSuggestClass('A');
75 } 75 }
76 76
77 test_for() { 77 test_for() {
78 addTestSource('main(args) {for (int i; i < 10; ++i) {^}}'); 78 addTestSource('main(args) {for (int i; i < 10; ++i) {^}}');
79 expect(computeFast(), isTrue); 79 expect(computeFast(), isTrue);
80 assertSuggestVariable('i'); 80 assertSuggestLocalVariable('i');
81 } 81 }
82 82
83 test_forEach() { 83 test_forEach() {
84 addTestSource('main(args) {for (foo in bar) {^}}'); 84 addTestSource('main(args) {for (foo in bar) {^}}');
85 expect(computeFast(), isTrue); 85 expect(computeFast(), isTrue);
86 assertSuggestVariable('foo'); 86 assertSuggestLocalVariable('foo');
87 } 87 }
88 88
89 test_function() { 89 test_function() {
90 addTestSource('main(args) {x.then((b) {^});}'); 90 addTestSource('main(args) {x.then((b) {^});}');
91 expect(computeFast(), isTrue); 91 expect(computeFast(), isTrue);
92 assertSuggestFunction('main'); 92 assertSuggestFunction('main');
93 assertSuggestParameter('args'); 93 assertSuggestParameter('args');
94 assertSuggestParameter('b'); 94 assertSuggestParameter('b');
95 } 95 }
96 96
97 test_local_name() { 97 test_local_name() {
98 addTestSource('class A {a() {var f; A ^}}'); 98 addTestSource('class A {a() {var f; A ^}}');
99 expect(computeFast(), isTrue); 99 expect(computeFast(), isTrue);
100 //TODO (danrubel) should not be suggested 100 //TODO (danrubel) should not be suggested
101 // but A ^ in this test 101 // but A ^ in this test
102 // parses differently than var ^ in test below 102 // parses differently than var ^ in test below
103 assertSuggestClass('A'); 103 assertSuggestClass('A');
104 assertSuggestMethodName('a'); 104 assertSuggestMethodName('a');
105 assertSuggestVariable('f'); 105 assertSuggestLocalVariable('f');
106 } 106 }
107 107
108 test_local_name2() { 108 test_local_name2() {
109 addTestSource('class A {a() {var f; var ^}}'); 109 addTestSource('class A {a() {var f; var ^}}');
110 expect(computeFast(), isTrue); 110 expect(computeFast(), isTrue);
111 assertNotSuggested('A'); 111 assertNotSuggested('A');
112 assertNotSuggested('a'); 112 assertNotSuggested('a');
113 assertNotSuggested('f'); 113 assertNotSuggested('f');
114 } 114 }
115 115
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 expect(computeFast(), isTrue); 148 expect(computeFast(), isTrue);
149 // TODO (danrubel) should not be suggested 149 // TODO (danrubel) should not be suggested
150 // but var ^ in this test 150 // but var ^ in this test
151 // parses differently than B ^ in test above 151 // parses differently than B ^ in test above
152 assertSuggestClass('A'); 152 assertSuggestClass('A');
153 } 153 }
154 154
155 test_variableDeclaration() { 155 test_variableDeclaration() {
156 addTestSource('main() {int a = 1, b = 2 + ^;}'); 156 addTestSource('main() {int a = 1, b = 2 + ^;}');
157 expect(computeFast(), isTrue); 157 expect(computeFast(), isTrue);
158 assertSuggestVariable('a'); 158 assertSuggestLocalVariable('a');
159 assertNotSuggested('b'); 159 assertNotSuggested('b');
160 } 160 }
161 } 161 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698