| 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.toplevel; | |
| 6 | |
| 7 import 'package:analysis_services/completion/completion_suggestion.dart'; | |
| 8 import 'package:analysis_services/src/completion/top_level_computer.dart'; | |
| 9 import 'package:analysis_testing/reflective_tests.dart'; | |
| 10 import 'package:unittest/unittest.dart'; | |
| 11 | |
| 12 import 'completion_test_util.dart'; | |
| 13 | |
| 14 main() { | |
| 15 groupSep = ' | '; | |
| 16 runReflectiveTests(TopLevelComputerTest); | |
| 17 } | |
| 18 | |
| 19 @ReflectiveTestCase() | |
| 20 class TopLevelComputerTest extends AbstractCompletionTest { | |
| 21 | |
| 22 @override | |
| 23 void setUp() { | |
| 24 super.setUp(); | |
| 25 computer = new TopLevelComputer(); | |
| 26 } | |
| 27 | |
| 28 test_class() { | |
| 29 addSource('/testA.dart', 'class A {int x;} class _B { }'); | |
| 30 addTestSource('import "/testA.dart"; class C {foo(){^}}'); | |
| 31 return computeFull().then((_) { | |
| 32 assertSuggestClass('A'); | |
| 33 assertNotSuggested('x'); | |
| 34 assertNotSuggested('_B'); | |
| 35 }); | |
| 36 } | |
| 37 | |
| 38 test_class_notImported() { | |
| 39 addSource('/testA.dart', 'class A {int x;} class _B { }'); | |
| 40 addTestSource('class C {foo(){^}}'); | |
| 41 return computeFull().then((_) { | |
| 42 assertSuggestClass('A', CompletionRelevance.LOW); | |
| 43 assertNotSuggested('x'); | |
| 44 assertNotSuggested('_B'); | |
| 45 }); | |
| 46 } | |
| 47 | |
| 48 test_dartCore() { | |
| 49 addTestSource('class C {foo(){^}}'); | |
| 50 return computeFull().then((_) { | |
| 51 assertSuggestClass('Object'); | |
| 52 assertNotSuggested('HtmlElement'); | |
| 53 }); | |
| 54 } | |
| 55 | |
| 56 test_dartHtml() { | |
| 57 addTestSource('import "dart:html"; class C {foo(){^}}'); | |
| 58 return computeFull().then((_) { | |
| 59 assertSuggestClass('Object'); | |
| 60 assertSuggestClass('HtmlElement'); | |
| 61 }); | |
| 62 } | |
| 63 | |
| 64 test_topLevelVar() { | |
| 65 addSource('/testA.dart', 'var T1; var _T2;'); | |
| 66 addTestSource('import "/testA.dart"; class C {foo(){^}}'); | |
| 67 return computeFull().then((_) { | |
| 68 assertSuggestTopLevelVar('T1'); | |
| 69 assertNotSuggested('_T2'); | |
| 70 }); | |
| 71 } | |
| 72 | |
| 73 test_topLevelVar_notImported() { | |
| 74 addSource('/testA.dart', 'var T1; var _T2;'); | |
| 75 addTestSource('class C {foo(){^}}'); | |
| 76 return computeFull().then((_) { | |
| 77 assertSuggestTopLevelVar('T1', CompletionRelevance.LOW); | |
| 78 assertNotSuggested('_T2'); | |
| 79 }); | |
| 80 } | |
| 81 } | |
| OLD | NEW |