Fix #117783: Allow Multiple Negatives in Numerical Inputs with Units

Support multiple unary operators before a number where only a single
negative value worked in the past.

Ref !117827.
This commit is contained in:
Campbell Barton
2024-02-06 09:28:30 +11:00
parent 72d324bd81
commit c527056f0c
2 changed files with 45 additions and 2 deletions
+18
View File
@@ -29,6 +29,24 @@ class UnitsTesting(unittest.TestCase):
('METRIC', 'LENGTH', "", "1+1ft", 1.3048), # no metric units, we default to meters.
('IMPERIAL', 'LENGTH', "", "3+1in+1ft", 0.3048 * 4 + 0.0254), # bigger unit becomes default one!
('IMPERIAL', 'LENGTH', "", "(3+1)in+1ft", 0.3048 + 0.0254 * 4),
# Support successive leading unary operators.
('IMPERIAL', 'LENGTH', "", "-1ft", -0.3048),
('IMPERIAL', 'LENGTH', "", "--1ft", --0.3048),
('IMPERIAL', 'LENGTH', "", "---1ft", ---0.3048),
('IMPERIAL', 'LENGTH', "", "- 1ft", -0.3048),
('IMPERIAL', 'LENGTH', "", "- - 1ft", --0.3048),
('IMPERIAL', 'LENGTH', "", "- - - 1ft", ---0.3048),
('IMPERIAL', 'LENGTH', "", "-+1ft", -+0.3048),
('IMPERIAL', 'LENGTH', "", "+-1ft", +-0.3048),
('METRIC', 'LENGTH', "", "~+-32m", ~+-32),
('METRIC', 'LENGTH', "", "-+~32m", -+~32),
('METRIC', 'LENGTH', "", "~ + - 32m", ~+-32),
('METRIC', 'LENGTH', "", "- + ~ 32m", -+~32),
)
# From 'internal' Blender value to user-friendly printing