| 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.invocation; | 5 library test.services.completion.invocation; |
| 6 | 6 |
| 7 | 7 |
| 8 import 'package:analysis_server/src/services/completion/invocation_computer.dart
'; | 8 import 'package:analysis_server/src/services/completion/invocation_computer.dart
'; |
| 9 import 'package:analysis_testing/reflective_tests.dart'; | 9 import 'package:analysis_testing/reflective_tests.dart'; |
| 10 import 'package:unittest/unittest.dart'; | 10 import 'package:unittest/unittest.dart'; |
| 11 | 11 |
| 12 import 'completion_test_util.dart'; | 12 import 'completion_test_util.dart'; |
| 13 | 13 |
| 14 main() { | 14 main() { |
| 15 groupSep = ' | '; | 15 groupSep = ' | '; |
| 16 runReflectiveTests(InvocationComputerTest); | 16 runReflectiveTests(InvocationComputerTest); |
| 17 } | 17 } |
| 18 | 18 |
| 19 @ReflectiveTestCase() | 19 @ReflectiveTestCase() |
| 20 class InvocationComputerTest extends AbstractCompletionTest { | 20 class InvocationComputerTest extends AbstractCompletionTest { |
| 21 | 21 |
| 22 @override | 22 @override |
| 23 void setUp() { | 23 void setUp() { |
| 24 super.setUp(); | 24 super.setUp(); |
| 25 computer = new InvocationComputer(); | 25 computer = new InvocationComputer(); |
| 26 } | 26 } |
| 27 | 27 |
| 28 test_library_prefix() { |
| 29 addSource('/testB.dart', 'lib B; class X { }'); |
| 30 addTestSource('import "/testB.dart" as b; main() {b.^}'); |
| 31 return computeFull().then((_) { |
| 32 assertSuggestClass('X'); |
| 33 }); |
| 34 } |
| 35 |
| 28 test_field() { | 36 test_field() { |
| 29 addTestSource('class A {A b;} main() {A a; a.^}'); | 37 addTestSource('class A {var b; var _c;} main() {A a; a.^}'); |
| 30 return computeFull().then((_) { | 38 return computeFull().then((_) { |
| 31 assertSuggestField('b'); | 39 assertSuggestField('b'); |
| 40 assertSuggestField('_c'); |
| 41 }); |
| 42 } |
| 43 |
| 44 test_field_imported() { |
| 45 addSource('/testB.dart', 'lib B; class X {var y; var _z;}'); |
| 46 addTestSource('import "/testB.dart"; main() {X x; x.^}'); |
| 47 return computeFull().then((_) { |
| 48 assertSuggestField('y'); |
| 49 assertNotSuggested('_z'); |
| 32 }); | 50 }); |
| 33 } | 51 } |
| 34 | 52 |
| 35 test_getter() { | 53 test_getter() { |
| 36 addTestSource('class A {A get b => new A();} main() {A a; a.^}'); | 54 addTestSource('class A {A get b => new A();A get _c => new A();} main() {A a
; a.^}'); |
| 37 return computeFull().then((_) { | 55 return computeFull().then((_) { |
| 38 assertSuggestGetter('b'); | 56 assertSuggestGetter('b'); |
| 57 assertSuggestGetter('_c'); |
| 58 }); |
| 59 } |
| 60 |
| 61 test_getter_imported() { |
| 62 addSource('/testB.dart', 'lib B; class X {X get y => new X(); X get _z => ne
w X();}'); |
| 63 addTestSource('import "/testB.dart"; main() {X x; x.^}'); |
| 64 return computeFull().then((_) { |
| 65 assertSuggestGetter('y'); |
| 66 assertNotSuggested('_z'); |
| 39 }); | 67 }); |
| 40 } | 68 } |
| 41 | 69 |
| 42 test_method() { | 70 test_method() { |
| 43 addTestSource('class A {b(X x) {}} main() {A a; a.^}'); | 71 addTestSource('class A {b(X x) {} _c(X x) {}} main() {A a; a.^}'); |
| 44 return computeFull().then((_) { | 72 return computeFull().then((_) { |
| 45 assertSuggestMethod('b'); | 73 assertSuggestMethod('b'); |
| 74 assertSuggestMethod('_c'); |
| 75 }); |
| 76 } |
| 77 |
| 78 test_method_imported() { |
| 79 addSource('/testB.dart', 'lib B; class X {y(X x) {} _z(X x) {}}'); |
| 80 addTestSource('import "/testB.dart"; main() {X x; x.^}'); |
| 81 return computeFull().then((_) { |
| 82 assertSuggestMethod('y'); |
| 83 assertNotSuggested('_z'); |
| 46 }); | 84 }); |
| 47 } | 85 } |
| 48 | 86 |
| 49 test_setter() { | 87 test_setter() { |
| 50 addTestSource('class A {set b(X x) {}} main() {A a; a.^}'); | 88 addTestSource('class A {set b(X x) {} set _c(X x) {}} main() {A a; a.^}'); |
| 51 return computeFull().then((_) { | 89 return computeFull().then((_) { |
| 52 assertSuggestSetter('b'); | 90 assertSuggestSetter('b'); |
| 91 assertSuggestSetter('_c'); |
| 92 }); |
| 93 } |
| 94 |
| 95 test_setter_imported() { |
| 96 addSource('/testB.dart', 'lib B; class X {set y(X x) {} set _z(X x) {}}'); |
| 97 addTestSource('import "/testB.dart"; main() {X x; x.^}'); |
| 98 return computeFull().then((_) { |
| 99 assertSuggestSetter('y'); |
| 100 assertNotSuggested('_z'); |
| 53 }); | 101 }); |
| 54 } | 102 } |
| 55 } | 103 } |
| OLD | NEW |