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

Unified Diff: pkg/analyzer/test/src/task/dart_test.dart

Issue 1700263002: Add data structures to AST to indicate potentially mutated variables. (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
Index: pkg/analyzer/test/src/task/dart_test.dart
diff --git a/pkg/analyzer/test/src/task/dart_test.dart b/pkg/analyzer/test/src/task/dart_test.dart
index f7b6aee66e6da5eb66364ac304db1e1df19bb315..ecc2240b5714ca49209585f10d8de0e9658439e1 100644
--- a/pkg/analyzer/test/src/task/dart_test.dart
+++ b/pkg/analyzer/test/src/task/dart_test.dart
@@ -4067,10 +4067,14 @@ class ResolveVariableReferencesTaskTest extends _AbstractDartTaskTest {
* Verify that the mutated states of the given [variable] correspond to the
* [mutatedInClosure] and [mutatedInScope] matchers.
*/
- void expectMutated(VariableElement variable, Matcher mutatedInClosure,
- Matcher mutatedInScope) {
+ void expectMutated(FunctionBody body, VariableElement variable,
+ bool mutatedInClosure, bool mutatedInScope) {
expect(variable.isPotentiallyMutatedInClosure, mutatedInClosure);
expect(variable.isPotentiallyMutatedInScope, mutatedInScope);
+ expect(body.localVariableInfo.potentiallyMutatedInClosure,
+ mutatedInClosure ? contains(variable) : isNot(contains(variable)));
+ expect(body.localVariableInfo.potentiallyMutatedInScope,
+ mutatedInScope ? contains(variable) : isNot(contains(variable)));
}
test_created_resolved_unit() {
@@ -4120,11 +4124,13 @@ main() {
matcher: isResolveVariableReferencesTask);
// validate
CompilationUnit unit = outputs[RESOLVED_UNIT4];
- FunctionElement main = unit.element.functions[0];
- expectMutated(main.localVariables[0], isFalse, isFalse);
- expectMutated(main.localVariables[1], isFalse, isTrue);
- expectMutated(main.localVariables[2], isTrue, isTrue);
- expectMutated(main.localVariables[3], isTrue, isTrue);
+ FunctionDeclaration mainDeclaration = unit.declarations[0];
+ FunctionBody body = mainDeclaration.functionExpression.body;
+ FunctionElement main = mainDeclaration.element;
+ expectMutated(body, main.localVariables[0], false, false);
+ expectMutated(body, main.localVariables[1], false, true);
+ expectMutated(body, main.localVariables[2], true, true);
+ expectMutated(body, main.localVariables[3], true, true);
}
test_perform_parameter() {
@@ -4145,11 +4151,13 @@ main(p1, p2, p3, p4) {
matcher: isResolveVariableReferencesTask);
// validate
CompilationUnit unit = outputs[RESOLVED_UNIT4];
- FunctionElement main = unit.element.functions[0];
- expectMutated(main.parameters[0], isFalse, isFalse);
- expectMutated(main.parameters[1], isFalse, isTrue);
- expectMutated(main.parameters[2], isTrue, isTrue);
- expectMutated(main.parameters[3], isTrue, isTrue);
+ FunctionDeclaration mainDeclaration = unit.declarations[0];
+ FunctionBody body = mainDeclaration.functionExpression.body;
+ FunctionElement main = mainDeclaration.element;
+ expectMutated(body, main.parameters[0], false, false);
+ expectMutated(body, main.parameters[1], false, true);
+ expectMutated(body, main.parameters[2], true, true);
+ expectMutated(body, main.parameters[3], true, true);
}
}
« pkg/analyzer/lib/src/generated/resolver.dart ('K') | « pkg/analyzer/lib/src/generated/resolver.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698