PY-12008 Add a bunch of tests covering various cases of malformed if statements

This commit is contained in:
Mikhail Golubev
2017-10-30 14:09:46 +03:00
parent 912ea0979e
commit b8b70bb856
25 changed files with 162 additions and 0 deletions
@@ -0,0 +1,9 @@
if foo and \
bar == 42:
pass
elif foo and \
bar:
pass
elif foo and \
bar == 24:
pass
@@ -0,0 +1,9 @@
if (foo and
bar == 42):
pass
elif (foo and
bar):
pass
elif (foo and
bar == 24):
pass
@@ -0,0 +1,9 @@
if (foo and
bar == 42):
pass
elif (foo and
bar):
pass
elif (foo and
bar == 24):
pass
@@ -0,0 +1,9 @@
if foo and \
bar == 42:
pass
elif foo and \
bar:
pass
elif foo and \
bar == 24:
pass
@@ -0,0 +1,9 @@
a = b = c = 0
if (a and b and c or
a and b or
a or
a and b or
a and b and c or
a and b or
a):
pass
@@ -0,0 +1,9 @@
a = b = c = 0
if (a and b and c or
a and b or
a or
a and b or
a and b and c or
a and b or
a):
pass
@@ -0,0 +1,3 @@
if (foo is None and
bar == 42):
pass
@@ -0,0 +1,3 @@
if (foo == 42 and
bar):
pass
@@ -0,0 +1,3 @@
if (foo == 42 and
bar):
pass
@@ -0,0 +1,3 @@
if (foo is None and
bar == 42):
pass
@@ -0,0 +1,3 @@
if (foo is None
and bar == 42):
pass
@@ -0,0 +1,3 @@
if (foo is None
and bar == 42):
pass
@@ -0,0 +1,3 @@
if not (foo == 42 or
bar == 42):
pass
@@ -0,0 +1,3 @@
if not (foo == 42 or
bar == 42):
pass
@@ -0,0 +1,4 @@
if (foo == 42 or
bar == 42 and
baz == 42):
pass
@@ -0,0 +1,4 @@
if (foo == 42 or
bar == 42 and
baz == 42):
pass
@@ -0,0 +1,3 @@
if foo is None and \
bar == 42:
pass
@@ -0,0 +1,3 @@
if foo is None and \
bar == 42:
pass
@@ -0,0 +1,3 @@
if foo is None \
and bar == 42:
pass
@@ -0,0 +1,3 @@
if foo is None \
and bar == 42:
pass
@@ -0,0 +1,3 @@
if 1 < 4 and \
5 < 7: # WRONG again, too many spaces
pass
@@ -0,0 +1,3 @@
if 1 < 4 and \
5 < 7: # WRONG again, too many spaces
pass
@@ -0,0 +1,4 @@
if foo == 42 or \
bar == 42 and \
baz == 42:
pass
@@ -0,0 +1,4 @@
if foo == 42 or \
bar == 42 and \
baz == 42:
pass
@@ -857,6 +857,56 @@ public class PyFormatterTest extends PyTestCase {
doTest();
}
public void testMultilineIfConditionKeywordAtEnd() {
doTest();
}
// PY-21328
public void testMultilineIfConditionLessComparisonsKeywordAtEnd() {
doTest();
}
public void testMultilineIfConditionKeywordAtStart() {
doTest();
}
public void testMultilineIfConditionInParenthesesKeywordAtEnd() {
doTest();
}
public void testMultilineIfConditionInParenthesesNegatedKeywordAtEnd() {
doTest();
}
public void testMultilineIfConditionInParenthesesKeywordAtEndSecondOperandIsReference() {
doTest();
}
public void testMultilineIfConditionInParenthesesKeywordAtStart() {
doTest();
}
public void testMultilineIfConditionNestedExpressions() {
doTest();
}
public void testMultilineIfConditionInParenthesesNestedExpressions() {
doTest();
}
public void testMultilineElifCondition() {
doTest();
}
public void testMultilineElifConditionInParentheses() {
doTest();
}
// PY-22035
public void testMultilineIfConditionComplex() {
doTest();
}
public void testVariableAnnotations() {
runWithLanguageLevel(LanguageLevel.PYTHON36, this::doTest);
}