diff options
| author | Ulf Magnusson <ulfalizer@gmail.com> | 2018-03-26 15:12:09 +0200 |
|---|---|---|
| committer | Ulf Magnusson <ulfalizer@gmail.com> | 2018-03-26 15:15:07 +0200 |
| commit | 6ef362c490bc2608c971eeabd5930ea0d8893dbe (patch) | |
| tree | d745b8b5427b5831998b289dc30bd0a75fe2d6be | |
| parent | 7374891d0a9b455ff7d20e84efd0e6b1e3705c11 (diff) | |
Refactor expr_str() cases
- Detect Symbol directly instead of as (not tuple) + (not choice)
- Test explicitly for a tuple (non-Symbol) in NOT
- Add some tests to get better coverage for NOT and parentheses
| -rw-r--r-- | kconfiglib.py | 21 | ||||
| -rw-r--r-- | tests/Kstr | 3 | ||||
| -rw-r--r-- | testsuite.py | 3 |
3 files changed, 11 insertions, 16 deletions
diff --git a/kconfiglib.py b/kconfiglib.py index ed945ca..46da1c1 100644 --- a/kconfiglib.py +++ b/kconfiglib.py @@ -4106,23 +4106,20 @@ def expr_str(expr): Passing subexpressions of expressions to this function works as expected. """ - if not isinstance(expr, tuple): - if isinstance(expr, Choice): - if expr.name is not None: - return "<choice {}>".format(expr.name) - return "<choice>" - - # Symbol - + if isinstance(expr, Symbol): if expr.is_constant: return '"{}"'.format(escape(expr.name)) - return expr.name + if isinstance(expr, Choice): + if expr.name is not None: + return "<choice {}>".format(expr.name) + return "<choice>" + if expr[0] == NOT: - if isinstance(expr[1], Symbol): - return "!" + expr_str(expr[1]) - return "!({})".format(expr_str(expr[1])) + if isinstance(expr[1], tuple): + return "!({})".format(expr_str(expr[1])) + return "!" + expr_str(expr[1]) # Symbol if expr[0] == AND: return "{} && {}".format(_format_and_op(expr[1]), @@ -30,8 +30,7 @@ config ADVANCED prompt "prompt 2" menuconfig ADVANCED - prompt "prompt 3" - depends on DEP2 + prompt "prompt 3" if DEP2 && (DEP3 || !DEP4 || !(DEP5 && DEP6)) if DEP3 diff --git a/testsuite.py b/testsuite.py index 7617226..9177efd 100644 --- a/testsuite.py +++ b/testsuite.py @@ -528,8 +528,7 @@ config ADVANCED prompt "prompt 2" menuconfig ADVANCED - prompt "prompt 3" if DEP2 - depends on DEP2 + prompt "prompt 3" if DEP2 && (DEP3 || !DEP4 || !(DEP5 && DEP6)) config ADVANCED depends on DEP4 && DEP3 |
