| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 library test.services.completion.dart.local; |
| 6 |
| 7 import 'package:analysis_services/src/completion/local_computer.dart'; |
| 8 import 'package:analysis_testing/reflective_tests.dart'; |
| 9 import 'package:unittest/unittest.dart'; |
| 10 |
| 11 import 'completion_test_util.dart'; |
| 12 |
| 13 main() { |
| 14 groupSep = ' | '; |
| 15 runReflectiveTests(LocalComputerTest); |
| 16 } |
| 17 |
| 18 @ReflectiveTestCase() |
| 19 class LocalComputerTest extends AbstractCompletionTest { |
| 20 |
| 21 @override |
| 22 void setUp() { |
| 23 super.setUp(); |
| 24 computer = new LocalComputer(); |
| 25 } |
| 26 |
| 27 test_block() { |
| 28 addTestSource('class A {a() {var f; ^ var g;}}'); |
| 29 expect(computeFast(), isTrue); |
| 30 assertSuggestVariable('f'); |
| 31 assertNotSuggested('g'); |
| 32 } |
| 33 |
| 34 test_catch() { |
| 35 addTestSource('class A {a() {try{} catch (e) {^}}}'); |
| 36 expect(computeFast(), isTrue); |
| 37 assertSuggestParameter('e'); |
| 38 } |
| 39 |
| 40 test_catch2() { |
| 41 addTestSource('class A {a() {try{} catch (e, s) {^}}}'); |
| 42 expect(computeFast(), isTrue); |
| 43 assertSuggestParameter('e'); |
| 44 assertSuggestParameter('s'); |
| 45 } |
| 46 |
| 47 test_compilationUnit_declarations() { |
| 48 addTestSource('class A {^} class B {} var T;'); |
| 49 expect(computeFast(), isTrue); |
| 50 assertSuggestClass('A'); |
| 51 assertSuggestClass('B'); |
| 52 assertSuggestTopLevelVar('T'); |
| 53 } |
| 54 |
| 55 test_compilationUnit_directives() { |
| 56 addTestSource('import "boo.dart" as x; class A {^}'); |
| 57 expect(computeFast(), isTrue); |
| 58 assertSuggestLibraryPrefix('x'); |
| 59 } |
| 60 |
| 61 test_for() { |
| 62 addTestSource('main(args) {for (int i; i < 10; ++i) {^}}'); |
| 63 expect(computeFast(), isTrue); |
| 64 assertSuggestVariable('i'); |
| 65 } |
| 66 |
| 67 test_forEach() { |
| 68 addTestSource('main(args) {for (foo in bar) {^}}'); |
| 69 expect(computeFast(), isTrue); |
| 70 assertSuggestVariable('foo'); |
| 71 } |
| 72 |
| 73 test_function() { |
| 74 addTestSource('main(args) {^}'); |
| 75 expect(computeFast(), isTrue); |
| 76 assertSuggestFunction('main'); |
| 77 assertSuggestParameter('args'); |
| 78 } |
| 79 |
| 80 test_members() { |
| 81 addTestSource('class A {var f; a() {^} var g;}'); |
| 82 expect(computeFast(), isTrue); |
| 83 assertSuggestMethodName('a'); |
| 84 assertSuggestField('f'); |
| 85 assertSuggestField('g'); |
| 86 } |
| 87 |
| 88 test_methodParam_named() { |
| 89 addTestSource('class A {a(x, {y: boo}) {^}}'); |
| 90 expect(computeFast(), isTrue); |
| 91 assertSuggestMethodName('a'); |
| 92 assertSuggestParameter('x'); |
| 93 assertSuggestParameter('y'); |
| 94 } |
| 95 |
| 96 test_methodParam_positional() { |
| 97 addTestSource('class A {a(x, [y=1]) {^}}'); |
| 98 expect(computeFast(), isTrue); |
| 99 assertSuggestMethodName('a'); |
| 100 assertSuggestParameter('x'); |
| 101 assertSuggestParameter('y'); |
| 102 } |
| 103 } |
| OLD | NEW |