summaryrefslogtreecommitdiff
path: root/tests/functional/n/nested_min_max.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/functional/n/nested_min_max.py')
-rw-r--r--tests/functional/n/nested_min_max.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/functional/n/nested_min_max.py b/tests/functional/n/nested_min_max.py
new file mode 100644
index 000000000..cef63dc2b
--- /dev/null
+++ b/tests/functional/n/nested_min_max.py
@@ -0,0 +1,21 @@
+"""Test detection of redundant nested calls to min/max functions"""
+
+# pylint: disable=redefined-builtin,unnecessary-lambda-assignment
+
+min(1, min(2, 3)) # [nested-min-max]
+max(1, max(2, 3)) # [nested-min-max]
+min(min(1, 2), 3) # [nested-min-max]
+min(min(min(1, 2), 3), 4) # [nested-min-max, nested-min-max]
+min(1, max(2, 3))
+min(1, 2, 3)
+min(min(1, 2), min(3, 4)) # [nested-min-max]
+min(len([]), min(len([1]), len([1, 2]))) # [nested-min-max]
+
+orig_min = min
+min = lambda *args: args[0]
+min(1, min(2, 3))
+orig_min(1, orig_min(2, 3)) # [nested-min-max]
+
+# This is too complicated (for now) as there is no clear better way to write it
+max(max(i for i in range(10)), 0)
+max(max(max(i for i in range(10)), 0), 1)