diff options
| author | Ulf Magnusson <ulfalizer@gmail.com> | 2018-02-08 06:03:44 +0100 |
|---|---|---|
| committer | Ulf Magnusson <ulfalizer@gmail.com> | 2018-02-08 10:14:48 +0100 |
| commit | e8b4ecb6ff6ccc1c7be0818314fbccda2ef2b2ee (patch) | |
| tree | 6ad3e42e6202bd88228613e8eb05745237c4eac1 /testsuite.py | |
| parent | 2abc0bb4c770723417e725dd1b947a494ac649b4 (diff) | |
Don't special-case user_value for choice symbols set to y
Previously, setting a choice symbol to y would only update
user_selection on the parent choice and not the symbol's own user_value.
Now both are updated.
The point of the old behavior was to remember the m mode selections of a
choice when it was switched back and forth between m and y mode, which
was a feature I thought the C implementation had. On closer inspection,
the C implementation never had that feature, though it might appear like
it if you only make "lucky" changes (if you never select any symbols in
y mode that were n in m mode).
The new behavior is simpler and easier to understand: Symbol.user_value
now always matches the value assigned in a .config file or via
set_value(), provided the value was well-formed. This might avoid some
special-casing in scripts too.
The loss in usability is pretty minimal.
Diffstat (limited to 'testsuite.py')
| -rw-r--r-- | testsuite.py | 35 |
1 files changed, 13 insertions, 22 deletions
diff --git a/testsuite.py b/testsuite.py index 2cd6fa8..ad32070 100644 --- a/testsuite.py +++ b/testsuite.py @@ -1550,12 +1550,10 @@ g sym.name + " should be the user selection of the choice") verify(sym.tri_value == 2, - sym.name + " should be y when selected") + sym.name + " should have value y when selected") - verify(sym.user_value != 2, - sym.name + " should not have user value y, because choice " - "y mode selections are remembered on the choice " - "itself") + verify(sym.user_value == 2, + sym.name + " should have user value y when selected") for sibling in choice.syms: if sibling is not sym: @@ -1628,28 +1626,21 @@ g # Test m mode selection c.named_choices["TRISTATE"].set_value(1) + + verify(c.named_choices["TRISTATE"].tri_value == 1, + "TRISTATE choice should have mode m after explicit mode assignment") + + assign_and_verify_value("T_1", 0, 0) + assign_and_verify_value("T_2", 0, 0) assign_and_verify_value("T_1", 1, 1) assign_and_verify_value("T_2", 1, 1) + assign_and_verify_value("T_1", 2, 1) + assign_and_verify_value("T_2", 2, 1) - c.syms["T_1"].set_value(0) # Check that this is remembered later - - # Switching to y mode should cause T_1 to become selected + # Switching to y mode should cause T_2 to become selected c.named_choices["TRISTATE"].set_value(2) - verify_value("T_1", 2) - verify_value("T_2", 0) - - # Switching back to m mode should restore the old values - c.named_choices["TRISTATE"].set_value(1) verify_value("T_1", 0) - verify_value("T_2", 1) - - assign_and_verify_value("TM_1", 1, 1) - assign_and_verify_value("TM_1", 2, 1) # Ignored - verify(c.named_choices["TRISTATE"].tri_value == 1, - "m-visible choice got invalid mode") - - assign_and_verify_value("TM_1", 0, 0) - assign_and_verify_value("TM_1", 2, 0) # Ignored + verify_value("T_2", 2) # Verify that choices with no explicitly specified type get the type of the # first contained symbol with a type |
