Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(864)

Unified Diff: pkg/analysis_server/test/services/completion/local_computer_test.dart

Issue 806473007: Add support for completion of case labels. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 0e629e13571985f0db413ff4cf158d1ba440a43e..6557a97b4f9a9dbe6478a4127cfd07aa061e1bba 100644
--- a/pkg/analysis_server/test/services/completion/local_computer_test.dart
+++ b/pkg/analysis_server/test/services/completion/local_computer_test.dart
@@ -99,7 +99,44 @@ void main() {
assertSuggestLabel('bar');
}
- test_continue_ignores_outer_functions_using_closure() {
+ test_continue_from_loop_to_switch() {
+ addTestSource('''
+void main() {
+ switch (x) {
+ foo: case 1:
+ break;
+ bar: case 2:
+ while (true) {
+ continue ^;
+ }
+ break;
+ baz: case 3:
+ break;
+ }
+}
+''');
+ expect(computeFast(), isTrue);
+ assertSuggestLabel('foo');
+ assertSuggestLabel('bar');
+ assertSuggestLabel('baz');
+ }
+
+ test_continue_from_switch_to_loop() {
+ addTestSource('''
+void main() {
+ foo: while (true) {
+ switch (x) {
+ case 1:
+ continue ^;
+ }
+ }
+}
+''');
+ expect(computeFast(), isTrue);
+ assertSuggestLabel('foo');
+ }
+
+ test_continue_ignores_outer_functions_using_closure_with_loop() {
addTestSource('''
void main() {
foo: while (true) {
@@ -115,7 +152,24 @@ void main() {
assertNotSuggested('foo');
}
- test_continue_ignores_outer_functions_using_local_function() {
+ test_continue_ignores_outer_functions_using_closure_with_switch() {
+ addTestSource('''
+void main() {
+ switch (x) {
+ foo: case 1:
+ 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_with_loop() {
addTestSource('''
void main() {
foo: while (true) {
@@ -131,6 +185,23 @@ void main() {
assertNotSuggested('foo');
}
+ test_continue_ignores_outer_functions_using_local_function_with_switch() {
+ addTestSource('''
+void main() {
+ switch (x) {
+ foo: case 1:
+ 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() {
@@ -147,6 +218,21 @@ void main() {
assertNotSuggested('bar');
}
+ test_continue_to_earlier_case() {
+ addTestSource('''
+void main() {
+ switch (x) {
+ foo: case 1:
+ break;
+ case 2:
+ continue ^;
+ case 3:
+ break;
+''');
+ expect(computeFast(), isTrue);
+ assertSuggestLabel('foo');
+ }
+
test_continue_to_enclosing_loop() {
addTestSource('''
void main() {
@@ -161,4 +247,57 @@ void main() {
assertSuggestLabel('foo');
assertSuggestLabel('bar');
}
+
+ test_continue_to_enclosing_switch() {
+ addTestSource('''
+void main() {
+ switch (x) {
+ foo: case 1:
+ break;
+ bar: case 2:
+ switch (y) {
+ case 1:
+ continue ^;
+ }
+ break;
+ baz: case 3:
+ break;
+ }
+}
+''');
+ expect(computeFast(), isTrue);
+ assertSuggestLabel('foo');
+ assertSuggestLabel('bar');
+ assertSuggestLabel('baz');
+ }
+
+ test_continue_to_later_case() {
+ addTestSource('''
+void main() {
+ switch (x) {
+ case 1:
+ break;
+ case 2:
+ continue ^;
+ foo: case 3:
+ break;
+''');
+ expect(computeFast(), isTrue);
+ assertSuggestLabel('foo');
+ }
+
+ test_continue_to_same_case() {
+ addTestSource('''
+void main() {
+ switch (x) {
+ case 1:
+ break;
+ foo: case 2:
+ continue ^;
+ case 3:
+ break;
+''');
+ expect(computeFast(), isTrue);
+ assertSuggestLabel('foo');
+ }
}

Powered by Google App Engine
This is Rietveld 408576698