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

Unified Diff: pkg/analyzer/test/src/summary/summary_common.dart

Issue 1712583003: Serialize and resynthesize labels. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 10 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
« no previous file with comments | « pkg/analyzer/test/src/summary/resynthesize_test.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/test/src/summary/summary_common.dart
diff --git a/pkg/analyzer/test/src/summary/summary_common.dart b/pkg/analyzer/test/src/summary/summary_common.dart
index 7b374da6d19ec53cccb15e0b8f89baf128b94afd..32aa856be9337784e070b6bf3a1e1366849792a6 100644
--- a/pkg/analyzer/test/src/summary/summary_common.dart
+++ b/pkg/analyzer/test/src/summary/summary_common.dart
@@ -4027,6 +4027,90 @@ f() { // 1
}
}
+ test_executable_localLabels_inMethod() {
+ String code = r'''
+class C {
+ m() {
+ aaa: while (true) {}
+ bbb: while (true) {}
+ }
+}
+''';
+ UnlinkedExecutable executable =
+ findExecutable('m', executables: serializeClassText(code).executables);
+ List<UnlinkedLabel> labels = executable.localLabels;
+ expect(labels, hasLength(2));
+ {
+ UnlinkedLabel aaa = labels.singleWhere((l) => l.name == 'aaa');
+ expect(aaa, isNotNull);
+ expect(aaa.isOnSwitchMember, isFalse);
+ expect(aaa.isOnSwitchStatement, isFalse);
+ }
+ {
+ UnlinkedLabel bbb = labels.singleWhere((l) => l.name == 'bbb');
+ expect(bbb, isNotNull);
+ expect(bbb.isOnSwitchMember, isFalse);
+ expect(bbb.isOnSwitchStatement, isFalse);
+ }
+ }
+
+ test_executable_localLabels_inTopLevelFunction() {
+ String code = r'''
+f() {
+ aaa: while (true) {}
+ bbb: switch (42) {
+ ccc: case 0:
+ break;
+ }
+}
+''';
+ UnlinkedExecutable executable = serializeExecutableText(code);
+ List<UnlinkedLabel> labels = executable.localLabels;
+ expect(labels, hasLength(3));
+ {
+ UnlinkedLabel aaa = labels.singleWhere((l) => l.name == 'aaa');
+ expect(aaa, isNotNull);
+ expect(aaa.isOnSwitchMember, isFalse);
+ expect(aaa.isOnSwitchStatement, isFalse);
+ }
+ {
+ UnlinkedLabel bbb = labels.singleWhere((l) => l.name == 'bbb');
+ expect(bbb, isNotNull);
+ expect(bbb.isOnSwitchMember, isFalse);
+ expect(bbb.isOnSwitchStatement, isTrue);
+ }
+ {
+ UnlinkedLabel ccc = labels.singleWhere((l) => l.name == 'ccc');
+ expect(ccc, isNotNull);
+ expect(ccc.isOnSwitchMember, isTrue);
+ expect(ccc.isOnSwitchStatement, isFalse);
+ }
+ }
+
+ test_executable_localLabels_inTopLevelGetter() {
+ String code = r'''
+get g {
+ aaa: while (true) {}
+ bbb: while (true) {}
+}
+''';
+ UnlinkedExecutable executable = serializeExecutableText(code, 'g');
+ List<UnlinkedLabel> labels = executable.localLabels;
+ expect(labels, hasLength(2));
+ {
+ UnlinkedLabel aaa = labels.singleWhere((l) => l.name == 'aaa');
+ expect(aaa, isNotNull);
+ expect(aaa.isOnSwitchMember, isFalse);
+ expect(aaa.isOnSwitchStatement, isFalse);
+ }
+ {
+ UnlinkedLabel bbb = labels.singleWhere((l) => l.name == 'bbb');
+ expect(bbb, isNotNull);
+ expect(bbb.isOnSwitchMember, isFalse);
+ expect(bbb.isOnSwitchStatement, isFalse);
+ }
+ }
+
test_executable_localVariables_empty() {
UnlinkedExecutable executable = serializeExecutableText(r'''
f() {
« no previous file with comments | « pkg/analyzer/test/src/summary/resynthesize_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698