| OLD | NEW |
| 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 4731 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4742 UnlinkedVariable e = variables.singleWhere((v) => v.name == 'e'); | 4742 UnlinkedVariable e = variables.singleWhere((v) => v.name == 'e'); |
| 4743 _assertVariableVisible(code, e, 'on int catch (', '} // 3'); | 4743 _assertVariableVisible(code, e, 'on int catch (', '} // 3'); |
| 4744 checkTypeRef(e.type, 'dart:core', 'dart:core', 'int'); | 4744 checkTypeRef(e.type, 'dart:core', 'dart:core', 'int'); |
| 4745 } | 4745 } |
| 4746 { | 4746 { |
| 4747 UnlinkedVariable st = variables.singleWhere((v) => v.name == 'st'); | 4747 UnlinkedVariable st = variables.singleWhere((v) => v.name == 'st'); |
| 4748 _assertVariableVisible(code, st, 'on int catch (', '} // 3'); | 4748 _assertVariableVisible(code, st, 'on int catch (', '} // 3'); |
| 4749 } | 4749 } |
| 4750 } | 4750 } |
| 4751 | 4751 |
| 4752 test_executable_localVariables_catch_noVariables() { |
| 4753 String code = r''' |
| 4754 f() { |
| 4755 try { |
| 4756 throw 42; |
| 4757 } on int {} |
| 4758 } |
| 4759 '''; |
| 4760 UnlinkedExecutable executable = serializeExecutableText(code); |
| 4761 List<UnlinkedVariable> variables = executable.localVariables; |
| 4762 expect(variables, isEmpty); |
| 4763 } |
| 4764 |
| 4752 test_executable_localVariables_empty() { | 4765 test_executable_localVariables_empty() { |
| 4753 UnlinkedExecutable executable = serializeExecutableText(r''' | 4766 UnlinkedExecutable executable = serializeExecutableText(r''' |
| 4754 f() { | 4767 f() { |
| 4755 } | 4768 } |
| 4756 '''); | 4769 '''); |
| 4757 expect(executable.localVariables, isEmpty); | 4770 expect(executable.localVariables, isEmpty); |
| 4758 } | 4771 } |
| 4759 | 4772 |
| 4760 test_executable_localVariables_forEachLoop() { | 4773 test_executable_localVariables_forEachLoop() { |
| 4761 String code = r''' | 4774 String code = r''' |
| (...skipping 29 matching lines...) Expand all Loading... |
| 4791 _assertVariableVisible(code, i, 'for', '} // 3'); | 4804 _assertVariableVisible(code, i, 'for', '} // 3'); |
| 4792 checkTypeRef(i.type, 'dart:core', 'dart:core', 'int'); | 4805 checkTypeRef(i.type, 'dart:core', 'dart:core', 'int'); |
| 4793 } | 4806 } |
| 4794 { | 4807 { |
| 4795 UnlinkedVariable i = variables.singleWhere((v) => v.name == 'j'); | 4808 UnlinkedVariable i = variables.singleWhere((v) => v.name == 'j'); |
| 4796 _assertVariableVisible(code, i, 'for', '} // 3'); | 4809 _assertVariableVisible(code, i, 'for', '} // 3'); |
| 4797 checkTypeRef(i.type, 'dart:core', 'dart:core', 'int'); | 4810 checkTypeRef(i.type, 'dart:core', 'dart:core', 'int'); |
| 4798 } | 4811 } |
| 4799 } | 4812 } |
| 4800 | 4813 |
| 4814 test_executable_localVariables_forLoop_noVariables() { |
| 4815 String code = r''' |
| 4816 f() { |
| 4817 for (; true;) {} |
| 4818 } |
| 4819 '''; |
| 4820 UnlinkedExecutable executable = serializeExecutableText(code); |
| 4821 List<UnlinkedVariable> variables = executable.localVariables; |
| 4822 expect(variables, isEmpty); |
| 4823 } |
| 4824 |
| 4801 test_executable_localVariables_inConstructor() { | 4825 test_executable_localVariables_inConstructor() { |
| 4802 String code = r''' | 4826 String code = r''' |
| 4803 class C { | 4827 class C { |
| 4804 C() { // 1 | 4828 C() { // 1 |
| 4805 int v; | 4829 int v; |
| 4806 } // 2 | 4830 } // 2 |
| 4807 } | 4831 } |
| 4808 '''; | 4832 '''; |
| 4809 UnlinkedExecutable executable = | 4833 UnlinkedExecutable executable = |
| 4810 findExecutable('', executables: serializeClassText(code).executables); | 4834 findExecutable('', executables: serializeClassText(code).executables); |
| (...skipping 3268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8079 class _PrefixExpectation { | 8103 class _PrefixExpectation { |
| 8080 final ReferenceKind kind; | 8104 final ReferenceKind kind; |
| 8081 final String name; | 8105 final String name; |
| 8082 final String absoluteUri; | 8106 final String absoluteUri; |
| 8083 final String relativeUri; | 8107 final String relativeUri; |
| 8084 final int numTypeParameters; | 8108 final int numTypeParameters; |
| 8085 | 8109 |
| 8086 _PrefixExpectation(this.kind, this.name, | 8110 _PrefixExpectation(this.kind, this.name, |
| 8087 {this.absoluteUri, this.relativeUri, this.numTypeParameters: 0}); | 8111 {this.absoluteUri, this.relativeUri, this.numTypeParameters: 0}); |
| 8088 } | 8112 } |
| OLD | NEW |