| Index: pkg/analysis_server/test/services/completion/local_computer_test.dart
|
| diff --git a/pkg/analysis_server/test/services/completion/local_computer_test.dart b/pkg/analysis_server/test/services/completion/local_computer_test.dart
|
| index 17c1f377ca1d0ae0135ae5c7f1dbfab996de1110..0e629e13571985f0db413ff4cf158d1ba440a43e 100644
|
| --- a/pkg/analysis_server/test/services/completion/local_computer_test.dart
|
| +++ b/pkg/analysis_server/test/services/completion/local_computer_test.dart
|
| @@ -22,4 +22,143 @@ class LocalComputerTest extends AbstractSelectorSuggestionTest {
|
| void setUpComputer() {
|
| computer = new LocalComputer();
|
| }
|
| +
|
| + test_break_ignores_outer_functions_using_closure() {
|
| + addTestSource('''
|
| +void main() {
|
| + foo: while (true) {
|
| + var f = () {
|
| + bar: while (true) { break ^ }
|
| + };
|
| + }
|
| +}
|
| +''');
|
| + expect(computeFast(), isTrue);
|
| + // Labels in outer functions are never accessible.
|
| + assertSuggestLabel('bar');
|
| + assertNotSuggested('foo');
|
| + }
|
| +
|
| + test_break_ignores_outer_functions_using_local_function() {
|
| + addTestSource('''
|
| +void main() {
|
| + foo: while (true) {
|
| + void f() {
|
| + bar: while (true) { break ^ }
|
| + };
|
| + }
|
| +}
|
| +''');
|
| + expect(computeFast(), isTrue);
|
| + // Labels in outer functions are never accessible.
|
| + assertSuggestLabel('bar');
|
| + assertNotSuggested('foo');
|
| + }
|
| +
|
| + test_break_ignores_toplevel_variables() {
|
| + addTestSource('''
|
| +int x;
|
| +void main() {
|
| + while (true) {
|
| + break ^
|
| + }
|
| +}
|
| +''');
|
| + expect(computeFast(), isTrue);
|
| + assertNotSuggested('x');
|
| + }
|
| +
|
| + test_break_ignores_unrelated_statements() {
|
| + addTestSource('''
|
| +void main() {
|
| + foo: while (true) {}
|
| + while (true) { break ^ }
|
| + bar: while (true) {}
|
| +}
|
| +''');
|
| + expect(computeFast(), isTrue);
|
| + // The scope of the label defined by a labeled statement is just the
|
| + // statement itself, so neither "foo" nor "bar" are in scope at the caret
|
| + // position.
|
| + assertNotSuggested('foo');
|
| + assertNotSuggested('bar');
|
| + }
|
| +
|
| + test_break_to_enclosing_loop() {
|
| + addTestSource('''
|
| +void main() {
|
| + foo: while (true) {
|
| + bar: while (true) {
|
| + break ^
|
| + }
|
| + }
|
| +}
|
| +''');
|
| + expect(computeFast(), isTrue);
|
| + assertSuggestLabel('foo');
|
| + assertSuggestLabel('bar');
|
| + }
|
| +
|
| + test_continue_ignores_outer_functions_using_closure() {
|
| + addTestSource('''
|
| +void main() {
|
| + foo: while (true) {
|
| + var f = () {
|
| + bar: while (true) { continue ^ }
|
| + };
|
| + }
|
| +}
|
| +''');
|
| + expect(computeFast(), isTrue);
|
| + // Labels in outer functions are never accessible.
|
| + assertSuggestLabel('bar');
|
| + assertNotSuggested('foo');
|
| + }
|
| +
|
| + test_continue_ignores_outer_functions_using_local_function() {
|
| + addTestSource('''
|
| +void main() {
|
| + foo: while (true) {
|
| + void f() {
|
| + bar: while (true) { continue ^ }
|
| + };
|
| + }
|
| +}
|
| +''');
|
| + expect(computeFast(), isTrue);
|
| + // Labels in outer functions are never accessible.
|
| + assertSuggestLabel('bar');
|
| + assertNotSuggested('foo');
|
| + }
|
| +
|
| + test_continue_ignores_unrelated_statements() {
|
| + addTestSource('''
|
| +void main() {
|
| + foo: while (true) {}
|
| + while (true) { continue ^ }
|
| + bar: while (true) {}
|
| +}
|
| +''');
|
| + expect(computeFast(), isTrue);
|
| + // The scope of the label defined by a labeled statement is just the
|
| + // statement itself, so neither "foo" nor "bar" are in scope at the caret
|
| + // position.
|
| + assertNotSuggested('foo');
|
| + assertNotSuggested('bar');
|
| + }
|
| +
|
| + test_continue_to_enclosing_loop() {
|
| + addTestSource('''
|
| +void main() {
|
| + foo: while (true) {
|
| + bar: while (true) {
|
| + continue ^
|
| + }
|
| + }
|
| +}
|
| +''');
|
| + expect(computeFast(), isTrue);
|
| + assertSuggestLabel('foo');
|
| + assertSuggestLabel('bar');
|
| + }
|
| }
|
|
|