Chromium Code Reviews| 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 test_class() { | 22 void addTestUnit(String content) { |
| 23 addTestUnit('class B {boolean v;}'); | 23 super.addTestUnit(content); |
| 24 computer = new TopLevelComputer(searchEngine, testUnit); | |
| 25 } | |
| 26 | |
| 27 test_class_1() { | |
| 28 addUnit('/testA.dart', 'var T1; class A {bool x;}'); | |
| 29 addUnit('/testB.dart', 'class B {bool y;}'); | |
| 30 addTestUnit('import "/testA.dart"; class C {bool v;^}'); | |
| 24 return compute().then((_) { | 31 return compute().then((_) { |
| 25 assertHasResult(CompletionSuggestionKind.CLASS, 'B'); | 32 assertHasResult(CompletionSuggestionKind.CLASS, 'A'); |
| 33 assertHasResult(CompletionSuggestionKind.CLASS, 'B', CompletionRelevance.L OW); | |
| 34 assertHasResult(CompletionSuggestionKind.CLASS, 'C'); | |
| 35 assertHasResult(CompletionSuggestionKind.CLASS, 'Object'); | |
| 36 assertHasResult(CompletionSuggestionKind.TOP_LEVEL_VARIABLE, 'T1'); | |
|
scheglov
2014/08/07 02:42:26
Is a top-level variable suggestion useful here?
I
danrubel
2014/08/08 20:28:39
Top level variables in one library can be accessed
scheglov
2014/08/08 20:58:43
Correct me if I'm wrong, but I don't think we can
danrubel
2014/08/09 10:23:03
Ah, now I understand what you are saying. Yes, thi
| |
| 37 assertNoResult('x'); | |
| 38 assertNoResult('y'); | |
| 26 assertNoResult('v'); | 39 assertNoResult('v'); |
| 27 }); | 40 }); |
| 28 } | 41 } |
| 29 | |
| 30 @override | |
| 31 void setUp() { | |
| 32 super.setUp(); | |
| 33 computer = new TopLevelComputer(searchEngine); | |
| 34 } | |
| 35 } | 42 } |
| OLD | NEW |