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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « pkg/analyzer/test/src/summary/resynthesize_test.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 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. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library analyzer.test.src.summary.summary_common; 5 library analyzer.test.src.summary.summary_common;
6 6
7 import 'package:analyzer/analyzer.dart'; 7 import 'package:analyzer/analyzer.dart';
8 import 'package:analyzer/dart/ast/ast.dart'; 8 import 'package:analyzer/dart/ast/ast.dart';
9 import 'package:analyzer/dart/element/element.dart'; 9 import 'package:analyzer/dart/element/element.dart';
10 import 'package:analyzer/src/dart/scanner/reader.dart'; 10 import 'package:analyzer/src/dart/scanner/reader.dart';
(...skipping 4009 matching lines...) Expand 10 before | Expand all | Expand 10 after
4020 { 4020 {
4021 UnlinkedExecutable f1 = functions.singleWhere((v) => v.name == 'f1'); 4021 UnlinkedExecutable f1 = functions.singleWhere((v) => v.name == 'f1');
4022 _assertExecutableVisible(code, f1, '{ // 1', '} // 4'); 4022 _assertExecutableVisible(code, f1, '{ // 1', '} // 4');
4023 } 4023 }
4024 { 4024 {
4025 UnlinkedExecutable f2 = functions.singleWhere((v) => v.name == 'f2'); 4025 UnlinkedExecutable f2 = functions.singleWhere((v) => v.name == 'f2');
4026 _assertExecutableVisible(code, f2, '{ // 2', '} // 3'); 4026 _assertExecutableVisible(code, f2, '{ // 2', '} // 3');
4027 } 4027 }
4028 } 4028 }
4029 4029
4030 test_executable_localLabels_inMethod() {
4031 String code = r'''
4032 class C {
4033 m() {
4034 aaa: while (true) {}
4035 bbb: while (true) {}
4036 }
4037 }
4038 ''';
4039 UnlinkedExecutable executable =
4040 findExecutable('m', executables: serializeClassText(code).executables);
4041 List<UnlinkedLabel> labels = executable.localLabels;
4042 expect(labels, hasLength(2));
4043 {
4044 UnlinkedLabel aaa = labels.singleWhere((l) => l.name == 'aaa');
4045 expect(aaa, isNotNull);
4046 expect(aaa.isOnSwitchMember, isFalse);
4047 expect(aaa.isOnSwitchStatement, isFalse);
4048 }
4049 {
4050 UnlinkedLabel bbb = labels.singleWhere((l) => l.name == 'bbb');
4051 expect(bbb, isNotNull);
4052 expect(bbb.isOnSwitchMember, isFalse);
4053 expect(bbb.isOnSwitchStatement, isFalse);
4054 }
4055 }
4056
4057 test_executable_localLabels_inTopLevelFunction() {
4058 String code = r'''
4059 f() {
4060 aaa: while (true) {}
4061 bbb: switch (42) {
4062 ccc: case 0:
4063 break;
4064 }
4065 }
4066 ''';
4067 UnlinkedExecutable executable = serializeExecutableText(code);
4068 List<UnlinkedLabel> labels = executable.localLabels;
4069 expect(labels, hasLength(3));
4070 {
4071 UnlinkedLabel aaa = labels.singleWhere((l) => l.name == 'aaa');
4072 expect(aaa, isNotNull);
4073 expect(aaa.isOnSwitchMember, isFalse);
4074 expect(aaa.isOnSwitchStatement, isFalse);
4075 }
4076 {
4077 UnlinkedLabel bbb = labels.singleWhere((l) => l.name == 'bbb');
4078 expect(bbb, isNotNull);
4079 expect(bbb.isOnSwitchMember, isFalse);
4080 expect(bbb.isOnSwitchStatement, isTrue);
4081 }
4082 {
4083 UnlinkedLabel ccc = labels.singleWhere((l) => l.name == 'ccc');
4084 expect(ccc, isNotNull);
4085 expect(ccc.isOnSwitchMember, isTrue);
4086 expect(ccc.isOnSwitchStatement, isFalse);
4087 }
4088 }
4089
4090 test_executable_localLabels_inTopLevelGetter() {
4091 String code = r'''
4092 get g {
4093 aaa: while (true) {}
4094 bbb: while (true) {}
4095 }
4096 ''';
4097 UnlinkedExecutable executable = serializeExecutableText(code, 'g');
4098 List<UnlinkedLabel> labels = executable.localLabels;
4099 expect(labels, hasLength(2));
4100 {
4101 UnlinkedLabel aaa = labels.singleWhere((l) => l.name == 'aaa');
4102 expect(aaa, isNotNull);
4103 expect(aaa.isOnSwitchMember, isFalse);
4104 expect(aaa.isOnSwitchStatement, isFalse);
4105 }
4106 {
4107 UnlinkedLabel bbb = labels.singleWhere((l) => l.name == 'bbb');
4108 expect(bbb, isNotNull);
4109 expect(bbb.isOnSwitchMember, isFalse);
4110 expect(bbb.isOnSwitchStatement, isFalse);
4111 }
4112 }
4113
4030 test_executable_localVariables_empty() { 4114 test_executable_localVariables_empty() {
4031 UnlinkedExecutable executable = serializeExecutableText(r''' 4115 UnlinkedExecutable executable = serializeExecutableText(r'''
4032 f() { 4116 f() {
4033 } 4117 }
4034 '''); 4118 ''');
4035 expect(executable.localVariables, isEmpty); 4119 expect(executable.localVariables, isEmpty);
4036 } 4120 }
4037 4121
4038 test_executable_localVariables_inConstructor() { 4122 test_executable_localVariables_inConstructor() {
4039 String code = r''' 4123 String code = r'''
(...skipping 2937 matching lines...) Expand 10 before | Expand all | Expand 10 after
6977 final String absoluteUri; 7061 final String absoluteUri;
6978 final String relativeUri; 7062 final String relativeUri;
6979 final int numTypeParameters; 7063 final int numTypeParameters;
6980 7064
6981 _PrefixExpectation(this.kind, this.name, 7065 _PrefixExpectation(this.kind, this.name,
6982 {this.inLibraryDefiningUnit: false, 7066 {this.inLibraryDefiningUnit: false,
6983 this.absoluteUri, 7067 this.absoluteUri,
6984 this.relativeUri, 7068 this.relativeUri,
6985 this.numTypeParameters: 0}); 7069 this.numTypeParameters: 0});
6986 } 7070 }
OLDNEW
« 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