| OLD | NEW |
| 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 AbstractSelectorSuggestionTest { | 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 | |
| 27 test_FunctionExpression_body_function() { | |
| 28 // Block BlockFunctionBody FunctionExpression | |
| 29 addTestSource('String foo(List args) {x.then((R b) {^});}'); | |
| 30 expect(computeFast(), isTrue); | |
| 31 var f = assertSuggestFunction('foo', 'String', false); | |
| 32 expect(f.element.isPrivate, isFalse); | |
| 33 assertSuggestParameter('args', 'List'); | |
| 34 assertSuggestParameter('b', 'R'); | |
| 35 } | |
| 36 | |
| 37 test_MethodDeclaration_body_getters() { | |
| 38 // Block BlockFunctionBody MethodDeclaration | |
| 39 addTestSource('class A {@deprecated X get f => 0; Z a() {^} get _g => 1;}'); | |
| 40 expect(computeFast(), isTrue); | |
| 41 var a = assertSuggestMethod('a', 'A', 'Z'); | |
| 42 expect(a.element.isDeprecated, isFalse); | |
| 43 expect(a.element.isPrivate, isFalse); | |
| 44 var f = assertSuggestGetter('f', 'X'); | |
| 45 expect(f.element.isDeprecated, isTrue); | |
| 46 expect(f.element.isPrivate, isFalse); | |
| 47 var g = assertSuggestGetter('_g', null); | |
| 48 expect(g.element.isDeprecated, isFalse); | |
| 49 expect(g.element.isPrivate, isTrue); | |
| 50 } | |
| 51 | |
| 52 test_MethodDeclaration_members() { | |
| 53 // Block BlockFunctionBody MethodDeclaration | |
| 54 addTestSource('class A {@deprecated X f; Z _a() {^} var _g;}'); | |
| 55 expect(computeFast(), isTrue); | |
| 56 var a = assertSuggestMethod('_a', 'A', 'Z'); | |
| 57 expect(a.element.isDeprecated, isFalse); | |
| 58 expect(a.element.isPrivate, isTrue); | |
| 59 var f = assertSuggestGetter('f', 'X'); | |
| 60 expect(f.element.isDeprecated, isTrue); | |
| 61 expect(f.element.isPrivate, isFalse); | |
| 62 var g = assertSuggestGetter('_g', null); | |
| 63 expect(g.element.isDeprecated, isFalse); | |
| 64 expect(g.element.isPrivate, isTrue); | |
| 65 } | |
| 66 | |
| 67 test_MethodDeclaration_parameters_named() { | |
| 68 // Block BlockFunctionBody MethodDeclaration | |
| 69 addTestSource('class A {@deprecated Z a(X x, {y: boo}) {^}}'); | |
| 70 expect(computeFast(), isTrue); | |
| 71 var a = assertSuggestMethod('a', 'A', 'Z'); | |
| 72 expect(a.element.isDeprecated, isTrue); | |
| 73 expect(a.element.isPrivate, isFalse); | |
| 74 assertSuggestParameter('x', 'X'); | |
| 75 assertSuggestParameter('y', null); | |
| 76 } | |
| 77 | |
| 78 test_MethodDeclaration_parameters_positional() { | |
| 79 // Block BlockFunctionBody MethodDeclaration | |
| 80 addTestSource('class A {Z a(X x, [int y=1]) {^}}'); | |
| 81 expect(computeFast(), isTrue); | |
| 82 assertSuggestMethod('a', 'A', 'Z'); | |
| 83 assertSuggestParameter('x', 'X'); | |
| 84 assertSuggestParameter('y', 'int'); | |
| 85 } | |
| 86 } | 26 } |
| OLD | NEW |