diff options
| author | Ulf Magnusson <ulfalizer@gmail.com> | 2017-11-03 06:40:40 +0100 |
|---|---|---|
| committer | Ulf Magnusson <ulfalizer@gmail.com> | 2017-11-03 06:43:12 +0100 |
| commit | de2e7f766f247d4e8701dcca9fc921f1d0230463 (patch) | |
| tree | 57f649164fd91b324af34299b080b72d1ecf7d20 | |
| parent | d1ea825a1d9d8bfc9496926b6a800ad58581b09a (diff) | |
Test Choice.assignable, fix for optional choices
Could never return 0 as a valid assignable value previously.
| -rw-r--r-- | kconfiglib.py | 2 | ||||
| -rw-r--r-- | tests/Kassignable | 26 | ||||
| -rw-r--r-- | testsuite.py | 17 |
3 files changed, 41 insertions, 4 deletions
diff --git a/kconfiglib.py b/kconfiglib.py index 612fc58..ae86b2a 100644 --- a/kconfiglib.py +++ b/kconfiglib.py @@ -3190,7 +3190,7 @@ class Choice(object): if vis == 2: if not self.is_optional: return (2,) if self.type == BOOL else (1, 2) - return (2,) + return (0, 2) if self.type == BOOL else (0, 1, 2) # vis == 1 diff --git a/tests/Kassignable b/tests/Kassignable index fe88abe..f134a74 100644 --- a/tests/Kassignable +++ b/tests/Kassignable @@ -201,3 +201,29 @@ config MY_CHOICE_N_VIS_TRISTATE tristate "m/y-mode choice tristate invisible" if n endchoice + + +# Choices with some other possible modes + +choice NMY_CHOICE + tristate "n/m/y-mode choice" + optional +endchoice + +choice NY_CHOICE + bool "n/y-mode choice" + optional +endchoice + +choice NM_CHOICE + tristate "n/m-mode choice" if m + optional +endchoice + +choice M_CHOICE + tristate "m-mode choice" if m +endchoice + +choice N_CHOICE + tristate "n-mode choice" if n +endchoice diff --git a/testsuite.py b/testsuite.py index dd0fe7c..3abcbb0 100644 --- a/testsuite.py +++ b/testsuite.py @@ -879,12 +879,12 @@ g def verify_assignable(sym_name, assignable, test_assign=True): verify_assignable_imp(c.syms[sym_name], assignable, test_assign) - def verify_const_unassignable(sym_name): - verify_assignable_imp(c.const_syms[sym_name], (), False) - # Test with modules enabled first c.modules.set_value(2) + def verify_const_unassignable(sym_name): + verify_assignable_imp(c.const_syms[sym_name], (), False) + # Things that shouldn't be .assignable verify_const_unassignable("n") verify_const_unassignable("m") @@ -954,6 +954,17 @@ g verify_assignable("MY_CHOICE_TRISTATE", (0, 2), test_assign=False) verify_assignable("MY_CHOICE_N_VIS_TRISTATE", ( )) + def verify_choice_assignable(choice_name, assignable): + verify_assignable_imp(c.named_choices[choice_name], assignable, True) + + verify_choice_assignable("Y_CHOICE", ( 2,)) + verify_choice_assignable("MY_CHOICE", ( 1, 2 )) + verify_choice_assignable("NMY_CHOICE", (0, 1, 2 )) + verify_choice_assignable("NY_CHOICE", (0, 2 )) + verify_choice_assignable("NM_CHOICE", (0, 1 )) + verify_choice_assignable("M_CHOICE", ( 1, )) + verify_choice_assignable("N_CHOICE", ( )) + print("Testing object relations") |
