mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-19 05:40:38 +01:00
[poincare/multiplication] Fix Multiplication::removeUnit
Scenario: f(x) = 0->_A evaluate 0f(0)
This commit is contained in:
committed by
EmilieNumworks
parent
36bc70aaee
commit
3a046f5bcb
@@ -264,8 +264,15 @@ Expression Multiplication::removeUnit(Expression * unit) {
|
||||
if (!currentUnit.isUninitialized()) {
|
||||
unitMult.addChildAtIndexInPlace(currentUnit, resultChildrenCount, resultChildrenCount);
|
||||
resultChildrenCount++;
|
||||
assert(childAtIndex(i).isRationalOne());
|
||||
removeChildAtIndexInPlace(i--);
|
||||
if (childAtIndex(i).isRationalOne()) {
|
||||
removeChildAtIndexInPlace(i--);
|
||||
} else {
|
||||
/* If the child was a unit convert, it replaced itself with an undefined
|
||||
* during the removeUnit. */
|
||||
assert(childAtIndex(i).isUndefined());
|
||||
*unit = Expression();
|
||||
return replaceWithUndefinedInPlace();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (resultChildrenCount == 0) {
|
||||
|
||||
@@ -1317,6 +1317,17 @@ QUIZ_CASE(poincare_simplification_user_function_with_convert) {
|
||||
Symbol::Builder('x')));
|
||||
assert_expression_reduce(e);
|
||||
assert_parsed_expression_simplify_to("e^(f(0))", "undef");
|
||||
|
||||
e = Store::Builder(
|
||||
UnitConvert::Builder(
|
||||
Rational::Builder(0),
|
||||
Unit::Second()),
|
||||
Function::Builder(
|
||||
"f", 1,
|
||||
Symbol::Builder('x')));
|
||||
assert_expression_reduce(e);
|
||||
assert_parsed_expression_simplify_to("0f(0)", "undef");
|
||||
|
||||
Ion::Storage::sharedStorage()->recordNamed("f.func").destroy();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user