summaryrefslogtreecommitdiff
path: root/tests/functional/c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/functional/c')
-rw-r--r--tests/functional/c/comparison_of_constants.py51
-rw-r--r--tests/functional/c/comparison_of_constants.txt9
-rw-r--r--tests/functional/c/comparison_with_callable.py2
-rw-r--r--tests/functional/c/consider/consider_using_get.py2
-rw-r--r--tests/functional/c/consider/consider_using_in.py2
5 files changed, 63 insertions, 3 deletions
diff --git a/tests/functional/c/comparison_of_constants.py b/tests/functional/c/comparison_of_constants.py
new file mode 100644
index 000000000..bfe4b8cdb
--- /dev/null
+++ b/tests/functional/c/comparison_of_constants.py
@@ -0,0 +1,51 @@
+# pylint: disable=missing-docstring, comparison-with-itself, invalid-name
+
+
+if 2 is 2: # [literal-comparison, comparison-of-constants]
+ pass
+
+while 2 == 2: # [comparison-of-constants]
+ pass
+
+while 2 > 2: # [comparison-of-constants]
+ pass
+
+n = 2
+if 2 != n:
+ pass
+
+if n != 1 + 1:
+ pass
+
+if True == True: # [comparison-of-constants, singleton-comparison]
+ pass
+
+CONST = 24
+
+if CONST is 0: # [literal-comparison]
+ pass
+
+if CONST is 1: # [literal-comparison]
+ pass
+
+if CONST is 42: # [literal-comparison]
+ pass
+
+if 0 < CONST < 42:
+ pass
+
+if 0 < n < 42:
+ pass
+
+if True == n != 42:
+ pass
+
+if 0 == n != 42:
+ pass
+
+
+print(0 < n < 42)
+print(0 <= n < 42 )
+print(n < 1 < n*42 < 42)
+print(42> n <= 0)
+print(0 == n > 42)
diff --git a/tests/functional/c/comparison_of_constants.txt b/tests/functional/c/comparison_of_constants.txt
new file mode 100644
index 000000000..1a0984024
--- /dev/null
+++ b/tests/functional/c/comparison_of_constants.txt
@@ -0,0 +1,9 @@
+comparison-of-constants:4:3:4:9::"Comparison between constants: '2 is 2' has a constant value":HIGH
+literal-comparison:4:3:4:9::Comparison to literal:UNDEFINED
+comparison-of-constants:7:6:7:12::"Comparison between constants: '2 == 2' has a constant value":HIGH
+comparison-of-constants:10:6:10:11::"Comparison between constants: '2 > 2' has a constant value":HIGH
+comparison-of-constants:20:3:20:15::"Comparison between constants: 'True == True' has a constant value":HIGH
+singleton-comparison:20:3:20:15::Comparison 'True == True' should be 'True is True' if checking for the singleton value True, or 'True' if testing for truthiness:UNDEFINED
+literal-comparison:25:3:25:13::Comparison to literal:UNDEFINED
+literal-comparison:28:3:28:13::Comparison to literal:UNDEFINED
+literal-comparison:31:3:31:14::Comparison to literal:UNDEFINED
diff --git a/tests/functional/c/comparison_with_callable.py b/tests/functional/c/comparison_with_callable.py
index 2afe43035..4b7123099 100644
--- a/tests/functional/c/comparison_with_callable.py
+++ b/tests/functional/c/comparison_with_callable.py
@@ -1,4 +1,4 @@
-# pylint: disable = disallowed-name, missing-docstring, useless-return, invalid-name, no-self-use, line-too-long, useless-object-inheritance
+# pylint: disable = disallowed-name, missing-docstring, useless-return, invalid-name, no-self-use, line-too-long, useless-object-inheritance, comparison-of-constants
def foo():
return None
diff --git a/tests/functional/c/consider/consider_using_get.py b/tests/functional/c/consider/consider_using_get.py
index 0b71431d0..728fccd50 100644
--- a/tests/functional/c/consider/consider_using_get.py
+++ b/tests/functional/c/consider/consider_using_get.py
@@ -1,4 +1,4 @@
-# pylint: disable=missing-docstring,invalid-name,using-constant-test,invalid-sequence-index,undefined-variable
+# pylint: disable=missing-docstring,invalid-name,using-constant-test,invalid-sequence-index,undefined-variable, comparison-of-constants
dictionary = {}
key = 'key'
diff --git a/tests/functional/c/consider/consider_using_in.py b/tests/functional/c/consider/consider_using_in.py
index 5bc06e438..c2b725173 100644
--- a/tests/functional/c/consider/consider_using_in.py
+++ b/tests/functional/c/consider/consider_using_in.py
@@ -1,4 +1,4 @@
-# pylint: disable=missing-docstring, invalid-name, pointless-statement, undefined-variable, literal-comparison, line-too-long, unneeded-not, too-few-public-methods, use-implicit-booleaness-not-comparison
+# pylint: disable=missing-docstring, invalid-name, pointless-statement, undefined-variable, literal-comparison, line-too-long, unneeded-not, too-few-public-methods, use-implicit-booleaness-not-comparison, comparison-of-constants
value = value1 = 1
value2 = 2