Skip to content

Commit

Permalink
Provide an equivalent of the original test.
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobtylerwalls committed Oct 16, 2022
1 parent 5625cd8 commit d97504e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
5 changes: 3 additions & 2 deletions tests/functional/t/ternary.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
"""Test for old ternary constructs"""
from UNINFERABLE import condition, some_callable # pylint: disable=import-error
from UNINFERABLE import condition, some_callable, maybe_true, maybe_false # pylint: disable=import-error

TRUE_VALUE = True
FALSE_VALUE = False

SOME_VALUE1 = TRUE_VALUE if condition else FALSE_VALUE
SOME_VALUE2 = condition and TRUE_VALUE or FALSE_VALUE # [consider-using-ternary]
NOT_SIMPLIFIABLE = condition and some_callable or FALSE_VALUE
NOT_SIMPLIFIABLE_1 = maybe_true if condition else maybe_false
NOT_SIMPLIFIABLE_2 = condition and maybe_true or maybe_false
SOME_VALUE3 = condition

def func1():
Expand Down
14 changes: 7 additions & 7 deletions tests/functional/t/ternary.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
consider-using-ternary:8:0:8:53::Consider using ternary (TRUE_VALUE if condition else FALSE_VALUE):INFERENCE
consider-using-ternary:19:4:19:50:func2:Consider using ternary (TRUE_VALUE if condition else FALSE_VALUE):INFERENCE
consider-using-ternary:22:0:22:63::Consider using ternary ('ERROR' if some_callable(condition) else 'SUCCESS'):INFERENCE
consider-using-ternary:23:0:23:60::Consider using ternary ('greater' if SOME_VALUE1 > 3 else 'not greater'):INFERENCE
consider-using-ternary:24:0:24:67::Consider using ternary ('both' if SOME_VALUE2 > 4 and SOME_VALUE3 else 'not'):INFERENCE
simplify-boolean-expression:27:0:27:50::Boolean expression may be simplified to SOME_VALUE2:INFERENCE
consider-using-ternary:37:4:37:51:func4:Consider using ternary (truth_value if condition else FALSE_VALUE):INFERENCE
simplify-boolean-expression:43:4:43:51:func5:Boolean expression may be simplified to FALSE_VALUE:INFERENCE
consider-using-ternary:20:4:20:50:func2:Consider using ternary (TRUE_VALUE if condition else FALSE_VALUE):INFERENCE
consider-using-ternary:23:0:23:63::Consider using ternary ('ERROR' if some_callable(condition) else 'SUCCESS'):INFERENCE
consider-using-ternary:24:0:24:60::Consider using ternary ('greater' if SOME_VALUE1 > 3 else 'not greater'):INFERENCE
consider-using-ternary:25:0:25:67::Consider using ternary ('both' if SOME_VALUE2 > 4 and SOME_VALUE3 else 'not'):INFERENCE
simplify-boolean-expression:28:0:28:50::Boolean expression may be simplified to SOME_VALUE2:INFERENCE
consider-using-ternary:38:4:38:51:func4:Consider using ternary (truth_value if condition else FALSE_VALUE):INFERENCE
simplify-boolean-expression:44:4:44:51:func5:Boolean expression may be simplified to FALSE_VALUE:INFERENCE

0 comments on commit d97504e

Please sign in to comment.