| 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 | 26 |
| 27 test_CatchClause_typed() { | |
| 28 // Block CatchClause TryStatement | |
| 29 addTestSource('class A {a() {try{} on E catch (e) {^}}}'); | |
| 30 expect(computeFast(), isTrue); | |
| 31 assertSuggestParameter('e', 'E'); | |
| 32 } | |
| 33 | |
| 34 test_CatchClause_untyped() { | |
| 35 // Block CatchClause TryStatement | |
| 36 addTestSource('class A {a() {try{} catch (e, s) {^}}}'); | |
| 37 expect(computeFast(), isTrue); | |
| 38 assertSuggestParameter('e', null); | |
| 39 assertSuggestParameter('s', 'StackTrace'); | |
| 40 } | |
| 41 | |
| 42 test_ClassDeclaration_body() { | |
| 43 // ClassDeclaration CompilationUnit | |
| 44 addTestSource( // | |
| 45 'import "boo.dart" as x;' // | |
| 46 ' @deprecated class A {^}' // | |
| 47 ' class _B {}' // | |
| 48 ' A T;'); | |
| 49 expect(computeFast(), isTrue); | |
| 50 var a = assertSuggestClass('A'); | |
| 51 expect(a.element.isDeprecated, isTrue); | |
| 52 expect(a.element.isPrivate, isFalse); | |
| 53 var b = assertSuggestClass('_B'); | |
| 54 expect(b.element.isDeprecated, isFalse); | |
| 55 expect(b.element.isPrivate, isTrue); | |
| 56 assertSuggestTopLevelVar('T', 'A'); | |
| 57 // Library prefix suggestion is provided by ImportedComputer | |
| 58 assertNotSuggested('x'); | |
| 59 } | |
| 60 | |
| 61 test_ExpressionStatement_name() { | |
| 62 // ExpressionStatement Block | |
| 63 addTestSource('class A {a() {var f; A ^}}'); | |
| 64 expect(computeFast(), isTrue); | |
| 65 assertNotSuggested('A'); | |
| 66 assertNotSuggested('a'); | |
| 67 assertNotSuggested('f'); | |
| 68 } | |
| 69 | |
| 70 test_FieldDeclaration_name() { | |
| 71 // SimpleIdentifier VariableDeclaration VariableDeclarationList | |
| 72 // FieldDeclaration | |
| 73 addTestSource('class A {B ^}}'); | |
| 74 expect(computeFast(), isTrue); | |
| 75 assertNotSuggested('A'); | |
| 76 } | |
| 77 | |
| 78 test_ForEachStatement_body_typed() { | 27 test_ForEachStatement_body_typed() { |
| 79 // Block ForEachStatement | 28 // Block ForEachStatement |
| 80 addTestSource('main(args) {for (int foo in bar) {^}}'); | 29 addTestSource('main(args) {for (int foo in bar) {^}}'); |
| 81 expect(computeFast(), isTrue); | 30 expect(computeFast(), isTrue); |
| 82 assertSuggestLocalVariable('foo', 'int'); | 31 assertSuggestLocalVariable('foo', 'int'); |
| 83 } | 32 } |
| 84 | 33 |
| 85 test_ForEachStatement_body_untyped() { | 34 test_ForEachStatement_body_untyped() { |
| 86 // Block ForEachStatement | 35 // Block ForEachStatement |
| 87 addTestSource('main(args) {for (foo in bar) {^}}'); | 36 addTestSource('main(args) {for (foo in bar) {^}}'); |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 | 133 |
| 185 test_MethodDeclaration_parameters_positional() { | 134 test_MethodDeclaration_parameters_positional() { |
| 186 // Block BlockFunctionBody MethodDeclaration | 135 // Block BlockFunctionBody MethodDeclaration |
| 187 addTestSource('class A {Z a(X x, [int y=1]) {^}}'); | 136 addTestSource('class A {Z a(X x, [int y=1]) {^}}'); |
| 188 expect(computeFast(), isTrue); | 137 expect(computeFast(), isTrue); |
| 189 assertSuggestMethod('a', 'A', 'Z'); | 138 assertSuggestMethod('a', 'A', 'Z'); |
| 190 assertSuggestParameter('x', 'X'); | 139 assertSuggestParameter('x', 'X'); |
| 191 assertSuggestParameter('y', 'int'); | 140 assertSuggestParameter('y', 'int'); |
| 192 } | 141 } |
| 193 } | 142 } |
| OLD | NEW |