Skip to content

Commit

Permalink
Fix constants
Browse files Browse the repository at this point in the history
  • Loading branch information
fintarin committed Jul 5, 2023
1 parent 2cce30e commit 560b115
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
5 changes: 2 additions & 3 deletions include/fintamath/expressions/IExpression.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,10 @@ class IExpression : public IArithmetic {

static void preciseSimplifyChild(ArgumentPtr &child);

static ArgumentPtr callFunction(const IFunction &func, const ArgumentsPtrVector &argPtrs);

private:
static void simplifyConstant(ArgumentPtr &child);

static ArgumentPtr callFunction(const IFunction &func, const ArgumentsPtrVector &argPtrs);

private:
static Parser::Vector<std::unique_ptr<IExpression>, const std::string &> &getParser();
};
Expand Down
6 changes: 2 additions & 4 deletions src/fintamath/expressions/IExpression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ void IExpression::simplifyChild(ArgumentPtr &child) {
child = simplObj;
}
}

simplifyConstant(child);
}

void IExpression::preSimplifyChild(ArgumentPtr &child) {
Expand All @@ -97,8 +99,6 @@ void IExpression::preSimplifyChild(ArgumentPtr &child) {
child = simplObj;
}
}

simplifyConstant(child);
}

void IExpression::postSimplifyChild(ArgumentPtr &child) {
Expand All @@ -107,8 +107,6 @@ void IExpression::postSimplifyChild(ArgumentPtr &child) {
child = simplObj;
}
}

simplifyConstant(child);
}

void IExpression::preciseSimplifyChild(ArgumentPtr &child) {
Expand Down
2 changes: 2 additions & 0 deletions tests/src/expressions/ExpressionTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ TEST(ExpressionTests, stringConstructorTest) {
EXPECT_EQ(Expression("2^(2/3) 1/7^(2/3) 3^(3/4)").toString(),
"(root(27, 4) root(4, 3))/root(49, 3)"); // TODO! root(27, 4) root(4/49, 3)

EXPECT_EQ(Expression("Deg").toString(), "1/180 Pi");
EXPECT_EQ(Expression("60Deg").toString(), "1/3 Pi");
EXPECT_EQ(Expression("E").toString(), "E");
EXPECT_EQ(Expression("Pi").toString(), "Pi");
EXPECT_EQ(Expression("E^101-E^101").toString(), "0");
Expand Down

0 comments on commit 560b115

Please sign in to comment.