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

Side by Side Diff: pkg/analysis_server/test/services/completion/arglist_contributor_test.dart

Issue 1266923004: More fixes for failures on the Windows bot (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 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
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.arglist; 5 library test.services.completion.dart.arglist;
6 6
7 import 'package:analysis_server/src/protocol.dart'; 7 import 'package:analysis_server/src/protocol.dart';
8 import 'package:analysis_server/src/services/completion/arglist_contributor.dart '; 8 import 'package:analysis_server/src/services/completion/arglist_contributor.dart ';
9 import 'package:analysis_server/src/services/completion/dart_completion_manager. dart'; 9 import 'package:analysis_server/src/services/completion/dart_completion_manager. dart';
10 import 'package:test_reflective_loader/test_reflective_loader.dart'; 10 import 'package:test_reflective_loader/test_reflective_loader.dart';
11 import 'package:unittest/unittest.dart'; 11 import 'package:unittest/unittest.dart';
12 12
13 import '../../utils.dart';
13 import 'completion_test_util.dart'; 14 import 'completion_test_util.dart';
14 15
15 main() { 16 main() {
16 groupSep = ' | '; 17 initializeTestEnvironment();
17 defineReflectiveTests(ArgListContributorTest); 18 defineReflectiveTests(ArgListContributorTest);
18 } 19 }
19 20
20 @reflectiveTest 21 @reflectiveTest
21 class ArgListContributorTest extends AbstractCompletionTest { 22 class ArgListContributorTest extends AbstractCompletionTest {
22 void assertNoOtherSuggestions(Iterable<CompletionSuggestion> expected) { 23 void assertNoOtherSuggestions(Iterable<CompletionSuggestion> expected) {
23 for (CompletionSuggestion suggestion in request.suggestions) { 24 for (CompletionSuggestion suggestion in request.suggestions) {
24 if (!expected.contains(suggestion)) { 25 if (!expected.contains(suggestion)) {
25 failedCompletion('did not expect completion: ' 26 failedCompletion('did not expect completion: '
26 '${suggestion.completion}\n $suggestion'); 27 '${suggestion.completion}\n $suggestion');
27 } 28 }
28 } 29 }
29 } 30 }
30 31
31 void assertSuggestArgumentList( 32 void assertSuggestArgumentList(
32 List<String> paramNames, List<String> paramTypes) { 33 List<String> paramNames, List<String> paramTypes) {
33 CompletionSuggestionKind csKind = CompletionSuggestionKind.ARGUMENT_LIST; 34 CompletionSuggestionKind csKind = CompletionSuggestionKind.ARGUMENT_LIST;
34 CompletionSuggestion cs = getSuggest(csKind: csKind); 35 CompletionSuggestion cs = getSuggest(csKind: csKind);
35 if (cs == null) { 36 if (cs == null) {
36 failedCompletion('expected completion $csKind', request.suggestions); 37 failedCompletion('expected completion $csKind', request.suggestions);
37 } 38 }
38 assertSuggestArgumentList_params( 39 assertSuggestArgumentList_params(
39 paramNames, paramTypes, cs.parameterNames, cs.parameterTypes); 40 paramNames, paramTypes, cs.parameterNames, cs.parameterTypes);
40 expect(cs.relevance, DART_RELEVANCE_HIGH); 41 expect(cs.relevance, DART_RELEVANCE_HIGH);
41 assertNoOtherSuggestions([cs]); 42 assertNoOtherSuggestions([cs]);
42 } 43 }
43 44
44 void assertSuggestArgumentList_params(List<String> expectedNames, 45 void assertSuggestArgumentList_params(
45 List<String> expectedTypes, List<String> actualNames, 46 List<String> expectedNames,
47 List<String> expectedTypes,
48 List<String> actualNames,
46 List<String> actualTypes) { 49 List<String> actualTypes) {
47 if (actualNames != null && 50 if (actualNames != null &&
48 actualNames.length == expectedNames.length && 51 actualNames.length == expectedNames.length &&
49 actualTypes != null && 52 actualTypes != null &&
50 actualTypes.length == expectedTypes.length) { 53 actualTypes.length == expectedTypes.length) {
51 int index = 0; 54 int index = 0;
52 while (index < expectedNames.length) { 55 while (index < expectedNames.length) {
53 if (actualNames[index] != expectedNames[index] || 56 if (actualNames[index] != expectedNames[index] ||
54 actualTypes[index] != expectedTypes[index]) { 57 actualTypes[index] != expectedTypes[index]) {
55 break; 58 break;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 test_ArgumentList_getter() { 93 test_ArgumentList_getter() {
91 addTestSource('class A {int get foo => 7; main() {foo(^)}'); 94 addTestSource('class A {int get foo => 7; main() {foo(^)}');
92 computeFast(); 95 computeFast();
93 return computeFull((bool result) { 96 return computeFull((bool result) {
94 assertNoSuggestions(); 97 assertNoSuggestions();
95 }); 98 });
96 } 99 }
97 100
98 test_ArgumentList_imported_function_0() { 101 test_ArgumentList_imported_function_0() {
99 // ArgumentList MethodInvocation ExpressionStatement Block 102 // ArgumentList MethodInvocation ExpressionStatement Block
100 addSource('/libA.dart', ''' 103 addSource(
104 '/libA.dart',
105 '''
101 library A; 106 library A;
102 bool hasLength(int expected) { } 107 bool hasLength(int expected) { }
103 expect() { } 108 expect() { }
104 void baz() { }'''); 109 void baz() { }''');
105 addTestSource(''' 110 addTestSource('''
106 import '/libA.dart' 111 import '/libA.dart'
107 class B { } 112 class B { }
108 String bar() => true; 113 String bar() => true;
109 void main() {expect(a^)}'''); 114 void main() {expect(a^)}''');
110 computeFast(); 115 computeFast();
111 return computeFull((bool result) { 116 return computeFull((bool result) {
112 assertNoSuggestions(); 117 assertNoSuggestions();
113 }); 118 });
114 } 119 }
115 120
116 test_ArgumentList_imported_function_1() { 121 test_ArgumentList_imported_function_1() {
117 // ArgumentList MethodInvocation ExpressionStatement Block 122 // ArgumentList MethodInvocation ExpressionStatement Block
118 addSource('/libA.dart', ''' 123 addSource(
124 '/libA.dart',
125 '''
119 library A; 126 library A;
120 bool hasLength(int expected) { } 127 bool hasLength(int expected) { }
121 expect(String arg) { } 128 expect(String arg) { }
122 void baz() { }'''); 129 void baz() { }''');
123 addTestSource(''' 130 addTestSource('''
124 import '/libA.dart' 131 import '/libA.dart'
125 class B { } 132 class B { }
126 String bar() => true; 133 String bar() => true;
127 void main() {expect(^)}'''); 134 void main() {expect(^)}''');
128 computeFast(); 135 computeFast();
129 return computeFull((bool result) { 136 return computeFull((bool result) {
130 assertSuggestArgumentList(['arg'], ['String']); 137 assertSuggestArgumentList(['arg'], ['String']);
131 }); 138 });
132 } 139 }
133 140
134 test_ArgumentList_imported_function_2() { 141 test_ArgumentList_imported_function_2() {
135 // ArgumentList MethodInvocation ExpressionStatement Block 142 // ArgumentList MethodInvocation ExpressionStatement Block
136 addSource('/libA.dart', ''' 143 addSource(
144 '/libA.dart',
145 '''
137 library A; 146 library A;
138 bool hasLength(int expected) { } 147 bool hasLength(int expected) { }
139 expect(String arg1, int arg2) { } 148 expect(String arg1, int arg2) { }
140 void baz() { }'''); 149 void baz() { }''');
141 addTestSource(''' 150 addTestSource('''
142 import '/libA.dart' 151 import '/libA.dart'
143 class B { } 152 class B { }
144 String bar() => true; 153 String bar() => true;
145 void main() {expect(^)}'''); 154 void main() {expect(^)}''');
146 computeFast(); 155 computeFast();
147 return computeFull((bool result) { 156 return computeFull((bool result) {
148 assertSuggestArgumentList(['arg1', 'arg2'], ['String', 'int']); 157 assertSuggestArgumentList(['arg1', 'arg2'], ['String', 'int']);
149 }); 158 });
150 } 159 }
151 160
152 test_ArgumentList_imported_function_3() { 161 test_ArgumentList_imported_function_3() {
153 // ArgumentList MethodInvocation ExpressionStatement Block 162 // ArgumentList MethodInvocation ExpressionStatement Block
154 addSource('/libA.dart', ''' 163 addSource(
164 '/libA.dart',
165 '''
155 library A; 166 library A;
156 bool hasLength(int expected) { } 167 bool hasLength(int expected) { }
157 expect(String arg1, int arg2, {bool arg3}) { } 168 expect(String arg1, int arg2, {bool arg3}) { }
158 void baz() { }'''); 169 void baz() { }''');
159 addTestSource(''' 170 addTestSource('''
160 import '/libA.dart' 171 import '/libA.dart'
161 class B { } 172 class B { }
162 String bar() => true; 173 String bar() => true;
163 void main() {expect(^)}'''); 174 void main() {expect(^)}''');
164 computeFast(); 175 computeFast();
165 return computeFull((bool result) { 176 return computeFull((bool result) {
166 assertSuggestArgumentList(['arg1', 'arg2'], ['String', 'int']); 177 assertSuggestArgumentList(['arg1', 'arg2'], ['String', 'int']);
167 }); 178 });
168 } 179 }
169 180
170 test_ArgumentList_imported_function_3a() { 181 test_ArgumentList_imported_function_3a() {
171 // ArgumentList MethodInvocation ExpressionStatement Block 182 // ArgumentList MethodInvocation ExpressionStatement Block
172 addSource('/libA.dart', ''' 183 addSource(
184 '/libA.dart',
185 '''
173 library A; 186 library A;
174 bool hasLength(int expected) { } 187 bool hasLength(int expected) { }
175 expect(String arg1, int arg2, {bool arg3}) { } 188 expect(String arg1, int arg2, {bool arg3}) { }
176 void baz() { }'''); 189 void baz() { }''');
177 addTestSource(''' 190 addTestSource('''
178 import '/libA.dart' 191 import '/libA.dart'
179 class B { } 192 class B { }
180 String bar() => true; 193 String bar() => true;
181 void main() {expect('hello', ^)}'''); 194 void main() {expect('hello', ^)}''');
182 computeFast(); 195 computeFast();
183 return computeFull((bool result) { 196 return computeFull((bool result) {
184 assertNoSuggestions(); 197 assertNoSuggestions();
185 }); 198 });
186 } 199 }
187 200
188 test_ArgumentList_imported_function_3b() { 201 test_ArgumentList_imported_function_3b() {
189 // ArgumentList MethodInvocation ExpressionStatement Block 202 // ArgumentList MethodInvocation ExpressionStatement Block
190 addSource('/libA.dart', ''' 203 addSource(
204 '/libA.dart',
205 '''
191 library A; 206 library A;
192 bool hasLength(int expected) { } 207 bool hasLength(int expected) { }
193 expect(String arg1, int arg2, {bool arg3}) { } 208 expect(String arg1, int arg2, {bool arg3}) { }
194 void baz() { }'''); 209 void baz() { }''');
195 addTestSource(''' 210 addTestSource('''
196 import '/libA.dart' 211 import '/libA.dart'
197 class B { } 212 class B { }
198 String bar() => true; 213 String bar() => true;
199 void main() {expect('hello', ^x)}'''); 214 void main() {expect('hello', ^x)}''');
200 computeFast(); 215 computeFast();
201 return computeFull((bool result) { 216 return computeFull((bool result) {
202 assertNoSuggestions(); 217 assertNoSuggestions();
203 }); 218 });
204 } 219 }
205 220
206 test_ArgumentList_imported_function_3c() { 221 test_ArgumentList_imported_function_3c() {
207 // ArgumentList MethodInvocation ExpressionStatement Block 222 // ArgumentList MethodInvocation ExpressionStatement Block
208 addSource('/libA.dart', ''' 223 addSource(
224 '/libA.dart',
225 '''
209 library A; 226 library A;
210 bool hasLength(int expected) { } 227 bool hasLength(int expected) { }
211 expect(String arg1, int arg2, {bool arg3}) { } 228 expect(String arg1, int arg2, {bool arg3}) { }
212 void baz() { }'''); 229 void baz() { }''');
213 addTestSource(''' 230 addTestSource('''
214 import '/libA.dart' 231 import '/libA.dart'
215 class B { } 232 class B { }
216 String bar() => true; 233 String bar() => true;
217 void main() {expect('hello', x^)}'''); 234 void main() {expect('hello', x^)}''');
218 computeFast(); 235 computeFast();
219 return computeFull((bool result) { 236 return computeFull((bool result) {
220 assertNoSuggestions(); 237 assertNoSuggestions();
221 }); 238 });
222 } 239 }
223 240
224 test_ArgumentList_imported_function_3d() { 241 test_ArgumentList_imported_function_3d() {
225 // ArgumentList MethodInvocation ExpressionStatement Block 242 // ArgumentList MethodInvocation ExpressionStatement Block
226 addSource('/libA.dart', ''' 243 addSource(
244 '/libA.dart',
245 '''
227 library A; 246 library A;
228 bool hasLength(int expected) { } 247 bool hasLength(int expected) { }
229 expect(String arg1, int arg2, {bool arg3}) { } 248 expect(String arg1, int arg2, {bool arg3}) { }
230 void baz() { }'''); 249 void baz() { }''');
231 addTestSource(''' 250 addTestSource('''
232 import '/libA.dart' 251 import '/libA.dart'
233 class B { } 252 class B { }
234 String bar() => true; 253 String bar() => true;
235 void main() {expect('hello', x ^)}'''); 254 void main() {expect('hello', x ^)}''');
236 computeFast(); 255 computeFast();
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 f(v,{int radix, int onError(String s)}){} 431 f(v,{int radix, int onError(String s)}){}
413 main() { f("16", radix: ^);}'''); 432 main() { f("16", radix: ^);}''');
414 computeFast(); 433 computeFast();
415 return computeFull((bool result) { 434 return computeFull((bool result) {
416 assertNoSuggestions(); 435 assertNoSuggestions();
417 }); 436 });
418 } 437 }
419 438
420 test_ArgumentList_local_method_0() { 439 test_ArgumentList_local_method_0() {
421 // ArgumentList MethodInvocation ExpressionStatement Block 440 // ArgumentList MethodInvocation ExpressionStatement Block
422 addSource('/libA.dart', ''' 441 addSource(
442 '/libA.dart',
443 '''
423 library A; 444 library A;
424 bool hasLength(int expected) { } 445 bool hasLength(int expected) { }
425 void baz() { }'''); 446 void baz() { }''');
426 addTestSource(''' 447 addTestSource('''
427 import '/libA.dart' 448 import '/libA.dart'
428 class B { 449 class B {
429 expect() { } 450 expect() { }
430 void foo() {expect(^)}} 451 void foo() {expect(^)}}
431 String bar() => true;'''); 452 String bar() => true;''');
432 computeFast(); 453 computeFast();
433 return computeFull((bool result) { 454 return computeFull((bool result) {
434 assertNoSuggestions(); 455 assertNoSuggestions();
435 }); 456 });
436 } 457 }
437 458
438 test_ArgumentList_local_method_2() { 459 test_ArgumentList_local_method_2() {
439 // ArgumentList MethodInvocation ExpressionStatement Block 460 // ArgumentList MethodInvocation ExpressionStatement Block
440 addSource('/libA.dart', ''' 461 addSource(
462 '/libA.dart',
463 '''
441 library A; 464 library A;
442 bool hasLength(int expected) { } 465 bool hasLength(int expected) { }
443 void baz() { }'''); 466 void baz() { }''');
444 addTestSource(''' 467 addTestSource('''
445 import '/libA.dart' 468 import '/libA.dart'
446 class B { 469 class B {
447 expect(arg, int blat) { } 470 expect(arg, int blat) { }
448 void foo() {expect(^)}} 471 void foo() {expect(^)}}
449 String bar() => true;'''); 472 String bar() => true;''');
450 computeFast(); 473 computeFast();
451 return computeFull((bool result) { 474 return computeFull((bool result) {
452 assertSuggestArgumentList(['arg', 'blat'], ['dynamic', 'int']); 475 assertSuggestArgumentList(['arg', 'blat'], ['dynamic', 'int']);
453 }); 476 });
454 } 477 }
455 } 478 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698