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

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

Issue 632323002: local cascade suggestion fix and move towards common tests (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: merge Created 6 years, 2 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
« no previous file with comments | « pkg/analysis_server/test/services/completion/invocation_computer_test.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_server/src/services/completion/local_computer.dart'; 7 import 'package:analysis_server/src/services/completion/local_computer.dart';
8 import 'package:unittest/unittest.dart'; 8 import 'package:unittest/unittest.dart';
9 9
10 import '../../reflective_tests.dart'; 10 import '../../reflective_tests.dart';
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 AbstractSelectorSuggestionTest {
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_BinaryExpression_LHS() { 27 test_BinaryExpression_LHS() {
28 // SimpleIdentifier BinaryExpression VariableDeclaration 28 // SimpleIdentifier BinaryExpression VariableDeclaration
29 // VariableDeclarationList VariableDeclarationStatement 29 // VariableDeclarationList VariableDeclarationStatement
30 addTestSource('main() {int a = 1, b = ^ + 2;}'); 30 addTestSource('main() {int a = 1, b = ^ + 2;}');
31 expect(computeFast(), isTrue); 31 expect(computeFast(), isTrue);
32 assertSuggestLocalVariable('a', 'int'); 32 assertSuggestLocalVariable('a', 'int');
33 assertNotSuggested('b'); 33 assertNotSuggested('b');
34 } 34 }
35 35
36 test_BinaryExpression_RHS() { 36 test_BinaryExpression_RHS() {
37 // SimpleIdentifier BinaryExpression VariableDeclaration 37 // SimpleIdentifier BinaryExpression VariableDeclaration
38 // VariableDeclarationList VariableDeclarationStatement 38 // VariableDeclarationList VariableDeclarationStatement
39 addTestSource('main() {int a = 1, b = 2 + ^;}'); 39 addTestSource('main() {int a = 1, b = 2 + ^;}');
40 expect(computeFast(), isTrue); 40 expect(computeFast(), isTrue);
41 assertSuggestLocalVariable('a', 'int'); 41 assertSuggestLocalVariable('a', 'int');
42 assertNotSuggested('b'); 42 assertNotSuggested('b');
43 } 43 }
44 44
45 test_Block() {
46 // Block BlockFunctionBody
47 addTestSource('class A {a() {var f; {var x;} ^ var g;}}');
48 expect(computeFast(), isTrue);
49 assertSuggestClass('A');
50 assertSuggestLocalVariable('f', null);
51 assertNotSuggested('g');
52 assertNotSuggested('x');
53 }
54
55 test_CatchClause_typed() { 45 test_CatchClause_typed() {
56 // Block CatchClause TryStatement 46 // Block CatchClause TryStatement
57 addTestSource('class A {a() {try{} on E catch (e) {^}}}'); 47 addTestSource('class A {a() {try{} on E catch (e) {^}}}');
58 expect(computeFast(), isTrue); 48 expect(computeFast(), isTrue);
59 assertSuggestParameter('e', 'E'); 49 assertSuggestParameter('e', 'E');
60 } 50 }
61 51
62 test_CatchClause_untyped() { 52 test_CatchClause_untyped() {
63 // Block CatchClause TryStatement 53 // Block CatchClause TryStatement
64 addTestSource('class A {a() {try{} catch (e, s) {^}}}'); 54 addTestSource('class A {a() {try{} catch (e, s) {^}}}');
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 // VariableDeclaration VariableDeclarationList 268 // VariableDeclaration VariableDeclarationList
279 // VariableDeclarationStatement 269 // VariableDeclarationStatement
280 addTestSource('class A {a() {var f; {var x;} var e = ^ var g;}}'); 270 addTestSource('class A {a() {var f; {var x;} var e = ^ var g;}}');
281 expect(computeFast(), isTrue); 271 expect(computeFast(), isTrue);
282 assertSuggestClass('A'); 272 assertSuggestClass('A');
283 assertSuggestLocalVariable('f', null); 273 assertSuggestLocalVariable('f', null);
284 assertNotSuggested('g'); 274 assertNotSuggested('g');
285 assertNotSuggested('x'); 275 assertNotSuggested('x');
286 } 276 }
287 277
288 //TODO (danrubel) implement
289 xtest_ConstructorName_importedClass() { 278 xtest_ConstructorName_importedClass() {
290 // SimpleIdentifier PrefixedIdentifier TypeName ConstructorName 279 // SimpleIdentifier PrefixedIdentifier TypeName ConstructorName
291 // InstanceCreationExpression 280 // InstanceCreationExpression
292 addSource('/testB.dart', ''' 281 addSource('/testB.dart', '''
293 lib B; 282 lib B;
294 class X {X.c(); X._d(); z() {}}'''); 283 class X {X.c(); X._d(); z() {}}''');
295 addTestSource(''' 284 addTestSource('''
296 import "/testB.dart"; 285 import "/testB.dart";
297 var m; 286 var m;
298 main() {new X.^}'''); 287 main() {new X.^}''');
299 return computeFull().then((_) { 288 return computeFull().then((_) {
300 assertNoSuggestions(); 289 assertNoSuggestions();
301 }); 290 });
302 } 291 }
303 292
304 //TODO (danrubel) implement
305 xtest_ConstructorName_localClass() { 293 xtest_ConstructorName_localClass() {
306 // SimpleIdentifier PrefixedIdentifier TypeName ConstructorName 294 // SimpleIdentifier PrefixedIdentifier TypeName ConstructorName
307 // InstanceCreationExpression 295 // InstanceCreationExpression
308 addTestSource(''' 296 addTestSource('''
309 var m; 297 var m;
310 class X {X.c(); X._d(); z() {}} 298 class X {X.c(); X._d(); z() {}}
311 main() {new X.^}'''); 299 main() {new X.^}''');
312 return computeFull().then((_) { 300 return computeFull().then((_) {
313 assertNoSuggestions(); 301 assertNoSuggestions();
314 }); 302 });
315 } 303 }
316 304
317 //TODO (danrubel) implement
318 xtest_InstanceCreationExpression() { 305 xtest_InstanceCreationExpression() {
319 // SimpleIdentifier TypeName ConstructorName InstanceCreationExpression 306 // SimpleIdentifier TypeName ConstructorName InstanceCreationExpression
320 addTestSource('class A {a() {var f; {var x;} new ^}} class B { }'); 307 addTestSource('class A {a() {var f; {var x;} new ^}} class B { }');
321 expect(computeFast(), isTrue); 308 expect(computeFast(), isTrue);
322 assertSuggestClass('A'); 309 assertSuggestClass('A');
323 assertSuggestClass('B'); 310 assertSuggestClass('B');
324 assertNotSuggested('a'); 311 assertNotSuggested('a');
325 assertNotSuggested('f'); 312 assertNotSuggested('f');
326 assertNotSuggested('x'); 313 assertNotSuggested('x');
327 } 314 }
328 315
329 //TODO (danrubel) implement
330 xtest_IsExpression_imported() { 316 xtest_IsExpression_imported() {
331 // SimpleIdentifier TypeName IsExpression IfStatement 317 // SimpleIdentifier TypeName IsExpression IfStatement
332 addSource('/testB.dart', ''' 318 addSource('/testB.dart', '''
333 lib B; 319 lib B;
334 class X {X.c(); X._d(); z() {}}'''); 320 class X {X.c(); X._d(); z() {}}''');
335 addTestSource(''' 321 addTestSource('''
336 import "/testB.dart"; 322 import "/testB.dart";
337 main() {var x; if (x is ^) { }}'''); 323 main() {var x; if (x is ^) { }}''');
338 return computeFull().then((_) { 324 return computeFull().then((_) {
339 assertNoSuggestions(); 325 assertNoSuggestions();
340 }); 326 });
341 } 327 }
342 328
343 //TODO (danrubel) implement
344 xtest_IsExpression_local() { 329 xtest_IsExpression_local() {
345 // SimpleIdentifier TypeName IsExpression IfStatement 330 // SimpleIdentifier TypeName IsExpression IfStatement
346 addTestSource(''' 331 addTestSource('''
347 class X {X.c(); X._d(); z() {}} 332 class X {X.c(); X._d(); z() {}}
348 main() {var x; if (x is ^) { }}'''); 333 main() {var x; if (x is ^) { }}''');
349 return computeFull().then((_) { 334 return computeFull().then((_) {
350 assertSuggestConstructor('c'); 335 assertSuggestConstructor('c');
351 assertNotSuggested('main'); 336 assertNotSuggested('main');
352 assertNotSuggested('X'); 337 assertNotSuggested('X');
353 assertNotSuggested('B'); 338 assertNotSuggested('B');
354 assertNotSuggested('x'); 339 assertNotSuggested('x');
355 }); 340 });
356 } 341 }
357 } 342 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/test/services/completion/invocation_computer_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698