| 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.toplevel; | 5 library test.services.completion.toplevel; |
| 6 | 6 |
| 7 import 'package:analysis_services/completion/completion_suggestion.dart'; | 7 import 'package:analysis_services/completion/completion_suggestion.dart'; |
| 8 import 'package:analysis_services/src/completion/top_level_computer.dart'; | 8 import 'package:analysis_services/src/completion/top_level_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(TopLevelComputerTest); | 16 runReflectiveTests(TopLevelComputerTest); |
| 17 } | 17 } |
| 18 | 18 |
| 19 @ReflectiveTestCase() | 19 @ReflectiveTestCase() |
| 20 class TopLevelComputerTest extends AbstractCompletionTest { | 20 class TopLevelComputerTest extends AbstractCompletionTest { |
| 21 | 21 |
| 22 void addTestUnit(String content) { | 22 void addTestUnit(String content) { |
| 23 super.addTestUnit(content); | 23 super.addTestUnit(content); |
| 24 computer = new TopLevelComputer(searchEngine, testUnit); | 24 computer = new TopLevelComputer(searchEngine, testUnit); |
| 25 } | 25 } |
| 26 | 26 |
| 27 test_class_1() { | 27 test_class_1() { |
| 28 addUnit('/testA.dart', 'var T1; class A {bool x;}'); | 28 addUnit('/testA.dart', 'var T1; class A {bool x;} var _T2; class _D { }'); |
| 29 addUnit('/testB.dart', 'class B {bool y;}'); | 29 addUnit('/testB.dart', 'class B {bool y;}'); |
| 30 addTestUnit('import "/testA.dart"; class C {bool v;^}'); | 30 addTestUnit('import "/testA.dart"; class C {bool v;^} class _E { }'); |
| 31 return compute().then((_) { | 31 return compute().then((_) { |
| 32 assertHasResult(CompletionSuggestionKind.CLASS, 'A'); | 32 assertHasResult(CompletionSuggestionKind.CLASS, 'A'); |
| 33 assertHasResult(CompletionSuggestionKind.CLASS, 'B', CompletionRelevance.L
OW); | 33 assertHasResult( |
| 34 CompletionSuggestionKind.CLASS, |
| 35 'B', |
| 36 CompletionRelevance.LOW); |
| 34 assertHasResult(CompletionSuggestionKind.CLASS, 'C'); | 37 assertHasResult(CompletionSuggestionKind.CLASS, 'C'); |
| 38 assertNoResult('_D'); |
| 39 assertHasResult(CompletionSuggestionKind.CLASS, '_E'); |
| 35 assertHasResult(CompletionSuggestionKind.CLASS, 'Object'); | 40 assertHasResult(CompletionSuggestionKind.CLASS, 'Object'); |
| 36 assertHasResult(CompletionSuggestionKind.TOP_LEVEL_VARIABLE, 'T1'); | 41 assertHasResult(CompletionSuggestionKind.TOP_LEVEL_VARIABLE, 'T1'); |
| 42 assertNoResult('_T2'); |
| 37 assertNoResult('x'); | 43 assertNoResult('x'); |
| 38 assertNoResult('y'); | 44 assertNoResult('y'); |
| 39 assertNoResult('v'); | 45 assertNoResult('v'); |
| 40 }); | 46 }); |
| 41 } | 47 } |
| 42 } | 48 } |
| OLD | NEW |