committed by
Chris Hennes
parent
d546b9d219
commit
145af5cddc
@@ -2471,7 +2471,9 @@ Py::Object FunctionExpression::evaluate(const Expression *expr, int f, const std
|
||||
case MOD:
|
||||
if (e2.isNone())
|
||||
_EXPR_THROW("Invalid second argument.",expr);
|
||||
unit = v1.getUnit() / v2.getUnit();
|
||||
if (v1.getUnit() != v2.getUnit() && !v1.isDimensionless() && !v2.isDimensionless())
|
||||
_EXPR_THROW("Units must be equal or dimensionless.",expr);
|
||||
unit = v1.getUnit();
|
||||
break;
|
||||
case POW: {
|
||||
if (e2.isNone())
|
||||
|
||||
@@ -1088,14 +1088,18 @@ class SpreadsheetCases(unittest.TestCase):
|
||||
self.assertEqual(sheet.B8, rot)
|
||||
self.assertEqual(sheet.C8, pla)
|
||||
|
||||
def testIssue3128(self):
|
||||
"""Regression test for issue 3128; mod should work with arbitrary units for both arguments"""
|
||||
def testIssue19517(self):
|
||||
"""Regression test for issue 19517; mod should work with units"""
|
||||
sheet = self.doc.addObject("Spreadsheet::Sheet", "Spreadsheet")
|
||||
sheet.set("A1", "=mod(7mm;3mm)")
|
||||
sheet.set("A2", "=mod(7kg;3mm)")
|
||||
self.doc.recompute()
|
||||
self.assertEqual(sheet.A1, Units.Quantity("1"))
|
||||
self.assertEqual(sheet.A2, Units.Quantity("1 kg/mm"))
|
||||
self.assertEqual(sheet.A1, Units.Quantity("1 mm"))
|
||||
try:
|
||||
sheet.set("A2", "=mod(7kg;3mm)")
|
||||
self.doc.recompute()
|
||||
self.fail("Units need to be the same or dimensionless")
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
def testIssue3363(self):
|
||||
"""Regression test for issue 3363; Nested conditionals statement fails with additional conditional statement in false-branch"""
|
||||
|
||||
Reference in New Issue
Block a user