fixed PY-5193 Move Statement: do not allow to move break and continue statements out of a loop

This commit is contained in:
Ekaterina Tuzova
2011-12-02 11:39:29 +01:00
parent 0c455eb332
commit 2219082ab8
5 changed files with 19 additions and 2 deletions
@@ -59,7 +59,8 @@ public class StatementMover extends LineMover {
// check if we want to move statement
if (myStatementToMove == null) return false;
//do not move pass statement
if (myStatementToMove instanceof PyPassStatement) {
if (myStatementToMove instanceof PyPassStatement || myStatementToMove instanceof PyBreakStatement
|| myStatementToMove instanceof PyContinueStatement) {
info.toMove2 = info.toMove;
return true;
}
+4
View File
@@ -0,0 +1,4 @@
test()
for item in range(10):
co<caret>ntinue
test1()
@@ -0,0 +1,4 @@
test()
for item in range(10):
continue
test1()
@@ -0,0 +1,4 @@
test()
for item in range(10):
continue
test1()
@@ -92,7 +92,11 @@ public class PyStatementMoverTest extends PyTestCase {
doTest();
}
public void testFunctionDown() {
public void testFunctionDown() { // PY-5195
doTest();
}
public void testContinueBreak() { // PY-5193
doTest();
}
}