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

Side by Side Diff: pkg/analysis_server/test/services/refactoring/rename_local_test.dart

Issue 1798223002: Fix visible range of local variables in 'for' loops. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 9 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 | « no previous file | pkg/analyzer/lib/src/dart/element/builder.dart » ('j') | 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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 test.services.refactoring.rename_local; 5 library test.services.refactoring.rename_local;
6 6
7 import 'package:analysis_server/plugin/protocol/protocol.dart'; 7 import 'package:analysis_server/plugin/protocol/protocol.dart';
8 import 'package:analysis_server/src/services/correction/status.dart'; 8 import 'package:analysis_server/src/services/correction/status.dart';
9 import 'package:test_reflective_loader/test_reflective_loader.dart'; 9 import 'package:test_reflective_loader/test_reflective_loader.dart';
10 import 'package:unittest/unittest.dart'; 10 import 'package:unittest/unittest.dart';
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 int test = 0; 94 int test = 0;
95 } 95 }
96 } 96 }
97 '''); 97 ''');
98 createRenameRefactoringAtString('test = 0'); 98 createRenameRefactoringAtString('test = 0');
99 // check status 99 // check status
100 refactoring.newName = 'newName'; 100 refactoring.newName = 'newName';
101 return assertRefactoringConditionsOK(); 101 return assertRefactoringConditionsOK();
102 } 102 }
103 103
104 test_checkFinalConditions_hasLocalVariable_otherForEachLoop() {
105 indexTestUnit('''
106 main() {
107 for (int newName in []) {}
108 for (int test in []) {}
109 }
110 ''');
111 createRenameRefactoringAtString('test in');
112 // check status
113 refactoring.newName = 'newName';
114 return assertRefactoringConditionsOK();
115 }
116
117 test_checkFinalConditions_hasLocalVariable_otherForLoop() {
118 indexTestUnit('''
119 main() {
120 for (int newName = 0; newName < 10; newName++) {}
121 for (int test = 0; test < 10; test++) {}
122 }
123 ''');
124 createRenameRefactoringAtString('test = 0');
125 // check status
126 refactoring.newName = 'newName';
127 return assertRefactoringConditionsOK();
128 }
129
104 test_checkFinalConditions_hasLocalVariable_otherFunction() { 130 test_checkFinalConditions_hasLocalVariable_otherFunction() {
105 indexTestUnit(''' 131 indexTestUnit('''
106 main() { 132 main() {
107 int test = 0; 133 int test = 0;
108 } 134 }
109 main2() { 135 main2() {
110 var newName = 1; 136 var newName = 1;
111 } 137 }
112 '''); 138 ''');
113 createRenameRefactoringAtString('test = 0'); 139 createRenameRefactoringAtString('test = 0');
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
520 main() { 546 main() {
521 int test = 0; 547 int test = 0;
522 } 548 }
523 '''); 549 ''');
524 // configure refactoring 550 // configure refactoring
525 createRenameRefactoringAtString('test = 0'); 551 createRenameRefactoringAtString('test = 0');
526 // old name 552 // old name
527 expect(refactoring.oldName, 'test'); 553 expect(refactoring.oldName, 'test');
528 } 554 }
529 } 555 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/dart/element/builder.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698