Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBastien Montagne <montagne29@wanadoo.fr>2014-08-20 14:12:03 +0400
committerBastien Montagne <montagne29@wanadoo.fr>2014-08-20 14:12:03 +0400
commit8535b9bd15434dc76e599a95a041422b17153116 (patch)
tree04414340e23b4e8e139fdc2454769929276783f1 /tests
parent21da42bd7ad542323eb15c63fd92e0029b590172 (diff)
Fix T38722: Adding units in Imperial setting results in inconsistent values
Now always check for a default unit, and evaluate the whole expression in this "unit space". Not an ideal solution, but should handle most cases nicely (we can't address all possible corner cases anyway). Note default unit is searched in current string first (bigger unit of current system wins), then in previous string. Note this also replaces ',' by '+' in default separation between units, helps solving issues with parenthesis (e.g. (1'1")*2.5 would fail in existing code)! This would break if someone uses py ops with lower precedence than '+' (like bitwise operations, and comparison), but these are not expected usecase here anyway. Reviewers: campbellbarton Differential Revision: https://developer.blender.org/D340
Diffstat (limited to 'tests')
-rw-r--r--tests/python/bl_pyapi_units.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/tests/python/bl_pyapi_units.py b/tests/python/bl_pyapi_units.py
index 478adef51b2..a09a25e4b71 100644
--- a/tests/python/bl_pyapi_units.py
+++ b/tests/python/bl_pyapi_units.py
@@ -23,7 +23,10 @@ class UnitsTesting(unittest.TestCase):
('METRIC', 'LENGTH', "33.3dm", "1", 0.1),
('IMPERIAL', 'LENGTH', "33.3cm", "1", 0.3048), # ref unit is not in IMPERIAL system, default to feet...
('IMPERIAL', 'LENGTH', "33.3ft", "1\"", 0.0254), # unused ref unit, since one is given already!
- #('IMPERIAL', 'LENGTH', "", "1+1ft", 0.3048 * 2), # Will fail with current code!
+ ('IMPERIAL', 'LENGTH', "", "1+1ft", 0.3048 * 2), # default unit taken from current string (feet).
+ ('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),
)
# From 'internal' Blender value to user-friendly printing