summaryrefslogtreecommitdiff
path: root/tests/functional/s/simplifiable/simplifiable_if_expression.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/functional/s/simplifiable/simplifiable_if_expression.py')
-rw-r--r--tests/functional/s/simplifiable/simplifiable_if_expression.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/functional/s/simplifiable/simplifiable_if_expression.py b/tests/functional/s/simplifiable/simplifiable_if_expression.py
new file mode 100644
index 000000000..bcfdf890b
--- /dev/null
+++ b/tests/functional/s/simplifiable/simplifiable_if_expression.py
@@ -0,0 +1,27 @@
+"""Test that some if expressions can be simplified."""
+
+# pylint: disable=missing-docstring, invalid-name
+
+
+def test_simplifiable_1(arg):
+ # Simple test that can be replaced by bool(arg)
+ return True if arg else False # [simplifiable-if-expression]
+
+def test_simplifiable_2(arg):
+ # Simple test that can be replaced by not arg
+ return False if arg else True # [simplifiable-if-expression]
+
+def test_simplifiable_3(arg):
+ # Simple test that can be replaced by arg == 1
+ return True if arg == 1 else False # [simplifiable-if-expression]
+
+def test_simplifiable_4(arg):
+ # Simple test that can be replaced by not (arg == 1)
+ return False if arg == 1 else True # [simplifiable-if-expression]
+
+def test_not_simplifiable(arg):
+ x = True if arg else True
+ y = 0 if arg else 1
+ t = False if arg != 1 else False
+ t2 = None if arg > 3 else False
+ return x, y, t, t2