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

Unified Diff: pkg/analyzer/test/src/summary/resynthesize_test.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/generated/resolver_test.dart ('k') | pkg/analyzer/test/src/summary/summary_common.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/test/src/summary/resynthesize_test.dart
diff --git a/pkg/analyzer/test/src/summary/resynthesize_test.dart b/pkg/analyzer/test/src/summary/resynthesize_test.dart
index 93d1bcedf74d7ffb1c22b87f9599cbc4670fd3a0..cb9b2d594612b91d97e0837e5e4aeb0a1ef5dd3a 100644
--- a/pkg/analyzer/test/src/summary/resynthesize_test.dart
+++ b/pkg/analyzer/test/src/summary/resynthesize_test.dart
@@ -577,6 +577,15 @@ class ResynthTest extends ResolverTestCase {
}
}
if (original is! Member) {
+ List<LabelElement> rLabels = resynthesized.labels;
+ List<LabelElement> oLabels = original.labels;
+ expect(rLabels, hasLength(oLabels.length));
+ for (int i = 0; i < oLabels.length; i++) {
+ compareLabelElements(
+ rLabels[i], oLabels[i], '$desc label ${oLabels[i].name}');
+ }
+ }
+ if (original is! Member) {
List<LocalVariableElement> rVariables = resynthesized.localVariables;
List<LocalVariableElement> oVariables = original.localVariables;
expect(rVariables, hasLength(oVariables.length));
@@ -654,6 +663,15 @@ class ResynthTest extends ResolverTestCase {
}
}
+ void compareLabelElements(
+ LabelElementImpl resynthesized, LabelElementImpl original, String desc) {
+ expect(resynthesized.isOnSwitchMember, original.isOnSwitchMember,
+ reason: desc);
+ expect(resynthesized.isOnSwitchStatement, original.isOnSwitchStatement,
+ reason: desc);
+ compareElements(resynthesized, original, desc);
+ }
+
void compareMetadata(List<ElementAnnotation> resynthesized,
List<ElementAnnotation> original, String desc) {
expect(resynthesized, hasLength(original.length), reason: desc);
@@ -2879,6 +2897,46 @@ get g {
''');
}
+ test_localLabels_inConstructor() {
+ checkLibrary(r'''
+class C {
+ C() {
+ aaa: while (true) {}
+ bbb: switch (42) {
+ ccc: case 0:
+ break;
+ }
+ }
+}
+''');
+ }
+
+ test_localLabels_inMethod() {
+ checkLibrary(r'''
+class C {
+ m() {
+ aaa: while (true) {}
+ bbb: switch (42) {
+ ccc: case 0:
+ break;
+ }
+ }
+}
+''');
+ }
+
+ test_localLabels_inTopLevelFunction() {
+ checkLibrary(r'''
+main() {
+ aaa: while (true) {}
+ bbb: switch (42) {
+ ccc: case 0:
+ break;
+ }
+}
+''');
+ }
+
test_localVariables_inConstructor() {
checkLibrary(r'''
class C {
« no previous file with comments | « pkg/analyzer/test/generated/resolver_test.dart ('k') | pkg/analyzer/test/src/summary/summary_common.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698