Chromium Code Reviews| Index: pkg/analysis_services/test/completion/local_computer_test.dart |
| diff --git a/pkg/analysis_services/test/completion/local_computer_test.dart b/pkg/analysis_services/test/completion/local_computer_test.dart |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..deb81346271b9bd558a00e9edcddcf095616c244 |
| --- /dev/null |
| +++ b/pkg/analysis_services/test/completion/local_computer_test.dart |
| @@ -0,0 +1,103 @@ |
| +// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| +// for details. All rights reserved. Use of this source code is governed by a |
| +// BSD-style license that can be found in the LICENSE file. |
| + |
| +library test.services.completion.dart.local; |
| + |
| +import 'package:analysis_services/src/completion/local_computer.dart'; |
| +import 'package:analysis_testing/reflective_tests.dart'; |
| +import 'package:unittest/unittest.dart'; |
| + |
| +import 'completion_test_util.dart'; |
| + |
| +main() { |
| + groupSep = ' | '; |
| + runReflectiveTests(LocalComputerTest); |
| +} |
| + |
| +@ReflectiveTestCase() |
| +class LocalComputerTest extends AbstractCompletionTest { |
|
scheglov
2014/08/10 21:45:15
Do we want to add tests that local variables of si
danrubel
2014/08/11 03:04:38
Good point. https://codereview.chromium.org/459743
|
| + |
| + @override |
| + void setUp() { |
| + super.setUp(); |
| + computer = new LocalComputer(); |
| + } |
| + |
| + test_block() { |
| + addTestSource('class A {a() {var f; ^ var g;}}'); |
| + expect(computeFast(), isTrue); |
| + assertSuggestVariable('f'); |
| + assertNotSuggested('g'); |
| + } |
| + |
| + test_catch() { |
| + addTestSource('class A {a() {try{} catch (e) {^}}}'); |
| + expect(computeFast(), isTrue); |
| + assertSuggestParameter('e'); |
| + } |
| + |
| + test_catch2() { |
| + addTestSource('class A {a() {try{} catch (e, s) {^}}}'); |
| + expect(computeFast(), isTrue); |
| + assertSuggestParameter('e'); |
| + assertSuggestParameter('s'); |
| + } |
| + |
| + test_compilationUnit_declarations() { |
| + addTestSource('class A {^} class B {} var T;'); |
| + expect(computeFast(), isTrue); |
| + assertSuggestClass('A'); |
| + assertSuggestClass('B'); |
| + assertSuggestTopLevelVar('T'); |
| + } |
| + |
| + test_compilationUnit_directives() { |
| + addTestSource('import "boo.dart" as x; class A {^}'); |
| + expect(computeFast(), isTrue); |
| + assertSuggestLibraryPrefix('x'); |
| + } |
| + |
| + test_for() { |
| + addTestSource('main(args) {for (int i; i < 10; ++i) {^}}'); |
| + expect(computeFast(), isTrue); |
| + assertSuggestVariable('i'); |
| + } |
| + |
| + test_forEach() { |
| + addTestSource('main(args) {for (foo in bar) {^}}'); |
| + expect(computeFast(), isTrue); |
| + assertSuggestVariable('foo'); |
| + } |
| + |
| + test_function() { |
| + addTestSource('main(args) {^}'); |
| + expect(computeFast(), isTrue); |
| + assertSuggestFunction('main'); |
| + assertSuggestParameter('args'); |
| + } |
| + |
| + test_members() { |
| + addTestSource('class A {var f; a() {^} var g;}'); |
| + expect(computeFast(), isTrue); |
| + assertSuggestMethodName('a'); |
| + assertSuggestField('f'); |
| + assertSuggestField('g'); |
| + } |
| + |
| + test_methodParam_named() { |
| + addTestSource('class A {a(x, {y: boo}) {^}}'); |
| + expect(computeFast(), isTrue); |
| + assertSuggestMethodName('a'); |
| + assertSuggestParameter('x'); |
| + assertSuggestParameter('y'); |
| + } |
| + |
| + test_methodParam_positional() { |
| + addTestSource('class A {a(x, [y=1]) {^}}'); |
| + expect(computeFast(), isTrue); |
| + assertSuggestMethodName('a'); |
| + assertSuggestParameter('x'); |
| + assertSuggestParameter('y'); |
| + } |
| +} |