summaryrefslogtreecommitdiff
path: root/addons/web/static/tests/core
diff options
context:
space:
mode:
authorCedric Snauwaert <csn@openerp.com>2019-07-03 08:58:30 +0000
committerCedric Snauwaert <csn@openerp.com>2019-07-09 07:45:42 +0000
commit9cab694bf594f6c7c8d795174d9159ac82f526b2 (patch)
tree59c3726d041e72f92eb40d7b123d96e63eb26445 /addons/web/static/tests/core
parent38753f95d9890171e8c9d81f29ae0b1b1eafa9cc (diff)
[IMP] web: add simple calculator on numeric fields
Add a new behavior to numeric fields, possibility to enter value manually or to use a simple arithmetic expression that will be evaluated. Example: =20+3*2 In order for the computation of the arithmetic expression to be done, the value needs to starts with = and then an expression can be entered. We only support the basics mathematical operations + - * / ( ) ^ User locale and digits separator are taken into account. If the value entered can't be evaluated to a numeric, the field will be displayed in error. closes odoo/odoo#34538 Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Diffstat (limited to 'addons/web/static/tests/core')
-rw-r--r--addons/web/static/tests/core/py_utils_tests.js4
1 files changed, 3 insertions, 1 deletions
diff --git a/addons/web/static/tests/core/py_utils_tests.js b/addons/web/static/tests/core/py_utils_tests.js
index 8de80fbb0d7..1a88ece088a 100644
--- a/addons/web/static/tests/core/py_utils_tests.js
+++ b/addons/web/static/tests/core/py_utils_tests.js
@@ -31,12 +31,14 @@ QUnit.module('core', function () {
});
QUnit.test('simple arithmetic', function(assert) {
- assert.expect(2);
+ assert.expect(3);
var result = pyUtils.py_eval("1 + 2");
assert.strictEqual(result, 3, "should properly evaluate sum");
result = pyUtils.py_eval("42 % 5");
assert.strictEqual(result, 2, "should properly evaluate modulo operator");
+ result = pyUtils.py_eval("2 ** 3");
+ assert.strictEqual(result, 8, "should properly evaluate power operator");
});