| 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 0f43fcaca8520e91dee544dab126ee5c235e512e..954002d85439d7387dcf71bde75c4b2538c8bd47 100644
|
| --- a/pkg/analyzer/test/src/summary/summary_common.dart
|
| +++ b/pkg/analyzer/test/src/summary/summary_common.dart
|
| @@ -4359,6 +4359,31 @@ get g {
|
| }
|
| }
|
|
|
| + test_executable_localVariables_catch() {
|
| + String code = r'''
|
| +f() { // 1
|
| + try {
|
| + throw 42;
|
| + } on int catch (e, st) { // 2
|
| + print(e);
|
| + print(st);
|
| + } // 3
|
| +} // 4
|
| +''';
|
| + UnlinkedExecutable executable = serializeExecutableText(code);
|
| + List<UnlinkedVariable> variables = executable.localVariables;
|
| + expect(variables, hasLength(2));
|
| + {
|
| + UnlinkedVariable e = variables.singleWhere((v) => v.name == 'e');
|
| + _assertVariableVisible(code, e, 'on int catch (', '} // 3');
|
| + checkTypeRef(e.type, 'dart:core', 'dart:core', 'int');
|
| + }
|
| + {
|
| + UnlinkedVariable st = variables.singleWhere((v) => v.name == 'st');
|
| + _assertVariableVisible(code, st, 'on int catch (', '} // 3');
|
| + }
|
| + }
|
| +
|
| test_executable_localVariables_empty() {
|
| UnlinkedExecutable executable = serializeExecutableText(r'''
|
| f() {
|
| @@ -4367,6 +4392,47 @@ f() {
|
| expect(executable.localVariables, isEmpty);
|
| }
|
|
|
| + test_executable_localVariables_forEachLoop() {
|
| + String code = r'''
|
| +f() { // 1
|
| + for (int i in <int>[]) { // 2
|
| + print(i);
|
| + } // 3
|
| +} // 4
|
| +''';
|
| + UnlinkedExecutable executable = serializeExecutableText(code);
|
| + List<UnlinkedVariable> variables = executable.localVariables;
|
| + expect(variables, hasLength(1));
|
| + {
|
| + UnlinkedVariable i = variables.singleWhere((v) => v.name == 'i');
|
| + _assertVariableVisible(code, i, 'for', '} // 3');
|
| + checkTypeRef(i.type, 'dart:core', 'dart:core', 'int');
|
| + }
|
| + }
|
| +
|
| + test_executable_localVariables_forLoop() {
|
| + String code = r'''
|
| +f() { // 1
|
| + for (int i = 0, j = 0; i < 10; i++, j++) { // 2
|
| + print(i);
|
| + } // 3
|
| +} // 4
|
| +''';
|
| + UnlinkedExecutable executable = serializeExecutableText(code);
|
| + List<UnlinkedVariable> variables = executable.localVariables;
|
| + expect(variables, hasLength(2));
|
| + {
|
| + UnlinkedVariable i = variables.singleWhere((v) => v.name == 'i');
|
| + _assertVariableVisible(code, i, 'for', '} // 3');
|
| + checkTypeRef(i.type, 'dart:core', 'dart:core', 'int');
|
| + }
|
| + {
|
| + UnlinkedVariable i = variables.singleWhere((v) => v.name == 'j');
|
| + _assertVariableVisible(code, i, 'for', '} // 3');
|
| + checkTypeRef(i.type, 'dart:core', 'dart:core', 'int');
|
| + }
|
| + }
|
| +
|
| test_executable_localVariables_inConstructor() {
|
| String code = r'''
|
| class C {
|
|
|