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 7083 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7094 | 7094 |
7095 test_expr_inClosure_refersToParam() { | 7095 test_expr_inClosure_refersToParam() { |
7096 if (skipNonConstInitializers) { | 7096 if (skipNonConstInitializers) { |
7097 return; | 7097 return; |
7098 } | 7098 } |
7099 UnlinkedVariable variable = serializeVariableText('var v = (x) => x;'); | 7099 UnlinkedVariable variable = serializeVariableText('var v = (x) => x;'); |
7100 _assertUnlinkedConst(variable.initializer.localFunctions[0].bodyExpr, | 7100 _assertUnlinkedConst(variable.initializer.localFunctions[0].bodyExpr, |
7101 operators: [UnlinkedConstOperation.pushParameter], strings: ['x']); | 7101 operators: [UnlinkedConstOperation.pushParameter], strings: ['x']); |
7102 } | 7102 } |
7103 | 7103 |
| 7104 test_expr_inClosure_refersToParam_methodCall() { |
| 7105 if (skipNonConstInitializers) { |
| 7106 return; |
| 7107 } |
| 7108 UnlinkedVariable variable = serializeVariableText('var v = (x) => x.f();'); |
| 7109 _assertUnlinkedConst(variable.initializer.localFunctions[0].bodyExpr, |
| 7110 isValidConst: false, |
| 7111 operators: [ |
| 7112 UnlinkedConstOperation.pushParameter, |
| 7113 UnlinkedConstOperation.invokeMethod |
| 7114 ], |
| 7115 strings: [ |
| 7116 'x', |
| 7117 'f' |
| 7118 ], |
| 7119 ints: [ |
| 7120 0, |
| 7121 0 |
| 7122 ]); |
| 7123 } |
| 7124 |
| 7125 test_expr_inClosure_refersToParam_methodCall_prefixed() { |
| 7126 if (skipNonConstInitializers) { |
| 7127 return; |
| 7128 } |
| 7129 UnlinkedVariable variable = |
| 7130 serializeVariableText('var v = (x) => x.y.f();'); |
| 7131 _assertUnlinkedConst(variable.initializer.localFunctions[0].bodyExpr, |
| 7132 isValidConst: false, |
| 7133 operators: [ |
| 7134 UnlinkedConstOperation.pushParameter, |
| 7135 UnlinkedConstOperation.extractProperty, |
| 7136 UnlinkedConstOperation.invokeMethod |
| 7137 ], |
| 7138 strings: [ |
| 7139 'x', |
| 7140 'y', |
| 7141 'f' |
| 7142 ], |
| 7143 ints: [ |
| 7144 0, |
| 7145 0 |
| 7146 ]); |
| 7147 } |
| 7148 |
7104 test_expr_inClosure_refersToParam_outOfScope() { | 7149 test_expr_inClosure_refersToParam_outOfScope() { |
7105 if (skipNonConstInitializers) { | 7150 if (skipNonConstInitializers) { |
7106 return; | 7151 return; |
7107 } | 7152 } |
7108 UnlinkedVariable variable = | 7153 UnlinkedVariable variable = |
7109 serializeVariableText('var x; var v = (b) => (b ? (x) => x : x);'); | 7154 serializeVariableText('var x; var v = (b) => (b ? (x) => x : x);'); |
7110 _assertUnlinkedConst(variable.initializer.localFunctions[0].bodyExpr, | 7155 _assertUnlinkedConst(variable.initializer.localFunctions[0].bodyExpr, |
7111 isValidConst: false, | 7156 isValidConst: false, |
7112 operators: [ | 7157 operators: [ |
7113 UnlinkedConstOperation.pushParameter, | 7158 UnlinkedConstOperation.pushParameter, |
7114 UnlinkedConstOperation.pushLocalFunctionReference, | 7159 UnlinkedConstOperation.pushLocalFunctionReference, |
7115 UnlinkedConstOperation.pushReference, | 7160 UnlinkedConstOperation.pushReference, |
7116 UnlinkedConstOperation.conditional, | 7161 UnlinkedConstOperation.conditional, |
7117 ], | 7162 ], |
7118 strings: [ | 7163 strings: [ |
7119 'b' | 7164 'b' |
7120 ], | 7165 ], |
7121 ints: [ | 7166 ints: [ |
7122 0, | 7167 0, |
7123 0 | 7168 0 |
7124 ], | 7169 ], |
7125 referenceValidators: [ | 7170 referenceValidators: [ |
7126 (EntityRef r) => checkTypeRef(r, null, null, 'x', | 7171 (EntityRef r) => checkTypeRef(r, null, null, 'x', |
7127 expectedKind: ReferenceKind.topLevelPropertyAccessor) | 7172 expectedKind: ReferenceKind.topLevelPropertyAccessor) |
7128 ]); | 7173 ]); |
7129 } | 7174 } |
7130 | 7175 |
| 7176 test_expr_inClosure_refersToParam_prefixedIdentifier() { |
| 7177 if (skipNonConstInitializers) { |
| 7178 return; |
| 7179 } |
| 7180 UnlinkedVariable variable = serializeVariableText('var v = (x) => x.y;'); |
| 7181 _assertUnlinkedConst(variable.initializer.localFunctions[0].bodyExpr, |
| 7182 operators: [ |
| 7183 UnlinkedConstOperation.pushParameter, |
| 7184 UnlinkedConstOperation.extractProperty |
| 7185 ], |
| 7186 strings: [ |
| 7187 'x', |
| 7188 'y' |
| 7189 ]); |
| 7190 } |
| 7191 |
| 7192 test_expr_inClosure_refersToParam_prefixedIdentifier_assign() { |
| 7193 if (skipNonConstInitializers) { |
| 7194 return; |
| 7195 } |
| 7196 UnlinkedVariable variable = |
| 7197 serializeVariableText('var v = (x) => x.y = null;'); |
| 7198 _assertUnlinkedConst(variable.initializer.localFunctions[0].bodyExpr, |
| 7199 isValidConst: false, |
| 7200 operators: [ |
| 7201 UnlinkedConstOperation.pushNull, |
| 7202 UnlinkedConstOperation.pushParameter, |
| 7203 UnlinkedConstOperation.assignToProperty |
| 7204 ], |
| 7205 strings: [ |
| 7206 'x', |
| 7207 'y' |
| 7208 ], |
| 7209 assignmentOperators: [ |
| 7210 UnlinkedExprAssignOperator.assign |
| 7211 ]); |
| 7212 } |
| 7213 |
| 7214 test_expr_inClosure_refersToParam_prefixedPrefixedIdentifier() { |
| 7215 if (skipNonConstInitializers) { |
| 7216 return; |
| 7217 } |
| 7218 UnlinkedVariable variable = serializeVariableText('var v = (x) => x.y.z;'); |
| 7219 _assertUnlinkedConst(variable.initializer.localFunctions[0].bodyExpr, |
| 7220 operators: [ |
| 7221 UnlinkedConstOperation.pushParameter, |
| 7222 UnlinkedConstOperation.extractProperty, |
| 7223 UnlinkedConstOperation.extractProperty |
| 7224 ], |
| 7225 strings: [ |
| 7226 'x', |
| 7227 'y', |
| 7228 'z' |
| 7229 ]); |
| 7230 } |
| 7231 |
| 7232 test_expr_inClosure_refersToParam_prefixedPrefixedIdentifier_assign() { |
| 7233 if (skipNonConstInitializers) { |
| 7234 return; |
| 7235 } |
| 7236 UnlinkedVariable variable = |
| 7237 serializeVariableText('var v = (x) => x.y.z = null;'); |
| 7238 _assertUnlinkedConst(variable.initializer.localFunctions[0].bodyExpr, |
| 7239 isValidConst: false, |
| 7240 operators: [ |
| 7241 UnlinkedConstOperation.pushNull, |
| 7242 UnlinkedConstOperation.pushParameter, |
| 7243 UnlinkedConstOperation.extractProperty, |
| 7244 UnlinkedConstOperation.assignToProperty |
| 7245 ], |
| 7246 strings: [ |
| 7247 'x', |
| 7248 'y', |
| 7249 'z' |
| 7250 ], |
| 7251 assignmentOperators: [ |
| 7252 UnlinkedExprAssignOperator.assign |
| 7253 ]); |
| 7254 } |
| 7255 |
7131 test_expr_invokeMethod_instance() { | 7256 test_expr_invokeMethod_instance() { |
7132 if (skipNonConstInitializers) { | 7257 if (skipNonConstInitializers) { |
7133 return; | 7258 return; |
7134 } | 7259 } |
7135 UnlinkedVariable variable = serializeVariableText(''' | 7260 UnlinkedVariable variable = serializeVariableText(''' |
7136 class C { | 7261 class C { |
7137 int m(a, {b, c}) => 42; | 7262 int m(a, {b, c}) => 42; |
7138 } | 7263 } |
7139 final v = new C().m(1, b: 2, c: 3); | 7264 final v = new C().m(1, b: 2, c: 3); |
7140 '''); | 7265 '''); |
(...skipping 3188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10329 class _PrefixExpectation { | 10454 class _PrefixExpectation { |
10330 final ReferenceKind kind; | 10455 final ReferenceKind kind; |
10331 final String name; | 10456 final String name; |
10332 final String absoluteUri; | 10457 final String absoluteUri; |
10333 final String relativeUri; | 10458 final String relativeUri; |
10334 final int numTypeParameters; | 10459 final int numTypeParameters; |
10335 | 10460 |
10336 _PrefixExpectation(this.kind, this.name, | 10461 _PrefixExpectation(this.kind, this.name, |
10337 {this.absoluteUri, this.relativeUri, this.numTypeParameters: 0}); | 10462 {this.absoluteUri, this.relativeUri, this.numTypeParameters: 0}); |
10338 } | 10463 } |
OLD | NEW |