From 1162cbb2e4381acba2151ee86139ff16fa1e0fb1 Mon Sep 17 00:00:00 2001 From: fintarin Date: Tue, 26 Mar 2024 22:51:21 +0300 Subject: [PATCH] MathObjectClass, new Parser, class body macro --- .gitmodules | 3 + CMakeLists.txt | 3 +- cmake/Coverage.cmake | 10 +- include/fintamath/core/IArithmetic.hpp | 26 +- include/fintamath/core/IComparable.hpp | 21 +- include/fintamath/core/IMathObject.hpp | 26 +- include/fintamath/core/IMathObjectCRTP.hpp | 4 +- include/fintamath/core/MathObjectBody.hpp | 46 +++ .../fintamath/core/MathObjectBoundTypes.hpp | 63 ---- include/fintamath/core/MathObjectClass.hpp | 107 ++++++ include/fintamath/core/MathObjectType.hpp | 197 ----------- .../{CoreUtils.hpp => MathObjectUtils.hpp} | 11 +- include/fintamath/core/MultiMethod.hpp | 12 +- include/fintamath/core/Parser.hpp | 119 +++---- include/fintamath/expressions/Expression.hpp | 47 ++- .../fintamath/expressions/ExpressionUtils.hpp | 12 +- include/fintamath/expressions/IExpression.hpp | 20 +- .../interfaces/IBinaryExpression.hpp | 8 +- .../interfaces/IPolynomExpression.hpp | 8 +- .../interfaces/IUnaryExpression.hpp | 8 +- .../fintamath/functions/FunctionArguments.hpp | 4 +- include/fintamath/functions/IFunction.hpp | 44 +-- include/fintamath/functions/IFunctionCRTP.hpp | 13 +- include/fintamath/functions/IOperator.hpp | 35 +- .../fintamath/functions/arithmetic/Abs.hpp | 8 +- .../fintamath/functions/arithmetic/Add.hpp | 8 +- .../fintamath/functions/arithmetic/Div.hpp | 8 +- .../fintamath/functions/arithmetic/Frac.hpp | 8 +- .../functions/arithmetic/FracMixed.hpp | 8 +- .../fintamath/functions/arithmetic/Mul.hpp | 8 +- .../fintamath/functions/arithmetic/Neg.hpp | 8 +- .../fintamath/functions/arithmetic/Sign.hpp | 8 +- .../fintamath/functions/arithmetic/Sub.hpp | 8 +- .../functions/arithmetic/UnaryPlus.hpp | 8 +- .../functions/calculus/Derivative.hpp | 8 +- .../fintamath/functions/calculus/Integral.hpp | 8 +- include/fintamath/functions/calculus/Max.hpp | 8 +- include/fintamath/functions/calculus/Min.hpp | 8 +- .../fintamath/functions/comparison/Eqv.hpp | 8 +- .../fintamath/functions/comparison/Less.hpp | 8 +- .../functions/comparison/LessEqv.hpp | 8 +- .../fintamath/functions/comparison/More.hpp | 8 +- .../functions/comparison/MoreEqv.hpp | 8 +- .../fintamath/functions/comparison/Neqv.hpp | 8 +- .../fintamath/functions/hyperbolic/Acosh.hpp | 8 +- .../fintamath/functions/hyperbolic/Acoth.hpp | 8 +- .../fintamath/functions/hyperbolic/Acsch.hpp | 8 +- .../fintamath/functions/hyperbolic/Asech.hpp | 8 +- .../fintamath/functions/hyperbolic/Asinh.hpp | 8 +- .../fintamath/functions/hyperbolic/Atanh.hpp | 8 +- .../fintamath/functions/hyperbolic/Cosh.hpp | 8 +- .../fintamath/functions/hyperbolic/Coth.hpp | 8 +- .../fintamath/functions/hyperbolic/Csch.hpp | 8 +- .../fintamath/functions/hyperbolic/Sech.hpp | 8 +- .../fintamath/functions/hyperbolic/Sinh.hpp | 8 +- .../fintamath/functions/hyperbolic/Tanh.hpp | 8 +- include/fintamath/functions/logarithms/Lb.hpp | 8 +- include/fintamath/functions/logarithms/Lg.hpp | 8 +- include/fintamath/functions/logarithms/Ln.hpp | 8 +- .../fintamath/functions/logarithms/Log.hpp | 8 +- include/fintamath/functions/logic/And.hpp | 8 +- include/fintamath/functions/logic/Equiv.hpp | 8 +- include/fintamath/functions/logic/Impl.hpp | 8 +- include/fintamath/functions/logic/Nequiv.hpp | 8 +- include/fintamath/functions/logic/Not.hpp | 8 +- include/fintamath/functions/logic/Or.hpp | 8 +- include/fintamath/functions/ntheory/Ceil.hpp | 8 +- include/fintamath/functions/ntheory/Floor.hpp | 8 +- include/fintamath/functions/ntheory/Mod.hpp | 8 +- include/fintamath/functions/other/Comma.hpp | 8 +- include/fintamath/functions/other/Deg.hpp | 8 +- .../fintamath/functions/other/Factorial.hpp | 8 +- include/fintamath/functions/other/Index.hpp | 8 +- include/fintamath/functions/other/Percent.hpp | 8 +- include/fintamath/functions/powers/Exp.hpp | 8 +- include/fintamath/functions/powers/Pow.hpp | 8 +- .../functions/powers/PowFunction.hpp | 8 +- include/fintamath/functions/powers/Root.hpp | 8 +- include/fintamath/functions/powers/Sqr.hpp | 8 +- include/fintamath/functions/powers/Sqrt.hpp | 8 +- .../fintamath/functions/trigonometry/Acos.hpp | 8 +- .../fintamath/functions/trigonometry/Acot.hpp | 8 +- .../fintamath/functions/trigonometry/Acsc.hpp | 8 +- .../fintamath/functions/trigonometry/Asec.hpp | 8 +- .../fintamath/functions/trigonometry/Asin.hpp | 8 +- .../fintamath/functions/trigonometry/Atan.hpp | 8 +- .../fintamath/functions/trigonometry/Cos.hpp | 8 +- .../fintamath/functions/trigonometry/Cot.hpp | 8 +- .../fintamath/functions/trigonometry/Csc.hpp | 8 +- .../fintamath/functions/trigonometry/Sec.hpp | 8 +- .../fintamath/functions/trigonometry/Sin.hpp | 8 +- .../fintamath/functions/trigonometry/Tan.hpp | 8 +- include/fintamath/literals/Boolean.hpp | 8 +- include/fintamath/literals/ILiteral.hpp | 26 +- include/fintamath/literals/Variable.hpp | 8 +- .../literals/constants/ComplexInf.hpp | 8 +- include/fintamath/literals/constants/E.hpp | 8 +- .../fintamath/literals/constants/False.hpp | 8 +- include/fintamath/literals/constants/I.hpp | 8 +- .../literals/constants/IConstant.hpp | 22 +- .../literals/constants/IConstantCRTP.hpp | 4 +- include/fintamath/literals/constants/Inf.hpp | 8 +- .../fintamath/literals/constants/NegInf.hpp | 8 +- include/fintamath/literals/constants/Pi.hpp | 8 +- include/fintamath/literals/constants/True.hpp | 8 +- .../literals/constants/Undefined.hpp | 8 +- include/fintamath/numbers/Complex.hpp | 12 +- include/fintamath/numbers/IInteger.hpp | 22 +- include/fintamath/numbers/INumber.hpp | 26 +- include/fintamath/numbers/Integer.hpp | 8 +- include/fintamath/numbers/Rational.hpp | 8 +- include/fintamath/numbers/Real.hpp | 8 +- src/fintamath/config/Config.cpp | 4 +- src/fintamath/config/ExpressionConfig.cpp | 178 ++++------ .../{ParserConfig.cpp => TypeConfig.cpp} | 74 ++++- .../{ParserConfig.hpp => TypeConfig.hpp} | 4 +- src/fintamath/core/IArithmetic.cpp | 5 +- src/fintamath/core/IComparable.cpp | 5 +- src/fintamath/core/IMathObject.cpp | 5 +- src/fintamath/core/MathObjectClass.cpp | 52 +++ src/fintamath/core/Tokenizer.cpp | 2 +- src/fintamath/expressions/Expression.cpp | 116 ++++--- .../expressions/ExpressionComparator.cpp | 8 +- src/fintamath/expressions/ExpressionUtils.cpp | 4 +- .../expressions/FunctionExpression.cpp | 4 +- .../expressions/FunctionExpression.hpp | 8 +- src/fintamath/expressions/IExpression.cpp | 11 +- src/fintamath/expressions/binary/CompExpr.cpp | 2 +- src/fintamath/expressions/binary/CompExpr.hpp | 8 +- .../expressions/binary/DerivativeExpr.cpp | 2 +- .../expressions/binary/DerivativeExpr.hpp | 8 +- src/fintamath/expressions/binary/DivExpr.cpp | 2 +- src/fintamath/expressions/binary/DivExpr.hpp | 8 +- .../expressions/binary/IntegralExpr.hpp | 8 +- src/fintamath/expressions/binary/LogExpr.cpp | 2 +- src/fintamath/expressions/binary/LogExpr.hpp | 8 +- src/fintamath/expressions/binary/PowExpr.cpp | 2 +- src/fintamath/expressions/binary/PowExpr.hpp | 8 +- .../functions/ExpressionFunctionSolve.cpp | 2 +- .../interfaces/IBinaryExpression.cpp | 4 +- .../interfaces/IPolynomExpression.cpp | 4 +- .../interfaces/IUnaryExpression.cpp | 4 +- .../expressions/polynomial/AddExpr.cpp | 2 +- .../expressions/polynomial/AddExpr.hpp | 8 +- .../expressions/polynomial/AndExpr.cpp | 2 +- .../expressions/polynomial/AndExpr.hpp | 8 +- .../expressions/polynomial/MinMaxExpr.hpp | 8 +- .../expressions/polynomial/MulExpr.cpp | 2 +- .../expressions/polynomial/MulExpr.hpp | 8 +- .../expressions/polynomial/OrExpr.cpp | 2 +- .../expressions/polynomial/OrExpr.hpp | 8 +- src/fintamath/expressions/unary/AbsExpr.hpp | 8 +- .../expressions/unary/FloorCeilExpr.cpp | 2 +- .../expressions/unary/FloorCeilExpr.hpp | 8 +- .../expressions/unary/HyperbExpr.cpp | 2 +- .../expressions/unary/HyperbExpr.hpp | 8 +- .../expressions/unary/InvHyperbExpr.hpp | 8 +- .../expressions/unary/InvTrigExpr.cpp | 2 +- .../expressions/unary/InvTrigExpr.hpp | 8 +- src/fintamath/expressions/unary/NotExpr.cpp | 2 +- src/fintamath/expressions/unary/NotExpr.hpp | 8 +- src/fintamath/expressions/unary/SignExpr.cpp | 2 +- src/fintamath/expressions/unary/SignExpr.hpp | 8 +- src/fintamath/expressions/unary/TrigExpr.cpp | 2 +- src/fintamath/expressions/unary/TrigExpr.hpp | 8 +- src/fintamath/functions/IFunction.cpp | 18 +- src/fintamath/functions/IOperator.cpp | 5 +- src/fintamath/functions/arithmetic/Abs.cpp | 2 +- src/fintamath/functions/arithmetic/Add.cpp | 2 +- src/fintamath/functions/arithmetic/Div.cpp | 2 +- .../functions/arithmetic/FracMixed.cpp | 2 +- src/fintamath/functions/arithmetic/Mul.cpp | 2 +- src/fintamath/functions/arithmetic/Neg.cpp | 2 +- src/fintamath/functions/arithmetic/Sign.cpp | 2 +- src/fintamath/functions/arithmetic/Sub.cpp | 2 +- .../functions/arithmetic/UnaryPlus.cpp | 2 +- src/fintamath/functions/calculus/Max.cpp | 2 +- src/fintamath/functions/calculus/Min.cpp | 2 +- src/fintamath/functions/comparison/Less.cpp | 2 +- .../functions/comparison/LessEqv.cpp | 2 +- src/fintamath/functions/comparison/More.cpp | 2 +- .../functions/comparison/MoreEqv.cpp | 2 +- src/fintamath/functions/hyperbolic/Acosh.cpp | 2 +- src/fintamath/functions/hyperbolic/Acoth.cpp | 2 +- src/fintamath/functions/hyperbolic/Acsch.cpp | 2 +- src/fintamath/functions/hyperbolic/Asech.cpp | 2 +- src/fintamath/functions/hyperbolic/Asinh.cpp | 2 +- src/fintamath/functions/hyperbolic/Atanh.cpp | 2 +- src/fintamath/functions/hyperbolic/Cosh.cpp | 2 +- src/fintamath/functions/hyperbolic/Coth.cpp | 2 +- src/fintamath/functions/hyperbolic/Csch.cpp | 2 +- src/fintamath/functions/hyperbolic/Sech.cpp | 2 +- src/fintamath/functions/hyperbolic/Sinh.cpp | 2 +- src/fintamath/functions/hyperbolic/Tanh.cpp | 2 +- src/fintamath/functions/logarithms/Ln.cpp | 2 +- src/fintamath/functions/logarithms/Log.cpp | 2 +- src/fintamath/functions/logic/And.cpp | 2 +- src/fintamath/functions/logic/Equiv.cpp | 2 +- src/fintamath/functions/logic/Impl.cpp | 2 +- src/fintamath/functions/logic/Nequiv.cpp | 2 +- src/fintamath/functions/logic/Not.cpp | 2 +- src/fintamath/functions/logic/Or.cpp | 2 +- src/fintamath/functions/ntheory/Ceil.cpp | 2 +- src/fintamath/functions/ntheory/Floor.cpp | 2 +- src/fintamath/functions/ntheory/Mod.cpp | 2 +- src/fintamath/functions/other/Factorial.cpp | 2 +- src/fintamath/functions/other/Index.cpp | 2 +- src/fintamath/functions/other/Percent.cpp | 2 +- src/fintamath/functions/powers/Pow.cpp | 2 +- src/fintamath/functions/powers/Root.cpp | 2 +- src/fintamath/functions/trigonometry/Acos.cpp | 2 +- src/fintamath/functions/trigonometry/Acot.cpp | 2 +- src/fintamath/functions/trigonometry/Acsc.cpp | 2 +- src/fintamath/functions/trigonometry/Asec.cpp | 2 +- src/fintamath/functions/trigonometry/Asin.cpp | 2 +- src/fintamath/functions/trigonometry/Atan.cpp | 2 +- src/fintamath/functions/trigonometry/Cos.cpp | 2 +- src/fintamath/functions/trigonometry/Cot.cpp | 2 +- src/fintamath/functions/trigonometry/Csc.cpp | 2 +- src/fintamath/functions/trigonometry/Sec.cpp | 2 +- src/fintamath/functions/trigonometry/Sin.cpp | 2 +- src/fintamath/functions/trigonometry/Tan.cpp | 2 +- src/fintamath/literals/ILiteral.cpp | 5 +- .../literals/constants/IConstant.cpp | 5 +- src/fintamath/numbers/Complex.cpp | 20 +- src/fintamath/numbers/IInteger.cpp | 5 +- src/fintamath/numbers/INumber.cpp | 5 +- src/fintamath/numbers/NumberAbstract.cpp | 2 +- tests/src/core/CacheTests.cpp | 2 +- tests/src/core/CoreUtilsTests.cpp | 6 +- tests/src/core/IArithmeticTests.cpp | 20 +- tests/src/core/IComparableTests.cpp | 21 +- tests/src/core/IMathObjectTests.cpp | 23 +- tests/src/core/MathObjectBoundTypesTests.cpp | 52 --- tests/src/core/MathObjectClassTests.cpp | 132 ++++++++ tests/src/core/MathObjectTypeTests.cpp | 60 ---- tests/src/core/ParseTests.cpp | 295 ----------------- tests/src/core/ParserTests.cpp | 55 +++- tests/src/expressions/ExpressionTests.cpp | 6 +- .../expressions/FunctionExpressionTests.cpp | 81 ++--- tests/src/expressions/IExpressionTests.cpp | 20 +- .../src/expressions/binary/CompExprTests.cpp | 8 +- .../binary/DerivativeExprTests.cpp | 8 +- tests/src/expressions/binary/DivExprTests.cpp | 8 +- .../expressions/binary/IntegralExprTests.cpp | 8 +- tests/src/expressions/binary/LogExprTests.cpp | 8 +- tests/src/expressions/binary/PowExprTests.cpp | 8 +- .../interfaces/IBinaryExpressionTests.cpp | 20 +- .../interfaces/IPolynomExpressionTests.cpp | 20 +- .../interfaces/IUnaryExpressionTests.cpp | 20 +- .../expressions/polynomial/AddExprTests.cpp | 8 +- .../expressions/polynomial/AndExprTests.cpp | 8 +- .../polynomial/MinMaxExprTests.cpp | 8 +- .../expressions/polynomial/MulExprTests.cpp | 8 +- .../expressions/polynomial/OrExprTests.cpp | 8 +- tests/src/expressions/unary/AbsExprTests.cpp | 5 +- .../expressions/unary/FloorCeilExprTests.cpp | 8 +- .../src/expressions/unary/HyperbExprTests.cpp | 8 +- .../expressions/unary/InvHyperbExprTests.cpp | 8 +- .../expressions/unary/InvTrigExprTests.cpp | 8 +- tests/src/expressions/unary/NotExprTests.cpp | 8 +- tests/src/expressions/unary/SignExprTests.cpp | 8 +- tests/src/expressions/unary/TrigExprTests.cpp | 9 +- tests/src/functions/IFunctionTests.cpp | 45 ++- tests/src/functions/IOperatorTests.cpp | 32 +- tests/src/functions/arithmetic/AbsTests.cpp | 14 +- tests/src/functions/arithmetic/AddTests.cpp | 14 +- tests/src/functions/arithmetic/DivTests.cpp | 14 +- .../functions/arithmetic/FracMixedTests.cpp | 14 +- tests/src/functions/arithmetic/FracTests.cpp | 14 +- tests/src/functions/arithmetic/MulTests.cpp | 14 +- tests/src/functions/arithmetic/NegTests.cpp | 14 +- tests/src/functions/arithmetic/SignTests.cpp | 14 +- tests/src/functions/arithmetic/SubTests.cpp | 14 +- .../functions/arithmetic/UnaryPlusTests.cpp | 14 +- .../functions/calculus/DerivativeTests.cpp | 43 +-- .../src/functions/calculus/IntegralTests.cpp | 14 +- tests/src/functions/calculus/MaxTests.cpp | 14 +- tests/src/functions/calculus/MinTests.cpp | 14 +- tests/src/functions/comparison/EqvTests.cpp | 14 +- .../src/functions/comparison/LessEqvTests.cpp | 14 +- tests/src/functions/comparison/LessTests.cpp | 14 +- .../src/functions/comparison/MoreEqvTests.cpp | 14 +- tests/src/functions/comparison/MoreTests.cpp | 14 +- tests/src/functions/comparison/NeqvTests.cpp | 14 +- tests/src/functions/hyperbolic/AcoshTests.cpp | 14 +- tests/src/functions/hyperbolic/AcothTests.cpp | 14 +- tests/src/functions/hyperbolic/AcschTests.cpp | 14 +- tests/src/functions/hyperbolic/AsechTests.cpp | 14 +- tests/src/functions/hyperbolic/AsinhTests.cpp | 14 +- tests/src/functions/hyperbolic/AtanhTests.cpp | 14 +- tests/src/functions/hyperbolic/CoshTests.cpp | 14 +- tests/src/functions/hyperbolic/CothTests.cpp | 14 +- tests/src/functions/hyperbolic/CschTests.cpp | 14 +- tests/src/functions/hyperbolic/SechTests.cpp | 14 +- tests/src/functions/hyperbolic/SinhTests.cpp | 14 +- tests/src/functions/hyperbolic/TanhTests.cpp | 14 +- tests/src/functions/logarithms/LbTests.cpp | 14 +- tests/src/functions/logarithms/LgTests.cpp | 14 +- tests/src/functions/logarithms/LnTests.cpp | 14 +- tests/src/functions/logarithms/LogTests.cpp | 14 +- tests/src/functions/logic/AndTests.cpp | 14 +- tests/src/functions/logic/EquivTests.cpp | 14 +- tests/src/functions/logic/ImplTests.cpp | 14 +- tests/src/functions/logic/NequivTests.cpp | 14 +- tests/src/functions/logic/NotTests.cpp | 14 +- tests/src/functions/logic/OrTests.cpp | 14 +- tests/src/functions/ntheory/CeilTests.cpp | 14 +- tests/src/functions/ntheory/FloorTests.cpp | 14 +- tests/src/functions/ntheory/ModTests.cpp | 14 +- tests/src/functions/other/CommaTests.cpp | 14 +- tests/src/functions/other/DegTests.cpp | 14 +- tests/src/functions/other/FactorialTests.cpp | 14 +- tests/src/functions/other/IndexTests.cpp | 14 +- tests/src/functions/other/PercentTests.cpp | 14 +- tests/src/functions/powers/ExpTests.cpp | 14 +- .../src/functions/powers/PowFunctionTests.cpp | 14 +- tests/src/functions/powers/PowTests.cpp | 14 +- tests/src/functions/powers/RootTests.cpp | 14 +- tests/src/functions/powers/SqrTests.cpp | 14 +- tests/src/functions/powers/SqrtTests.cpp | 14 +- .../src/functions/trigonometry/AcosTests.cpp | 14 +- .../src/functions/trigonometry/AcotTests.cpp | 14 +- .../src/functions/trigonometry/AcscTests.cpp | 14 +- .../src/functions/trigonometry/AsecTests.cpp | 14 +- .../src/functions/trigonometry/AsinTests.cpp | 14 +- .../src/functions/trigonometry/AtanTests.cpp | 14 +- tests/src/functions/trigonometry/CosTests.cpp | 14 +- tests/src/functions/trigonometry/CotTests.cpp | 14 +- tests/src/functions/trigonometry/CscTests.cpp | 14 +- tests/src/functions/trigonometry/SecTests.cpp | 14 +- tests/src/functions/trigonometry/SinTests.cpp | 14 +- tests/src/functions/trigonometry/TanTests.cpp | 14 +- tests/src/literals/BooleanTests.cpp | 6 +- tests/src/literals/ILiteralTests.cpp | 21 +- tests/src/literals/VariableTests.cpp | 6 +- .../literals/constants/ComplexInfTests.cpp | 6 +- tests/src/literals/constants/ETests.cpp | 6 +- tests/src/literals/constants/FalseTests.cpp | 6 +- .../src/literals/constants/IConstantTests.cpp | 26 +- tests/src/literals/constants/ITests.cpp | 6 +- tests/src/literals/constants/InfTests.cpp | 6 +- tests/src/literals/constants/NegInfTests.cpp | 6 +- tests/src/literals/constants/PiTests.cpp | 6 +- tests/src/literals/constants/TrueTests.cpp | 6 +- .../src/literals/constants/UndefinedTests.cpp | 6 +- tests/src/numbers/ComplexTests.cpp | 6 +- tests/src/numbers/IIntegerTests.cpp | 66 ++-- tests/src/numbers/INumberTests.cpp | 47 ++- tests/src/numbers/IntegerTests.cpp | 306 ++---------------- tests/src/numbers/RationalTests.cpp | 6 +- tests/src/numbers/RealTests.cpp | 6 +- thirdparty/CMakeLists.txt | 35 +- thirdparty/cppcoro | 1 + 354 files changed, 2219 insertions(+), 2874 deletions(-) create mode 100644 include/fintamath/core/MathObjectBody.hpp delete mode 100644 include/fintamath/core/MathObjectBoundTypes.hpp create mode 100644 include/fintamath/core/MathObjectClass.hpp delete mode 100644 include/fintamath/core/MathObjectType.hpp rename include/fintamath/core/{CoreUtils.hpp => MathObjectUtils.hpp} (93%) rename src/fintamath/config/{ParserConfig.cpp => TypeConfig.cpp} (72%) rename src/fintamath/config/{ParserConfig.hpp => TypeConfig.hpp} (52%) create mode 100644 src/fintamath/core/MathObjectClass.cpp delete mode 100644 tests/src/core/MathObjectBoundTypesTests.cpp create mode 100644 tests/src/core/MathObjectClassTests.cpp delete mode 100644 tests/src/core/MathObjectTypeTests.cpp delete mode 100644 tests/src/core/ParseTests.cpp create mode 160000 thirdparty/cppcoro diff --git a/.gitmodules b/.gitmodules index a459312cb..09f0a67e4 100644 --- a/.gitmodules +++ b/.gitmodules @@ -25,3 +25,6 @@ [submodule "thirdparty/fmt"] path = thirdparty/fmt url = https://github.com/fmtlib/fmt +[submodule "thirdparty/cppcoro"] + path = thirdparty/cppcoro + url = https://github.com/andreasbuhr/cppcoro diff --git a/CMakeLists.txt b/CMakeLists.txt index 29cf97159..156ea435d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -51,7 +51,8 @@ target_link_libraries( Boost::multiprecision Boost::math Boost::container_hash - fmt::fmt) + fmt::fmt + cppcoro) include(cmake/CompilerWarnings.cmake) include(cmake/Coverage.cmake) diff --git a/cmake/Coverage.cmake b/cmake/Coverage.cmake index b962d7791..86852a75e 100644 --- a/cmake/Coverage.cmake +++ b/cmake/Coverage.cmake @@ -3,16 +3,16 @@ if(CMAKE_CXX_COMPILER_ID MATCHES ".*Clang") option(${PROJECT_NAME}_enable_coverage "Enable coverage reporting for gcc/clang" OFF) if(${PROJECT_NAME}_enable_coverage) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-instr-generate -fcoverage-mapping -O0 -g") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-instr-generate -fcoverage-mapping -O0") add_custom_target( ${PROJECT_NAME}_coverage COMMAND ./bin/fintamath_tests COMMAND llvm-profdata merge -o merged.profdata *.profraw - COMMAND llvm-cov show --show-branches=count --ignore-filename-regex='tests|build|thirdparty|MathObjectType.hpp' - --show-instantiations --instr-profile merged.profdata bin/fintamath_tests > coverage.txt - COMMAND llvm-cov export --ignore-filename-regex='tests|build|thirdparty|MathObjectType.hpp' --instr-profile - merged.profdata bin/fintamath_tests -format lcov > lcov.info + COMMAND llvm-cov show --show-branches=count --ignore-filename-regex='tests|build|thirdparty' --instr-profile + merged.profdata bin/fintamath_tests > coverage.txt + COMMAND llvm-cov export --ignore-filename-regex='tests|build|thirdparty' --instr-profile merged.profdata + bin/fintamath_tests -format lcov > lcov.info COMMAND genhtml --branch-coverage lcov.info -o coverage DEPENDS ${PROJECT_NAME}_tests WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) diff --git a/include/fintamath/core/IArithmetic.hpp b/include/fintamath/core/IArithmetic.hpp index 55f9b77cc..e531d13e3 100644 --- a/include/fintamath/core/IArithmetic.hpp +++ b/include/fintamath/core/IArithmetic.hpp @@ -5,15 +5,15 @@ #include #include -#include "fintamath/core/CoreUtils.hpp" #include "fintamath/core/IMathObject.hpp" -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.hpp" +#include "fintamath/core/MathObjectUtils.hpp" #include "fintamath/core/Parser.hpp" namespace fintamath { class IArithmetic : public IMathObject { - using ArithmeticParser = detail::Parser()>; + FINTAMATH_PARENT_CLASS_BODY(IArithmetic) public: friend std::unique_ptr operator+(const IArithmetic &lhs, const IArithmetic &rhs) { @@ -40,23 +40,6 @@ class IArithmetic : public IMathObject { return rhs.negateAbstract(); } - static std::unique_ptr parse(const std::string &str) { - return getParser().parse(str); - } - - template T> - static void registerType() { - getParser().registerType(); - } - - static void registerType(ArithmeticParser::StringConstructor constructor) { - getParser().registerType(std::move(constructor)); - } - - static constexpr MathObjectType getTypeStatic() { - return {MathObjectType::IArithmetic, "IArithmetic"}; - } - protected: virtual std::unique_ptr addAbstract(const IArithmetic &rhs) const = 0; @@ -67,9 +50,6 @@ class IArithmetic : public IMathObject { virtual std::unique_ptr divideAbstract(const IArithmetic &rhs) const = 0; virtual std::unique_ptr negateAbstract() const = 0; - -private: - static ArithmeticParser &getParser(); }; template diff --git a/include/fintamath/core/IComparable.hpp b/include/fintamath/core/IComparable.hpp index dd07bb1b2..b8ed7be85 100644 --- a/include/fintamath/core/IComparable.hpp +++ b/include/fintamath/core/IComparable.hpp @@ -6,38 +6,23 @@ #include #include -#include "fintamath/core/CoreUtils.hpp" #include "fintamath/core/IArithmetic.hpp" -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.hpp" +#include "fintamath/core/MathObjectUtils.hpp" #include "fintamath/core/Parser.hpp" namespace fintamath { class IComparable : public IArithmetic { - using ComparableParser = detail::Parser()>; + FINTAMATH_PARENT_CLASS_BODY(IComparable) public: friend std::strong_ordering operator<=>(const IComparable &lhs, const IComparable &rhs) { return lhs.compareAbstract(rhs); } - static std::unique_ptr parse(const std::string &str) { - return getParser().parse(str); - } - - static void registerType(ComparableParser::StringConstructor constructor) { - getParser().registerType(std::move(constructor)); - } - - static constexpr MathObjectType getTypeStatic() { - return {MathObjectType::IComparable, "IComparable"}; - } - protected: virtual std::strong_ordering compareAbstract(const IComparable &rhs) const = 0; - -private: - static ComparableParser &getParser(); }; template diff --git a/include/fintamath/core/IMathObject.hpp b/include/fintamath/core/IMathObject.hpp index 6a252df34..1d225c889 100644 --- a/include/fintamath/core/IMathObject.hpp +++ b/include/fintamath/core/IMathObject.hpp @@ -7,14 +7,15 @@ #include #include "fintamath/core/Converter.hpp" -#include "fintamath/core/CoreUtils.hpp" -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectBody.hpp" +#include "fintamath/core/MathObjectClass.hpp" +#include "fintamath/core/MathObjectUtils.hpp" #include "fintamath/core/Parser.hpp" namespace fintamath { class IMathObject { - using MathObjectParser = detail::Parser()>; + FINTAMATH_PARENT_CLASS_BODY(IMathObject) public: virtual ~IMathObject() = default; @@ -24,36 +25,21 @@ class IMathObject { virtual std::unique_ptr clone() && = 0; virtual std::string toString() const { - return std::string(getType().getName()); + return std::string(getClass().getName()); } virtual std::unique_ptr toMinimalObject() const { return clone(); } - virtual MathObjectType getType() const = 0; + virtual MathObjectClass getClass() const = 0; friend bool operator==(const IMathObject &lhs, const IMathObject &rhs) { return lhs.equalsAbstract(rhs); } - static std::unique_ptr parse(const std::string &str) { - return getParser().parse(str); - } - - static void registerType(MathObjectParser::StringConstructor constructor) { - getParser().registerType(std::move(constructor)); - } - - static constexpr MathObjectType getTypeStatic() { - return {MathObjectType::IMathObject, "IMathObject"}; - } - protected: virtual bool equalsAbstract(const IMathObject &rhs) const = 0; - -private: - static MathObjectParser &getParser(); }; template diff --git a/include/fintamath/core/IMathObjectCRTP.hpp b/include/fintamath/core/IMathObjectCRTP.hpp index 96efa505c..e7b386f83 100644 --- a/include/fintamath/core/IMathObjectCRTP.hpp +++ b/include/fintamath/core/IMathObjectCRTP.hpp @@ -22,8 +22,8 @@ class IMathObjectCRTP_ : public IMathObject { return equals(cast(rhs)); } - MathObjectType getType() const override { - return Derived::getTypeStatic(); + MathObjectClass getClass() const override { + return Derived::getClassStatic(); } protected: diff --git a/include/fintamath/core/MathObjectBody.hpp b/include/fintamath/core/MathObjectBody.hpp new file mode 100644 index 000000000..80b4ad729 --- /dev/null +++ b/include/fintamath/core/MathObjectBody.hpp @@ -0,0 +1,46 @@ +#pragma once + +#include + +#include "fintamath/core/MathObjectClass.hpp" +#include "fintamath/core/Parser.hpp" + +#define FINTAMATH_CLASS_BODY(Class) \ +public: \ + static constexpr MathObjectClass getClassStatic() { \ + return {#Class}; \ + } \ + \ +private: + +#define FINTAMATH_PARENT_CLASS_BODY(Class) \ + FINTAMATH_CLASS_BODY(Class) \ + \ +private: \ + using Class##Parser = detail::Parser>; \ + \ + static Class##Parser &getParser(); \ + \ +public: \ + template String> \ + static auto parse(String &&str) { \ + return getParser().parse(std::forward(str)); \ + } \ + \ + static auto parseFirst(const std::string &str) { \ + return getParser().parseFirst(str); \ + } \ + \ + template T> \ + static void registerType() { \ + MathObjectClass::bindTypes(); \ + getParser().registerType(); \ + } \ + \ +private: + +#define FINTAMATH_PARENT_CLASS_IMPLEMENTATION(Class) \ + Class::Class##Parser &Class::getParser() { \ + static Class##Parser parser; \ + return parser; \ + } diff --git a/include/fintamath/core/MathObjectBoundTypes.hpp b/include/fintamath/core/MathObjectBoundTypes.hpp deleted file mode 100644 index 3e17ba8de..000000000 --- a/include/fintamath/core/MathObjectBoundTypes.hpp +++ /dev/null @@ -1,63 +0,0 @@ -#pragma once - -#include - -#include "fintamath/core/MathObjectType.hpp" - -namespace fintamath { - -bool isBaseOf(const MathObjectType &toType, const MathObjectType &fromType); - -namespace detail { - -class MathObjectBoundTypes final { - using enum MathObjectType::Id; - - using TypeIdToBoundTypeIdMap = std::unordered_map; - - static TypeIdToBoundTypeIdMap &getMap() { - static TypeIdToBoundTypeIdMap typeIdToBoundTypeIdMap{ - makeTypeIdPair(IMathObject, None), - makeTypeIdPair(IArithmetic, ILiteral), - makeTypeIdPair(IArithmetic, ILiteral), - makeTypeIdPair(IExpression, IComparable), - makeTypeIdPair(IUnaryExpression, IBinaryExpression), - makeTypeIdPair(IBinaryExpression, IPolynomExpression), - makeTypeIdPair(IPolynomExpression, IComparable), - makeTypeIdPair(IComparable, ILiteral), - makeTypeIdPair(INumber, ILiteral), - makeTypeIdPair(IInteger, ILiteral), - makeTypeIdPair(ILiteral, IFunction), - makeTypeIdPair(IConstant, IFunction), - makeTypeIdPair(IFunction, None), - makeTypeIdPair(IOperator, None), - }; - return typeIdToBoundTypeIdMap; - } - -public: - static void bindTypes(const MathObjectType &type, const MathObjectType &boundType) { - getMap().emplace(type.getId(), boundType.getId()); - } - - friend bool fintamath::isBaseOf(const MathObjectType &toType, const MathObjectType &fromType); - -private: - static std::pair makeTypeIdPair(const MathObjectType::Id lhs, const MathObjectType::Id rhs) { - return {static_cast(lhs), static_cast(rhs)}; - } -}; - -} - -inline bool isBaseOf(const MathObjectType &toType, const MathObjectType &fromType) { - const auto &map = detail::MathObjectBoundTypes::getMap(); - - if (const auto boundaries = map.find(toType.getId()); boundaries != map.end()) { - return fromType.getId() >= boundaries->first && fromType.getId() < boundaries->second; - } - - return toType == fromType; -} - -} diff --git a/include/fintamath/core/MathObjectClass.hpp b/include/fintamath/core/MathObjectClass.hpp new file mode 100644 index 000000000..eb834a108 --- /dev/null +++ b/include/fintamath/core/MathObjectClass.hpp @@ -0,0 +1,107 @@ +#pragma once + +#include +#include +#include +#include +#include + +#include + +#include "fintamath/config/Config.hpp" + +namespace fintamath { + +class MathObjectClass; + +size_t hash_value(MathObjectClass rhs) noexcept; + +} + +template <> +struct std::hash { + size_t operator()(const fintamath::MathObjectClass &rhs) const noexcept { + return boost::hash{}(rhs); + } +}; + +namespace fintamath { + +class MathObjectClass final { +public: + using Name = std::string_view; + + using Id = size_t; + + using Children = std::unordered_set; + +private: + using ClassToIdMap = std::unordered_map; + + using ChildToParentMap = std::unordered_map; + + using ParentToChildrenMap = std::unordered_map; + +public: + constexpr MathObjectClass(const Name inName) : name(inName) { + } + + constexpr Name getName() const { + return name; + } + + constexpr bool operator==(const MathObjectClass rhs) const { + return getName() == rhs.getName(); + } + + std::strong_ordering operator<=>(MathObjectClass rhs) const; + + std::optional getParent() const; + + const Children &getChildren(bool recursive = false) const; + + template Child> + static void bindTypes(); + +private: + Id getId() const; + + static ClassToIdMap &getClassToIdMap(); + + static ChildToParentMap &getChildToParentMap(); + + static ParentToChildrenMap &getParentToChildrenMap(); + + static ParentToChildrenMap &getParentToRecursiveChildrenMap(); + +private: + Name name; + + inline static Id maxId = 0; + + [[maybe_unused]] inline static const detail::Config config; +}; + +template Child> +void MathObjectClass::bindTypes() { + MathObjectClass parent = Parent::getClassStatic(); + MathObjectClass child = Child::getClassStatic(); + + getClassToIdMap()[parent] = ++maxId; + getClassToIdMap()[child] = ++maxId; + + getChildToParentMap().insert_or_assign(child, parent); + getParentToChildrenMap()[parent].emplace(child); + + for (std::optional superParent = child.getParent(); superParent; superParent = superParent->getParent()) { + Children &superParentChildren = getParentToRecursiveChildrenMap()[*superParent]; + superParentChildren.emplace(child); + superParentChildren.insert(child.getChildren().begin(), child.getChildren().end()); + } +} + +inline size_t hash_value(const MathObjectClass rhs) noexcept { + return boost::hash{}(rhs.getName()); +} + +} diff --git a/include/fintamath/core/MathObjectType.hpp b/include/fintamath/core/MathObjectType.hpp deleted file mode 100644 index 7b297e62d..000000000 --- a/include/fintamath/core/MathObjectType.hpp +++ /dev/null @@ -1,197 +0,0 @@ -#pragma once - -#include -#include -#include -#include - -#include "fintamath/config/Config.hpp" - -namespace fintamath { - -struct MathObjectType final { - enum class Id : size_t { - IMathObject = 0, - - IArithmetic = 1000, - - IExpression = 2000, - - Expression, - FunctionExpression, - - IUnaryExpression = 3000, - - NotExpr, - TrigExpr, - InvTrigExpr, - HyperbExpr, - InvHyperbExpr, - FloorCeilExpr, - AbsExpr, - SignExpr, - - IBinaryExpression = 4000, - - PowExpr, - DivExpr, - LogExpr, - CompExpr, - DerivativeExpr, - IntegralExpr, - - IPolynomExpression = 5000, - - AddExpr, - MulExpr, - AndExpr, - OrExpr, - MinMaxExpr, - - IComparable = 6000, - - INumber = 7000, - - Rational, - Real, - Complex, - - IInteger = 8000, - - Integer, - - ILiteral = 9000, - - Boolean, - Variable, - - IConstant = 10000, - - E, - Pi, - True, - False, - Inf, - NegInf, - ComplexInf, - Undefined, - I, - - IFunction = 11000, - - Abs, - Log, - Ln, - Lb, - Lg, - Exp, - Sqr, - Sqrt, - Root, - Sin, - Cos, - Tan, - Cot, - Sec, - Csc, - Asin, - Acos, - Atan, - Acot, - Asec, - Acsc, - Sign, - Sinh, - Cosh, - Tanh, - Coth, - Sech, - Csch, - Asinh, - Acosh, - Atanh, - Acoth, - Asech, - Acsch, - Min, - Max, - Derivative, - Integral, - Frac, - FracMixed, - PowFunction, - Floor, - Ceil, - - IOperator = 12000, - - Add, - Sub, - Mul, - Div, - Neg, - UnaryPlus, - Factorial, - Percent, - Pow, - Eqv, - Neqv, - Less, - More, - LessEqv, - MoreEqv, - Not, - And, - Or, - Impl, - Equiv, - Nequiv, - Index, - Deg, - Comma, - Mod, - - None = std::numeric_limits::max(), - }; - - using enum Id; - -public: - consteval MathObjectType(const size_t inId, const std::string_view inName) - : name(inName), - id(inId) { - } - - consteval MathObjectType(const Id inId, const std::string_view inName) - : MathObjectType(static_cast(inId), inName) { - } - - constexpr bool operator==(const MathObjectType &rhs) const { - return id == rhs.id && name == rhs.name; - } - - constexpr std::strong_ordering operator<=>(const MathObjectType &rhs) const { - return id <=> rhs.id; - } - - constexpr size_t getId() const { - return id; - } - - constexpr std::string_view getName() const { - return name; - } - -private: - std::string_view name; - size_t id; - -private: - [[maybe_unused]] inline static const detail::Config config; -}; - -constexpr size_t hash_value(const MathObjectType &rhs) noexcept { - return rhs.getId(); -} - -} diff --git a/include/fintamath/core/CoreUtils.hpp b/include/fintamath/core/MathObjectUtils.hpp similarity index 93% rename from include/fintamath/core/CoreUtils.hpp rename to include/fintamath/core/MathObjectUtils.hpp index 96b7eef1e..044ab59c1 100644 --- a/include/fintamath/core/CoreUtils.hpp +++ b/include/fintamath/core/MathObjectUtils.hpp @@ -6,7 +6,7 @@ #include #include -#include "fintamath/core/MathObjectBoundTypes.hpp" +#include "fintamath/core/MathObjectClass.hpp" namespace fintamath { @@ -18,8 +18,9 @@ namespace stdv = std::views; template concept ConvertibleToAndNotSameAs = std::convertible_to && !std::same_as; -template -concept SameAsUnqual = (std::same_as, std::remove_cvref_t>); +inline bool is(const MathObjectClass to, const MathObjectClass from) { + return to == from || to.getChildren(true).contains(from); +} template To, std::derived_from From> bool is(const From &from) { @@ -30,7 +31,7 @@ bool is(const From &from) { return false; } else { - return isBaseOf(To::getTypeStatic(), from.getType()); + return is(To::getClassStatic(), from.getClass()); } } @@ -142,4 +143,4 @@ std::shared_ptr cast(const std::shared_ptr &from) { return std::const_pointer_cast(cast(std::const_pointer_cast(from))); } -} +} \ No newline at end of file diff --git a/include/fintamath/core/MultiMethod.hpp b/include/fintamath/core/MultiMethod.hpp index c267a23ab..d4eb78331 100644 --- a/include/fintamath/core/MultiMethod.hpp +++ b/include/fintamath/core/MultiMethod.hpp @@ -6,8 +6,8 @@ #include -#include "fintamath/core/CoreUtils.hpp" -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.hpp" +#include "fintamath/core/MathObjectUtils.hpp" namespace fintamath::detail { @@ -17,7 +17,7 @@ class MultiMethod; template class MultiMethod final { template - using ArgId = MathObjectType; + using ArgId = MathObjectClass; using CallbackId = std::tuple...>; @@ -29,7 +29,7 @@ class MultiMethod final { template requires(sizeof...(Args) == sizeof...(ArgsBase)) void add(const auto &func) { - idToCallbackMap[CallbackId(Args::getTypeStatic()...)] = [func](const ArgsBase &...args) { + idToCallbackMap[CallbackId(Args::getClassStatic()...)] = [func](const ArgsBase &...args) { return func(cast(args)...); }; } @@ -37,7 +37,7 @@ class MultiMethod final { template requires(sizeof...(Args) == sizeof...(ArgsBase)) Res operator()(Args &&...args) const { - if (auto iter = idToCallbackMap.find(CallbackId(args.getType()...)); iter != idToCallbackMap.end()) { + if (auto iter = idToCallbackMap.find(CallbackId(args.getClass()...)); iter != idToCallbackMap.end()) { return iter->second(std::forward(args)...); } @@ -47,7 +47,7 @@ class MultiMethod final { template requires(sizeof...(Args) == sizeof...(ArgsBase)) bool contains(const Args &...args) const { - return idToCallbackMap.contains(CallbackId(args.getType()...)); + return idToCallbackMap.contains(CallbackId(args.getClass()...)); } private: diff --git a/include/fintamath/core/Parser.hpp b/include/fintamath/core/Parser.hpp index d9246dfcf..5f31a135e 100644 --- a/include/fintamath/core/Parser.hpp +++ b/include/fintamath/core/Parser.hpp @@ -3,112 +3,121 @@ #include #include #include -#include #include #include #include -#include "fintamath/core/CoreUtils.hpp" +#include + #include "fintamath/core/Tokenizer.hpp" #include "fintamath/exceptions/InvalidInputException.hpp" namespace fintamath::detail { -template -concept StringConstructable = requires(const std::string &str, Args &&...args) { - T(str, args...); +template +concept EmptyConstructable = requires { + T().toString(); +}; + +template +concept StringConstructable = requires(std::string str) { + T(str).toString(); }; template class Parser; -template -class Parser final { +template +class Parser final { public: - using Validator = std::function; + using Generator = cppcoro::generator; - using StringConstructor = std::function; +private: + using Constructor = std::function; - using Constructor = std::function; + using StringToConstructorsMap = std::unordered_map>; - using ConstructorVector = std::vector; + using GeneratorConstructor = std::function; - using StringToConstructorMap = std::unordered_multimap; + using GeneratorConstructorVector = std::vector; public: - template - requires(SameAsUnqual && ...) - Return parse(const std::string &str, ConstructorArgs &&...args) const { - constexpr auto trueValidator = [](const Return &) { return true; }; - return parse(trueValidator, str, std::forward(args)...); - } - - template - requires(SameAsUnqual && ...) - Return parse(const Validator &validator, const std::string &str, ConstructorArgs &&...args) const { - for (const auto &pairs = stringToConstructorMap.equal_range(str); - const auto &pair : stdv::iota(pairs.first, pairs.second)) { - - if (Return value = pair->second(std::forward(args)...); - value && validator(value)) { - - return value; + Generator parse(const std::string &str) const { + if (const auto stringToConstructors = stringToConstructorsMap.find(str); stringToConstructors != stringToConstructorsMap.end()) { + for (const auto &constructor : stringToConstructors->second) { + co_yield constructor(); } } - for (const auto &constructor : extraConstructors) { - if (Return value = constructor(str, std::forward(args)...); - value && validator(value)) { - - return value; + for (const auto &generatorConstructor : generatorConstructors) { + for (auto &value : generatorConstructor(str)) { + co_yield std::move(value); } } + } - return Return{}; + Generator parse(std::string &&str) const { + return [](const Parser &parser, const std::string localStr) -> Generator { + for (auto &value : parser.parse(localStr)) { + co_yield std::move(value); + } + }(*this, std::move(str)); } - template - requires(!StringConstructable) - void registerType() { - Constructor constructor = [](ConstructorArgs &&...args) -> Return { - return std::make_unique(std::forward(args)...); - }; + std::optional parseFirst(const std::string &str) const { + auto gener = parse(str); + + if (auto iter = gener.begin(); iter != gener.end()) { + return std::move(*iter); + } - registerType(std::move(constructor)); + return {}; } template - requires(!StringConstructable) - void registerType(Constructor constructor) { + requires(!std::is_abstract_v && !StringConstructable && EmptyConstructable) + void registerType() { static const std::string name = Type{}.toString(); - stringToConstructorMap.emplace(name, std::move(constructor)); + + stringToConstructorsMap[name].emplace_back([]() -> Return { + return std::make_unique(); + }); Tokenizer::registerToken(name); } template - requires(StringConstructable) + requires(!std::is_abstract_v && StringConstructable) void registerType() { - StringConstructor constructor = [](const std::string &str, ConstructorArgs &&...args) -> Return { + generatorConstructors.emplace_back([](const std::string &str) -> Generator { try { - return std::make_unique(str, std::forward(args)...); + co_yield std::make_unique(str); } catch (const InvalidInputException &) { - return std::unique_ptr{}; + // Go to the next constructor } - }; + }); + } - registerType(std::move(constructor)); + template + requires(std::is_abstract_v) + void registerType() { + generatorConstructors.emplace_back([](const std::string &str) -> Generator { + for (auto &value : Type::parse(str)) { + co_yield std::move(value); + } + }); } - void registerType(StringConstructor constructor) { - extraConstructors.emplace_back(std::move(constructor)); + template + void registerType() const { + // No object of this type can be constructed } private: - StringToConstructorMap stringToConstructorMap; + StringToConstructorsMap stringToConstructorsMap; - ConstructorVector extraConstructors; + GeneratorConstructorVector generatorConstructors; }; } diff --git a/include/fintamath/expressions/Expression.hpp b/include/fintamath/expressions/Expression.hpp index 976a3e56f..56e2d1964 100644 --- a/include/fintamath/expressions/Expression.hpp +++ b/include/fintamath/expressions/Expression.hpp @@ -11,7 +11,7 @@ #include #include "fintamath/core/IMathObject.hpp" -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.hpp" #include "fintamath/core/Parser.hpp" #include "fintamath/core/Tokenizer.hpp" #include "fintamath/expressions/IExpression.hpp" @@ -61,9 +61,11 @@ using OperandStack = std::stack>; } class Expression final : public IExpressionCRTP { - using TermParser = detail::Parser()>; - using ExpressionParser = detail::Parser(ArgumentPtrVector &&)>; - using ExpressionMaker = std::function(ArgumentPtrVector &&)>; + FINTAMATH_CLASS_BODY(Expression) + + using ExpressionConstructor = std::function(ArgumentPtrVector &&)>; + + using ExpressionMaker = std::unordered_map; public: Expression(); @@ -88,16 +90,8 @@ class Expression final : public IExpressionCRTP { void setVariable(const Variable &var, const Expression &val); - static void registerTermParser(TermParser::StringConstructor constructor) { - getTermParser().registerType(std::move(constructor)); - } - template - static void registerFunctionExpressionMaker(ExpressionMaker maker); - - static constexpr MathObjectType getTypeStatic() { - return {MathObjectType::Expression, "Expression"}; - } + static void registerExpressionConstructor(ExpressionConstructor constructor); protected: Expression &add(const Expression &rhs) override; @@ -123,7 +117,13 @@ class Expression final : public IExpressionCRTP { static std::unique_ptr operandsToObject(detail::OperandStack &operands); - static void moveFunctionsToOperands(detail::OperandStack &operands, detail::FunctionTermStack &functions, const IOperator *nextOper); + static std::unique_ptr parseFunction(const std::string &str, size_t argNum); + + static std::unique_ptr parseOperator(const std::string &str, IOperator::Priority priority); + + static detail::Term parseTerm(const std::string &str); + + static void moveFunctionTermsToOperands(detail::OperandStack &operands, detail::FunctionTermStack &functions, const IOperator *nextOper); static void insertMultiplications(detail::TermVector &terms); @@ -145,7 +145,7 @@ class Expression final : public IExpressionCRTP { static void validateFunctionArgs(const IFunction &func, const ArgumentPtrVector &args); - static bool doesArgMatch(const MathObjectType &expectedType, const ArgumentPtr &arg); + static bool doesArgMatch(const MathObjectClass &expectedType, const ArgumentPtr &arg); static ArgumentPtrVector unwrapComma(const ArgumentPtr &child); @@ -157,9 +157,7 @@ class Expression final : public IExpressionCRTP { friend Expression approximate(const Expression &rhs, unsigned precision); - static TermParser &getTermParser(); - - static ExpressionParser &getExpressionParser(); + static ExpressionMaker &getExpressionMaker(); private: mutable ArgumentPtr child; @@ -196,29 +194,28 @@ Expression operator/(const Expression &lhs, const Variable &rhs); Expression operator/(const Variable &lhs, const Expression &rhs); template -void Expression::registerFunctionExpressionMaker(ExpressionMaker maker) { - ExpressionParser::Constructor constructor = [maker = std::move(maker)](ArgumentPtrVector &&args) { - static const size_t argSize = Function{}.getArgumentTypes().size(); +void Expression::registerExpressionConstructor(ExpressionConstructor constructor) { + getExpressionMaker()[Function::getClassStatic()] = [maker = std::move(constructor)](ArgumentPtrVector &&args) { + static const size_t funcArgSize = Function{}.getArgumentClasses().size(); + std::unique_ptr res; if constexpr (Function::isVariadicStatic()) { res = maker(std::move(args)); } else if constexpr (isPolynomial) { - if (argSize <= args.size()) { + if (funcArgSize <= args.size()) { res = maker(std::move(args)); } } else { - if (argSize == args.size()) { + if (funcArgSize == args.size()) { res = maker(std::move(args)); } } return res; }; - - getExpressionParser().registerType(std::move(constructor)); } } diff --git a/include/fintamath/expressions/ExpressionUtils.hpp b/include/fintamath/expressions/ExpressionUtils.hpp index 277b34de9..201571bb6 100644 --- a/include/fintamath/expressions/ExpressionUtils.hpp +++ b/include/fintamath/expressions/ExpressionUtils.hpp @@ -6,7 +6,7 @@ #include #include -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/functions/IFunction.hpp" #include "fintamath/functions/IOperator.hpp" @@ -33,11 +33,11 @@ ArgumentPtr simplifyUndefined(const IFunction &func, const std::same_as(args) || ...)) { - static const MathObjectType undefinedReturnType = Undefined{}.getReturnType(); - const MathObjectType funcReturnType = func.getReturnType(); + static const MathObjectClass undefinedReturnType = Undefined{}.getReturnClass(); + const MathObjectClass funcReturnType = func.getReturnClass(); - if (isBaseOf(undefinedReturnType, funcReturnType) || - isBaseOf(funcReturnType, undefinedReturnType)) { + if (is(undefinedReturnType, funcReturnType) || + is(funcReturnType, undefinedReturnType)) { res = Undefined{}.clone(); } @@ -100,4 +100,4 @@ std::string prefixUnaryOperatorToString(const IOperator &oper, const ArgumentPtr std::string postfixUnaryOperatorToString(const IOperator &oper, const ArgumentPtr &rhs); -} +} \ No newline at end of file diff --git a/include/fintamath/expressions/IExpression.hpp b/include/fintamath/expressions/IExpression.hpp index 3b80d521e..5d8e83942 100644 --- a/include/fintamath/expressions/IExpression.hpp +++ b/include/fintamath/expressions/IExpression.hpp @@ -8,7 +8,7 @@ #include "fintamath/core/IArithmetic.hpp" #include "fintamath/core/IMathObject.hpp" -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.hpp" #include "fintamath/core/Parser.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/functions/IFunction.hpp" @@ -19,7 +19,7 @@ namespace fintamath { class IExpression : public IArithmetic { - using ExpressionParser = detail::Parser()>; + FINTAMATH_PARENT_CLASS_BODY(IExpression) public: virtual const std::shared_ptr &getFunction() const = 0; @@ -36,19 +36,6 @@ class IExpression : public IArithmetic { virtual const std::shared_ptr &getOutputFunction() const; - template T> - static void registerType() { - getParser().registerType(); - } - - static std::unique_ptr parse(const std::string &str) { - return getParser().parse(str); - } - - static constexpr MathObjectType getTypeStatic() { - return {MathObjectType::IExpression, "IExpression"}; - } - protected: virtual ArgumentPtr simplify() const; @@ -78,9 +65,6 @@ class IExpression : public IArithmetic { static std::unique_ptr convertToApproximated(const INumber &num, unsigned precision, const Integer &maxInt); static ArgumentPtrVector convertToApproximatedNumbers(const ArgumentPtrVector &args); - -private: - static ExpressionParser &getParser(); }; template diff --git a/include/fintamath/expressions/interfaces/IBinaryExpression.hpp b/include/fintamath/expressions/interfaces/IBinaryExpression.hpp index 247cc364a..7d65d6dc6 100644 --- a/include/fintamath/expressions/interfaces/IBinaryExpression.hpp +++ b/include/fintamath/expressions/interfaces/IBinaryExpression.hpp @@ -6,7 +6,7 @@ #include #include -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.hpp" #include "fintamath/expressions/IExpression.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/functions/IFunction.hpp" @@ -14,6 +14,8 @@ namespace fintamath { class IBinaryExpression : public IExpression { + FINTAMATH_PARENT_CLASS_BODY(IBinaryExpression) + public: explicit IBinaryExpression(const IFunction &inFunc, ArgumentPtr lhs, ArgumentPtr rhs); @@ -25,10 +27,6 @@ class IBinaryExpression : public IExpression { void setChildren(const ArgumentPtrVector &childVect) final; - static constexpr MathObjectType getTypeStatic() { - return {MathObjectType::IBinaryExpression, "IBinaryExpression"}; - } - protected: using SimplifyFunction = std::function; diff --git a/include/fintamath/expressions/interfaces/IPolynomExpression.hpp b/include/fintamath/expressions/interfaces/IPolynomExpression.hpp index 8f89c4517..43000b620 100644 --- a/include/fintamath/expressions/interfaces/IPolynomExpression.hpp +++ b/include/fintamath/expressions/interfaces/IPolynomExpression.hpp @@ -7,7 +7,7 @@ #include #include -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.hpp" #include "fintamath/expressions/IExpression.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/functions/IFunction.hpp" @@ -17,6 +17,8 @@ namespace fintamath { class IOperator; class IPolynomExpression : public IExpression { + FINTAMATH_PARENT_CLASS_BODY(IPolynomExpression) + public: explicit IPolynomExpression(const IFunction &inFunc, ArgumentPtrVector args); @@ -28,10 +30,6 @@ class IPolynomExpression : public IExpression { void setChildren(const ArgumentPtrVector &childVect) final; - static constexpr MathObjectType getTypeStatic() { - return {MathObjectType::IPolynomExpression, "IPolynomExpression"}; - } - protected: using SimplifyFunction = std::function; diff --git a/include/fintamath/expressions/interfaces/IUnaryExpression.hpp b/include/fintamath/expressions/interfaces/IUnaryExpression.hpp index 81170fbef..fab8029a7 100644 --- a/include/fintamath/expressions/interfaces/IUnaryExpression.hpp +++ b/include/fintamath/expressions/interfaces/IUnaryExpression.hpp @@ -6,7 +6,7 @@ #include #include -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.hpp" #include "fintamath/expressions/IExpression.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/functions/IFunction.hpp" @@ -14,6 +14,8 @@ namespace fintamath { class IUnaryExpression : public IExpression { + FINTAMATH_PARENT_CLASS_BODY(IUnaryExpression) + public: explicit IUnaryExpression(const IFunction &inFunc, ArgumentPtr rhs); @@ -25,10 +27,6 @@ class IUnaryExpression : public IExpression { void setChildren(const ArgumentPtrVector &childVect) override; - static constexpr MathObjectType getTypeStatic() { - return {MathObjectType::IUnaryExpression, "IUnaryExpression"}; - } - protected: using SimplifyFunction = std::function; diff --git a/include/fintamath/functions/FunctionArguments.hpp b/include/fintamath/functions/FunctionArguments.hpp index 4f0ef188d..729202ac4 100644 --- a/include/fintamath/functions/FunctionArguments.hpp +++ b/include/fintamath/functions/FunctionArguments.hpp @@ -4,7 +4,7 @@ #include #include -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.hpp" namespace fintamath { @@ -16,6 +16,6 @@ using ArgumentPtr = std::shared_ptr; using ArgumentRefVector = std::vector; using ArgumentPtrVector = std::vector; -using ArgumentTypeVector = std::vector; +using ArgumentTypeVector = std::vector; } diff --git a/include/fintamath/functions/IFunction.hpp b/include/fintamath/functions/IFunction.hpp index cf6616861..7de60acd5 100644 --- a/include/fintamath/functions/IFunction.hpp +++ b/include/fintamath/functions/IFunction.hpp @@ -7,7 +7,7 @@ #include #include "fintamath/core/IMathObject.hpp" -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.hpp" #include "fintamath/core/Parser.hpp" #include "fintamath/exceptions/UndefinedException.hpp" #include "fintamath/functions/FunctionArguments.hpp" @@ -16,16 +16,14 @@ namespace fintamath { class IFunction : public IMathObject { - using FunctionNameToOrderMap = std::unordered_map; + FINTAMATH_PARENT_CLASS_BODY(IFunction) - using FunctionParser = detail::Parser()>; + using ClassToOrderMap = std::unordered_map; public: - virtual const ArgumentTypeVector &getArgumentTypes() const = 0; + virtual const ArgumentTypeVector &getArgumentClasses() const = 0; - virtual MathObjectType getReturnType() const = 0; - - virtual size_t getFunctionOrder() const = 0; + virtual MathObjectClass getReturnClass() const = 0; virtual bool doArgsMatch(const ArgumentRefVector &argVect) const = 0; @@ -42,42 +40,10 @@ class IFunction : public IMathObject { return callAbstract(argVect); } - static std::unique_ptr parse(const std::string &parsedStr) { - return getParser().parse(parsedStr); - } - - static std::unique_ptr parse(const std::string &parsedStr, size_t argSize) { - const auto validator = [argSize](const std::unique_ptr &func) { - return argSize == func->getArgumentTypes().size(); - }; - return getParser().parse(validator, parsedStr); - } - - template T> - static void registerType() { - getParser().registerType(); - - getFunctionNameToOrderMutableMap()[T{}.toString()] = maxFunctionOrder; - maxFunctionOrder++; - } - - static constexpr MathObjectType getTypeStatic() { - return {MathObjectType::IFunction, "IFunction"}; - } - protected: virtual std::unique_ptr callAbstract(const ArgumentRefVector &argVect) const = 0; virtual void validateArgsSize(const ArgumentRefVector &argVect) const; - - static const FunctionNameToOrderMap &getFunctionNameToOrderMap(); - -private: - static FunctionNameToOrderMap &getFunctionNameToOrderMutableMap(); - - static FunctionParser &getParser(); - - inline static size_t maxFunctionOrder = 0; }; template diff --git a/include/fintamath/functions/IFunctionCRTP.hpp b/include/fintamath/functions/IFunctionCRTP.hpp index 89b6ab255..79d757058 100644 --- a/include/fintamath/functions/IFunctionCRTP.hpp +++ b/include/fintamath/functions/IFunctionCRTP.hpp @@ -14,17 +14,12 @@ class IFunctionCRTP_ : public IFunction { #undef I_MATH_OBJECT_CRTP public: - const std::vector &getArgumentTypes() const final { + const std::vector &getArgumentClasses() const final { return argTypes; } - MathObjectType getReturnType() const final { - return Return::getTypeStatic(); - } - - size_t getFunctionOrder() const final { - static const std::string funcStr = Derived{}.toString(); - return getFunctionNameToOrderMap().at(funcStr); + MathObjectClass getReturnClass() const final { + return Return::getClassStatic(); } bool doArgsMatch(const ArgumentRefVector &argVect) const override { @@ -102,7 +97,7 @@ class IFunctionCRTP_ : public IFunction { } private: - inline static const ArgumentTypeVector argTypes = {Args::getTypeStatic()...}; + inline static const ArgumentTypeVector argTypes = {Args::getClassStatic()...}; private: #if !defined(I_FUNCTION_CRTP) && !defined(NDEBUG) diff --git a/include/fintamath/functions/IOperator.hpp b/include/fintamath/functions/IOperator.hpp index 78ae056fe..8f8e21dfe 100644 --- a/include/fintamath/functions/IOperator.hpp +++ b/include/fintamath/functions/IOperator.hpp @@ -6,14 +6,14 @@ #include #include -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.hpp" #include "fintamath/core/Parser.hpp" #include "fintamath/functions/IFunction.hpp" namespace fintamath { class IOperator : public IFunction { - using OperatorParser = detail::Parser()>; + FINTAMATH_PARENT_CLASS_BODY(IOperator) public: enum class Priority : uint8_t { @@ -35,37 +35,6 @@ class IOperator : public IFunction { virtual Priority getPriority() const = 0; virtual bool isAssociative() const = 0; - - static std::unique_ptr parse(const std::string &parsedStr, size_t argSize) { - const auto validator = [argSize](const std::unique_ptr &oper) { - return argSize == oper->getArgumentTypes().size(); - }; - return getParser().parse(validator, parsedStr); - } - - static std::unique_ptr parse(const std::string &parsedStr) { - return getParser().parse(parsedStr); - } - - static std::unique_ptr parse(const std::string &parsedStr, Priority priority) { - const auto validator = [priority](const std::unique_ptr &oper) { - return oper->getPriority() == priority; - }; - return getParser().parse(validator, parsedStr); - } - - template T> - static void registerType() { - IFunction::registerType(); - getParser().registerType(); - } - - static constexpr MathObjectType getTypeStatic() { - return {MathObjectType::IOperator, "IOperator"}; - } - -private: - static OperatorParser &getParser(); }; template diff --git a/include/fintamath/functions/arithmetic/Abs.hpp b/include/fintamath/functions/arithmetic/Abs.hpp index f09280548..2ab8df6c3 100644 --- a/include/fintamath/functions/arithmetic/Abs.hpp +++ b/include/fintamath/functions/arithmetic/Abs.hpp @@ -4,7 +4,7 @@ #include #include "fintamath/core/IMathObject.hpp" -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/functions/FunctionUtils.hpp" #include "fintamath/functions/IFunction.hpp" @@ -13,15 +13,13 @@ namespace fintamath { class Abs final : public IFunctionCRTP { + FINTAMATH_CLASS_BODY(Abs) + public: std::string toString() const override { return "abs"; } - static constexpr MathObjectType getTypeStatic() { - return {MathObjectType::Abs, "Abs"}; - } - protected: std::unique_ptr call(const ArgumentRefVector &argVect) const override; diff --git a/include/fintamath/functions/arithmetic/Add.hpp b/include/fintamath/functions/arithmetic/Add.hpp index c440491d6..310593bbd 100644 --- a/include/fintamath/functions/arithmetic/Add.hpp +++ b/include/fintamath/functions/arithmetic/Add.hpp @@ -5,7 +5,7 @@ #include "fintamath/core/IArithmetic.hpp" #include "fintamath/core/IMathObject.hpp" -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/functions/FunctionUtils.hpp" #include "fintamath/functions/IOperator.hpp" @@ -13,6 +13,8 @@ namespace fintamath { class Add final : public IOperatorCRTP { + FINTAMATH_CLASS_BODY(Add) + public: std::string toString() const override { return "+"; @@ -26,10 +28,6 @@ class Add final : public IOperatorCRTP call(const ArgumentRefVector &argVect) const override; }; diff --git a/include/fintamath/functions/arithmetic/Div.hpp b/include/fintamath/functions/arithmetic/Div.hpp index d17536b35..7d9a47fff 100644 --- a/include/fintamath/functions/arithmetic/Div.hpp +++ b/include/fintamath/functions/arithmetic/Div.hpp @@ -5,7 +5,7 @@ #include "fintamath/core/IArithmetic.hpp" #include "fintamath/core/IMathObject.hpp" -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/functions/FunctionUtils.hpp" #include "fintamath/functions/IOperator.hpp" @@ -16,6 +16,8 @@ class Integer; class INumber; class Div final : public IOperatorCRTP { + FINTAMATH_CLASS_BODY(Div) + public: std::string toString() const override { return "/"; @@ -25,10 +27,6 @@ class Div final : public IOperatorCRTP call(const ArgumentRefVector &argVect) const override; }; diff --git a/include/fintamath/functions/arithmetic/Frac.hpp b/include/fintamath/functions/arithmetic/Frac.hpp index 56b460211..09fb77def 100644 --- a/include/fintamath/functions/arithmetic/Frac.hpp +++ b/include/fintamath/functions/arithmetic/Frac.hpp @@ -5,22 +5,20 @@ #include "fintamath/core/IArithmetic.hpp" #include "fintamath/core/IMathObject.hpp" -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/functions/IFunction.hpp" namespace fintamath { class Frac final : public IFunctionCRTP { + FINTAMATH_CLASS_BODY(Frac) + public: std::string toString() const override { return "frac"; } - static constexpr MathObjectType getTypeStatic() { - return {MathObjectType::Frac, "Frac"}; - } - protected: std::unique_ptr call(const ArgumentRefVector &argVect) const override; }; diff --git a/include/fintamath/functions/arithmetic/FracMixed.hpp b/include/fintamath/functions/arithmetic/FracMixed.hpp index 3274dc8b4..b828ead4a 100644 --- a/include/fintamath/functions/arithmetic/FracMixed.hpp +++ b/include/fintamath/functions/arithmetic/FracMixed.hpp @@ -5,22 +5,20 @@ #include "fintamath/core/IArithmetic.hpp" #include "fintamath/core/IMathObject.hpp" -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/functions/IFunction.hpp" namespace fintamath { class FracMixed final : public IFunctionCRTP { + FINTAMATH_CLASS_BODY(FracMixed) + public: std::string toString() const override { return "frac"; } - static constexpr MathObjectType getTypeStatic() { - return {MathObjectType::FracMixed, "FracMixed"}; - } - protected: std::unique_ptr call(const ArgumentRefVector &argVect) const override; }; diff --git a/include/fintamath/functions/arithmetic/Mul.hpp b/include/fintamath/functions/arithmetic/Mul.hpp index 49a8c84ac..6f9103d4f 100644 --- a/include/fintamath/functions/arithmetic/Mul.hpp +++ b/include/fintamath/functions/arithmetic/Mul.hpp @@ -5,7 +5,7 @@ #include "fintamath/core/IArithmetic.hpp" #include "fintamath/core/IMathObject.hpp" -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/functions/FunctionUtils.hpp" #include "fintamath/functions/IOperator.hpp" @@ -13,6 +13,8 @@ namespace fintamath { class Mul final : public IOperatorCRTP { + FINTAMATH_CLASS_BODY(Mul) + public: std::string toString() const override { return "*"; @@ -26,10 +28,6 @@ class Mul final : public IOperatorCRTP call(const ArgumentRefVector &argVect) const override; }; diff --git a/include/fintamath/functions/arithmetic/Neg.hpp b/include/fintamath/functions/arithmetic/Neg.hpp index af9c18109..52b593f34 100644 --- a/include/fintamath/functions/arithmetic/Neg.hpp +++ b/include/fintamath/functions/arithmetic/Neg.hpp @@ -5,7 +5,7 @@ #include "fintamath/core/IArithmetic.hpp" #include "fintamath/core/IMathObject.hpp" -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/functions/FunctionUtils.hpp" #include "fintamath/functions/IOperator.hpp" @@ -13,6 +13,8 @@ namespace fintamath { class Neg final : public IOperatorCRTP { + FINTAMATH_CLASS_BODY(Neg) + public: std::string toString() const override { return "-"; @@ -22,10 +24,6 @@ class Neg final : public IOperatorCRTP { return Priority::PrefixUnary; } - static constexpr MathObjectType getTypeStatic() { - return {MathObjectType::Neg, "Neg"}; - } - protected: std::unique_ptr call(const ArgumentRefVector &argVect) const override; }; diff --git a/include/fintamath/functions/arithmetic/Sign.hpp b/include/fintamath/functions/arithmetic/Sign.hpp index 95854bb2b..475c8109d 100644 --- a/include/fintamath/functions/arithmetic/Sign.hpp +++ b/include/fintamath/functions/arithmetic/Sign.hpp @@ -4,7 +4,7 @@ #include #include "fintamath/core/IMathObject.hpp" -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/functions/FunctionUtils.hpp" #include "fintamath/functions/IFunction.hpp" @@ -13,15 +13,13 @@ namespace fintamath { class Sign final : public IFunctionCRTP { + FINTAMATH_CLASS_BODY(Sign) + public: std::string toString() const override { return "sign"; } - static constexpr MathObjectType getTypeStatic() { - return {MathObjectType::Sign, "Sign"}; - } - protected: std::unique_ptr call(const ArgumentRefVector &argVect) const override; diff --git a/include/fintamath/functions/arithmetic/Sub.hpp b/include/fintamath/functions/arithmetic/Sub.hpp index 346eb18fd..91239303d 100644 --- a/include/fintamath/functions/arithmetic/Sub.hpp +++ b/include/fintamath/functions/arithmetic/Sub.hpp @@ -5,7 +5,7 @@ #include "fintamath/core/IArithmetic.hpp" #include "fintamath/core/IMathObject.hpp" -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/functions/FunctionUtils.hpp" #include "fintamath/functions/IOperator.hpp" @@ -13,6 +13,8 @@ namespace fintamath { class Sub final : public IOperatorCRTP { + FINTAMATH_CLASS_BODY(Sub) + public: std::string toString() const override { return "-"; @@ -22,10 +24,6 @@ class Sub final : public IOperatorCRTP call(const ArgumentRefVector &argVect) const override; }; diff --git a/include/fintamath/functions/arithmetic/UnaryPlus.hpp b/include/fintamath/functions/arithmetic/UnaryPlus.hpp index 58502b53a..172f48735 100644 --- a/include/fintamath/functions/arithmetic/UnaryPlus.hpp +++ b/include/fintamath/functions/arithmetic/UnaryPlus.hpp @@ -5,13 +5,15 @@ #include "fintamath/core/IArithmetic.hpp" #include "fintamath/core/IMathObject.hpp" -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/functions/IOperator.hpp" namespace fintamath { class UnaryPlus final : public IOperatorCRTP { + FINTAMATH_CLASS_BODY(UnaryPlus) + public: std::string toString() const override { return "+"; @@ -21,10 +23,6 @@ class UnaryPlus final : public IOperatorCRTP call(const ArgumentRefVector &argVect) const override; }; diff --git a/include/fintamath/functions/calculus/Derivative.hpp b/include/fintamath/functions/calculus/Derivative.hpp index fc2c64deb..a924a9646 100644 --- a/include/fintamath/functions/calculus/Derivative.hpp +++ b/include/fintamath/functions/calculus/Derivative.hpp @@ -5,7 +5,7 @@ #include "fintamath/core/IComparable.hpp" #include "fintamath/core/IMathObject.hpp" -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/functions/FunctionUtils.hpp" #include "fintamath/functions/IFunction.hpp" @@ -14,6 +14,8 @@ namespace fintamath { class Derivative final : public IFunctionCRTP { + FINTAMATH_CLASS_BODY(Derivative) + public: std::string toString() const override { return "derivative"; @@ -23,10 +25,6 @@ class Derivative final : public IFunctionCRTP call(const ArgumentRefVector &argVect) const override; }; diff --git a/include/fintamath/functions/calculus/Integral.hpp b/include/fintamath/functions/calculus/Integral.hpp index 3afccac89..deaae948f 100644 --- a/include/fintamath/functions/calculus/Integral.hpp +++ b/include/fintamath/functions/calculus/Integral.hpp @@ -5,7 +5,7 @@ #include "fintamath/core/IComparable.hpp" #include "fintamath/core/IMathObject.hpp" -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/functions/FunctionUtils.hpp" #include "fintamath/functions/IFunction.hpp" @@ -14,6 +14,8 @@ namespace fintamath { class Integral final : public IFunctionCRTP { + FINTAMATH_CLASS_BODY(Integral) + public: std::string toString() const override { return "integral"; @@ -23,10 +25,6 @@ class Integral final : public IFunctionCRTP call(const ArgumentRefVector &argVect) const override; }; diff --git a/include/fintamath/functions/calculus/Max.hpp b/include/fintamath/functions/calculus/Max.hpp index df1fac6e5..5d491dafb 100644 --- a/include/fintamath/functions/calculus/Max.hpp +++ b/include/fintamath/functions/calculus/Max.hpp @@ -5,7 +5,7 @@ #include "fintamath/core/IComparable.hpp" #include "fintamath/core/IMathObject.hpp" -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/functions/FunctionUtils.hpp" #include "fintamath/functions/IFunction.hpp" @@ -13,6 +13,8 @@ namespace fintamath { class Max final : public IFunctionCRTP { + FINTAMATH_CLASS_BODY(Max) + public: std::string toString() const override { return "max"; @@ -22,10 +24,6 @@ class Max final : public IFunctionCRTP { return true; } - static constexpr MathObjectType getTypeStatic() { - return {MathObjectType::Max, "Max"}; - } - protected: std::unique_ptr call(const ArgumentRefVector &argVect) const override; }; diff --git a/include/fintamath/functions/calculus/Min.hpp b/include/fintamath/functions/calculus/Min.hpp index de5652a26..d42a205b7 100644 --- a/include/fintamath/functions/calculus/Min.hpp +++ b/include/fintamath/functions/calculus/Min.hpp @@ -5,7 +5,7 @@ #include "fintamath/core/IComparable.hpp" #include "fintamath/core/IMathObject.hpp" -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/functions/FunctionUtils.hpp" #include "fintamath/functions/IFunction.hpp" @@ -13,6 +13,8 @@ namespace fintamath { class Min final : public IFunctionCRTP { + FINTAMATH_CLASS_BODY(Min) + public: std::string toString() const override { return "min"; @@ -22,10 +24,6 @@ class Min final : public IFunctionCRTP { return true; } - static constexpr MathObjectType getTypeStatic() { - return {MathObjectType::Min, "Min"}; - } - protected: std::unique_ptr call(const ArgumentRefVector &argVect) const override; }; diff --git a/include/fintamath/functions/comparison/Eqv.hpp b/include/fintamath/functions/comparison/Eqv.hpp index bb759a0bd..3b115b6b3 100644 --- a/include/fintamath/functions/comparison/Eqv.hpp +++ b/include/fintamath/functions/comparison/Eqv.hpp @@ -5,7 +5,7 @@ #include "fintamath/core/IComparable.hpp" #include "fintamath/core/IMathObject.hpp" -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/functions/FunctionUtils.hpp" #include "fintamath/functions/IOperator.hpp" @@ -14,6 +14,8 @@ namespace fintamath { class Eqv final : public IOperatorCRTP { + FINTAMATH_CLASS_BODY(Eqv) + public: std::string toString() const override { return "="; @@ -27,10 +29,6 @@ class Eqv final : public IOperatorCRTP { return Priority::Comparison; } - static constexpr MathObjectType getTypeStatic() { - return {MathObjectType::Eqv, "Eqv"}; - } - protected: std::unique_ptr call(const ArgumentRefVector &argVect) const override; }; diff --git a/include/fintamath/functions/comparison/Less.hpp b/include/fintamath/functions/comparison/Less.hpp index 533f127ce..d720206c0 100644 --- a/include/fintamath/functions/comparison/Less.hpp +++ b/include/fintamath/functions/comparison/Less.hpp @@ -5,7 +5,7 @@ #include "fintamath/core/IComparable.hpp" #include "fintamath/core/IMathObject.hpp" -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/functions/FunctionUtils.hpp" #include "fintamath/functions/IOperator.hpp" @@ -14,6 +14,8 @@ namespace fintamath { class Less final : public IOperatorCRTP { + FINTAMATH_CLASS_BODY(Less) + public: std::string toString() const override { return "<"; @@ -27,10 +29,6 @@ class Less final : public IOperatorCRTP return Priority::Comparison; } - static constexpr MathObjectType getTypeStatic() { - return {MathObjectType::Less, "Less"}; - } - protected: std::unique_ptr call(const ArgumentRefVector &argVect) const override; }; diff --git a/include/fintamath/functions/comparison/LessEqv.hpp b/include/fintamath/functions/comparison/LessEqv.hpp index 2444b8b6c..639d28a78 100644 --- a/include/fintamath/functions/comparison/LessEqv.hpp +++ b/include/fintamath/functions/comparison/LessEqv.hpp @@ -5,7 +5,7 @@ #include "fintamath/core/IComparable.hpp" #include "fintamath/core/IMathObject.hpp" -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/functions/FunctionUtils.hpp" #include "fintamath/functions/IOperator.hpp" @@ -14,6 +14,8 @@ namespace fintamath { class LessEqv final : public IOperatorCRTP { + FINTAMATH_CLASS_BODY(LessEqv) + public: std::string toString() const override { return "<="; @@ -27,10 +29,6 @@ class LessEqv final : public IOperatorCRTP call(const ArgumentRefVector &argVect) const override; }; diff --git a/include/fintamath/functions/comparison/More.hpp b/include/fintamath/functions/comparison/More.hpp index f24b1df74..aab27c8ba 100644 --- a/include/fintamath/functions/comparison/More.hpp +++ b/include/fintamath/functions/comparison/More.hpp @@ -5,7 +5,7 @@ #include "fintamath/core/IComparable.hpp" #include "fintamath/core/IMathObject.hpp" -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/functions/FunctionUtils.hpp" #include "fintamath/functions/IOperator.hpp" @@ -14,6 +14,8 @@ namespace fintamath { class More final : public IOperatorCRTP { + FINTAMATH_CLASS_BODY(More) + public: std::string toString() const override { return ">"; @@ -27,10 +29,6 @@ class More final : public IOperatorCRTP return Priority::Comparison; } - static constexpr MathObjectType getTypeStatic() { - return {MathObjectType::More, "More"}; - } - protected: std::unique_ptr call(const ArgumentRefVector &argVect) const override; }; diff --git a/include/fintamath/functions/comparison/MoreEqv.hpp b/include/fintamath/functions/comparison/MoreEqv.hpp index 186282c85..954edfbfb 100644 --- a/include/fintamath/functions/comparison/MoreEqv.hpp +++ b/include/fintamath/functions/comparison/MoreEqv.hpp @@ -5,7 +5,7 @@ #include "fintamath/core/IComparable.hpp" #include "fintamath/core/IMathObject.hpp" -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/functions/FunctionUtils.hpp" #include "fintamath/functions/IOperator.hpp" @@ -14,6 +14,8 @@ namespace fintamath { class MoreEqv final : public IOperatorCRTP { + FINTAMATH_CLASS_BODY(MoreEqv) + public: std::string toString() const override { return ">="; @@ -27,10 +29,6 @@ class MoreEqv final : public IOperatorCRTP call(const ArgumentRefVector &argVect) const override; }; diff --git a/include/fintamath/functions/comparison/Neqv.hpp b/include/fintamath/functions/comparison/Neqv.hpp index e00788abd..92324b196 100644 --- a/include/fintamath/functions/comparison/Neqv.hpp +++ b/include/fintamath/functions/comparison/Neqv.hpp @@ -5,7 +5,7 @@ #include "fintamath/core/IComparable.hpp" #include "fintamath/core/IMathObject.hpp" -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/functions/FunctionUtils.hpp" #include "fintamath/functions/IOperator.hpp" @@ -14,6 +14,8 @@ namespace fintamath { class Neqv final : public IOperatorCRTP { + FINTAMATH_CLASS_BODY(Neqv) + public: std::string toString() const override { return "!="; @@ -27,10 +29,6 @@ class Neqv final : public IOperatorCRTP return Priority::Comparison; } - static constexpr MathObjectType getTypeStatic() { - return {MathObjectType::Neqv, "Neqv"}; - } - protected: std::unique_ptr call(const ArgumentRefVector &argVect) const override; }; diff --git a/include/fintamath/functions/hyperbolic/Acosh.hpp b/include/fintamath/functions/hyperbolic/Acosh.hpp index d2dbb5175..ed67c828e 100644 --- a/include/fintamath/functions/hyperbolic/Acosh.hpp +++ b/include/fintamath/functions/hyperbolic/Acosh.hpp @@ -4,7 +4,7 @@ #include #include "fintamath/core/IMathObject.hpp" -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/functions/FunctionUtils.hpp" #include "fintamath/functions/IFunction.hpp" @@ -15,15 +15,13 @@ namespace fintamath { class Real; class Acosh final : public IFunctionCRTP { + FINTAMATH_CLASS_BODY(Acosh) + public: std::string toString() const override { return "acosh"; } - static constexpr MathObjectType getTypeStatic() { - return {MathObjectType::Acosh, "Acosh"}; - } - protected: std::unique_ptr call(const ArgumentRefVector &argVect) const override; diff --git a/include/fintamath/functions/hyperbolic/Acoth.hpp b/include/fintamath/functions/hyperbolic/Acoth.hpp index 3bff2f76a..2b0aafe95 100644 --- a/include/fintamath/functions/hyperbolic/Acoth.hpp +++ b/include/fintamath/functions/hyperbolic/Acoth.hpp @@ -4,7 +4,7 @@ #include #include "fintamath/core/IMathObject.hpp" -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/functions/FunctionUtils.hpp" #include "fintamath/functions/IFunction.hpp" @@ -15,15 +15,13 @@ namespace fintamath { class Real; class Acoth final : public IFunctionCRTP { + FINTAMATH_CLASS_BODY(Acoth) + public: std::string toString() const override { return "acoth"; } - static constexpr MathObjectType getTypeStatic() { - return {MathObjectType::Acoth, "Acoth"}; - } - protected: std::unique_ptr call(const ArgumentRefVector &argVect) const override; diff --git a/include/fintamath/functions/hyperbolic/Acsch.hpp b/include/fintamath/functions/hyperbolic/Acsch.hpp index e5247dcd4..523e6fd4c 100644 --- a/include/fintamath/functions/hyperbolic/Acsch.hpp +++ b/include/fintamath/functions/hyperbolic/Acsch.hpp @@ -4,7 +4,7 @@ #include #include "fintamath/core/IMathObject.hpp" -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/functions/FunctionUtils.hpp" #include "fintamath/functions/IFunction.hpp" @@ -15,15 +15,13 @@ namespace fintamath { class Real; class Acsch final : public IFunctionCRTP { + FINTAMATH_CLASS_BODY(Acsch) + public: std::string toString() const override { return "acsch"; } - static constexpr MathObjectType getTypeStatic() { - return {MathObjectType::Acsch, "Acsch"}; - } - protected: std::unique_ptr call(const ArgumentRefVector &argVect) const override; diff --git a/include/fintamath/functions/hyperbolic/Asech.hpp b/include/fintamath/functions/hyperbolic/Asech.hpp index 751a122c4..7e1eba0dd 100644 --- a/include/fintamath/functions/hyperbolic/Asech.hpp +++ b/include/fintamath/functions/hyperbolic/Asech.hpp @@ -4,7 +4,7 @@ #include #include "fintamath/core/IMathObject.hpp" -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/functions/FunctionUtils.hpp" #include "fintamath/functions/IFunction.hpp" @@ -15,15 +15,13 @@ namespace fintamath { class Real; class Asech final : public IFunctionCRTP { + FINTAMATH_CLASS_BODY(Asech) + public: std::string toString() const override { return "asech"; } - static constexpr MathObjectType getTypeStatic() { - return {MathObjectType::Asech, "Asech"}; - } - protected: std::unique_ptr call(const ArgumentRefVector &argVect) const override; diff --git a/include/fintamath/functions/hyperbolic/Asinh.hpp b/include/fintamath/functions/hyperbolic/Asinh.hpp index 9b378346d..551861a8d 100644 --- a/include/fintamath/functions/hyperbolic/Asinh.hpp +++ b/include/fintamath/functions/hyperbolic/Asinh.hpp @@ -4,7 +4,7 @@ #include #include "fintamath/core/IMathObject.hpp" -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/functions/FunctionUtils.hpp" #include "fintamath/functions/IFunction.hpp" @@ -13,15 +13,13 @@ namespace fintamath { class Asinh final : public IFunctionCRTP { + FINTAMATH_CLASS_BODY(Asinh) + public: std::string toString() const override { return "asinh"; } - static constexpr MathObjectType getTypeStatic() { - return {MathObjectType::Asinh, "Asinh"}; - } - protected: std::unique_ptr call(const ArgumentRefVector &argVect) const override; diff --git a/include/fintamath/functions/hyperbolic/Atanh.hpp b/include/fintamath/functions/hyperbolic/Atanh.hpp index 8f642ac9f..a6cf9eb1d 100644 --- a/include/fintamath/functions/hyperbolic/Atanh.hpp +++ b/include/fintamath/functions/hyperbolic/Atanh.hpp @@ -4,7 +4,7 @@ #include #include "fintamath/core/IMathObject.hpp" -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/functions/FunctionUtils.hpp" #include "fintamath/functions/IFunction.hpp" @@ -15,15 +15,13 @@ namespace fintamath { class Real; class Atanh final : public IFunctionCRTP { + FINTAMATH_CLASS_BODY(Atanh) + public: std::string toString() const override { return "atanh"; } - static constexpr MathObjectType getTypeStatic() { - return {MathObjectType::Atanh, "Atanh"}; - } - protected: std::unique_ptr call(const ArgumentRefVector &argVect) const override; diff --git a/include/fintamath/functions/hyperbolic/Cosh.hpp b/include/fintamath/functions/hyperbolic/Cosh.hpp index d2559df27..56c28aea3 100644 --- a/include/fintamath/functions/hyperbolic/Cosh.hpp +++ b/include/fintamath/functions/hyperbolic/Cosh.hpp @@ -4,7 +4,7 @@ #include #include "fintamath/core/IMathObject.hpp" -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/functions/FunctionUtils.hpp" #include "fintamath/functions/IFunction.hpp" @@ -15,15 +15,13 @@ namespace fintamath { class Real; class Cosh final : public IFunctionCRTP { + FINTAMATH_CLASS_BODY(Cosh) + public: std::string toString() const override { return "cosh"; } - static constexpr MathObjectType getTypeStatic() { - return {MathObjectType::Cosh, "Cosh"}; - } - protected: std::unique_ptr call(const ArgumentRefVector &argVect) const override; diff --git a/include/fintamath/functions/hyperbolic/Coth.hpp b/include/fintamath/functions/hyperbolic/Coth.hpp index 217839289..ce9427450 100644 --- a/include/fintamath/functions/hyperbolic/Coth.hpp +++ b/include/fintamath/functions/hyperbolic/Coth.hpp @@ -4,7 +4,7 @@ #include #include "fintamath/core/IMathObject.hpp" -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/functions/FunctionUtils.hpp" #include "fintamath/functions/IFunction.hpp" @@ -13,15 +13,13 @@ namespace fintamath { class Coth final : public IFunctionCRTP { + FINTAMATH_CLASS_BODY(Coth) + public: std::string toString() const override { return "coth"; } - static constexpr MathObjectType getTypeStatic() { - return {MathObjectType::Coth, "Coth"}; - } - protected: std::unique_ptr call(const ArgumentRefVector &argVect) const override; diff --git a/include/fintamath/functions/hyperbolic/Csch.hpp b/include/fintamath/functions/hyperbolic/Csch.hpp index e6537f410..ee54f4c2b 100644 --- a/include/fintamath/functions/hyperbolic/Csch.hpp +++ b/include/fintamath/functions/hyperbolic/Csch.hpp @@ -4,7 +4,7 @@ #include #include "fintamath/core/IMathObject.hpp" -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/functions/FunctionUtils.hpp" #include "fintamath/functions/IFunction.hpp" @@ -15,15 +15,13 @@ namespace fintamath { class Real; class Csch final : public IFunctionCRTP { + FINTAMATH_CLASS_BODY(Csch) + public: std::string toString() const override { return "csch"; } - static constexpr MathObjectType getTypeStatic() { - return {MathObjectType::Csch, "Csch"}; - } - protected: std::unique_ptr call(const ArgumentRefVector &argVect) const override; diff --git a/include/fintamath/functions/hyperbolic/Sech.hpp b/include/fintamath/functions/hyperbolic/Sech.hpp index 1fe8ae655..f6ed88872 100644 --- a/include/fintamath/functions/hyperbolic/Sech.hpp +++ b/include/fintamath/functions/hyperbolic/Sech.hpp @@ -4,7 +4,7 @@ #include #include "fintamath/core/IMathObject.hpp" -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/functions/FunctionUtils.hpp" #include "fintamath/functions/IFunction.hpp" @@ -15,15 +15,13 @@ namespace fintamath { class Real; class Sech final : public IFunctionCRTP { + FINTAMATH_CLASS_BODY(Sech) + public: std::string toString() const override { return "sech"; } - static constexpr MathObjectType getTypeStatic() { - return {MathObjectType::Sech, "Sech"}; - } - protected: std::unique_ptr call(const ArgumentRefVector &argVect) const override; diff --git a/include/fintamath/functions/hyperbolic/Sinh.hpp b/include/fintamath/functions/hyperbolic/Sinh.hpp index c512f30e8..8331e9516 100644 --- a/include/fintamath/functions/hyperbolic/Sinh.hpp +++ b/include/fintamath/functions/hyperbolic/Sinh.hpp @@ -4,7 +4,7 @@ #include #include "fintamath/core/IMathObject.hpp" -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/functions/FunctionUtils.hpp" #include "fintamath/functions/IFunction.hpp" @@ -15,15 +15,13 @@ namespace fintamath { class Real; class Sinh final : public IFunctionCRTP { + FINTAMATH_CLASS_BODY(Sinh) + public: std::string toString() const override { return "sinh"; } - static constexpr MathObjectType getTypeStatic() { - return {MathObjectType::Sinh, "Sinh"}; - } - protected: std::unique_ptr call(const ArgumentRefVector &argVect) const override; diff --git a/include/fintamath/functions/hyperbolic/Tanh.hpp b/include/fintamath/functions/hyperbolic/Tanh.hpp index 3ea28aafe..fb2886ed3 100644 --- a/include/fintamath/functions/hyperbolic/Tanh.hpp +++ b/include/fintamath/functions/hyperbolic/Tanh.hpp @@ -4,7 +4,7 @@ #include #include "fintamath/core/IMathObject.hpp" -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/functions/FunctionUtils.hpp" #include "fintamath/functions/IFunction.hpp" @@ -13,15 +13,13 @@ namespace fintamath { class Tanh final : public IFunctionCRTP { + FINTAMATH_CLASS_BODY(Tanh) + public: std::string toString() const override { return "tanh"; } - static constexpr MathObjectType getTypeStatic() { - return {MathObjectType::Tanh, "Tanh"}; - } - protected: std::unique_ptr call(const ArgumentRefVector &argVect) const override; diff --git a/include/fintamath/functions/logarithms/Lb.hpp b/include/fintamath/functions/logarithms/Lb.hpp index fc8427a77..d90568704 100644 --- a/include/fintamath/functions/logarithms/Lb.hpp +++ b/include/fintamath/functions/logarithms/Lb.hpp @@ -4,7 +4,7 @@ #include #include "fintamath/core/IMathObject.hpp" -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/functions/FunctionUtils.hpp" #include "fintamath/functions/IFunction.hpp" @@ -13,15 +13,13 @@ namespace fintamath { class Lb final : public IFunctionCRTP { + FINTAMATH_CLASS_BODY(Lb) + public: std::string toString() const override { return "lb"; } - static constexpr MathObjectType getTypeStatic() { - return {MathObjectType::Lb, "Lb"}; - } - protected: std::unique_ptr call(const ArgumentRefVector &argVect) const override; }; diff --git a/include/fintamath/functions/logarithms/Lg.hpp b/include/fintamath/functions/logarithms/Lg.hpp index 57986f99f..b3ff5c05f 100644 --- a/include/fintamath/functions/logarithms/Lg.hpp +++ b/include/fintamath/functions/logarithms/Lg.hpp @@ -4,7 +4,7 @@ #include #include "fintamath/core/IMathObject.hpp" -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/functions/FunctionUtils.hpp" #include "fintamath/functions/IFunction.hpp" @@ -13,15 +13,13 @@ namespace fintamath { class Lg final : public IFunctionCRTP { + FINTAMATH_CLASS_BODY(Lg) + public: std::string toString() const override { return "lg"; } - static constexpr MathObjectType getTypeStatic() { - return {MathObjectType::Lg, "Lg"}; - } - protected: std::unique_ptr call(const ArgumentRefVector &argVect) const override; }; diff --git a/include/fintamath/functions/logarithms/Ln.hpp b/include/fintamath/functions/logarithms/Ln.hpp index 50ede8bcf..fb05931e7 100644 --- a/include/fintamath/functions/logarithms/Ln.hpp +++ b/include/fintamath/functions/logarithms/Ln.hpp @@ -4,7 +4,7 @@ #include #include "fintamath/core/IMathObject.hpp" -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/functions/FunctionUtils.hpp" #include "fintamath/functions/IFunction.hpp" @@ -13,15 +13,13 @@ namespace fintamath { class Ln final : public IFunctionCRTP { + FINTAMATH_CLASS_BODY(Ln) + public: std::string toString() const override { return "ln"; } - static constexpr MathObjectType getTypeStatic() { - return {MathObjectType::Ln, "Ln"}; - } - protected: std::unique_ptr call(const ArgumentRefVector &argVect) const override; diff --git a/include/fintamath/functions/logarithms/Log.hpp b/include/fintamath/functions/logarithms/Log.hpp index bd585c4dd..12c6fb427 100644 --- a/include/fintamath/functions/logarithms/Log.hpp +++ b/include/fintamath/functions/logarithms/Log.hpp @@ -4,7 +4,7 @@ #include #include "fintamath/core/IMathObject.hpp" -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/functions/FunctionUtils.hpp" #include "fintamath/functions/IFunction.hpp" @@ -16,15 +16,13 @@ namespace fintamath { class Log final : public IFunctionCRTP { + FINTAMATH_CLASS_BODY(Log) + public: std::string toString() const override { return "log"; } - static constexpr MathObjectType getTypeStatic() { - return {MathObjectType::Log, "Log"}; - } - protected: std::unique_ptr call(const ArgumentRefVector &argVect) const override; diff --git a/include/fintamath/functions/logic/And.hpp b/include/fintamath/functions/logic/And.hpp index fd15849c6..19670ded5 100644 --- a/include/fintamath/functions/logic/And.hpp +++ b/include/fintamath/functions/logic/And.hpp @@ -4,7 +4,7 @@ #include #include "fintamath/core/IMathObject.hpp" -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/functions/FunctionUtils.hpp" #include "fintamath/functions/IOperator.hpp" @@ -13,6 +13,8 @@ namespace fintamath { class And final : public IOperatorCRTP { + FINTAMATH_CLASS_BODY(And) + public: std::string toString() const override { return "&"; @@ -26,10 +28,6 @@ class And final : public IOperatorCRTP { return Priority::Conjunction; } - static constexpr MathObjectType getTypeStatic() { - return {MathObjectType::And, "And"}; - } - protected: std::unique_ptr call(const ArgumentRefVector &argVect) const override; }; diff --git a/include/fintamath/functions/logic/Equiv.hpp b/include/fintamath/functions/logic/Equiv.hpp index 72985223f..2022f5e26 100644 --- a/include/fintamath/functions/logic/Equiv.hpp +++ b/include/fintamath/functions/logic/Equiv.hpp @@ -4,7 +4,7 @@ #include #include "fintamath/core/IMathObject.hpp" -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/functions/FunctionUtils.hpp" #include "fintamath/functions/IOperator.hpp" @@ -13,6 +13,8 @@ namespace fintamath { class Equiv final : public IOperatorCRTP { + FINTAMATH_CLASS_BODY(Equiv) + public: std::string toString() const override { return "<->"; @@ -26,10 +28,6 @@ class Equiv final : public IOperatorCRTP { return Priority::Equivalence; } - static constexpr MathObjectType getTypeStatic() { - return {MathObjectType::Equiv, "Equiv"}; - } - protected: std::unique_ptr call(const ArgumentRefVector &argVect) const override; }; diff --git a/include/fintamath/functions/logic/Impl.hpp b/include/fintamath/functions/logic/Impl.hpp index 8b1321fcf..8b8598b0a 100644 --- a/include/fintamath/functions/logic/Impl.hpp +++ b/include/fintamath/functions/logic/Impl.hpp @@ -4,7 +4,7 @@ #include #include "fintamath/core/IMathObject.hpp" -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/functions/FunctionUtils.hpp" #include "fintamath/functions/IOperator.hpp" @@ -13,6 +13,8 @@ namespace fintamath { class Impl final : public IOperatorCRTP { + FINTAMATH_CLASS_BODY(Impl) + public: std::string toString() const override { return "->"; @@ -22,10 +24,6 @@ class Impl final : public IOperatorCRTP { return Priority::Implication; } - static constexpr MathObjectType getTypeStatic() { - return {MathObjectType::Impl, "Impl"}; - } - protected: std::unique_ptr call(const ArgumentRefVector &argVect) const override; }; diff --git a/include/fintamath/functions/logic/Nequiv.hpp b/include/fintamath/functions/logic/Nequiv.hpp index ee35f0d86..41f5fa9d9 100644 --- a/include/fintamath/functions/logic/Nequiv.hpp +++ b/include/fintamath/functions/logic/Nequiv.hpp @@ -4,7 +4,7 @@ #include #include "fintamath/core/IMathObject.hpp" -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/functions/FunctionUtils.hpp" #include "fintamath/functions/IOperator.hpp" @@ -13,6 +13,8 @@ namespace fintamath { class Nequiv final : public IOperatorCRTP { + FINTAMATH_CLASS_BODY(Nequiv) + public: std::string toString() const override { return "!<->"; @@ -26,10 +28,6 @@ class Nequiv final : public IOperatorCRTP { return Priority::Equivalence; } - static constexpr MathObjectType getTypeStatic() { - return {MathObjectType::Nequiv, "Nequiv"}; - } - protected: std::unique_ptr call(const ArgumentRefVector &argVect) const override; }; diff --git a/include/fintamath/functions/logic/Not.hpp b/include/fintamath/functions/logic/Not.hpp index 7074087c3..768a75251 100644 --- a/include/fintamath/functions/logic/Not.hpp +++ b/include/fintamath/functions/logic/Not.hpp @@ -4,7 +4,7 @@ #include #include "fintamath/core/IMathObject.hpp" -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/functions/FunctionUtils.hpp" #include "fintamath/functions/IOperator.hpp" @@ -13,6 +13,8 @@ namespace fintamath { class Not final : public IOperatorCRTP { + FINTAMATH_CLASS_BODY(Not) + public: std::string toString() const override { return "~"; @@ -22,10 +24,6 @@ class Not final : public IOperatorCRTP { return Priority::PrefixUnary; } - static constexpr MathObjectType getTypeStatic() { - return {MathObjectType::Not, "Not"}; - } - protected: std::unique_ptr call(const ArgumentRefVector &argVect) const override; }; diff --git a/include/fintamath/functions/logic/Or.hpp b/include/fintamath/functions/logic/Or.hpp index 49c97f146..d49a3b0eb 100644 --- a/include/fintamath/functions/logic/Or.hpp +++ b/include/fintamath/functions/logic/Or.hpp @@ -4,7 +4,7 @@ #include #include "fintamath/core/IMathObject.hpp" -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/functions/FunctionUtils.hpp" #include "fintamath/functions/IOperator.hpp" @@ -13,6 +13,8 @@ namespace fintamath { class Or final : public IOperatorCRTP { + FINTAMATH_CLASS_BODY(Or) + public: std::string toString() const override { return "|"; @@ -26,10 +28,6 @@ class Or final : public IOperatorCRTP { return Priority::Disjunction; } - static constexpr MathObjectType getTypeStatic() { - return {MathObjectType::Or, "Or"}; - } - protected: std::unique_ptr call(const ArgumentRefVector &argVect) const override; }; diff --git a/include/fintamath/functions/ntheory/Ceil.hpp b/include/fintamath/functions/ntheory/Ceil.hpp index 0920c05ef..cf41064f9 100644 --- a/include/fintamath/functions/ntheory/Ceil.hpp +++ b/include/fintamath/functions/ntheory/Ceil.hpp @@ -4,7 +4,7 @@ #include #include "fintamath/core/IMathObject.hpp" -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/functions/FunctionUtils.hpp" #include "fintamath/functions/IFunction.hpp" @@ -13,15 +13,13 @@ namespace fintamath { class Ceil final : public IFunctionCRTP { + FINTAMATH_CLASS_BODY(Ceil) + public: std::string toString() const override { return "ceil"; } - static constexpr MathObjectType getTypeStatic() { - return {MathObjectType::Ceil, "Ceil"}; - } - protected: std::unique_ptr call(const ArgumentRefVector &argVect) const override; diff --git a/include/fintamath/functions/ntheory/Floor.hpp b/include/fintamath/functions/ntheory/Floor.hpp index cd0ed71e2..9344450dd 100644 --- a/include/fintamath/functions/ntheory/Floor.hpp +++ b/include/fintamath/functions/ntheory/Floor.hpp @@ -4,7 +4,7 @@ #include #include "fintamath/core/IMathObject.hpp" -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/functions/FunctionUtils.hpp" #include "fintamath/functions/IFunction.hpp" @@ -13,15 +13,13 @@ namespace fintamath { class Floor final : public IFunctionCRTP { + FINTAMATH_CLASS_BODY(Floor) + public: std::string toString() const override { return "floor"; } - static constexpr MathObjectType getTypeStatic() { - return {MathObjectType::Floor, "Floor"}; - } - protected: std::unique_ptr call(const ArgumentRefVector &argVect) const override; diff --git a/include/fintamath/functions/ntheory/Mod.hpp b/include/fintamath/functions/ntheory/Mod.hpp index 51cdf8728..a581023b1 100644 --- a/include/fintamath/functions/ntheory/Mod.hpp +++ b/include/fintamath/functions/ntheory/Mod.hpp @@ -4,7 +4,7 @@ #include #include "fintamath/core/IMathObject.hpp" -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/functions/FunctionUtils.hpp" #include "fintamath/functions/IOperator.hpp" @@ -13,6 +13,8 @@ namespace fintamath { class Mod final : public IOperatorCRTP { + FINTAMATH_CLASS_BODY(Mod) + public: std::string toString() const override { return "mod"; @@ -22,10 +24,6 @@ class Mod final : public IOperatorCRTP { return Priority::Modulo; } - static constexpr MathObjectType getTypeStatic() { - return {MathObjectType::Mod, "Mod"}; - } - protected: std::unique_ptr call(const ArgumentRefVector &argVect) const override; diff --git a/include/fintamath/functions/other/Comma.hpp b/include/fintamath/functions/other/Comma.hpp index 5ea716b44..7ac4fd0b1 100644 --- a/include/fintamath/functions/other/Comma.hpp +++ b/include/fintamath/functions/other/Comma.hpp @@ -4,7 +4,7 @@ #include #include "fintamath/core/IMathObject.hpp" -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/functions/FunctionUtils.hpp" #include "fintamath/functions/IOperator.hpp" @@ -12,6 +12,8 @@ namespace fintamath { class Comma final : public IOperatorCRTP { + FINTAMATH_CLASS_BODY(Comma) + public: std::string toString() const override { return ","; @@ -25,10 +27,6 @@ class Comma final : public IOperatorCRTP call(const ArgumentRefVector &argVect) const override; }; diff --git a/include/fintamath/functions/other/Deg.hpp b/include/fintamath/functions/other/Deg.hpp index 6e8506df8..0044c627a 100644 --- a/include/fintamath/functions/other/Deg.hpp +++ b/include/fintamath/functions/other/Deg.hpp @@ -4,7 +4,7 @@ #include #include "fintamath/core/IMathObject.hpp" -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/functions/FunctionUtils.hpp" #include "fintamath/functions/IOperator.hpp" @@ -13,6 +13,8 @@ namespace fintamath { class Deg final : public IOperatorCRTP { + FINTAMATH_CLASS_BODY(Deg) + public: std::string toString() const override { return "deg"; @@ -22,10 +24,6 @@ class Deg final : public IOperatorCRTP { return Priority::PostfixUnary; } - static constexpr MathObjectType getTypeStatic() { - return {MathObjectType::Deg, "Deg"}; - } - protected: std::unique_ptr call(const ArgumentRefVector &argVect) const override; }; diff --git a/include/fintamath/functions/other/Factorial.hpp b/include/fintamath/functions/other/Factorial.hpp index 3214be448..4305359b5 100644 --- a/include/fintamath/functions/other/Factorial.hpp +++ b/include/fintamath/functions/other/Factorial.hpp @@ -6,7 +6,7 @@ #include #include "fintamath/core/IMathObject.hpp" -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/functions/FunctionUtils.hpp" #include "fintamath/functions/IOperator.hpp" @@ -19,6 +19,8 @@ class Rational; class Real; class Factorial final : public IOperatorCRTP { + FINTAMATH_CLASS_BODY(Factorial) + public: Factorial() = default; @@ -43,10 +45,6 @@ class Factorial final : public IOperatorCRTP { order = inOrder; } - static constexpr MathObjectType getTypeStatic() { - return {MathObjectType::Factorial, "Factorial"}; - } - protected: std::unique_ptr call(const ArgumentRefVector &argVect) const override; diff --git a/include/fintamath/functions/other/Index.hpp b/include/fintamath/functions/other/Index.hpp index 83c467cc7..bea96eec9 100644 --- a/include/fintamath/functions/other/Index.hpp +++ b/include/fintamath/functions/other/Index.hpp @@ -4,7 +4,7 @@ #include #include "fintamath/core/IMathObject.hpp" -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/functions/FunctionUtils.hpp" #include "fintamath/functions/IOperator.hpp" @@ -14,6 +14,8 @@ namespace fintamath { class Index final : public IOperatorCRTP { + FINTAMATH_CLASS_BODY(Index) + public: std::string toString() const override { return "_"; @@ -23,10 +25,6 @@ class Index final : public IOperatorCRTP { return Priority::Exponentiation; } - static constexpr MathObjectType getTypeStatic() { - return {MathObjectType::Index, "Index"}; - } - protected: std::unique_ptr call(const ArgumentRefVector &argVect) const override; }; diff --git a/include/fintamath/functions/other/Percent.hpp b/include/fintamath/functions/other/Percent.hpp index 4243de4e9..ad55fcf73 100644 --- a/include/fintamath/functions/other/Percent.hpp +++ b/include/fintamath/functions/other/Percent.hpp @@ -4,7 +4,7 @@ #include #include "fintamath/core/IMathObject.hpp" -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/functions/FunctionUtils.hpp" #include "fintamath/functions/IOperator.hpp" @@ -13,6 +13,8 @@ namespace fintamath { class Percent final : public IOperatorCRTP { + FINTAMATH_CLASS_BODY(Percent) + public: std::string toString() const override { return "%"; @@ -22,10 +24,6 @@ class Percent final : public IOperatorCRTP { return Priority::PostfixUnary; } - static constexpr MathObjectType getTypeStatic() { - return {MathObjectType::Percent, "Percent"}; - } - protected: std::unique_ptr call(const ArgumentRefVector &argVect) const override; }; diff --git a/include/fintamath/functions/powers/Exp.hpp b/include/fintamath/functions/powers/Exp.hpp index 0181c5f7f..c4e389b0b 100644 --- a/include/fintamath/functions/powers/Exp.hpp +++ b/include/fintamath/functions/powers/Exp.hpp @@ -4,7 +4,7 @@ #include #include "fintamath/core/IMathObject.hpp" -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/functions/FunctionUtils.hpp" #include "fintamath/functions/IFunction.hpp" @@ -13,15 +13,13 @@ namespace fintamath { class Exp final : public IFunctionCRTP { + FINTAMATH_CLASS_BODY(Exp) + public: std::string toString() const override { return "exp"; } - static constexpr MathObjectType getTypeStatic() { - return {MathObjectType::Exp, "Exp"}; - } - protected: std::unique_ptr call(const ArgumentRefVector &argVect) const override; }; diff --git a/include/fintamath/functions/powers/Pow.hpp b/include/fintamath/functions/powers/Pow.hpp index e36058302..9c34f396d 100644 --- a/include/fintamath/functions/powers/Pow.hpp +++ b/include/fintamath/functions/powers/Pow.hpp @@ -4,7 +4,7 @@ #include #include "fintamath/core/IMathObject.hpp" -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/functions/FunctionUtils.hpp" #include "fintamath/functions/IOperator.hpp" @@ -18,6 +18,8 @@ class Real; class Complex; class Pow final : public IOperatorCRTP { + FINTAMATH_CLASS_BODY(Pow) + public: std::string toString() const override { return "^"; @@ -27,10 +29,6 @@ class Pow final : public IOperatorCRTP { return Priority::Exponentiation; } - static constexpr MathObjectType getTypeStatic() { - return {MathObjectType::Pow, "Pow"}; - } - protected: std::unique_ptr call(const ArgumentRefVector &argVect) const override; diff --git a/include/fintamath/functions/powers/PowFunction.hpp b/include/fintamath/functions/powers/PowFunction.hpp index d255a54fe..f071108e0 100644 --- a/include/fintamath/functions/powers/PowFunction.hpp +++ b/include/fintamath/functions/powers/PowFunction.hpp @@ -5,22 +5,20 @@ #include "fintamath/core/IArithmetic.hpp" #include "fintamath/core/IMathObject.hpp" -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/functions/IFunction.hpp" namespace fintamath { class PowFunction final : public IFunctionCRTP { + FINTAMATH_CLASS_BODY(PowFunction) + public: std::string toString() const override { return "pow"; } - static constexpr MathObjectType getTypeStatic() { - return {MathObjectType::PowFunction, "PowFunction"}; - } - protected: std::unique_ptr call(const ArgumentRefVector &argVect) const override; }; diff --git a/include/fintamath/functions/powers/Root.hpp b/include/fintamath/functions/powers/Root.hpp index bba7834e8..05b77fe01 100644 --- a/include/fintamath/functions/powers/Root.hpp +++ b/include/fintamath/functions/powers/Root.hpp @@ -5,7 +5,7 @@ #include #include "fintamath/core/IMathObject.hpp" -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/functions/FunctionUtils.hpp" #include "fintamath/functions/IFunction.hpp" @@ -18,6 +18,8 @@ class Rational; class Real; class Root final : public IFunctionCRTP { + FINTAMATH_CLASS_BODY(Root) + using RootToFactorMap = std::map; public: @@ -25,10 +27,6 @@ class Root final : public IFunctionCRTP { return "root"; } - static constexpr MathObjectType getTypeStatic() { - return {MathObjectType::Root, "Root"}; - } - protected: std::unique_ptr call(const ArgumentRefVector &argVect) const override; diff --git a/include/fintamath/functions/powers/Sqr.hpp b/include/fintamath/functions/powers/Sqr.hpp index 0d4a16df3..a53051db4 100644 --- a/include/fintamath/functions/powers/Sqr.hpp +++ b/include/fintamath/functions/powers/Sqr.hpp @@ -4,7 +4,7 @@ #include #include "fintamath/core/IMathObject.hpp" -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/functions/FunctionUtils.hpp" #include "fintamath/functions/IFunction.hpp" @@ -13,15 +13,13 @@ namespace fintamath { class Sqr final : public IFunctionCRTP { + FINTAMATH_CLASS_BODY(Sqr) + public: std::string toString() const override { return "sqr"; } - static constexpr MathObjectType getTypeStatic() { - return {MathObjectType::Sqr, "Sqr"}; - } - protected: std::unique_ptr call(const ArgumentRefVector &argVect) const override; }; diff --git a/include/fintamath/functions/powers/Sqrt.hpp b/include/fintamath/functions/powers/Sqrt.hpp index 628a58526..1d360cb8a 100644 --- a/include/fintamath/functions/powers/Sqrt.hpp +++ b/include/fintamath/functions/powers/Sqrt.hpp @@ -4,7 +4,7 @@ #include #include "fintamath/core/IMathObject.hpp" -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/functions/FunctionUtils.hpp" #include "fintamath/functions/IFunction.hpp" @@ -13,15 +13,13 @@ namespace fintamath { class Sqrt final : public IFunctionCRTP { + FINTAMATH_CLASS_BODY(Sqrt) + public: std::string toString() const override { return "sqrt"; } - static constexpr MathObjectType getTypeStatic() { - return {MathObjectType::Sqrt, "Sqrt"}; - } - protected: std::unique_ptr call(const ArgumentRefVector &argVect) const override; }; diff --git a/include/fintamath/functions/trigonometry/Acos.hpp b/include/fintamath/functions/trigonometry/Acos.hpp index f7cc32c53..65eea4330 100644 --- a/include/fintamath/functions/trigonometry/Acos.hpp +++ b/include/fintamath/functions/trigonometry/Acos.hpp @@ -4,7 +4,7 @@ #include #include "fintamath/core/IMathObject.hpp" -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/functions/FunctionUtils.hpp" #include "fintamath/functions/IFunction.hpp" @@ -15,15 +15,13 @@ namespace fintamath { class Real; class Acos final : public IFunctionCRTP { + FINTAMATH_CLASS_BODY(Acos) + public: std::string toString() const override { return "acos"; } - static constexpr MathObjectType getTypeStatic() { - return {MathObjectType::Acos, "Acos"}; - } - protected: std::unique_ptr call(const ArgumentRefVector &argVect) const override; diff --git a/include/fintamath/functions/trigonometry/Acot.hpp b/include/fintamath/functions/trigonometry/Acot.hpp index 8cb355c5f..6729bb50e 100644 --- a/include/fintamath/functions/trigonometry/Acot.hpp +++ b/include/fintamath/functions/trigonometry/Acot.hpp @@ -4,7 +4,7 @@ #include #include "fintamath/core/IMathObject.hpp" -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/functions/FunctionUtils.hpp" #include "fintamath/functions/IFunction.hpp" @@ -13,15 +13,13 @@ namespace fintamath { class Acot final : public IFunctionCRTP { + FINTAMATH_CLASS_BODY(Acot) + public: std::string toString() const override { return "acot"; } - static constexpr MathObjectType getTypeStatic() { - return {MathObjectType::Acot, "Acot"}; - } - protected: std::unique_ptr call(const ArgumentRefVector &argVect) const override; diff --git a/include/fintamath/functions/trigonometry/Acsc.hpp b/include/fintamath/functions/trigonometry/Acsc.hpp index 172ea589c..816199d74 100644 --- a/include/fintamath/functions/trigonometry/Acsc.hpp +++ b/include/fintamath/functions/trigonometry/Acsc.hpp @@ -4,7 +4,7 @@ #include #include "fintamath/core/IMathObject.hpp" -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/functions/FunctionUtils.hpp" #include "fintamath/functions/IFunction.hpp" @@ -15,15 +15,13 @@ namespace fintamath { class Real; class Acsc final : public IFunctionCRTP { + FINTAMATH_CLASS_BODY(Acsc) + public: std::string toString() const override { return "acsc"; } - static constexpr MathObjectType getTypeStatic() { - return {MathObjectType::Acsc, "Acsc"}; - } - protected: std::unique_ptr call(const ArgumentRefVector &argVect) const override; diff --git a/include/fintamath/functions/trigonometry/Asec.hpp b/include/fintamath/functions/trigonometry/Asec.hpp index a54614057..85030f466 100644 --- a/include/fintamath/functions/trigonometry/Asec.hpp +++ b/include/fintamath/functions/trigonometry/Asec.hpp @@ -4,7 +4,7 @@ #include #include "fintamath/core/IMathObject.hpp" -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/functions/FunctionUtils.hpp" #include "fintamath/functions/IFunction.hpp" @@ -15,15 +15,13 @@ namespace fintamath { class Real; class Asec final : public IFunctionCRTP { + FINTAMATH_CLASS_BODY(Asec) + public: std::string toString() const override { return "asec"; } - static constexpr MathObjectType getTypeStatic() { - return {MathObjectType::Asec, "Asec"}; - } - protected: std::unique_ptr call(const ArgumentRefVector &argVect) const override; diff --git a/include/fintamath/functions/trigonometry/Asin.hpp b/include/fintamath/functions/trigonometry/Asin.hpp index 0c9cc140d..df451eb8b 100644 --- a/include/fintamath/functions/trigonometry/Asin.hpp +++ b/include/fintamath/functions/trigonometry/Asin.hpp @@ -4,7 +4,7 @@ #include #include "fintamath/core/IMathObject.hpp" -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/functions/FunctionUtils.hpp" #include "fintamath/functions/IFunction.hpp" @@ -15,15 +15,13 @@ namespace fintamath { class Real; class Asin final : public IFunctionCRTP { + FINTAMATH_CLASS_BODY(Asin) + public: std::string toString() const override { return "asin"; } - static constexpr MathObjectType getTypeStatic() { - return {MathObjectType::Asin, "Asin"}; - } - protected: std::unique_ptr call(const ArgumentRefVector &argVect) const override; diff --git a/include/fintamath/functions/trigonometry/Atan.hpp b/include/fintamath/functions/trigonometry/Atan.hpp index 5020409f8..86f70c35d 100644 --- a/include/fintamath/functions/trigonometry/Atan.hpp +++ b/include/fintamath/functions/trigonometry/Atan.hpp @@ -4,7 +4,7 @@ #include #include "fintamath/core/IMathObject.hpp" -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/functions/FunctionUtils.hpp" #include "fintamath/functions/IFunction.hpp" @@ -13,15 +13,13 @@ namespace fintamath { class Atan final : public IFunctionCRTP { + FINTAMATH_CLASS_BODY(Atan) + public: std::string toString() const override { return "atan"; } - static constexpr MathObjectType getTypeStatic() { - return {MathObjectType::Atan, "Atan"}; - } - protected: std::unique_ptr call(const ArgumentRefVector &argVect) const override; diff --git a/include/fintamath/functions/trigonometry/Cos.hpp b/include/fintamath/functions/trigonometry/Cos.hpp index e9f971511..29f5c7193 100644 --- a/include/fintamath/functions/trigonometry/Cos.hpp +++ b/include/fintamath/functions/trigonometry/Cos.hpp @@ -4,7 +4,7 @@ #include #include "fintamath/core/IMathObject.hpp" -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/functions/FunctionUtils.hpp" #include "fintamath/functions/IFunction.hpp" @@ -15,15 +15,13 @@ namespace fintamath { class Real; class Cos final : public IFunctionCRTP { + FINTAMATH_CLASS_BODY(Cos) + public: std::string toString() const override { return "cos"; } - static constexpr MathObjectType getTypeStatic() { - return {MathObjectType::Cos, "Cos"}; - } - protected: std::unique_ptr call(const ArgumentRefVector &argVect) const override; diff --git a/include/fintamath/functions/trigonometry/Cot.hpp b/include/fintamath/functions/trigonometry/Cot.hpp index dc5296204..dbb785145 100644 --- a/include/fintamath/functions/trigonometry/Cot.hpp +++ b/include/fintamath/functions/trigonometry/Cot.hpp @@ -4,7 +4,7 @@ #include #include "fintamath/core/IMathObject.hpp" -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/functions/FunctionUtils.hpp" #include "fintamath/functions/IFunction.hpp" @@ -15,15 +15,13 @@ namespace fintamath { class Real; class Cot final : public IFunctionCRTP { + FINTAMATH_CLASS_BODY(Cot) + public: std::string toString() const override { return "cot"; } - static constexpr MathObjectType getTypeStatic() { - return {MathObjectType::Cot, "Cot"}; - } - protected: std::unique_ptr call(const ArgumentRefVector &argVect) const override; diff --git a/include/fintamath/functions/trigonometry/Csc.hpp b/include/fintamath/functions/trigonometry/Csc.hpp index 2f79ca97b..b459c02d2 100644 --- a/include/fintamath/functions/trigonometry/Csc.hpp +++ b/include/fintamath/functions/trigonometry/Csc.hpp @@ -4,7 +4,7 @@ #include #include "fintamath/core/IMathObject.hpp" -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/functions/FunctionUtils.hpp" #include "fintamath/functions/IFunction.hpp" @@ -15,15 +15,13 @@ namespace fintamath { class Real; class Csc final : public IFunctionCRTP { + FINTAMATH_CLASS_BODY(Csc) + public: std::string toString() const override { return "csc"; } - static constexpr MathObjectType getTypeStatic() { - return {MathObjectType::Csc, "Csc"}; - } - protected: std::unique_ptr call(const ArgumentRefVector &argVect) const override; diff --git a/include/fintamath/functions/trigonometry/Sec.hpp b/include/fintamath/functions/trigonometry/Sec.hpp index 406ab3bd7..90d31543c 100644 --- a/include/fintamath/functions/trigonometry/Sec.hpp +++ b/include/fintamath/functions/trigonometry/Sec.hpp @@ -4,7 +4,7 @@ #include #include "fintamath/core/IMathObject.hpp" -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/functions/FunctionUtils.hpp" #include "fintamath/functions/IFunction.hpp" @@ -15,15 +15,13 @@ namespace fintamath { class Real; class Sec final : public IFunctionCRTP { + FINTAMATH_CLASS_BODY(Sec) + public: std::string toString() const override { return "sec"; } - static constexpr MathObjectType getTypeStatic() { - return {MathObjectType::Sec, "Sec"}; - } - protected: std::unique_ptr call(const ArgumentRefVector &argVect) const override; diff --git a/include/fintamath/functions/trigonometry/Sin.hpp b/include/fintamath/functions/trigonometry/Sin.hpp index fde454889..34c761adc 100644 --- a/include/fintamath/functions/trigonometry/Sin.hpp +++ b/include/fintamath/functions/trigonometry/Sin.hpp @@ -4,7 +4,7 @@ #include #include "fintamath/core/IMathObject.hpp" -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/functions/FunctionUtils.hpp" #include "fintamath/functions/IFunction.hpp" @@ -15,15 +15,13 @@ namespace fintamath { class Real; class Sin final : public IFunctionCRTP { + FINTAMATH_CLASS_BODY(Sin) + public: std::string toString() const override { return "sin"; } - static constexpr MathObjectType getTypeStatic() { - return {MathObjectType::Sin, "Sin"}; - } - protected: std::unique_ptr call(const ArgumentRefVector &argVect) const override; diff --git a/include/fintamath/functions/trigonometry/Tan.hpp b/include/fintamath/functions/trigonometry/Tan.hpp index 6c712d748..0ef5bde12 100644 --- a/include/fintamath/functions/trigonometry/Tan.hpp +++ b/include/fintamath/functions/trigonometry/Tan.hpp @@ -4,7 +4,7 @@ #include #include "fintamath/core/IMathObject.hpp" -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/functions/FunctionUtils.hpp" #include "fintamath/functions/IFunction.hpp" @@ -15,15 +15,13 @@ namespace fintamath { class Real; class Tan final : public IFunctionCRTP { + FINTAMATH_CLASS_BODY(Tan) + public: std::string toString() const override { return "tan"; } - static constexpr MathObjectType getTypeStatic() { - return {MathObjectType::Tan, "Tan"}; - } - protected: std::unique_ptr call(const ArgumentRefVector &argVect) const override; diff --git a/include/fintamath/literals/Boolean.hpp b/include/fintamath/literals/Boolean.hpp index 021d164d9..29e326726 100644 --- a/include/fintamath/literals/Boolean.hpp +++ b/include/fintamath/literals/Boolean.hpp @@ -2,12 +2,14 @@ #include -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.hpp" #include "fintamath/literals/ILiteral.hpp" namespace fintamath { class Boolean final : public ILiteralCRTP { + FINTAMATH_CLASS_BODY(Boolean) + public: Boolean(); @@ -19,10 +21,6 @@ class Boolean final : public ILiteralCRTP { operator bool() const; - static constexpr MathObjectType getTypeStatic() { - return {MathObjectType::Boolean, "Boolean"}; - } - private: std::string name; }; diff --git a/include/fintamath/literals/ILiteral.hpp b/include/fintamath/literals/ILiteral.hpp index 7a8fc7726..9b9b7fc97 100644 --- a/include/fintamath/literals/ILiteral.hpp +++ b/include/fintamath/literals/ILiteral.hpp @@ -6,41 +6,19 @@ #include #include "fintamath/core/IMathObject.hpp" -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.hpp" #include "fintamath/core/Parser.hpp" namespace fintamath { class ILiteral : public IMathObject { - using LiteralParser = detail::Parser()>; - -public: - static std::unique_ptr parse(const std::string &str) { - return getParser().parse(str); - } - - template T> - static void registerType() { - getParser().registerType(); - } - - static void registerType(LiteralParser::StringConstructor constructor) { - getParser().registerType(std::move(constructor)); - } - - static constexpr MathObjectType getTypeStatic() { - return {MathObjectType::ILiteral, "ILiteral"}; - } - -private: - static LiteralParser &getParser(); + FINTAMATH_PARENT_CLASS_BODY(ILiteral) }; template class ILiteralCRTP : public ILiteral { #define I_LITERAL_CRTP ILiteralCRTP #include "fintamath/literals/ILiteralCRTP.hpp" - #undef I_LITERAL_CRTP }; diff --git a/include/fintamath/literals/Variable.hpp b/include/fintamath/literals/Variable.hpp index 3ae8ed9fc..a879e6fb9 100644 --- a/include/fintamath/literals/Variable.hpp +++ b/include/fintamath/literals/Variable.hpp @@ -2,13 +2,15 @@ #include -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.hpp" #include "fintamath/literals/ILiteral.hpp" #include "fintamath/numbers/Integer.hpp" namespace fintamath { class Variable final : public ILiteralCRTP { + FINTAMATH_CLASS_BODY(Variable) + public: explicit Variable(std::string inName); @@ -16,10 +18,6 @@ class Variable final : public ILiteralCRTP { std::string toString() const override; - static constexpr MathObjectType getTypeStatic() { - return {MathObjectType::Variable, "Variable"}; - } - private: std::string name; diff --git a/include/fintamath/literals/constants/ComplexInf.hpp b/include/fintamath/literals/constants/ComplexInf.hpp index 47ca70050..80ae57ed1 100644 --- a/include/fintamath/literals/constants/ComplexInf.hpp +++ b/include/fintamath/literals/constants/ComplexInf.hpp @@ -4,22 +4,20 @@ #include #include "fintamath/core/IMathObject.hpp" -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.hpp" #include "fintamath/literals/constants/IConstant.hpp" #include "fintamath/numbers/INumber.hpp" namespace fintamath { class ComplexInf final : public IConstantCRTP { + FINTAMATH_CLASS_BODY(ComplexInf) + public: std::string toString() const override { return "ComplexInf"; } - static constexpr MathObjectType getTypeStatic() { - return {MathObjectType::ComplexInf, "ComplexInf"}; - } - protected: std::unique_ptr call() const override; }; diff --git a/include/fintamath/literals/constants/E.hpp b/include/fintamath/literals/constants/E.hpp index 7c5fa17b6..50eb52f50 100644 --- a/include/fintamath/literals/constants/E.hpp +++ b/include/fintamath/literals/constants/E.hpp @@ -4,22 +4,20 @@ #include #include "fintamath/core/IMathObject.hpp" -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.hpp" #include "fintamath/literals/constants/IConstant.hpp" #include "fintamath/numbers/Real.hpp" namespace fintamath { class E final : public IConstantCRTP { + FINTAMATH_CLASS_BODY(E) + public: std::string toString() const override { return "E"; } - static constexpr MathObjectType getTypeStatic() { - return {MathObjectType::E, "E"}; - } - protected: std::unique_ptr call() const override; }; diff --git a/include/fintamath/literals/constants/False.hpp b/include/fintamath/literals/constants/False.hpp index 1967ae0fe..44f565456 100644 --- a/include/fintamath/literals/constants/False.hpp +++ b/include/fintamath/literals/constants/False.hpp @@ -4,22 +4,20 @@ #include #include "fintamath/core/IMathObject.hpp" -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.hpp" #include "fintamath/literals/Boolean.hpp" #include "fintamath/literals/constants/IConstant.hpp" namespace fintamath { class False final : public IConstantCRTP { + FINTAMATH_CLASS_BODY(False) + public: std::string toString() const override { return Boolean(false).toString(); } - static constexpr MathObjectType getTypeStatic() { - return {MathObjectType::False, "False"}; - } - protected: std::unique_ptr call() const override; }; diff --git a/include/fintamath/literals/constants/I.hpp b/include/fintamath/literals/constants/I.hpp index 292283ea6..23805d11d 100644 --- a/include/fintamath/literals/constants/I.hpp +++ b/include/fintamath/literals/constants/I.hpp @@ -4,22 +4,20 @@ #include #include "fintamath/core/IMathObject.hpp" -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.hpp" #include "fintamath/literals/constants/IConstant.hpp" #include "fintamath/numbers/Complex.hpp" namespace fintamath { class I final : public IConstantCRTP { + FINTAMATH_CLASS_BODY(I) + public: std::string toString() const override { return "I"; } - static constexpr MathObjectType getTypeStatic() { - return {MathObjectType::I, "I"}; - } - protected: std::unique_ptr call() const override; }; diff --git a/include/fintamath/literals/constants/IConstant.hpp b/include/fintamath/literals/constants/IConstant.hpp index 23bf67d5a..b641d5fcc 100644 --- a/include/fintamath/literals/constants/IConstant.hpp +++ b/include/fintamath/literals/constants/IConstant.hpp @@ -5,40 +5,24 @@ #include #include "fintamath/core/IMathObject.hpp" -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.hpp" #include "fintamath/core/Parser.hpp" #include "fintamath/literals/ILiteral.hpp" namespace fintamath { class IConstant : public ILiteral { - using ConstantParser = detail::Parser()>; + FINTAMATH_PARENT_CLASS_BODY(IConstant) public: - virtual MathObjectType getReturnType() const = 0; + virtual MathObjectClass getReturnClass() const = 0; std::unique_ptr operator()() const { return call(); } - static std::unique_ptr parse(const std::string &parsedStr) { - return getParser().parse(parsedStr); - } - - template T> - static void registerType() { - getParser().registerType(); - } - - static constexpr MathObjectType getTypeStatic() { - return {MathObjectType::IConstant, "IConstant"}; - } - protected: virtual std::unique_ptr call() const = 0; - -private: - static ConstantParser &getParser(); }; template diff --git a/include/fintamath/literals/constants/IConstantCRTP.hpp b/include/fintamath/literals/constants/IConstantCRTP.hpp index 0bd61d45f..7d28d8c4e 100644 --- a/include/fintamath/literals/constants/IConstantCRTP.hpp +++ b/include/fintamath/literals/constants/IConstantCRTP.hpp @@ -14,8 +14,8 @@ class IConstantCRTP_ : public IConstant { #undef I_LITERAL_CRTP public: - MathObjectType getReturnType() const final { - return Return::getTypeStatic(); + MathObjectClass getReturnClass() const final { + return Return::getClassStatic(); } private: diff --git a/include/fintamath/literals/constants/Inf.hpp b/include/fintamath/literals/constants/Inf.hpp index fab3e282a..09f0f7141 100644 --- a/include/fintamath/literals/constants/Inf.hpp +++ b/include/fintamath/literals/constants/Inf.hpp @@ -4,22 +4,20 @@ #include #include "fintamath/core/IMathObject.hpp" -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.hpp" #include "fintamath/literals/constants/IConstant.hpp" #include "fintamath/numbers/INumber.hpp" namespace fintamath { class Inf final : public IConstantCRTP { + FINTAMATH_CLASS_BODY(Inf) + public: std::string toString() const override { return "Inf"; } - static constexpr MathObjectType getTypeStatic() { - return {MathObjectType::Inf, "Inf"}; - } - protected: std::unique_ptr call() const override; }; diff --git a/include/fintamath/literals/constants/NegInf.hpp b/include/fintamath/literals/constants/NegInf.hpp index 5486eac4b..aa2aea146 100644 --- a/include/fintamath/literals/constants/NegInf.hpp +++ b/include/fintamath/literals/constants/NegInf.hpp @@ -4,22 +4,20 @@ #include #include "fintamath/core/IMathObject.hpp" -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.hpp" #include "fintamath/literals/constants/IConstant.hpp" #include "fintamath/numbers/INumber.hpp" namespace fintamath { class NegInf final : public IConstantCRTP { + FINTAMATH_CLASS_BODY(NegInf) + public: std::string toString() const override { return "-Inf"; } - static constexpr MathObjectType getTypeStatic() { - return {MathObjectType::NegInf, "NegInf"}; - } - protected: std::unique_ptr call() const override; }; diff --git a/include/fintamath/literals/constants/Pi.hpp b/include/fintamath/literals/constants/Pi.hpp index 56f2cc23b..b586cfc78 100644 --- a/include/fintamath/literals/constants/Pi.hpp +++ b/include/fintamath/literals/constants/Pi.hpp @@ -4,22 +4,20 @@ #include #include "fintamath/core/IMathObject.hpp" -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.hpp" #include "fintamath/literals/constants/IConstant.hpp" #include "fintamath/numbers/Real.hpp" namespace fintamath { class Pi final : public IConstantCRTP { + FINTAMATH_CLASS_BODY(Pi) + public: std::string toString() const override { return "Pi"; } - static constexpr MathObjectType getTypeStatic() { - return {MathObjectType::Pi, "Pi"}; - } - protected: std::unique_ptr call() const override; }; diff --git a/include/fintamath/literals/constants/True.hpp b/include/fintamath/literals/constants/True.hpp index 0be168c10..5fc092b39 100644 --- a/include/fintamath/literals/constants/True.hpp +++ b/include/fintamath/literals/constants/True.hpp @@ -4,22 +4,20 @@ #include #include "fintamath/core/IMathObject.hpp" -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.hpp" #include "fintamath/literals/Boolean.hpp" #include "fintamath/literals/constants/IConstant.hpp" namespace fintamath { class True final : public IConstantCRTP { + FINTAMATH_CLASS_BODY(True) + public: std::string toString() const override { return Boolean(true).toString(); } - static constexpr MathObjectType getTypeStatic() { - return {MathObjectType::True, "True"}; - } - protected: std::unique_ptr call() const override; }; diff --git a/include/fintamath/literals/constants/Undefined.hpp b/include/fintamath/literals/constants/Undefined.hpp index 4959cedc2..116f4427d 100644 --- a/include/fintamath/literals/constants/Undefined.hpp +++ b/include/fintamath/literals/constants/Undefined.hpp @@ -5,21 +5,19 @@ #include "fintamath/core/IArithmetic.hpp" #include "fintamath/core/IMathObject.hpp" -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.hpp" #include "fintamath/literals/constants/IConstant.hpp" namespace fintamath { class Undefined final : public IConstantCRTP { + FINTAMATH_CLASS_BODY(Undefined) + public: std::string toString() const override { return "Undefined"; } - static constexpr MathObjectType getTypeStatic() { - return {MathObjectType::Undefined, "Undefined"}; - } - protected: std::unique_ptr call() const override; }; diff --git a/include/fintamath/numbers/Complex.hpp b/include/fintamath/numbers/Complex.hpp index b4188d3ed..e34bfde6a 100644 --- a/include/fintamath/numbers/Complex.hpp +++ b/include/fintamath/numbers/Complex.hpp @@ -6,7 +6,7 @@ #include #include "fintamath/core/IMathObject.hpp" -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.hpp" #include "fintamath/numbers/INumber.hpp" #include "fintamath/numbers/Integer.hpp" #include "fintamath/numbers/Rational.hpp" @@ -15,6 +15,8 @@ namespace fintamath { class Complex final : public INumberCRTP { + FINTAMATH_CLASS_BODY(Complex) + public: Complex() = default; @@ -52,10 +54,6 @@ class Complex final : public INumberCRTP { const INumber &imag() const; - static constexpr MathObjectType getTypeStatic() { - return {MathObjectType::Complex, "Complex"}; - } - protected: bool equals(const Complex &rhs) const override; @@ -71,8 +69,12 @@ class Complex final : public INumberCRTP { Complex &negate() override; +private: + static std::unique_ptr parseNonComplexNumber(const std::string &str); + private: std::unique_ptr re = std::make_unique(0); + std::unique_ptr im = std::make_unique(0); }; diff --git a/include/fintamath/numbers/IInteger.hpp b/include/fintamath/numbers/IInteger.hpp index 7a6eac8ba..93f4fe2db 100644 --- a/include/fintamath/numbers/IInteger.hpp +++ b/include/fintamath/numbers/IInteger.hpp @@ -4,15 +4,15 @@ #include #include -#include "fintamath/core/CoreUtils.hpp" -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.hpp" +#include "fintamath/core/MathObjectUtils.hpp" #include "fintamath/core/Parser.hpp" #include "fintamath/numbers/INumber.hpp" namespace fintamath { class IInteger : public INumber { - using IntegerParser = detail::Parser()>; + FINTAMATH_PARENT_CLASS_BODY(IInteger) public: friend std::unique_ptr operator%(const IInteger &lhs, const IInteger &rhs) { @@ -63,19 +63,6 @@ class IInteger : public INumber { return res; } - static std::unique_ptr parse(const std::string &str) { - return getParser().parse(str); - } - - template T> - static void registerType() { - getParser().registerType(); - } - - static constexpr MathObjectType getTypeStatic() { - return {MathObjectType::IInteger, "IInteger"}; - } - protected: virtual std::unique_ptr modAbstract(const IInteger &rhs) const = 0; @@ -94,9 +81,6 @@ class IInteger : public INumber { virtual IInteger &increaseAbstract() = 0; virtual IInteger &decreaseAbstract() = 0; - -private: - static IntegerParser &getParser(); }; template diff --git a/include/fintamath/numbers/INumber.hpp b/include/fintamath/numbers/INumber.hpp index 0527d6112..de33d7f0e 100644 --- a/include/fintamath/numbers/INumber.hpp +++ b/include/fintamath/numbers/INumber.hpp @@ -5,16 +5,16 @@ #include #include -#include "fintamath/core/CoreUtils.hpp" #include "fintamath/core/IArithmetic.hpp" #include "fintamath/core/IComparable.hpp" -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.hpp" +#include "fintamath/core/MathObjectUtils.hpp" #include "fintamath/core/Parser.hpp" namespace fintamath { class INumber : public IComparable { - using NumberParser = detail::Parser()>; + FINTAMATH_PARENT_CLASS_BODY(INumber) public: virtual bool isPrecise() const { @@ -24,26 +24,6 @@ class INumber : public IComparable { virtual bool isComplex() const { return false; } - - static std::unique_ptr parse(const std::string &str) { - return getParser().parse(str); - } - - template T> - static void registerType() { - getParser().registerType(); - } - - static void registerType(NumberParser::StringConstructor constructor) { - getParser().registerType(std::move(constructor)); - } - - static constexpr MathObjectType getTypeStatic() { - return {MathObjectType::INumber, "INumber"}; - } - -private: - static NumberParser &getParser(); }; inline std::unique_ptr operator+(const INumber &lhs, const INumber &rhs) { diff --git a/include/fintamath/numbers/Integer.hpp b/include/fintamath/numbers/Integer.hpp index 1e73a317b..029f10544 100644 --- a/include/fintamath/numbers/Integer.hpp +++ b/include/fintamath/numbers/Integer.hpp @@ -12,12 +12,14 @@ #include #include "fintamath/core/IArithmetic.hpp" -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.hpp" #include "fintamath/numbers/IInteger.hpp" namespace fintamath { class Integer final : public IIntegerCRTP { + FINTAMATH_CLASS_BODY(Integer) + public: using Backend = boost::multiprecision::mpz_int; @@ -44,10 +46,6 @@ class Integer final : public IIntegerCRTP { return backend.convert_to(); } - static constexpr MathObjectType getTypeStatic() { - return {MathObjectType::Integer, "Integer"}; - } - protected: bool equals(const Integer &rhs) const override; diff --git a/include/fintamath/numbers/Rational.hpp b/include/fintamath/numbers/Rational.hpp index 153e9638c..2f5fff71b 100644 --- a/include/fintamath/numbers/Rational.hpp +++ b/include/fintamath/numbers/Rational.hpp @@ -10,13 +10,15 @@ #include "fintamath/core/IArithmetic.hpp" #include "fintamath/core/IMathObject.hpp" -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.hpp" #include "fintamath/numbers/INumber.hpp" #include "fintamath/numbers/Integer.hpp" namespace fintamath { class Rational final : public INumberCRTP { + FINTAMATH_CLASS_BODY(Rational) + public: Rational() = default; @@ -38,10 +40,6 @@ class Rational final : public INumberCRTP { const Integer &denominator() const; - static constexpr MathObjectType getTypeStatic() { - return {MathObjectType::Rational, "Rational"}; - } - protected: bool equals(const Rational &rhs) const override; diff --git a/include/fintamath/numbers/Real.hpp b/include/fintamath/numbers/Real.hpp index c13c30168..24c7e4a98 100644 --- a/include/fintamath/numbers/Real.hpp +++ b/include/fintamath/numbers/Real.hpp @@ -13,7 +13,7 @@ #include "fintamath/core/IArithmetic.hpp" #include "fintamath/core/IComparable.hpp" #include "fintamath/core/IMathObject.hpp" -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.hpp" #include "fintamath/numbers/INumber.hpp" #include "fintamath/numbers/Integer.hpp" #include "fintamath/numbers/Rational.hpp" @@ -21,6 +21,8 @@ namespace fintamath { class Real final : public INumberCRTP { + FINTAMATH_CLASS_BODY(Real) + public: using Backend = boost::multiprecision::mpfr_float; @@ -72,10 +74,6 @@ class Real final : public INumberCRTP { static void setPrecision(unsigned precision); - static constexpr MathObjectType getTypeStatic() { - return {MathObjectType::Real, "Real"}; - } - protected: bool equals(const Real &rhs) const override; diff --git a/src/fintamath/config/Config.cpp b/src/fintamath/config/Config.cpp index b56723048..9dab57d4e 100644 --- a/src/fintamath/config/Config.cpp +++ b/src/fintamath/config/Config.cpp @@ -2,14 +2,14 @@ #include "fintamath/config/ConverterConfig.hpp" #include "fintamath/config/ExpressionConfig.hpp" -#include "fintamath/config/ParserConfig.hpp" #include "fintamath/config/PrecisionConfig.hpp" +#include "fintamath/config/TypeConfig.hpp" namespace fintamath::detail { Config::Config() { + [[maybe_unused]] static const TypeConfig typeConfig; [[maybe_unused]] static const PrecisionConfig precisionConfig; - [[maybe_unused]] static const ParserConfig parserConfig; [[maybe_unused]] static const ConverterConfig converterConfig; [[maybe_unused]] static const ExpressionConfig expressionConfig; } diff --git a/src/fintamath/config/ExpressionConfig.cpp b/src/fintamath/config/ExpressionConfig.cpp index 623ddc51d..bc98453b8 100644 --- a/src/fintamath/config/ExpressionConfig.cpp +++ b/src/fintamath/config/ExpressionConfig.cpp @@ -3,8 +3,7 @@ #include #include -#include "fintamath/core/CoreUtils.hpp" -#include "fintamath/core/Tokenizer.hpp" +#include "fintamath/core/MathObjectUtils.hpp" #include "fintamath/expressions/Expression.hpp" #include "fintamath/expressions/binary/CompExpr.hpp" #include "fintamath/expressions/binary/DerivativeExpr.hpp" @@ -97,48 +96,12 @@ namespace fintamath::detail { -namespace { - -void registerTermParsers() { - Expression::registerTermParser([](const Token &token) { - if (auto arg = IOperator::parse(token, 2)) { - return std::make_unique(token, std::move(arg)); - } - - if (auto arg = IOperator::parse(token, 1)) { - return std::make_unique(token, std::move(arg)); - } - - if (auto arg = IFunction::parse(token)) { - return std::make_unique(token, std::move(arg)); - } - - return std::unique_ptr{}; - }); - - Expression::registerTermParser([](const Token &token) { - if (auto arg = ILiteral::parse(token)) { - return std::make_unique(token, std::move(arg)); - } - - return std::unique_ptr{}; - }); - - Expression::registerTermParser([](const Token &token) { - if (auto arg = INumber::parse(token)) { - return std::make_unique(token, std::move(arg)); - } - - return std::unique_ptr{}; - }); -} - -void registerFunctionExpressionMakers() { - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector &&args) { +ExpressionConfig::ExpressionConfig() { + Expression::registerExpressionConstructor([](ArgumentPtrVector &&args) { return AddExpr(std::move(args)).clone(); }); - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector args) { + Expression::registerExpressionConstructor([](ArgumentPtrVector args) { ArgumentPtr lhs = std::move(args.front()); ArgumentPtr rhs = std::move(args.back()); @@ -147,19 +110,19 @@ void registerFunctionExpressionMakers() { return AddExpr({std::move(lhs), std::move(negRhs)}).clone(); }); - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector &&args) { + Expression::registerExpressionConstructor([](ArgumentPtrVector &&args) { return MulExpr(std::move(args)).clone(); }); - Expression::registerFunctionExpressionMaker
([](ArgumentPtrVector args) { + Expression::registerExpressionConstructor
([](ArgumentPtrVector args) { return DivExpr(std::move(args.front()), std::move(args.back())).clone(); }); - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector &&args) { + Expression::registerExpressionConstructor([](ArgumentPtrVector &&args) { return divExpr(std::move(args)); }); - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector args) { + Expression::registerExpressionConstructor([](ArgumentPtrVector args) { ArgumentPtr integ = std::move(args[0]); ArgumentPtr numer = std::move(args[1]); ArgumentPtr denom = std::move(args[2]); @@ -167,47 +130,47 @@ void registerFunctionExpressionMakers() { return addExpr(std::move(integ), divExpr(std::move(numer), std::move(denom))); }); - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector &&args) { + Expression::registerExpressionConstructor([](ArgumentPtrVector &&args) { return AndExpr(std::move(args)).clone(); }); - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector &&args) { + Expression::registerExpressionConstructor([](ArgumentPtrVector &&args) { return OrExpr(std::move(args)).clone(); }); - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector args) { + Expression::registerExpressionConstructor([](ArgumentPtrVector args) { return PowExpr(std::move(args.front()), std::move(args.back())).clone(); }); - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector &&args) { + Expression::registerExpressionConstructor([](ArgumentPtrVector &&args) { return powExpr(std::move(args)); }); - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector args) { + Expression::registerExpressionConstructor([](ArgumentPtrVector args) { return CompExpr(Eqv{}, std::move(args.front()), std::move(args.back())).clone(); }); - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector args) { + Expression::registerExpressionConstructor([](ArgumentPtrVector args) { return CompExpr(Neqv{}, std::move(args.front()), std::move(args.back())).clone(); }); - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector args) { + Expression::registerExpressionConstructor([](ArgumentPtrVector args) { return CompExpr(Less{}, std::move(args.front()), std::move(args.back())).clone(); }); - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector args) { + Expression::registerExpressionConstructor([](ArgumentPtrVector args) { return CompExpr(More{}, std::move(args.front()), std::move(args.back())).clone(); }); - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector args) { + Expression::registerExpressionConstructor([](ArgumentPtrVector args) { return CompExpr(LessEqv{}, std::move(args.front()), std::move(args.back())).clone(); }); - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector args) { + Expression::registerExpressionConstructor([](ArgumentPtrVector args) { return CompExpr(MoreEqv{}, std::move(args.front()), std::move(args.back())).clone(); }); - Expression::registerFunctionExpressionMaker([](const ArgumentPtrVector &args) { + Expression::registerExpressionConstructor([](const ArgumentPtrVector &args) { static const Index indexFunc; const ArgumentPtr &lhs = args.front(); @@ -220,7 +183,7 @@ void registerFunctionExpressionMakers() { return Expression(indexFunc(*lhs, *rhs)).clone(); // TODO: looks weird }); - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector args) { + Expression::registerExpressionConstructor([](ArgumentPtrVector args) { ArgumentPtr lhs = std::move(args.front()); ArgumentPtr rhs = std::move(args.back()); @@ -229,7 +192,7 @@ void registerFunctionExpressionMakers() { return orExpr(std::move(notLhs), std::move(rhs)); }); - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector args) { + Expression::registerExpressionConstructor([](ArgumentPtrVector args) { ArgumentPtr lhs = std::move(args.front()); ArgumentPtr rhs = std::move(args.back()); @@ -242,7 +205,7 @@ void registerFunctionExpressionMakers() { return orExpr(std::move(lhsAndRhs), std::move(notLhsAndNotRhs)); }); - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector args) { + Expression::registerExpressionConstructor([](ArgumentPtrVector args) { ArgumentPtr lhs = std::move(args.front()); ArgumentPtr rhs = std::move(args.back()); @@ -255,75 +218,75 @@ void registerFunctionExpressionMakers() { return orExpr(std::move(notLhsAndRhs), std::move(lhsAndNotRhs)); }); - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector args) { + Expression::registerExpressionConstructor([](ArgumentPtrVector args) { static const ArgumentPtr negOne = Integer(-1).clone(); return mulExpr(negOne, std::move(args.front())); }); - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector args) { + Expression::registerExpressionConstructor([](ArgumentPtrVector args) { return std::move(args.front())->clone(); }); - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector args) { + Expression::registerExpressionConstructor([](ArgumentPtrVector args) { return NotExpr(std::move(args.front())).clone(); }); - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector args) { + Expression::registerExpressionConstructor([](ArgumentPtrVector args) { return DerivativeExpr(std::move(args.front()), std::move(args.back())).clone(); }); - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector args) { + Expression::registerExpressionConstructor([](ArgumentPtrVector args) { return IntegralExpr(std::move(args.front()), std::move(args.back())).clone(); }); - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector args) { + Expression::registerExpressionConstructor([](ArgumentPtrVector args) { return LogExpr(std::move(args.front()), std::move(args.back())).clone(); }); - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector args) { + Expression::registerExpressionConstructor([](ArgumentPtrVector args) { static const ArgumentPtr logBase = E{}.clone(); return logExpr(logBase, std::move(args.front())); }); - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector args) { + Expression::registerExpressionConstructor([](ArgumentPtrVector args) { static const ArgumentPtr logBase = Integer(2).clone(); return logExpr(logBase, std::move(args.front())); }); - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector args) { + Expression::registerExpressionConstructor([](ArgumentPtrVector args) { static const ArgumentPtr logBase = Integer(10).clone(); return logExpr(logBase, std::move(args.front())); }); - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector args) { + Expression::registerExpressionConstructor([](ArgumentPtrVector args) { static const ArgumentPtr powBase = E{}.clone(); return powExpr(powBase, std::move(args.front())); }); - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector args) { + Expression::registerExpressionConstructor([](ArgumentPtrVector args) { static const ArgumentPtr percentValue = Integer(100).clone(); return divExpr(std::move(args.front()), percentValue); }); - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector &&args) { + Expression::registerExpressionConstructor([](ArgumentPtrVector &&args) { return MinMaxExpr(Min{}, std::move(args)).clone(); }); - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector &&args) { + Expression::registerExpressionConstructor([](ArgumentPtrVector &&args) { return MinMaxExpr(Max{}, std::move(args)).clone(); }); - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector args) { + Expression::registerExpressionConstructor([](ArgumentPtrVector args) { static const ArgumentPtr powRate = Integer(2).clone(); return powExpr(std::move(args.front()), powRate); }); - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector args) { + Expression::registerExpressionConstructor([](ArgumentPtrVector args) { static const ArgumentPtr powRate = Rational(1, 2).clone(); return powExpr(std::move(args.front()), powRate); }); - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector args) { + Expression::registerExpressionConstructor([](ArgumentPtrVector args) { ArgumentPtr lhs = std::move(args.front()); ArgumentPtr rhs = std::move(args.back()); @@ -337,129 +300,122 @@ void registerFunctionExpressionMakers() { return powExpr(std::move(lhs), std::move(invRhs)); }); - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector args) { + Expression::registerExpressionConstructor([](ArgumentPtrVector args) { return TrigExpr(Sin{}, std::move(args.front())).clone(); }); - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector args) { + Expression::registerExpressionConstructor([](ArgumentPtrVector args) { return TrigExpr(Cos{}, std::move(args.front())).clone(); }); - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector args) { + Expression::registerExpressionConstructor([](ArgumentPtrVector args) { return TrigExpr(Tan{}, std::move(args.front())).clone(); }); - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector args) { + Expression::registerExpressionConstructor([](ArgumentPtrVector args) { return TrigExpr(Cot{}, std::move(args.front())).clone(); }); - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector args) { + Expression::registerExpressionConstructor([](ArgumentPtrVector args) { return TrigExpr(Sec{}, std::move(args.front())).clone(); }); - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector args) { + Expression::registerExpressionConstructor([](ArgumentPtrVector args) { return TrigExpr(Csc{}, std::move(args.front())).clone(); }); - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector args) { + Expression::registerExpressionConstructor([](ArgumentPtrVector args) { return InvTrigExpr(Asin{}, std::move(args.front())).clone(); }); - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector args) { + Expression::registerExpressionConstructor([](ArgumentPtrVector args) { return InvTrigExpr(Acos{}, std::move(args.front())).clone(); }); - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector args) { + Expression::registerExpressionConstructor([](ArgumentPtrVector args) { return InvTrigExpr(Atan{}, std::move(args.front())).clone(); }); - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector args) { + Expression::registerExpressionConstructor([](ArgumentPtrVector args) { return InvTrigExpr(Acot{}, std::move(args.front())).clone(); }); - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector args) { + Expression::registerExpressionConstructor([](ArgumentPtrVector args) { return InvTrigExpr(Asec{}, std::move(args.front())).clone(); }); - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector args) { + Expression::registerExpressionConstructor([](ArgumentPtrVector args) { return InvTrigExpr(Acsc{}, std::move(args.front())).clone(); }); - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector args) { + Expression::registerExpressionConstructor([](ArgumentPtrVector args) { return HyperbExpr(Sinh{}, std::move(args.front())).clone(); }); - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector args) { + Expression::registerExpressionConstructor([](ArgumentPtrVector args) { return HyperbExpr(Cosh{}, std::move(args.front())).clone(); }); - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector args) { + Expression::registerExpressionConstructor([](ArgumentPtrVector args) { return HyperbExpr(Tanh{}, std::move(args.front())).clone(); }); - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector args) { + Expression::registerExpressionConstructor([](ArgumentPtrVector args) { return HyperbExpr(Coth{}, std::move(args.front())).clone(); }); - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector args) { + Expression::registerExpressionConstructor([](ArgumentPtrVector args) { return HyperbExpr(Sech{}, std::move(args.front())).clone(); }); - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector args) { + Expression::registerExpressionConstructor([](ArgumentPtrVector args) { return HyperbExpr(Csch{}, std::move(args.front())).clone(); }); - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector args) { + Expression::registerExpressionConstructor([](ArgumentPtrVector args) { return InvHyperbExpr(Asinh{}, std::move(args.front())).clone(); }); - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector args) { + Expression::registerExpressionConstructor([](ArgumentPtrVector args) { return InvHyperbExpr(Acosh{}, std::move(args.front())).clone(); }); - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector args) { + Expression::registerExpressionConstructor([](ArgumentPtrVector args) { return InvHyperbExpr(Atanh{}, std::move(args.front())).clone(); }); - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector args) { + Expression::registerExpressionConstructor([](ArgumentPtrVector args) { return InvHyperbExpr(Acoth{}, std::move(args.front())).clone(); }); - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector args) { + Expression::registerExpressionConstructor([](ArgumentPtrVector args) { return InvHyperbExpr(Asech{}, std::move(args.front())).clone(); }); - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector args) { + Expression::registerExpressionConstructor([](ArgumentPtrVector args) { return InvHyperbExpr(Acsch{}, std::move(args.front())).clone(); }); - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector args) { + Expression::registerExpressionConstructor([](ArgumentPtrVector args) { static const ArgumentPtr deg1 = Deg{}(Integer(1)); return mulExpr(std::move(args.front()), deg1); }); - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector args) { + Expression::registerExpressionConstructor([](ArgumentPtrVector args) { return FloorCeilExpr(Floor{}, std::move(args.front())).clone(); }); - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector args) { + Expression::registerExpressionConstructor([](ArgumentPtrVector args) { return FloorCeilExpr(Ceil{}, std::move(args.front())).clone(); }); - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector args) { + Expression::registerExpressionConstructor([](ArgumentPtrVector args) { return AbsExpr(std::move(args.front())).clone(); }); - Expression::registerFunctionExpressionMaker([](ArgumentPtrVector args) { + Expression::registerExpressionConstructor([](ArgumentPtrVector args) { return SignExpr(std::move(args.front())).clone(); }); } } - -ExpressionConfig::ExpressionConfig() { - registerTermParsers(); - registerFunctionExpressionMakers(); -} - -} diff --git a/src/fintamath/config/ParserConfig.cpp b/src/fintamath/config/TypeConfig.cpp similarity index 72% rename from src/fintamath/config/ParserConfig.cpp rename to src/fintamath/config/TypeConfig.cpp index f37e33f3f..c190eeaf5 100644 --- a/src/fintamath/config/ParserConfig.cpp +++ b/src/fintamath/config/TypeConfig.cpp @@ -1,12 +1,33 @@ -#include "fintamath/config/ParserConfig.hpp" - -#include +#include "fintamath/config/TypeConfig.hpp" #include "fintamath/core/IArithmetic.hpp" #include "fintamath/core/IComparable.hpp" #include "fintamath/core/IMathObject.hpp" #include "fintamath/expressions/Expression.hpp" +#include "fintamath/expressions/FunctionExpression.hpp" #include "fintamath/expressions/IExpression.hpp" +#include "fintamath/expressions/binary/CompExpr.hpp" +#include "fintamath/expressions/binary/DerivativeExpr.hpp" +#include "fintamath/expressions/binary/DivExpr.hpp" +#include "fintamath/expressions/binary/IntegralExpr.hpp" +#include "fintamath/expressions/binary/LogExpr.hpp" +#include "fintamath/expressions/binary/PowExpr.hpp" +#include "fintamath/expressions/interfaces/IBinaryExpression.hpp" +#include "fintamath/expressions/interfaces/IPolynomExpression.hpp" +#include "fintamath/expressions/interfaces/IUnaryExpression.hpp" +#include "fintamath/expressions/polynomial/AddExpr.hpp" +#include "fintamath/expressions/polynomial/AndExpr.hpp" +#include "fintamath/expressions/polynomial/MinMaxExpr.hpp" +#include "fintamath/expressions/polynomial/MulExpr.hpp" +#include "fintamath/expressions/polynomial/OrExpr.hpp" +#include "fintamath/expressions/unary/AbsExpr.hpp" +#include "fintamath/expressions/unary/FloorCeilExpr.hpp" +#include "fintamath/expressions/unary/HyperbExpr.hpp" +#include "fintamath/expressions/unary/InvHyperbExpr.hpp" +#include "fintamath/expressions/unary/InvTrigExpr.hpp" +#include "fintamath/expressions/unary/NotExpr.hpp" +#include "fintamath/expressions/unary/SignExpr.hpp" +#include "fintamath/expressions/unary/TrigExpr.hpp" #include "fintamath/functions/IFunction.hpp" #include "fintamath/functions/IOperator.hpp" #include "fintamath/functions/arithmetic/Abs.hpp" @@ -97,22 +118,24 @@ namespace fintamath::detail { -ParserConfig::ParserConfig() { - IMathObject::registerType(&ILiteral::parse); - IMathObject::registerType([](const std::string &str) { return IFunction::parse(str); }); - IMathObject::registerType(&IArithmetic::parse); +TypeConfig::TypeConfig() { + IMathObject::registerType(); + IMathObject::registerType(); + IMathObject::registerType(); - IArithmetic::registerType(&IComparable::parse); - IArithmetic::registerType(); + IArithmetic::registerType(); + IArithmetic::registerType(); - IComparable::registerType(&INumber::parse); + IComparable::registerType(); - INumber::registerType(&IInteger::parse); + INumber::registerType(); INumber::registerType(); + INumber::registerType(); + INumber::registerType(); IInteger::registerType(); - ILiteral::registerType(&IConstant::parse); + ILiteral::registerType(); ILiteral::registerType(); ILiteral::registerType(); @@ -126,6 +149,7 @@ ParserConfig::ParserConfig() { IConstant::registerType(); IConstant::registerType(); + IFunction::registerType(); IFunction::registerType(); IFunction::registerType(); IFunction::registerType(); @@ -196,7 +220,33 @@ ParserConfig::ParserConfig() { IOperator::registerType(); IOperator::registerType(); + IExpression::registerType(); + IExpression::registerType(); + IExpression::registerType(); + IExpression::registerType(); IExpression::registerType(); + + IPolynomExpression::registerType(); + IPolynomExpression::registerType(); + IPolynomExpression::registerType(); + IPolynomExpression::registerType(); + IPolynomExpression::registerType(); + + IBinaryExpression::registerType(); + IBinaryExpression::registerType(); + IBinaryExpression::registerType(); + IBinaryExpression::registerType(); + IBinaryExpression::registerType(); + IBinaryExpression::registerType(); + + IUnaryExpression::registerType(); + IUnaryExpression::registerType(); + IUnaryExpression::registerType(); + IUnaryExpression::registerType(); + IUnaryExpression::registerType(); + IUnaryExpression::registerType(); + IUnaryExpression::registerType(); + IUnaryExpression::registerType(); } } diff --git a/src/fintamath/config/ParserConfig.hpp b/src/fintamath/config/TypeConfig.hpp similarity index 52% rename from src/fintamath/config/ParserConfig.hpp rename to src/fintamath/config/TypeConfig.hpp index b4140e18d..2dbaf37b8 100644 --- a/src/fintamath/config/ParserConfig.hpp +++ b/src/fintamath/config/TypeConfig.hpp @@ -2,8 +2,8 @@ namespace fintamath::detail { -struct ParserConfig final { - ParserConfig(); +struct TypeConfig final { + TypeConfig(); }; } diff --git a/src/fintamath/core/IArithmetic.cpp b/src/fintamath/core/IArithmetic.cpp index 1904da1d2..799969394 100644 --- a/src/fintamath/core/IArithmetic.cpp +++ b/src/fintamath/core/IArithmetic.cpp @@ -2,9 +2,6 @@ namespace fintamath { -IArithmetic::ArithmeticParser &IArithmetic::getParser() { - static ArithmeticParser parser; - return parser; -} +FINTAMATH_PARENT_CLASS_IMPLEMENTATION(IArithmetic) } diff --git a/src/fintamath/core/IComparable.cpp b/src/fintamath/core/IComparable.cpp index 905a46088..68843e7e4 100644 --- a/src/fintamath/core/IComparable.cpp +++ b/src/fintamath/core/IComparable.cpp @@ -2,9 +2,6 @@ namespace fintamath { -IComparable::ComparableParser &IComparable::getParser() { - static ComparableParser parser; - return parser; -} +FINTAMATH_PARENT_CLASS_IMPLEMENTATION(IComparable) } diff --git a/src/fintamath/core/IMathObject.cpp b/src/fintamath/core/IMathObject.cpp index 7c62bbc70..e889cae1e 100644 --- a/src/fintamath/core/IMathObject.cpp +++ b/src/fintamath/core/IMathObject.cpp @@ -2,9 +2,6 @@ namespace fintamath { -IMathObject::MathObjectParser &IMathObject::getParser() { - static MathObjectParser parser; - return parser; -} +FINTAMATH_PARENT_CLASS_IMPLEMENTATION(IMathObject) } diff --git a/src/fintamath/core/MathObjectClass.cpp b/src/fintamath/core/MathObjectClass.cpp new file mode 100644 index 000000000..eb073ac6f --- /dev/null +++ b/src/fintamath/core/MathObjectClass.cpp @@ -0,0 +1,52 @@ +#include "fintamath/core/MathObjectClass.hpp" + +namespace fintamath { + +std::strong_ordering MathObjectClass::operator<=>(const MathObjectClass rhs) const { + const Id lhsId = getId(); + const Id rhsId = rhs.getId(); + + return lhsId != 0 && rhsId != 0 + ? lhsId <=> rhsId + : name <=> rhs.name; +} + +std::optional MathObjectClass::getParent() const { + const auto iter = getChildToParentMap().find(name); + return iter != getChildToParentMap().end() ? iter->second : std::optional{}; +} + +const MathObjectClass::Children &MathObjectClass::getChildren(const bool recursive) const { + if (recursive) { + return getParentToRecursiveChildrenMap()[name]; + } + + return getParentToChildrenMap()[name]; +} + +MathObjectClass::Id MathObjectClass::getId() const { + const auto classToId = getClassToIdMap().find(*this); + return classToId != getClassToIdMap().end() ? classToId->second : 0; +} + +MathObjectClass::ClassToIdMap &MathObjectClass::getClassToIdMap() { + static ClassToIdMap map; + return map; +} + +MathObjectClass::ChildToParentMap &MathObjectClass::getChildToParentMap() { + static ChildToParentMap map; + return map; +} + +MathObjectClass::ParentToChildrenMap &MathObjectClass::getParentToChildrenMap() { + static ParentToChildrenMap map; + return map; +} + +MathObjectClass::ParentToChildrenMap &MathObjectClass::getParentToRecursiveChildrenMap() { + static ParentToChildrenMap map; + return map; +} + +} diff --git a/src/fintamath/core/Tokenizer.cpp b/src/fintamath/core/Tokenizer.cpp index b5302dd89..f98c199f1 100644 --- a/src/fintamath/core/Tokenizer.cpp +++ b/src/fintamath/core/Tokenizer.cpp @@ -4,7 +4,7 @@ #include #include -#include "fintamath/core/CoreUtils.hpp" +#include "fintamath/core/MathObjectUtils.hpp" namespace fintamath::detail { diff --git a/src/fintamath/expressions/Expression.cpp b/src/fintamath/expressions/Expression.cpp index 534ee631e..37e1e0ace 100644 --- a/src/fintamath/expressions/Expression.cpp +++ b/src/fintamath/expressions/Expression.cpp @@ -12,9 +12,9 @@ #include #include "fintamath/core/Cache.hpp" -#include "fintamath/core/CoreUtils.hpp" #include "fintamath/core/IMathObject.hpp" -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.hpp" +#include "fintamath/core/MathObjectUtils.hpp" #include "fintamath/core/Tokenizer.hpp" #include "fintamath/exceptions/InvalidInputException.hpp" #include "fintamath/expressions/ExpressionParser.hpp" @@ -182,12 +182,7 @@ TermVector Expression::tokensToTerms(TokenVector &tokens) { TermVector terms(tokens.size()); for (const auto i : stdv::iota(0U, terms.size())) { - if (auto term = getTermParser().parse(tokens[i])) { - terms[i] = std::move(*term); - } - else { - terms[i] = Term(std::move(tokens[i]), std::unique_ptr{}); - } + terms[i] = parseTerm(tokens[i]); } fixOperatorTypes(terms); @@ -209,7 +204,7 @@ OperandStack Expression::termsToOperands(TermVector &terms) { functions.emplace(std::move(term), std::optional{}); } else if (term.name == ")") { - moveFunctionsToOperands(operands, functions, {}); + moveFunctionTermsToOperands(operands, functions, {}); if (functions.empty()) { throw InvalidInputException(""); @@ -225,7 +220,7 @@ OperandStack Expression::termsToOperands(TermVector &terms) { std::optional priority; if (const auto *oper = cast(term.value.get())) { - moveFunctionsToOperands(operands, functions, oper); + moveFunctionTermsToOperands(operands, functions, oper); priority = oper->getPriority(); } @@ -236,7 +231,7 @@ OperandStack Expression::termsToOperands(TermVector &terms) { } } - moveFunctionsToOperands(operands, functions, {}); + moveFunctionTermsToOperands(operands, functions, {}); if (!functions.empty()) { throw InvalidInputException(""); @@ -264,8 +259,8 @@ std::unique_ptr Expression::operandsToObject(OperandStack &operands ArgumentPtrVector children = unwrapComma(rhsChild); - if (!func->isVariadic() && func->getArgumentTypes().size() != children.size()) { - func = IFunction::parse(func->toString(), children.size()); + if (!func->isVariadic() && func->getArgumentClasses().size() != children.size()) { + func = parseFunction(func->toString(), children.size()); if (!func) { throw InvalidInputException(""); @@ -278,7 +273,45 @@ std::unique_ptr Expression::operandsToObject(OperandStack &operands return arg; } -void Expression::moveFunctionsToOperands(OperandStack &operands, std::stack &functions, const IOperator *nextOper) { +std::unique_ptr Expression::parseFunction(const std::string &str, const size_t argNum) { + for (auto &func : IFunction::parse(str)) { + if (func->getArgumentClasses().size() == argNum) { + return std::move(func); + } + } + + return {}; +} + +auto Expression::parseOperator(const std::string &str, IOperator::Priority priority) -> std::unique_ptr { + for (auto &oper : IOperator::parse(str)) { + if (oper->getPriority() == priority) { + return std::move(oper); + } + } + + return {}; +} + +Term Expression::parseTerm(const std::string &str) { + static auto termValueParser = [] { + Parser> parser; + parser.registerType(); + parser.registerType(); + parser.registerType(); + return parser; + }(); + + Term term = {str, {}}; + + if (auto termValue = termValueParser.parseFirst(str)) { + term.value = std::move(*termValue); + } + + return term; +} + +void Expression::moveFunctionTermsToOperands(OperandStack &operands, std::stack &functions, const IOperator *nextOper) { if (isPrefixOperator(nextOper)) { return; } @@ -315,7 +348,7 @@ void Expression::fixOperatorTypes(TermVector &terms) { is(term.value) && !isPrefixOperator(term.value.get())) { - term.value = IOperator::parse(term.name, IOperator::Priority::PrefixUnary); + term.value = parseOperator(term.name, IOperator::Priority::PrefixUnary); isFixed = static_cast(term.value); } @@ -323,7 +356,7 @@ void Expression::fixOperatorTypes(TermVector &terms) { is(term.value) && !isPostfixOperator(term.value.get())) { - term.value = IOperator::parse(term.name, IOperator::Priority::PostfixUnary); + term.value = parseOperator(term.name, IOperator::Priority::PostfixUnary); isFixed = isFixed && static_cast(term.value); } @@ -343,7 +376,7 @@ void Expression::fixOperatorTypes(TermVector &terms) { !isPrefixOperator(term.value.get()) && !canNextTermBeBinaryOperator(termPrev)) { - term.value = IOperator::parse(term.name, IOperator::Priority::PrefixUnary); + term.value = parseOperator(term.name, IOperator::Priority::PrefixUnary); isFixed = isFixed && term.value; } } @@ -356,7 +389,7 @@ void Expression::fixOperatorTypes(TermVector &terms) { !isPostfixOperator(term.value.get()) && !canPrevTermBeBinaryOperator(termNext)) { - term.value = IOperator::parse(term.name, IOperator::Priority::PostfixUnary); + term.value = parseOperator(term.name, IOperator::Priority::PostfixUnary); isFixed = isFixed && term.value; } } @@ -398,7 +431,7 @@ bool Expression::canPrevTermBeBinaryOperator(const Term &term) { bool Expression::isBinaryOperator(const IMathObject *val) { const auto *oper = cast(val); - return oper && oper->getArgumentTypes().size() == 2; + return oper && oper->getArgumentClasses().size() == 2; } bool Expression::isPrefixOperator(const IMathObject *val) { @@ -439,25 +472,20 @@ ArgumentPtr Expression::compress(const ArgumentPtr &child) { return child; } -Expression::TermParser &Expression::getTermParser() { - static TermParser parser; - return parser; -} - -Expression::ExpressionParser &Expression::getExpressionParser() { - static ExpressionParser parser; - return parser; +Expression::ExpressionMaker &Expression::getExpressionMaker() { + static ExpressionMaker map; + return map; } void Expression::validateFunctionArgs(const IFunction &func, const ArgumentPtrVector &args) { - const ArgumentTypeVector &expectedArgTypes = func.getArgumentTypes(); + const ArgumentTypeVector &expectedArgTypes = func.getArgumentClasses(); if (args.empty() || (!func.isVariadic() && args.size() < expectedArgTypes.size())) { throw InvalidInputFunctionException(func.toString(), argumentVectorToStringVector(args)); } const bool doesArgSizeMatch = !func.isVariadic() && args.size() == expectedArgTypes.size(); - MathObjectType expectedType = expectedArgTypes.front(); + MathObjectClass expectedType = expectedArgTypes.front(); for (const auto i : stdv::iota(0U, args.size())) { if (doesArgSizeMatch) { @@ -470,30 +498,30 @@ void Expression::validateFunctionArgs(const IFunction &func, const ArgumentPtrVe } } -bool Expression::doesArgMatch(const MathObjectType &expectedType, const ArgumentPtr &arg) { +bool Expression::doesArgMatch(const MathObjectClass &expectedType, const ArgumentPtr &arg) { if (const auto childExpr = cast(arg)) { const std::shared_ptr &childFunc = childExpr->getFunction(); - const MathObjectType childType = childFunc->getReturnType(); + const MathObjectClass childType = childFunc->getReturnClass(); - if (childType != Variable::getTypeStatic() && - !isBaseOf(expectedType, childType) && - !isBaseOf(childType, expectedType)) { + if (childType != Variable::getClassStatic() && + !is(expectedType, childType) && + !is(childType, expectedType)) { return false; } } else if (const auto childConst = cast(arg)) { - if (const MathObjectType childType = childConst->getReturnType(); - !isBaseOf(expectedType, childType) && - !isBaseOf(childType, expectedType)) { + if (const MathObjectClass childType = childConst->getReturnClass(); + !is(expectedType, childType) && + !is(childType, expectedType)) { return false; } } else { - if (const MathObjectType childType = arg->getType(); - childType != Variable::getTypeStatic() && - !isBaseOf(expectedType, childType)) { + if (const MathObjectClass childType = arg->getClass(); + childType != Variable::getClassStatic() && + !is(expectedType, childType)) { return false; } @@ -556,8 +584,12 @@ std::unique_ptr makeExpr(const IFunction &func, ArgumentPtrVector a stdr::transform(args, args.begin(), &Expression::compress); Expression::validateFunctionArgs(func, args); - if (auto expr = Expression::getExpressionParser().parse(func.toString(), std::move(args))) { - return expr; + if (const auto strToConstr = Expression::getExpressionMaker().find(func.getClass()); + strToConstr != Expression::getExpressionMaker().end()) { + + if (auto expr = strToConstr->second(std::move(args))) { + return expr; + } } return FunctionExpression(func, std::move(args)).clone(); diff --git a/src/fintamath/expressions/ExpressionComparator.cpp b/src/fintamath/expressions/ExpressionComparator.cpp index c98c463c0..cc957a001 100644 --- a/src/fintamath/expressions/ExpressionComparator.cpp +++ b/src/fintamath/expressions/ExpressionComparator.cpp @@ -8,8 +8,8 @@ #include #include -#include "fintamath/core/CoreUtils.hpp" #include "fintamath/core/IComparable.hpp" +#include "fintamath/core/MathObjectUtils.hpp" #include "fintamath/expressions/ExpressionUtils.hpp" #include "fintamath/expressions/IExpression.hpp" #include "fintamath/expressions/interfaces/IPolynomExpression.hpp" @@ -372,8 +372,8 @@ Ordering compareFunctions(const std::shared_ptr &lhs, return Ordering::equal; } - if (lhs->getFunctionOrder() != rhs->getFunctionOrder()) { - return lhs->getFunctionOrder() < rhs->getFunctionOrder() ? Ordering::greater : Ordering::less; + if (lhs->getClass() != rhs->getClass()) { + return lhs->getClass() < rhs->getClass() ? Ordering::greater : Ordering::less; } return lhs->toString() < rhs->toString() ? Ordering::greater : Ordering::less; @@ -463,7 +463,7 @@ ChildrenComparatorResult compareChildren(const ArgumentPtrVector &lhsChildren, bool unwrapUnaryExpression(ArgumentPtr &arg) { if (const auto expr = cast(arg); expr && - expr->getFunction()->getArgumentTypes().size() == 1) { + expr->getFunction()->getArgumentClasses().size() == 1) { arg = expr->getChildren().front(); return true; diff --git a/src/fintamath/expressions/ExpressionUtils.cpp b/src/fintamath/expressions/ExpressionUtils.cpp index ffe214ba4..99ad079c3 100644 --- a/src/fintamath/expressions/ExpressionUtils.cpp +++ b/src/fintamath/expressions/ExpressionUtils.cpp @@ -9,8 +9,8 @@ #include #include -#include "fintamath/core/CoreUtils.hpp" #include "fintamath/core/IMathObject.hpp" +#include "fintamath/core/MathObjectUtils.hpp" #include "fintamath/expressions/IExpression.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/functions/FunctionUtils.hpp" @@ -358,7 +358,7 @@ std::string operatorChildToString(const IOperator &oper, const ArgumentPtr &chil if (oper.getPriority() == IOperator::Priority::PostfixUnary) { shouldPutInBrackets = true; } - else if (childOper->getArgumentTypes().size() == 1) { + else if (childOper->getArgumentClasses().size() == 1) { shouldPutInBrackets = childOper->getPriority() >= oper.getPriority(); } else { diff --git a/src/fintamath/expressions/FunctionExpression.cpp b/src/fintamath/expressions/FunctionExpression.cpp index 3cd53e225..82a16c578 100644 --- a/src/fintamath/expressions/FunctionExpression.cpp +++ b/src/fintamath/expressions/FunctionExpression.cpp @@ -4,7 +4,7 @@ #include #include -#include "fintamath/core/CoreUtils.hpp" +#include "fintamath/core/MathObjectUtils.hpp" #include "fintamath/expressions/ExpressionUtils.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/functions/IFunction.hpp" @@ -73,7 +73,7 @@ ArgumentPtr FunctionExpression::postSimplify() const { } void FunctionExpression::setChildren(const ArgumentPtrVector &childVect) { - if (childVect.size() != func->getArgumentTypes().size()) { + if (childVect.size() != func->getArgumentClasses().size()) { throw InvalidInputFunctionException(func->toString(), argumentVectorToStringVector(childVect)); } diff --git a/src/fintamath/expressions/FunctionExpression.hpp b/src/fintamath/expressions/FunctionExpression.hpp index 54c5ffe7e..2e0640e0a 100644 --- a/src/fintamath/expressions/FunctionExpression.hpp +++ b/src/fintamath/expressions/FunctionExpression.hpp @@ -3,7 +3,7 @@ #include #include -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.hpp" #include "fintamath/expressions/IExpression.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/functions/IFunction.hpp" @@ -11,6 +11,8 @@ namespace fintamath { class FunctionExpression final : public IExpressionCRTP { + FINTAMATH_CLASS_BODY(FunctionExpression) + public: explicit FunctionExpression(const IFunction &inFunc, ArgumentPtrVector inChildren); @@ -22,10 +24,6 @@ class FunctionExpression final : public IExpressionCRTP { void setChildren(const ArgumentPtrVector &childVect) override; - static constexpr MathObjectType getTypeStatic() { - return {MathObjectType::FunctionExpression, "FunctionExpression"}; - } - protected: ArgumentPtr preSimplify() const override; diff --git a/src/fintamath/expressions/IExpression.cpp b/src/fintamath/expressions/IExpression.cpp index b8bceaf3a..182018937 100644 --- a/src/fintamath/expressions/IExpression.cpp +++ b/src/fintamath/expressions/IExpression.cpp @@ -8,8 +8,8 @@ #include #include "fintamath/core/Converter.hpp" -#include "fintamath/core/CoreUtils.hpp" #include "fintamath/core/IMathObject.hpp" +#include "fintamath/core/MathObjectUtils.hpp" #include "fintamath/core/MultiMethod.hpp" #include "fintamath/expressions/ExpressionUtils.hpp" #include "fintamath/functions/FunctionArguments.hpp" @@ -26,6 +26,8 @@ namespace fintamath { using namespace detail; +FINTAMATH_PARENT_CLASS_IMPLEMENTATION(IExpression) + std::vector IExpression::getVariables() const { std::vector vars; @@ -323,7 +325,7 @@ ArgumentPtr IExpression::approximateSimplify() const { if (containsVar && (numberChildrenCount < 2 || - approxChildren.size() == getFunction()->getArgumentTypes().size())) { + approxChildren.size() == getFunction()->getArgumentClasses().size())) { return approxExpr; } @@ -359,9 +361,4 @@ ArgumentPtr IExpression::setPrecision(const unsigned precision, const Integer &m return newExprArg; } -IExpression::ExpressionParser &IExpression::getParser() { - static ExpressionParser parser; - return parser; -} - } diff --git a/src/fintamath/expressions/binary/CompExpr.cpp b/src/fintamath/expressions/binary/CompExpr.cpp index 1da787184..e5e4c9126 100644 --- a/src/fintamath/expressions/binary/CompExpr.cpp +++ b/src/fintamath/expressions/binary/CompExpr.cpp @@ -6,7 +6,7 @@ #include #include -#include "fintamath/core/CoreUtils.hpp" +#include "fintamath/core/MathObjectUtils.hpp" #include "fintamath/expressions/ExpressionUtils.hpp" #include "fintamath/expressions/IExpression.hpp" #include "fintamath/expressions/interfaces/IBinaryExpression.hpp" diff --git a/src/fintamath/expressions/binary/CompExpr.hpp b/src/fintamath/expressions/binary/CompExpr.hpp index a653e5522..225bfc9d7 100644 --- a/src/fintamath/expressions/binary/CompExpr.hpp +++ b/src/fintamath/expressions/binary/CompExpr.hpp @@ -3,7 +3,7 @@ #include #include -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.hpp" #include "fintamath/expressions/interfaces/IBinaryExpression.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/functions/IFunction.hpp" @@ -13,6 +13,8 @@ namespace fintamath { class IOperator; class CompExpr final : public IBinaryExpressionCRTP { + FINTAMATH_CLASS_BODY(CompExpr) + public: CompExpr(const IOperator &inOper, ArgumentPtr inLhsChild, ArgumentPtr inRhsChild); @@ -20,10 +22,6 @@ class CompExpr final : public IBinaryExpressionCRTP { void markAsSolution(); - static constexpr MathObjectType getTypeStatic() { - return {MathObjectType::CompExpr, "CompExpr"}; - } - protected: ArgumentPtr preSimplify() const override; diff --git a/src/fintamath/expressions/binary/DerivativeExpr.cpp b/src/fintamath/expressions/binary/DerivativeExpr.cpp index 93197ba3c..340e86e08 100644 --- a/src/fintamath/expressions/binary/DerivativeExpr.cpp +++ b/src/fintamath/expressions/binary/DerivativeExpr.cpp @@ -8,7 +8,7 @@ #include #include -#include "fintamath/core/CoreUtils.hpp" +#include "fintamath/core/MathObjectUtils.hpp" #include "fintamath/expressions/ExpressionUtils.hpp" #include "fintamath/expressions/IExpression.hpp" #include "fintamath/expressions/interfaces/IBinaryExpression.hpp" diff --git a/src/fintamath/expressions/binary/DerivativeExpr.hpp b/src/fintamath/expressions/binary/DerivativeExpr.hpp index 1a864c12a..89c5e6568 100644 --- a/src/fintamath/expressions/binary/DerivativeExpr.hpp +++ b/src/fintamath/expressions/binary/DerivativeExpr.hpp @@ -2,7 +2,7 @@ #include -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.hpp" #include "fintamath/expressions/IExpression.hpp" #include "fintamath/expressions/interfaces/IBinaryExpression.hpp" #include "fintamath/functions/FunctionArguments.hpp" @@ -12,13 +12,11 @@ namespace fintamath { class DerivativeExpr final : public IBinaryExpressionCRTP { + FINTAMATH_CLASS_BODY(DerivativeExpr) + public: explicit DerivativeExpr(ArgumentPtr inLhsChild, ArgumentPtr inRhsChild); - static constexpr MathObjectType getTypeStatic() { - return {MathObjectType::DerivativeExpr, "DerivativeExpr"}; - } - protected: SimplifyFunctionVector getFunctionsForPostSimplify() const override; diff --git a/src/fintamath/expressions/binary/DivExpr.cpp b/src/fintamath/expressions/binary/DivExpr.cpp index 20cf88dda..0c92896ff 100644 --- a/src/fintamath/expressions/binary/DivExpr.cpp +++ b/src/fintamath/expressions/binary/DivExpr.cpp @@ -7,7 +7,7 @@ #include #include -#include "fintamath/core/CoreUtils.hpp" +#include "fintamath/core/MathObjectUtils.hpp" #include "fintamath/expressions/ExpressionComparator.hpp" #include "fintamath/expressions/ExpressionUtils.hpp" #include "fintamath/expressions/IExpression.hpp" diff --git a/src/fintamath/expressions/binary/DivExpr.hpp b/src/fintamath/expressions/binary/DivExpr.hpp index c67984720..34ff07184 100644 --- a/src/fintamath/expressions/binary/DivExpr.hpp +++ b/src/fintamath/expressions/binary/DivExpr.hpp @@ -3,7 +3,7 @@ #include #include -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.hpp" #include "fintamath/expressions/interfaces/IBinaryExpression.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/functions/IFunction.hpp" @@ -12,15 +12,13 @@ namespace fintamath { class DivExpr final : public IBinaryExpressionCRTP { + FINTAMATH_CLASS_BODY(DivExpr) + public: explicit DivExpr(ArgumentPtr inLhsChild, ArgumentPtr inRhsChild); std::string toString() const override; - static constexpr MathObjectType getTypeStatic() { - return {MathObjectType::DivExpr, "DivExpr"}; - } - protected: SimplifyFunctionVector getFunctionsForPreSimplify() const override; diff --git a/src/fintamath/expressions/binary/IntegralExpr.hpp b/src/fintamath/expressions/binary/IntegralExpr.hpp index 2c67b0d90..0682f4553 100644 --- a/src/fintamath/expressions/binary/IntegralExpr.hpp +++ b/src/fintamath/expressions/binary/IntegralExpr.hpp @@ -1,6 +1,6 @@ #pragma once -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.hpp" #include "fintamath/expressions/interfaces/IBinaryExpression.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/functions/IFunction.hpp" @@ -8,13 +8,11 @@ namespace fintamath { class IntegralExpr final : public IBinaryExpressionCRTP { + FINTAMATH_CLASS_BODY(IntegralExpr) + public: explicit IntegralExpr(ArgumentPtr inLhsChild, ArgumentPtr inRhsChild); - static constexpr MathObjectType getTypeStatic() { - return {MathObjectType::IntegralExpr, "IntegralExpr"}; - } - protected: SimplifyFunctionVector getFunctionsForPostSimplify() const override; diff --git a/src/fintamath/expressions/binary/LogExpr.cpp b/src/fintamath/expressions/binary/LogExpr.cpp index 3cc9e5548..971ce1609 100644 --- a/src/fintamath/expressions/binary/LogExpr.cpp +++ b/src/fintamath/expressions/binary/LogExpr.cpp @@ -4,7 +4,7 @@ #include #include -#include "fintamath/core/CoreUtils.hpp" +#include "fintamath/core/MathObjectUtils.hpp" #include "fintamath/expressions/ExpressionUtils.hpp" #include "fintamath/expressions/IExpression.hpp" #include "fintamath/expressions/interfaces/IBinaryExpression.hpp" diff --git a/src/fintamath/expressions/binary/LogExpr.hpp b/src/fintamath/expressions/binary/LogExpr.hpp index ec73f0374..8fa11eb98 100644 --- a/src/fintamath/expressions/binary/LogExpr.hpp +++ b/src/fintamath/expressions/binary/LogExpr.hpp @@ -3,7 +3,7 @@ #include #include -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.hpp" #include "fintamath/expressions/interfaces/IBinaryExpression.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/functions/IFunction.hpp" @@ -12,6 +12,8 @@ namespace fintamath { class LogExpr final : public IBinaryExpressionCRTP { + FINTAMATH_CLASS_BODY(LogExpr) + public: explicit LogExpr(ArgumentPtr inLhsChild, ArgumentPtr inRhsChild); @@ -19,10 +21,6 @@ class LogExpr final : public IBinaryExpressionCRTP { const std::shared_ptr &getOutputFunction() const override; - static constexpr MathObjectType getTypeStatic() { - return {MathObjectType::LogExpr, "LogExpr"}; - } - protected: ArgumentPtr approximateSimplify() const override; diff --git a/src/fintamath/expressions/binary/PowExpr.cpp b/src/fintamath/expressions/binary/PowExpr.cpp index 32a2d7e99..fd7e1c866 100644 --- a/src/fintamath/expressions/binary/PowExpr.cpp +++ b/src/fintamath/expressions/binary/PowExpr.cpp @@ -8,7 +8,7 @@ #include #include -#include "fintamath/core/CoreUtils.hpp" +#include "fintamath/core/MathObjectUtils.hpp" #include "fintamath/expressions/ExpressionUtils.hpp" #include "fintamath/expressions/IExpression.hpp" #include "fintamath/expressions/interfaces/IBinaryExpression.hpp" diff --git a/src/fintamath/expressions/binary/PowExpr.hpp b/src/fintamath/expressions/binary/PowExpr.hpp index 922782cb5..41b69e567 100644 --- a/src/fintamath/expressions/binary/PowExpr.hpp +++ b/src/fintamath/expressions/binary/PowExpr.hpp @@ -4,7 +4,7 @@ #include #include -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.hpp" #include "fintamath/expressions/interfaces/IBinaryExpression.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/functions/IFunction.hpp" @@ -13,6 +13,8 @@ namespace fintamath { class PowExpr final : public IBinaryExpressionCRTP { + FINTAMATH_CLASS_BODY(PowExpr) + public: explicit PowExpr(ArgumentPtr inLhsChild, ArgumentPtr inRhsChild); @@ -20,10 +22,6 @@ class PowExpr final : public IBinaryExpressionCRTP { const std::shared_ptr &getOutputFunction() const override; - static constexpr MathObjectType getTypeStatic() { - return {MathObjectType::PowExpr, "PowExpr"}; - } - protected: ArgumentPtr approximateSimplify() const override; diff --git a/src/fintamath/expressions/functions/ExpressionFunctionSolve.cpp b/src/fintamath/expressions/functions/ExpressionFunctionSolve.cpp index 771281980..eb213668f 100644 --- a/src/fintamath/expressions/functions/ExpressionFunctionSolve.cpp +++ b/src/fintamath/expressions/functions/ExpressionFunctionSolve.cpp @@ -4,7 +4,7 @@ #include #include -#include "fintamath/core/CoreUtils.hpp" +#include "fintamath/core/MathObjectUtils.hpp" #include "fintamath/expressions/Expression.hpp" #include "fintamath/expressions/ExpressionUtils.hpp" #include "fintamath/expressions/IExpression.hpp" diff --git a/src/fintamath/expressions/interfaces/IBinaryExpression.cpp b/src/fintamath/expressions/interfaces/IBinaryExpression.cpp index 5aa3be82a..650cfabd7 100644 --- a/src/fintamath/expressions/interfaces/IBinaryExpression.cpp +++ b/src/fintamath/expressions/interfaces/IBinaryExpression.cpp @@ -4,7 +4,7 @@ #include #include -#include "fintamath/core/CoreUtils.hpp" +#include "fintamath/core/MathObjectUtils.hpp" #include "fintamath/expressions/ExpressionUtils.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/functions/IFunction.hpp" @@ -14,6 +14,8 @@ namespace fintamath { using namespace detail; +FINTAMATH_PARENT_CLASS_IMPLEMENTATION(IBinaryExpression) + IBinaryExpression::IBinaryExpression(const IFunction &inFunc, ArgumentPtr lhs, ArgumentPtr rhs) : func(cast(inFunc.clone())), lhsChild(std::move(lhs)), diff --git a/src/fintamath/expressions/interfaces/IPolynomExpression.cpp b/src/fintamath/expressions/interfaces/IPolynomExpression.cpp index e819a0624..1fe45eb46 100644 --- a/src/fintamath/expressions/interfaces/IPolynomExpression.cpp +++ b/src/fintamath/expressions/interfaces/IPolynomExpression.cpp @@ -9,7 +9,7 @@ #include #include -#include "fintamath/core/CoreUtils.hpp" +#include "fintamath/core/MathObjectUtils.hpp" #include "fintamath/expressions/ExpressionComparator.hpp" #include "fintamath/expressions/ExpressionUtils.hpp" #include "fintamath/expressions/binary/CompExpr.hpp" @@ -23,6 +23,8 @@ namespace fintamath { using namespace detail; +FINTAMATH_PARENT_CLASS_IMPLEMENTATION(IPolynomExpression) + IPolynomExpression::IPolynomExpression(const IFunction &inFunc, ArgumentPtrVector args) : func(cast(inFunc.clone())), children(std::move(args)) { diff --git a/src/fintamath/expressions/interfaces/IUnaryExpression.cpp b/src/fintamath/expressions/interfaces/IUnaryExpression.cpp index ffbf50912..eea6dd31f 100644 --- a/src/fintamath/expressions/interfaces/IUnaryExpression.cpp +++ b/src/fintamath/expressions/interfaces/IUnaryExpression.cpp @@ -4,7 +4,7 @@ #include #include -#include "fintamath/core/CoreUtils.hpp" +#include "fintamath/core/MathObjectUtils.hpp" #include "fintamath/expressions/ExpressionUtils.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/functions/IFunction.hpp" @@ -14,6 +14,8 @@ namespace fintamath { using namespace detail; +FINTAMATH_PARENT_CLASS_IMPLEMENTATION(IUnaryExpression) + IUnaryExpression::IUnaryExpression(const IFunction &inFunc, ArgumentPtr rhs) : func(cast(inFunc.clone())), child(std::move(rhs)) { diff --git a/src/fintamath/expressions/polynomial/AddExpr.cpp b/src/fintamath/expressions/polynomial/AddExpr.cpp index 82630599d..af2354d9c 100644 --- a/src/fintamath/expressions/polynomial/AddExpr.cpp +++ b/src/fintamath/expressions/polynomial/AddExpr.cpp @@ -8,7 +8,7 @@ #include #include -#include "fintamath/core/CoreUtils.hpp" +#include "fintamath/core/MathObjectUtils.hpp" #include "fintamath/expressions/ExpressionUtils.hpp" #include "fintamath/expressions/IExpression.hpp" #include "fintamath/expressions/interfaces/IPolynomExpression.hpp" diff --git a/src/fintamath/expressions/polynomial/AddExpr.hpp b/src/fintamath/expressions/polynomial/AddExpr.hpp index 1e1403633..c9413a78f 100644 --- a/src/fintamath/expressions/polynomial/AddExpr.hpp +++ b/src/fintamath/expressions/polynomial/AddExpr.hpp @@ -6,7 +6,7 @@ #include #include -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.hpp" #include "fintamath/expressions/IExpression.hpp" #include "fintamath/expressions/interfaces/IPolynomExpression.hpp" #include "fintamath/functions/FunctionArguments.hpp" @@ -15,13 +15,11 @@ namespace fintamath { class AddExpr final : public IPolynomExpressionCRTP { + FINTAMATH_CLASS_BODY(AddExpr) + public: explicit AddExpr(ArgumentPtrVector inChildren); - static constexpr MathObjectType getTypeStatic() { - return {MathObjectType::AddExpr, "AddExpr"}; - } - protected: SimplifyFunctionVector getFunctionsForPreSimplify() const override; diff --git a/src/fintamath/expressions/polynomial/AndExpr.cpp b/src/fintamath/expressions/polynomial/AndExpr.cpp index 4f707493b..d3e70d7c7 100644 --- a/src/fintamath/expressions/polynomial/AndExpr.cpp +++ b/src/fintamath/expressions/polynomial/AndExpr.cpp @@ -2,7 +2,7 @@ #include -#include "fintamath/core/CoreUtils.hpp" +#include "fintamath/core/MathObjectUtils.hpp" #include "fintamath/expressions/IExpression.hpp" #include "fintamath/expressions/interfaces/IPolynomExpression.hpp" #include "fintamath/functions/FunctionArguments.hpp" diff --git a/src/fintamath/expressions/polynomial/AndExpr.hpp b/src/fintamath/expressions/polynomial/AndExpr.hpp index e60e8e1ea..fe19e63a2 100644 --- a/src/fintamath/expressions/polynomial/AndExpr.hpp +++ b/src/fintamath/expressions/polynomial/AndExpr.hpp @@ -1,6 +1,6 @@ #pragma once -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.hpp" #include "fintamath/expressions/interfaces/IPolynomExpression.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/functions/IFunction.hpp" @@ -8,13 +8,11 @@ namespace fintamath { class AndExpr final : public IPolynomExpressionCRTP { + FINTAMATH_CLASS_BODY(AndExpr) + public: explicit AndExpr(ArgumentPtrVector inChildren); - static constexpr MathObjectType getTypeStatic() { - return {MathObjectType::AndExpr, "AndExpr"}; - } - protected: SimplifyFunctionVector getFunctionsForPreSimplify() const override; diff --git a/src/fintamath/expressions/polynomial/MinMaxExpr.hpp b/src/fintamath/expressions/polynomial/MinMaxExpr.hpp index a4be0740f..983b14a65 100644 --- a/src/fintamath/expressions/polynomial/MinMaxExpr.hpp +++ b/src/fintamath/expressions/polynomial/MinMaxExpr.hpp @@ -1,6 +1,6 @@ #pragma once -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.hpp" #include "fintamath/expressions/interfaces/IPolynomExpression.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/functions/IFunction.hpp" @@ -8,12 +8,10 @@ namespace fintamath { class MinMaxExpr final : public IPolynomExpressionCRTP { + FINTAMATH_CLASS_BODY(MinMaxExpr) + public: explicit MinMaxExpr(const IFunction &inFunc, ArgumentPtrVector inChildren); - - static constexpr MathObjectType getTypeStatic() { - return {MathObjectType::MinMaxExpr, "MinMaxExpr"}; - } }; } diff --git a/src/fintamath/expressions/polynomial/MulExpr.cpp b/src/fintamath/expressions/polynomial/MulExpr.cpp index 0b9d3c399..634cd2434 100644 --- a/src/fintamath/expressions/polynomial/MulExpr.cpp +++ b/src/fintamath/expressions/polynomial/MulExpr.cpp @@ -4,7 +4,7 @@ #include #include -#include "fintamath/core/CoreUtils.hpp" +#include "fintamath/core/MathObjectUtils.hpp" #include "fintamath/expressions/ExpressionUtils.hpp" #include "fintamath/expressions/IExpression.hpp" #include "fintamath/expressions/interfaces/IPolynomExpression.hpp" diff --git a/src/fintamath/expressions/polynomial/MulExpr.hpp b/src/fintamath/expressions/polynomial/MulExpr.hpp index b23503bb2..2e5cd7277 100644 --- a/src/fintamath/expressions/polynomial/MulExpr.hpp +++ b/src/fintamath/expressions/polynomial/MulExpr.hpp @@ -2,22 +2,20 @@ #include -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.hpp" #include "fintamath/expressions/interfaces/IPolynomExpression.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/functions/IFunction.hpp" namespace fintamath { class MulExpr final : public IPolynomExpressionCRTP { + FINTAMATH_CLASS_BODY(MulExpr) + public: explicit MulExpr(ArgumentPtrVector inChildren); std::string toString() const override; - static constexpr MathObjectType getTypeStatic() { - return {MathObjectType::MulExpr, "MulExpr"}; - } - protected: std::string childToString(const IOperator &oper, const ArgumentPtr &inChild, const ArgumentPtr &prevChild) const override; diff --git a/src/fintamath/expressions/polynomial/OrExpr.cpp b/src/fintamath/expressions/polynomial/OrExpr.cpp index bf3ff4b2b..3fd2bbe34 100644 --- a/src/fintamath/expressions/polynomial/OrExpr.cpp +++ b/src/fintamath/expressions/polynomial/OrExpr.cpp @@ -5,7 +5,7 @@ #include #include -#include "fintamath/core/CoreUtils.hpp" +#include "fintamath/core/MathObjectUtils.hpp" #include "fintamath/expressions/ExpressionUtils.hpp" #include "fintamath/expressions/IExpression.hpp" #include "fintamath/expressions/interfaces/IPolynomExpression.hpp" diff --git a/src/fintamath/expressions/polynomial/OrExpr.hpp b/src/fintamath/expressions/polynomial/OrExpr.hpp index 15b0c06a0..0c12762cb 100644 --- a/src/fintamath/expressions/polynomial/OrExpr.hpp +++ b/src/fintamath/expressions/polynomial/OrExpr.hpp @@ -2,7 +2,7 @@ #include -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.hpp" #include "fintamath/expressions/interfaces/IPolynomExpression.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/functions/IFunction.hpp" @@ -10,13 +10,11 @@ namespace fintamath { class OrExpr final : public IPolynomExpressionCRTP { + FINTAMATH_CLASS_BODY(OrExpr) + public: explicit OrExpr(ArgumentPtrVector inChildren); - static constexpr MathObjectType getTypeStatic() { - return {MathObjectType::OrExpr, "OrExpr"}; - } - protected: std::string childToString(const IOperator &oper, const ArgumentPtr &inChild, const ArgumentPtr &prevChild) const override; diff --git a/src/fintamath/expressions/unary/AbsExpr.hpp b/src/fintamath/expressions/unary/AbsExpr.hpp index b72f6b8c0..ec5cf037e 100644 --- a/src/fintamath/expressions/unary/AbsExpr.hpp +++ b/src/fintamath/expressions/unary/AbsExpr.hpp @@ -1,6 +1,6 @@ #pragma once -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.hpp" #include "fintamath/expressions/interfaces/IUnaryExpression.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/functions/IFunction.hpp" @@ -8,13 +8,11 @@ namespace fintamath { class AbsExpr final : public IUnaryExpressionCRTP { + FINTAMATH_CLASS_BODY(AbsExpr) + public: explicit AbsExpr(ArgumentPtr inChild); - static constexpr MathObjectType getTypeStatic() { - return {MathObjectType::AbsExpr, "AbsExpr"}; - } - protected: SimplifyFunctionVector getFunctionsForPostSimplify() const override; diff --git a/src/fintamath/expressions/unary/FloorCeilExpr.cpp b/src/fintamath/expressions/unary/FloorCeilExpr.cpp index 54c109116..5896a8fde 100644 --- a/src/fintamath/expressions/unary/FloorCeilExpr.cpp +++ b/src/fintamath/expressions/unary/FloorCeilExpr.cpp @@ -5,7 +5,7 @@ #include #include -#include "fintamath/core/CoreUtils.hpp" +#include "fintamath/core/MathObjectUtils.hpp" #include "fintamath/expressions/ExpressionUtils.hpp" #include "fintamath/expressions/interfaces/IUnaryExpression.hpp" #include "fintamath/functions/FunctionArguments.hpp" diff --git a/src/fintamath/expressions/unary/FloorCeilExpr.hpp b/src/fintamath/expressions/unary/FloorCeilExpr.hpp index 76be1fc4d..3b1058bef 100644 --- a/src/fintamath/expressions/unary/FloorCeilExpr.hpp +++ b/src/fintamath/expressions/unary/FloorCeilExpr.hpp @@ -2,7 +2,7 @@ #include -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.hpp" #include "fintamath/expressions/interfaces/IUnaryExpression.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/functions/IFunction.hpp" @@ -12,13 +12,11 @@ namespace fintamath { class Rational; class FloorCeilExpr final : public IUnaryExpressionCRTP { + FINTAMATH_CLASS_BODY(FloorCeilExpr) + public: explicit FloorCeilExpr(const IFunction &inFunc, ArgumentPtr inChild); - static constexpr MathObjectType getTypeStatic() { - return {MathObjectType::FloorCeilExpr, "FloorCeilExpr"}; - } - protected: SimplifyFunctionVector getFunctionsForPostSimplify() const override; diff --git a/src/fintamath/expressions/unary/HyperbExpr.cpp b/src/fintamath/expressions/unary/HyperbExpr.cpp index 7cb4c70a5..6a773e05f 100644 --- a/src/fintamath/expressions/unary/HyperbExpr.cpp +++ b/src/fintamath/expressions/unary/HyperbExpr.cpp @@ -6,7 +6,7 @@ #include #include -#include "fintamath/core/CoreUtils.hpp" +#include "fintamath/core/MathObjectUtils.hpp" #include "fintamath/expressions/ExpressionUtils.hpp" #include "fintamath/expressions/IExpression.hpp" #include "fintamath/expressions/interfaces/IUnaryExpression.hpp" diff --git a/src/fintamath/expressions/unary/HyperbExpr.hpp b/src/fintamath/expressions/unary/HyperbExpr.hpp index 66c87edde..3a5e5543b 100644 --- a/src/fintamath/expressions/unary/HyperbExpr.hpp +++ b/src/fintamath/expressions/unary/HyperbExpr.hpp @@ -2,7 +2,7 @@ #include -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.hpp" #include "fintamath/expressions/interfaces/IUnaryExpression.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/functions/IFunction.hpp" @@ -10,13 +10,11 @@ namespace fintamath { class HyperbExpr final : public IUnaryExpressionCRTP { + FINTAMATH_CLASS_BODY(HyperbExpr) + public: explicit HyperbExpr(const IFunction &inFunc, ArgumentPtr inChild); - static constexpr MathObjectType getTypeStatic() { - return {MathObjectType::HyperbExpr, "HyperbExpr"}; - } - protected: SimplifyFunctionVector getFunctionsForPreSimplify() const override; diff --git a/src/fintamath/expressions/unary/InvHyperbExpr.hpp b/src/fintamath/expressions/unary/InvHyperbExpr.hpp index 8dcf74f03..6b05440ce 100644 --- a/src/fintamath/expressions/unary/InvHyperbExpr.hpp +++ b/src/fintamath/expressions/unary/InvHyperbExpr.hpp @@ -1,6 +1,6 @@ #pragma once -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.hpp" #include "fintamath/expressions/interfaces/IUnaryExpression.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/functions/IFunction.hpp" @@ -8,12 +8,10 @@ namespace fintamath { class InvHyperbExpr final : public IUnaryExpressionCRTP { + FINTAMATH_CLASS_BODY(InvHyperbExpr) + public: explicit InvHyperbExpr(const IFunction &inFunc, ArgumentPtr inChild); - - static constexpr MathObjectType getTypeStatic() { - return {MathObjectType::InvHyperbExpr, "InvHyperbExpr"}; - } }; } diff --git a/src/fintamath/expressions/unary/InvTrigExpr.cpp b/src/fintamath/expressions/unary/InvTrigExpr.cpp index a9b7fdb8f..0b4d54669 100644 --- a/src/fintamath/expressions/unary/InvTrigExpr.cpp +++ b/src/fintamath/expressions/unary/InvTrigExpr.cpp @@ -8,7 +8,7 @@ #include #include "fintamath/core/Converter.hpp" -#include "fintamath/core/CoreUtils.hpp" +#include "fintamath/core/MathObjectUtils.hpp" #include "fintamath/expressions/IExpression.hpp" #include "fintamath/expressions/interfaces/IUnaryExpression.hpp" #include "fintamath/functions/FunctionArguments.hpp" diff --git a/src/fintamath/expressions/unary/InvTrigExpr.hpp b/src/fintamath/expressions/unary/InvTrigExpr.hpp index 0f1f4f589..df8f0f5ae 100644 --- a/src/fintamath/expressions/unary/InvTrigExpr.hpp +++ b/src/fintamath/expressions/unary/InvTrigExpr.hpp @@ -1,6 +1,6 @@ #pragma once -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.hpp" #include "fintamath/expressions/interfaces/IUnaryExpression.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/functions/IFunction.hpp" @@ -10,13 +10,11 @@ namespace fintamath { class Rational; class InvTrigExpr final : public IUnaryExpressionCRTP { + FINTAMATH_CLASS_BODY(InvTrigExpr) + public: explicit InvTrigExpr(const IFunction &inFunc, ArgumentPtr inChild); - static constexpr MathObjectType getTypeStatic() { - return {MathObjectType::InvTrigExpr, "InvTrigExpr"}; - } - protected: SimplifyFunctionVector getFunctionsForPostSimplify() const override; diff --git a/src/fintamath/expressions/unary/NotExpr.cpp b/src/fintamath/expressions/unary/NotExpr.cpp index 463fd812b..b8ea00fe3 100644 --- a/src/fintamath/expressions/unary/NotExpr.cpp +++ b/src/fintamath/expressions/unary/NotExpr.cpp @@ -5,7 +5,7 @@ #include #include -#include "fintamath/core/CoreUtils.hpp" +#include "fintamath/core/MathObjectUtils.hpp" #include "fintamath/expressions/IExpression.hpp" #include "fintamath/expressions/interfaces/IUnaryExpression.hpp" #include "fintamath/functions/FunctionArguments.hpp" diff --git a/src/fintamath/expressions/unary/NotExpr.hpp b/src/fintamath/expressions/unary/NotExpr.hpp index 1f001ce27..1bbf58260 100644 --- a/src/fintamath/expressions/unary/NotExpr.hpp +++ b/src/fintamath/expressions/unary/NotExpr.hpp @@ -2,7 +2,7 @@ #include -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.hpp" #include "fintamath/expressions/interfaces/IUnaryExpression.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/functions/IFunction.hpp" @@ -10,13 +10,11 @@ namespace fintamath { class NotExpr final : public IUnaryExpressionCRTP { + FINTAMATH_CLASS_BODY(NotExpr) + public: explicit NotExpr(ArgumentPtr inChild); - static constexpr MathObjectType getTypeStatic() { - return {MathObjectType::NotExpr, "NotExpr"}; - } - protected: SimplifyFunctionVector getFunctionsForPreSimplify() const override; diff --git a/src/fintamath/expressions/unary/SignExpr.cpp b/src/fintamath/expressions/unary/SignExpr.cpp index fb77bb287..3f8fa2e16 100644 --- a/src/fintamath/expressions/unary/SignExpr.cpp +++ b/src/fintamath/expressions/unary/SignExpr.cpp @@ -2,7 +2,7 @@ #include -#include "fintamath/core/CoreUtils.hpp" +#include "fintamath/core/MathObjectUtils.hpp" #include "fintamath/expressions/ExpressionUtils.hpp" #include "fintamath/expressions/interfaces/IUnaryExpression.hpp" #include "fintamath/functions/FunctionArguments.hpp" diff --git a/src/fintamath/expressions/unary/SignExpr.hpp b/src/fintamath/expressions/unary/SignExpr.hpp index 1795da67f..46c492f71 100644 --- a/src/fintamath/expressions/unary/SignExpr.hpp +++ b/src/fintamath/expressions/unary/SignExpr.hpp @@ -1,6 +1,6 @@ #pragma once -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.hpp" #include "fintamath/expressions/interfaces/IUnaryExpression.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/functions/IFunction.hpp" @@ -8,13 +8,11 @@ namespace fintamath { class SignExpr final : public IUnaryExpressionCRTP { + FINTAMATH_CLASS_BODY(SignExpr) + public: explicit SignExpr(ArgumentPtr inChild); - static constexpr MathObjectType getTypeStatic() { - return {MathObjectType::SignExpr, "SignExpr"}; - } - protected: SimplifyFunctionVector getFunctionsForPostSimplify() const override; diff --git a/src/fintamath/expressions/unary/TrigExpr.cpp b/src/fintamath/expressions/unary/TrigExpr.cpp index 84bd5f10a..519d37f5a 100644 --- a/src/fintamath/expressions/unary/TrigExpr.cpp +++ b/src/fintamath/expressions/unary/TrigExpr.cpp @@ -10,7 +10,7 @@ #include #include "fintamath/core/Converter.hpp" -#include "fintamath/core/CoreUtils.hpp" +#include "fintamath/core/MathObjectUtils.hpp" #include "fintamath/expressions/ExpressionUtils.hpp" #include "fintamath/expressions/IExpression.hpp" #include "fintamath/expressions/interfaces/IUnaryExpression.hpp" diff --git a/src/fintamath/expressions/unary/TrigExpr.hpp b/src/fintamath/expressions/unary/TrigExpr.hpp index aadaec53e..6affab39e 100644 --- a/src/fintamath/expressions/unary/TrigExpr.hpp +++ b/src/fintamath/expressions/unary/TrigExpr.hpp @@ -3,7 +3,7 @@ #include #include -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.hpp" #include "fintamath/expressions/interfaces/IUnaryExpression.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/functions/IFunction.hpp" @@ -13,13 +13,11 @@ namespace fintamath { class Rational; class TrigExpr final : public IUnaryExpressionCRTP { + FINTAMATH_CLASS_BODY(TrigExpr) + public: explicit TrigExpr(const IFunction &inFunc, ArgumentPtr inChild); - static constexpr MathObjectType getTypeStatic() { - return {MathObjectType::TrigExpr, "TrigExpr"}; - } - protected: SimplifyFunctionVector getFunctionsForPreSimplify() const override; diff --git a/src/fintamath/functions/IFunction.cpp b/src/fintamath/functions/IFunction.cpp index 61312a54b..a85518b1b 100644 --- a/src/fintamath/functions/IFunction.cpp +++ b/src/fintamath/functions/IFunction.cpp @@ -8,8 +8,10 @@ namespace fintamath { +FINTAMATH_PARENT_CLASS_IMPLEMENTATION(IFunction) + void IFunction::validateArgsSize(const ArgumentRefVector &argVect) const { - if (!argVect.empty() && (getArgumentTypes().size() == argVect.size() || isVariadic())) { + if (!argVect.empty() && (getArgumentClasses().size() == argVect.size() || isVariadic())) { return; } @@ -22,18 +24,4 @@ void IFunction::validateArgsSize(const ArgumentRefVector &argVect) const { throw InvalidInputFunctionException(toString(), argNameVect); } -const IFunction::FunctionNameToOrderMap &IFunction::getFunctionNameToOrderMap() { - return getFunctionNameToOrderMutableMap(); -} - -IFunction::FunctionNameToOrderMap &IFunction::getFunctionNameToOrderMutableMap() { - static FunctionNameToOrderMap map; - return map; -} - -IFunction::FunctionParser &IFunction::getParser() { - static FunctionParser parser; - return parser; -} - } diff --git a/src/fintamath/functions/IOperator.cpp b/src/fintamath/functions/IOperator.cpp index 9821a0426..089c96481 100644 --- a/src/fintamath/functions/IOperator.cpp +++ b/src/fintamath/functions/IOperator.cpp @@ -2,9 +2,6 @@ namespace fintamath { -IOperator::OperatorParser &IOperator::getParser() { - static OperatorParser parser; - return parser; -} +FINTAMATH_PARENT_CLASS_IMPLEMENTATION(IOperator) } diff --git a/src/fintamath/functions/arithmetic/Abs.cpp b/src/fintamath/functions/arithmetic/Abs.cpp index 081dd1825..7168c53b1 100644 --- a/src/fintamath/functions/arithmetic/Abs.cpp +++ b/src/fintamath/functions/arithmetic/Abs.cpp @@ -2,8 +2,8 @@ #include -#include "fintamath/core/CoreUtils.hpp" #include "fintamath/core/IMathObject.hpp" +#include "fintamath/core/MathObjectUtils.hpp" #include "fintamath/core/MultiMethod.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/functions/powers/Sqrt.hpp" diff --git a/src/fintamath/functions/arithmetic/Add.cpp b/src/fintamath/functions/arithmetic/Add.cpp index 3262e7856..3b67b7c9f 100644 --- a/src/fintamath/functions/arithmetic/Add.cpp +++ b/src/fintamath/functions/arithmetic/Add.cpp @@ -2,9 +2,9 @@ #include -#include "fintamath/core/CoreUtils.hpp" #include "fintamath/core/IArithmetic.hpp" #include "fintamath/core/IMathObject.hpp" +#include "fintamath/core/MathObjectUtils.hpp" #include "fintamath/functions/FunctionArguments.hpp" namespace fintamath { diff --git a/src/fintamath/functions/arithmetic/Div.cpp b/src/fintamath/functions/arithmetic/Div.cpp index 13a3e8525..781c78901 100644 --- a/src/fintamath/functions/arithmetic/Div.cpp +++ b/src/fintamath/functions/arithmetic/Div.cpp @@ -2,9 +2,9 @@ #include -#include "fintamath/core/CoreUtils.hpp" #include "fintamath/core/IArithmetic.hpp" #include "fintamath/core/IMathObject.hpp" +#include "fintamath/core/MathObjectUtils.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/literals/constants/ComplexInf.hpp" #include "fintamath/literals/constants/Undefined.hpp" diff --git a/src/fintamath/functions/arithmetic/FracMixed.cpp b/src/fintamath/functions/arithmetic/FracMixed.cpp index 6d54df9ad..cb2b96fff 100644 --- a/src/fintamath/functions/arithmetic/FracMixed.cpp +++ b/src/fintamath/functions/arithmetic/FracMixed.cpp @@ -2,9 +2,9 @@ #include -#include "fintamath/core/CoreUtils.hpp" #include "fintamath/core/IArithmetic.hpp" #include "fintamath/core/IMathObject.hpp" +#include "fintamath/core/MathObjectUtils.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/functions/arithmetic/Add.hpp" #include "fintamath/functions/arithmetic/Div.hpp" diff --git a/src/fintamath/functions/arithmetic/Mul.cpp b/src/fintamath/functions/arithmetic/Mul.cpp index ca02540e9..5661abf75 100644 --- a/src/fintamath/functions/arithmetic/Mul.cpp +++ b/src/fintamath/functions/arithmetic/Mul.cpp @@ -2,9 +2,9 @@ #include -#include "fintamath/core/CoreUtils.hpp" #include "fintamath/core/IArithmetic.hpp" #include "fintamath/core/IMathObject.hpp" +#include "fintamath/core/MathObjectUtils.hpp" #include "fintamath/functions/FunctionArguments.hpp" namespace fintamath { diff --git a/src/fintamath/functions/arithmetic/Neg.cpp b/src/fintamath/functions/arithmetic/Neg.cpp index cbb6643c3..e0fe071f6 100644 --- a/src/fintamath/functions/arithmetic/Neg.cpp +++ b/src/fintamath/functions/arithmetic/Neg.cpp @@ -2,9 +2,9 @@ #include -#include "fintamath/core/CoreUtils.hpp" #include "fintamath/core/IArithmetic.hpp" #include "fintamath/core/IMathObject.hpp" +#include "fintamath/core/MathObjectUtils.hpp" #include "fintamath/functions/FunctionArguments.hpp" namespace fintamath { diff --git a/src/fintamath/functions/arithmetic/Sign.cpp b/src/fintamath/functions/arithmetic/Sign.cpp index 13e65beb1..a72c57bb2 100644 --- a/src/fintamath/functions/arithmetic/Sign.cpp +++ b/src/fintamath/functions/arithmetic/Sign.cpp @@ -2,8 +2,8 @@ #include -#include "fintamath/core/CoreUtils.hpp" #include "fintamath/core/IMathObject.hpp" +#include "fintamath/core/MathObjectUtils.hpp" #include "fintamath/core/MultiMethod.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/functions/arithmetic/Abs.hpp" diff --git a/src/fintamath/functions/arithmetic/Sub.cpp b/src/fintamath/functions/arithmetic/Sub.cpp index 19459aa25..0130a8f8a 100644 --- a/src/fintamath/functions/arithmetic/Sub.cpp +++ b/src/fintamath/functions/arithmetic/Sub.cpp @@ -2,9 +2,9 @@ #include -#include "fintamath/core/CoreUtils.hpp" #include "fintamath/core/IArithmetic.hpp" #include "fintamath/core/IMathObject.hpp" +#include "fintamath/core/MathObjectUtils.hpp" #include "fintamath/functions/FunctionArguments.hpp" namespace fintamath { diff --git a/src/fintamath/functions/arithmetic/UnaryPlus.cpp b/src/fintamath/functions/arithmetic/UnaryPlus.cpp index 8d8c33c65..4c5b6171a 100644 --- a/src/fintamath/functions/arithmetic/UnaryPlus.cpp +++ b/src/fintamath/functions/arithmetic/UnaryPlus.cpp @@ -2,9 +2,9 @@ #include -#include "fintamath/core/CoreUtils.hpp" #include "fintamath/core/IArithmetic.hpp" #include "fintamath/core/IMathObject.hpp" +#include "fintamath/core/MathObjectUtils.hpp" #include "fintamath/functions/FunctionArguments.hpp" namespace fintamath { diff --git a/src/fintamath/functions/calculus/Max.cpp b/src/fintamath/functions/calculus/Max.cpp index 93caf91d4..34c83fe7c 100644 --- a/src/fintamath/functions/calculus/Max.cpp +++ b/src/fintamath/functions/calculus/Max.cpp @@ -4,9 +4,9 @@ #include #include -#include "fintamath/core/CoreUtils.hpp" #include "fintamath/core/IComparable.hpp" #include "fintamath/core/IMathObject.hpp" +#include "fintamath/core/MathObjectUtils.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/numbers/Complex.hpp" diff --git a/src/fintamath/functions/calculus/Min.cpp b/src/fintamath/functions/calculus/Min.cpp index c1cdc724c..6010020b4 100644 --- a/src/fintamath/functions/calculus/Min.cpp +++ b/src/fintamath/functions/calculus/Min.cpp @@ -4,9 +4,9 @@ #include #include -#include "fintamath/core/CoreUtils.hpp" #include "fintamath/core/IComparable.hpp" #include "fintamath/core/IMathObject.hpp" +#include "fintamath/core/MathObjectUtils.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/numbers/Complex.hpp" diff --git a/src/fintamath/functions/comparison/Less.cpp b/src/fintamath/functions/comparison/Less.cpp index fe01dd871..9c5db1334 100644 --- a/src/fintamath/functions/comparison/Less.cpp +++ b/src/fintamath/functions/comparison/Less.cpp @@ -2,9 +2,9 @@ #include -#include "fintamath/core/CoreUtils.hpp" #include "fintamath/core/IComparable.hpp" #include "fintamath/core/IMathObject.hpp" +#include "fintamath/core/MathObjectUtils.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/numbers/Complex.hpp" diff --git a/src/fintamath/functions/comparison/LessEqv.cpp b/src/fintamath/functions/comparison/LessEqv.cpp index 48eae6da4..70eef74ba 100644 --- a/src/fintamath/functions/comparison/LessEqv.cpp +++ b/src/fintamath/functions/comparison/LessEqv.cpp @@ -2,9 +2,9 @@ #include -#include "fintamath/core/CoreUtils.hpp" #include "fintamath/core/IComparable.hpp" #include "fintamath/core/IMathObject.hpp" +#include "fintamath/core/MathObjectUtils.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/numbers/Complex.hpp" diff --git a/src/fintamath/functions/comparison/More.cpp b/src/fintamath/functions/comparison/More.cpp index fa303eca9..be3171bdc 100644 --- a/src/fintamath/functions/comparison/More.cpp +++ b/src/fintamath/functions/comparison/More.cpp @@ -2,9 +2,9 @@ #include -#include "fintamath/core/CoreUtils.hpp" #include "fintamath/core/IComparable.hpp" #include "fintamath/core/IMathObject.hpp" +#include "fintamath/core/MathObjectUtils.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/numbers/Complex.hpp" diff --git a/src/fintamath/functions/comparison/MoreEqv.cpp b/src/fintamath/functions/comparison/MoreEqv.cpp index 3b29e6b46..f10d24663 100644 --- a/src/fintamath/functions/comparison/MoreEqv.cpp +++ b/src/fintamath/functions/comparison/MoreEqv.cpp @@ -2,9 +2,9 @@ #include -#include "fintamath/core/CoreUtils.hpp" #include "fintamath/core/IComparable.hpp" #include "fintamath/core/IMathObject.hpp" +#include "fintamath/core/MathObjectUtils.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/numbers/Complex.hpp" diff --git a/src/fintamath/functions/hyperbolic/Acosh.cpp b/src/fintamath/functions/hyperbolic/Acosh.cpp index 7c6cb8436..52d5f6df6 100644 --- a/src/fintamath/functions/hyperbolic/Acosh.cpp +++ b/src/fintamath/functions/hyperbolic/Acosh.cpp @@ -2,8 +2,8 @@ #include -#include "fintamath/core/CoreUtils.hpp" #include "fintamath/core/IMathObject.hpp" +#include "fintamath/core/MathObjectUtils.hpp" #include "fintamath/core/MultiMethod.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/functions/arithmetic/Div.hpp" diff --git a/src/fintamath/functions/hyperbolic/Acoth.cpp b/src/fintamath/functions/hyperbolic/Acoth.cpp index 91066f91c..a551a1ea9 100644 --- a/src/fintamath/functions/hyperbolic/Acoth.cpp +++ b/src/fintamath/functions/hyperbolic/Acoth.cpp @@ -2,8 +2,8 @@ #include -#include "fintamath/core/CoreUtils.hpp" #include "fintamath/core/IMathObject.hpp" +#include "fintamath/core/MathObjectUtils.hpp" #include "fintamath/core/MultiMethod.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/functions/arithmetic/Div.hpp" diff --git a/src/fintamath/functions/hyperbolic/Acsch.cpp b/src/fintamath/functions/hyperbolic/Acsch.cpp index 9fc0de718..b65e43e0c 100644 --- a/src/fintamath/functions/hyperbolic/Acsch.cpp +++ b/src/fintamath/functions/hyperbolic/Acsch.cpp @@ -2,8 +2,8 @@ #include -#include "fintamath/core/CoreUtils.hpp" #include "fintamath/core/IMathObject.hpp" +#include "fintamath/core/MathObjectUtils.hpp" #include "fintamath/core/MultiMethod.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/literals/constants/ComplexInf.hpp" diff --git a/src/fintamath/functions/hyperbolic/Asech.cpp b/src/fintamath/functions/hyperbolic/Asech.cpp index 9092e970d..48f450a88 100644 --- a/src/fintamath/functions/hyperbolic/Asech.cpp +++ b/src/fintamath/functions/hyperbolic/Asech.cpp @@ -2,8 +2,8 @@ #include -#include "fintamath/core/CoreUtils.hpp" #include "fintamath/core/IMathObject.hpp" +#include "fintamath/core/MathObjectUtils.hpp" #include "fintamath/core/MultiMethod.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/functions/arithmetic/Mul.hpp" diff --git a/src/fintamath/functions/hyperbolic/Asinh.cpp b/src/fintamath/functions/hyperbolic/Asinh.cpp index 570804bf9..f39405772 100644 --- a/src/fintamath/functions/hyperbolic/Asinh.cpp +++ b/src/fintamath/functions/hyperbolic/Asinh.cpp @@ -2,8 +2,8 @@ #include -#include "fintamath/core/CoreUtils.hpp" #include "fintamath/core/IMathObject.hpp" +#include "fintamath/core/MathObjectUtils.hpp" #include "fintamath/core/MultiMethod.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/numbers/INumber.hpp" diff --git a/src/fintamath/functions/hyperbolic/Atanh.cpp b/src/fintamath/functions/hyperbolic/Atanh.cpp index 5dc53a579..6736b4231 100644 --- a/src/fintamath/functions/hyperbolic/Atanh.cpp +++ b/src/fintamath/functions/hyperbolic/Atanh.cpp @@ -2,8 +2,8 @@ #include -#include "fintamath/core/CoreUtils.hpp" #include "fintamath/core/IMathObject.hpp" +#include "fintamath/core/MathObjectUtils.hpp" #include "fintamath/core/MultiMethod.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/literals/constants/Inf.hpp" diff --git a/src/fintamath/functions/hyperbolic/Cosh.cpp b/src/fintamath/functions/hyperbolic/Cosh.cpp index 83b7b762c..80c7eaa49 100644 --- a/src/fintamath/functions/hyperbolic/Cosh.cpp +++ b/src/fintamath/functions/hyperbolic/Cosh.cpp @@ -2,8 +2,8 @@ #include -#include "fintamath/core/CoreUtils.hpp" #include "fintamath/core/IMathObject.hpp" +#include "fintamath/core/MathObjectUtils.hpp" #include "fintamath/core/MultiMethod.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/numbers/INumber.hpp" diff --git a/src/fintamath/functions/hyperbolic/Coth.cpp b/src/fintamath/functions/hyperbolic/Coth.cpp index 06d15ecdd..a8cbd13d1 100644 --- a/src/fintamath/functions/hyperbolic/Coth.cpp +++ b/src/fintamath/functions/hyperbolic/Coth.cpp @@ -2,8 +2,8 @@ #include -#include "fintamath/core/CoreUtils.hpp" #include "fintamath/core/IMathObject.hpp" +#include "fintamath/core/MathObjectUtils.hpp" #include "fintamath/core/MultiMethod.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/literals/constants/ComplexInf.hpp" diff --git a/src/fintamath/functions/hyperbolic/Csch.cpp b/src/fintamath/functions/hyperbolic/Csch.cpp index c9fbbc7f3..c79cdcff2 100644 --- a/src/fintamath/functions/hyperbolic/Csch.cpp +++ b/src/fintamath/functions/hyperbolic/Csch.cpp @@ -2,8 +2,8 @@ #include -#include "fintamath/core/CoreUtils.hpp" #include "fintamath/core/IMathObject.hpp" +#include "fintamath/core/MathObjectUtils.hpp" #include "fintamath/core/MultiMethod.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/literals/constants/ComplexInf.hpp" diff --git a/src/fintamath/functions/hyperbolic/Sech.cpp b/src/fintamath/functions/hyperbolic/Sech.cpp index 5872ff48b..cb28608ef 100644 --- a/src/fintamath/functions/hyperbolic/Sech.cpp +++ b/src/fintamath/functions/hyperbolic/Sech.cpp @@ -2,8 +2,8 @@ #include -#include "fintamath/core/CoreUtils.hpp" #include "fintamath/core/IMathObject.hpp" +#include "fintamath/core/MathObjectUtils.hpp" #include "fintamath/core/MultiMethod.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/numbers/INumber.hpp" diff --git a/src/fintamath/functions/hyperbolic/Sinh.cpp b/src/fintamath/functions/hyperbolic/Sinh.cpp index 5895b7767..e4305e38c 100644 --- a/src/fintamath/functions/hyperbolic/Sinh.cpp +++ b/src/fintamath/functions/hyperbolic/Sinh.cpp @@ -2,8 +2,8 @@ #include -#include "fintamath/core/CoreUtils.hpp" #include "fintamath/core/IMathObject.hpp" +#include "fintamath/core/MathObjectUtils.hpp" #include "fintamath/core/MultiMethod.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/numbers/INumber.hpp" diff --git a/src/fintamath/functions/hyperbolic/Tanh.cpp b/src/fintamath/functions/hyperbolic/Tanh.cpp index 8ba3ba820..2b96695e9 100644 --- a/src/fintamath/functions/hyperbolic/Tanh.cpp +++ b/src/fintamath/functions/hyperbolic/Tanh.cpp @@ -2,8 +2,8 @@ #include -#include "fintamath/core/CoreUtils.hpp" #include "fintamath/core/IMathObject.hpp" +#include "fintamath/core/MathObjectUtils.hpp" #include "fintamath/core/MultiMethod.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/numbers/INumber.hpp" diff --git a/src/fintamath/functions/logarithms/Ln.cpp b/src/fintamath/functions/logarithms/Ln.cpp index 6163a6bdf..fff09c50d 100644 --- a/src/fintamath/functions/logarithms/Ln.cpp +++ b/src/fintamath/functions/logarithms/Ln.cpp @@ -2,8 +2,8 @@ #include -#include "fintamath/core/CoreUtils.hpp" #include "fintamath/core/IMathObject.hpp" +#include "fintamath/core/MathObjectUtils.hpp" #include "fintamath/core/MultiMethod.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/literals/constants/NegInf.hpp" diff --git a/src/fintamath/functions/logarithms/Log.cpp b/src/fintamath/functions/logarithms/Log.cpp index 1aa6ca091..70fdfcada 100644 --- a/src/fintamath/functions/logarithms/Log.cpp +++ b/src/fintamath/functions/logarithms/Log.cpp @@ -4,8 +4,8 @@ #include #include "fintamath/core/Converter.hpp" -#include "fintamath/core/CoreUtils.hpp" #include "fintamath/core/IMathObject.hpp" +#include "fintamath/core/MathObjectUtils.hpp" #include "fintamath/core/MultiMethod.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/functions/arithmetic/Neg.hpp" diff --git a/src/fintamath/functions/logic/And.cpp b/src/fintamath/functions/logic/And.cpp index c89689d3a..ea06c8073 100644 --- a/src/fintamath/functions/logic/And.cpp +++ b/src/fintamath/functions/logic/And.cpp @@ -2,8 +2,8 @@ #include -#include "fintamath/core/CoreUtils.hpp" #include "fintamath/core/IMathObject.hpp" +#include "fintamath/core/MathObjectUtils.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/literals/Boolean.hpp" diff --git a/src/fintamath/functions/logic/Equiv.cpp b/src/fintamath/functions/logic/Equiv.cpp index 921b18443..b2fdda2f5 100644 --- a/src/fintamath/functions/logic/Equiv.cpp +++ b/src/fintamath/functions/logic/Equiv.cpp @@ -2,8 +2,8 @@ #include -#include "fintamath/core/CoreUtils.hpp" #include "fintamath/core/IMathObject.hpp" +#include "fintamath/core/MathObjectUtils.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/literals/Boolean.hpp" diff --git a/src/fintamath/functions/logic/Impl.cpp b/src/fintamath/functions/logic/Impl.cpp index 76a840bf5..b17544217 100644 --- a/src/fintamath/functions/logic/Impl.cpp +++ b/src/fintamath/functions/logic/Impl.cpp @@ -2,8 +2,8 @@ #include -#include "fintamath/core/CoreUtils.hpp" #include "fintamath/core/IMathObject.hpp" +#include "fintamath/core/MathObjectUtils.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/literals/Boolean.hpp" diff --git a/src/fintamath/functions/logic/Nequiv.cpp b/src/fintamath/functions/logic/Nequiv.cpp index f5b6965e5..4fbf419a1 100644 --- a/src/fintamath/functions/logic/Nequiv.cpp +++ b/src/fintamath/functions/logic/Nequiv.cpp @@ -2,8 +2,8 @@ #include -#include "fintamath/core/CoreUtils.hpp" #include "fintamath/core/IMathObject.hpp" +#include "fintamath/core/MathObjectUtils.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/literals/Boolean.hpp" diff --git a/src/fintamath/functions/logic/Not.cpp b/src/fintamath/functions/logic/Not.cpp index 0a3c696e3..b60dd2aae 100644 --- a/src/fintamath/functions/logic/Not.cpp +++ b/src/fintamath/functions/logic/Not.cpp @@ -2,8 +2,8 @@ #include -#include "fintamath/core/CoreUtils.hpp" #include "fintamath/core/IMathObject.hpp" +#include "fintamath/core/MathObjectUtils.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/literals/Boolean.hpp" diff --git a/src/fintamath/functions/logic/Or.cpp b/src/fintamath/functions/logic/Or.cpp index 0a96efb72..d460896a1 100644 --- a/src/fintamath/functions/logic/Or.cpp +++ b/src/fintamath/functions/logic/Or.cpp @@ -2,8 +2,8 @@ #include -#include "fintamath/core/CoreUtils.hpp" #include "fintamath/core/IMathObject.hpp" +#include "fintamath/core/MathObjectUtils.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/literals/Boolean.hpp" diff --git a/src/fintamath/functions/ntheory/Ceil.cpp b/src/fintamath/functions/ntheory/Ceil.cpp index ab7bb524b..10633dc20 100644 --- a/src/fintamath/functions/ntheory/Ceil.cpp +++ b/src/fintamath/functions/ntheory/Ceil.cpp @@ -3,8 +3,8 @@ #include #include -#include "fintamath/core/CoreUtils.hpp" #include "fintamath/core/IMathObject.hpp" +#include "fintamath/core/MathObjectUtils.hpp" #include "fintamath/core/MultiMethod.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/numbers/Complex.hpp" diff --git a/src/fintamath/functions/ntheory/Floor.cpp b/src/fintamath/functions/ntheory/Floor.cpp index 662f9ba9c..0262251fe 100644 --- a/src/fintamath/functions/ntheory/Floor.cpp +++ b/src/fintamath/functions/ntheory/Floor.cpp @@ -3,8 +3,8 @@ #include #include -#include "fintamath/core/CoreUtils.hpp" #include "fintamath/core/IMathObject.hpp" +#include "fintamath/core/MathObjectUtils.hpp" #include "fintamath/core/MultiMethod.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/numbers/Complex.hpp" diff --git a/src/fintamath/functions/ntheory/Mod.cpp b/src/fintamath/functions/ntheory/Mod.cpp index ea9713015..a7fe4b7fe 100644 --- a/src/fintamath/functions/ntheory/Mod.cpp +++ b/src/fintamath/functions/ntheory/Mod.cpp @@ -3,8 +3,8 @@ #include #include -#include "fintamath/core/CoreUtils.hpp" #include "fintamath/core/IMathObject.hpp" +#include "fintamath/core/MathObjectUtils.hpp" #include "fintamath/core/MultiMethod.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/literals/constants/Undefined.hpp" diff --git a/src/fintamath/functions/other/Factorial.cpp b/src/fintamath/functions/other/Factorial.cpp index fcd9d1b1e..dcd6e06db 100644 --- a/src/fintamath/functions/other/Factorial.cpp +++ b/src/fintamath/functions/other/Factorial.cpp @@ -3,8 +3,8 @@ #include #include -#include "fintamath/core/CoreUtils.hpp" #include "fintamath/core/IMathObject.hpp" +#include "fintamath/core/MathObjectUtils.hpp" #include "fintamath/core/MultiMethod.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/literals/constants/ComplexInf.hpp" diff --git a/src/fintamath/functions/other/Index.cpp b/src/fintamath/functions/other/Index.cpp index 4236ef64f..eddb24652 100644 --- a/src/fintamath/functions/other/Index.cpp +++ b/src/fintamath/functions/other/Index.cpp @@ -2,8 +2,8 @@ #include -#include "fintamath/core/CoreUtils.hpp" #include "fintamath/core/IMathObject.hpp" +#include "fintamath/core/MathObjectUtils.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/literals/Variable.hpp" #include "fintamath/numbers/Integer.hpp" diff --git a/src/fintamath/functions/other/Percent.cpp b/src/fintamath/functions/other/Percent.cpp index 2bbd64312..c2c865b09 100644 --- a/src/fintamath/functions/other/Percent.cpp +++ b/src/fintamath/functions/other/Percent.cpp @@ -2,8 +2,8 @@ #include -#include "fintamath/core/CoreUtils.hpp" #include "fintamath/core/IMathObject.hpp" +#include "fintamath/core/MathObjectUtils.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/numbers/INumber.hpp" #include "fintamath/numbers/Rational.hpp" diff --git a/src/fintamath/functions/powers/Pow.cpp b/src/fintamath/functions/powers/Pow.cpp index dae1e6ef7..d037e6e92 100644 --- a/src/fintamath/functions/powers/Pow.cpp +++ b/src/fintamath/functions/powers/Pow.cpp @@ -3,8 +3,8 @@ #include #include "fintamath/core/Converter.hpp" -#include "fintamath/core/CoreUtils.hpp" #include "fintamath/core/IMathObject.hpp" +#include "fintamath/core/MathObjectUtils.hpp" #include "fintamath/core/MultiMethod.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/functions/powers/Root.hpp" diff --git a/src/fintamath/functions/powers/Root.cpp b/src/fintamath/functions/powers/Root.cpp index dfc7bbb3c..6469d4d8e 100644 --- a/src/fintamath/functions/powers/Root.cpp +++ b/src/fintamath/functions/powers/Root.cpp @@ -2,8 +2,8 @@ #include -#include "fintamath/core/CoreUtils.hpp" #include "fintamath/core/IMathObject.hpp" +#include "fintamath/core/MathObjectUtils.hpp" #include "fintamath/core/MultiMethod.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/functions/arithmetic/Div.hpp" diff --git a/src/fintamath/functions/trigonometry/Acos.cpp b/src/fintamath/functions/trigonometry/Acos.cpp index 6a2305b6b..a34490002 100644 --- a/src/fintamath/functions/trigonometry/Acos.cpp +++ b/src/fintamath/functions/trigonometry/Acos.cpp @@ -2,8 +2,8 @@ #include -#include "fintamath/core/CoreUtils.hpp" #include "fintamath/core/IMathObject.hpp" +#include "fintamath/core/MathObjectUtils.hpp" #include "fintamath/core/MultiMethod.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/functions/arithmetic/Div.hpp" diff --git a/src/fintamath/functions/trigonometry/Acot.cpp b/src/fintamath/functions/trigonometry/Acot.cpp index 4333ad441..4e864cf8f 100644 --- a/src/fintamath/functions/trigonometry/Acot.cpp +++ b/src/fintamath/functions/trigonometry/Acot.cpp @@ -2,8 +2,8 @@ #include -#include "fintamath/core/CoreUtils.hpp" #include "fintamath/core/IMathObject.hpp" +#include "fintamath/core/MathObjectUtils.hpp" #include "fintamath/core/MultiMethod.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/functions/arithmetic/Div.hpp" diff --git a/src/fintamath/functions/trigonometry/Acsc.cpp b/src/fintamath/functions/trigonometry/Acsc.cpp index 5be9181a8..06795f9b2 100644 --- a/src/fintamath/functions/trigonometry/Acsc.cpp +++ b/src/fintamath/functions/trigonometry/Acsc.cpp @@ -2,8 +2,8 @@ #include -#include "fintamath/core/CoreUtils.hpp" #include "fintamath/core/IMathObject.hpp" +#include "fintamath/core/MathObjectUtils.hpp" #include "fintamath/core/MultiMethod.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/functions/arithmetic/Div.hpp" diff --git a/src/fintamath/functions/trigonometry/Asec.cpp b/src/fintamath/functions/trigonometry/Asec.cpp index 1b8f96908..06daaa365 100644 --- a/src/fintamath/functions/trigonometry/Asec.cpp +++ b/src/fintamath/functions/trigonometry/Asec.cpp @@ -2,8 +2,8 @@ #include -#include "fintamath/core/CoreUtils.hpp" #include "fintamath/core/IMathObject.hpp" +#include "fintamath/core/MathObjectUtils.hpp" #include "fintamath/core/MultiMethod.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/literals/constants/ComplexInf.hpp" diff --git a/src/fintamath/functions/trigonometry/Asin.cpp b/src/fintamath/functions/trigonometry/Asin.cpp index df57242c0..ca7819d26 100644 --- a/src/fintamath/functions/trigonometry/Asin.cpp +++ b/src/fintamath/functions/trigonometry/Asin.cpp @@ -2,8 +2,8 @@ #include -#include "fintamath/core/CoreUtils.hpp" #include "fintamath/core/IMathObject.hpp" +#include "fintamath/core/MathObjectUtils.hpp" #include "fintamath/core/MultiMethod.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/functions/arithmetic/Div.hpp" diff --git a/src/fintamath/functions/trigonometry/Atan.cpp b/src/fintamath/functions/trigonometry/Atan.cpp index 5c3a258c1..d998d6085 100644 --- a/src/fintamath/functions/trigonometry/Atan.cpp +++ b/src/fintamath/functions/trigonometry/Atan.cpp @@ -2,8 +2,8 @@ #include -#include "fintamath/core/CoreUtils.hpp" #include "fintamath/core/IMathObject.hpp" +#include "fintamath/core/MathObjectUtils.hpp" #include "fintamath/core/MultiMethod.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/functions/arithmetic/Div.hpp" diff --git a/src/fintamath/functions/trigonometry/Cos.cpp b/src/fintamath/functions/trigonometry/Cos.cpp index 97ffe4119..0b82f36a1 100644 --- a/src/fintamath/functions/trigonometry/Cos.cpp +++ b/src/fintamath/functions/trigonometry/Cos.cpp @@ -2,8 +2,8 @@ #include -#include "fintamath/core/CoreUtils.hpp" #include "fintamath/core/IMathObject.hpp" +#include "fintamath/core/MathObjectUtils.hpp" #include "fintamath/core/MultiMethod.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/numbers/INumber.hpp" diff --git a/src/fintamath/functions/trigonometry/Cot.cpp b/src/fintamath/functions/trigonometry/Cot.cpp index 836dfaf82..ed27a0474 100644 --- a/src/fintamath/functions/trigonometry/Cot.cpp +++ b/src/fintamath/functions/trigonometry/Cot.cpp @@ -2,8 +2,8 @@ #include -#include "fintamath/core/CoreUtils.hpp" #include "fintamath/core/IMathObject.hpp" +#include "fintamath/core/MathObjectUtils.hpp" #include "fintamath/core/MultiMethod.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/literals/constants/ComplexInf.hpp" diff --git a/src/fintamath/functions/trigonometry/Csc.cpp b/src/fintamath/functions/trigonometry/Csc.cpp index 9f6eff367..9d8a14cca 100644 --- a/src/fintamath/functions/trigonometry/Csc.cpp +++ b/src/fintamath/functions/trigonometry/Csc.cpp @@ -2,8 +2,8 @@ #include -#include "fintamath/core/CoreUtils.hpp" #include "fintamath/core/IMathObject.hpp" +#include "fintamath/core/MathObjectUtils.hpp" #include "fintamath/core/MultiMethod.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/literals/constants/ComplexInf.hpp" diff --git a/src/fintamath/functions/trigonometry/Sec.cpp b/src/fintamath/functions/trigonometry/Sec.cpp index fcf9ac1dc..51c25fd72 100644 --- a/src/fintamath/functions/trigonometry/Sec.cpp +++ b/src/fintamath/functions/trigonometry/Sec.cpp @@ -2,8 +2,8 @@ #include -#include "fintamath/core/CoreUtils.hpp" #include "fintamath/core/IMathObject.hpp" +#include "fintamath/core/MathObjectUtils.hpp" #include "fintamath/core/MultiMethod.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/numbers/INumber.hpp" diff --git a/src/fintamath/functions/trigonometry/Sin.cpp b/src/fintamath/functions/trigonometry/Sin.cpp index 19941fd1a..908c4abf2 100644 --- a/src/fintamath/functions/trigonometry/Sin.cpp +++ b/src/fintamath/functions/trigonometry/Sin.cpp @@ -2,8 +2,8 @@ #include -#include "fintamath/core/CoreUtils.hpp" #include "fintamath/core/IMathObject.hpp" +#include "fintamath/core/MathObjectUtils.hpp" #include "fintamath/core/MultiMethod.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/numbers/INumber.hpp" diff --git a/src/fintamath/functions/trigonometry/Tan.cpp b/src/fintamath/functions/trigonometry/Tan.cpp index efa831732..3088a4f0a 100644 --- a/src/fintamath/functions/trigonometry/Tan.cpp +++ b/src/fintamath/functions/trigonometry/Tan.cpp @@ -2,8 +2,8 @@ #include -#include "fintamath/core/CoreUtils.hpp" #include "fintamath/core/IMathObject.hpp" +#include "fintamath/core/MathObjectUtils.hpp" #include "fintamath/core/MultiMethod.hpp" #include "fintamath/functions/FunctionArguments.hpp" #include "fintamath/numbers/INumber.hpp" diff --git a/src/fintamath/literals/ILiteral.cpp b/src/fintamath/literals/ILiteral.cpp index 9a3719085..695683b8b 100644 --- a/src/fintamath/literals/ILiteral.cpp +++ b/src/fintamath/literals/ILiteral.cpp @@ -2,9 +2,6 @@ namespace fintamath { -ILiteral::LiteralParser &ILiteral::getParser() { - static LiteralParser parser; - return parser; -} +FINTAMATH_PARENT_CLASS_IMPLEMENTATION(ILiteral) } diff --git a/src/fintamath/literals/constants/IConstant.cpp b/src/fintamath/literals/constants/IConstant.cpp index 21917e619..036ee0cd9 100644 --- a/src/fintamath/literals/constants/IConstant.cpp +++ b/src/fintamath/literals/constants/IConstant.cpp @@ -2,9 +2,6 @@ namespace fintamath { -IConstant::ConstantParser &IConstant::getParser() { - static ConstantParser parser; - return parser; -} +FINTAMATH_PARENT_CLASS_IMPLEMENTATION(IConstant) } diff --git a/src/fintamath/numbers/Complex.cpp b/src/fintamath/numbers/Complex.cpp index e52b8d22c..3c7829c4c 100644 --- a/src/fintamath/numbers/Complex.cpp +++ b/src/fintamath/numbers/Complex.cpp @@ -6,8 +6,8 @@ #include #include "fintamath/core/Converter.hpp" -#include "fintamath/core/CoreUtils.hpp" #include "fintamath/core/IMathObject.hpp" +#include "fintamath/core/MathObjectUtils.hpp" #include "fintamath/exceptions/InvalidInputException.hpp" #include "fintamath/exceptions/UndefinedException.hpp" #include "fintamath/numbers/INumber.hpp" @@ -31,10 +31,10 @@ Complex &Complex::operator=(const Complex &rhs) { Complex::Complex(const std::string &str) { if (!str.empty() && str.back() == 'I') { - im = parse(str.substr(0, str.size() - 1)); + im = parseNonComplexNumber(str.substr(0, str.size() - 1)); } else { - re = parse(str); + re = parseNonComplexNumber(str); } if (!re || !im) { @@ -204,4 +204,18 @@ Complex &Complex::negate() { return *this; } +std::unique_ptr Complex::parseNonComplexNumber(const std::string &str) { + static auto numberParser = [] { + detail::Parser> parser; + parser.registerType(); + parser.registerType(); + parser.registerType(); + return parser; + }(); + + return numberParser + .parseFirst(str) + .value_or(std::unique_ptr{}); +} + } diff --git a/src/fintamath/numbers/IInteger.cpp b/src/fintamath/numbers/IInteger.cpp index e621d66ca..e3f972ec4 100644 --- a/src/fintamath/numbers/IInteger.cpp +++ b/src/fintamath/numbers/IInteger.cpp @@ -2,9 +2,6 @@ namespace fintamath { -IInteger::IntegerParser &IInteger::getParser() { - static IntegerParser parser; - return parser; -} +FINTAMATH_PARENT_CLASS_IMPLEMENTATION(IInteger) } diff --git a/src/fintamath/numbers/INumber.cpp b/src/fintamath/numbers/INumber.cpp index 9c99338e4..e9b27c355 100644 --- a/src/fintamath/numbers/INumber.cpp +++ b/src/fintamath/numbers/INumber.cpp @@ -2,9 +2,6 @@ namespace fintamath { -INumber::NumberParser &INumber::getParser() { - static NumberParser parser; - return parser; -} +FINTAMATH_PARENT_CLASS_IMPLEMENTATION(INumber) } diff --git a/src/fintamath/numbers/NumberAbstract.cpp b/src/fintamath/numbers/NumberAbstract.cpp index c721dcb3c..9ad847284 100644 --- a/src/fintamath/numbers/NumberAbstract.cpp +++ b/src/fintamath/numbers/NumberAbstract.cpp @@ -3,10 +3,10 @@ #include #include -#include "fintamath/core/CoreUtils.hpp" #include "fintamath/core/IArithmetic.hpp" #include "fintamath/core/IComparable.hpp" #include "fintamath/core/IMathObject.hpp" +#include "fintamath/core/MathObjectUtils.hpp" #include "fintamath/numbers/IInteger.hpp" #include "fintamath/numbers/Integer.hpp" #include "fintamath/numbers/Rational.hpp" diff --git a/tests/src/core/CacheTests.cpp b/tests/src/core/CacheTests.cpp index fa4566db1..8d63acfdd 100644 --- a/tests/src/core/CacheTests.cpp +++ b/tests/src/core/CacheTests.cpp @@ -1,6 +1,6 @@ #include -#include "fintamath/core/CoreUtils.hpp" +#include "fintamath/core/Cache.hpp" #include "fintamath/literals/constants/E.hpp" #include "fintamath/numbers/Integer.hpp" diff --git a/tests/src/core/CoreUtilsTests.cpp b/tests/src/core/CoreUtilsTests.cpp index 52efeb02d..bc4b6223f 100644 --- a/tests/src/core/CoreUtilsTests.cpp +++ b/tests/src/core/CoreUtilsTests.cpp @@ -1,6 +1,6 @@ #include -#include "fintamath/core/CoreUtils.hpp" +#include "fintamath/core/MathObjectUtils.hpp" #include "fintamath/literals/constants/E.hpp" #include "fintamath/numbers/Integer.hpp" @@ -11,7 +11,7 @@ using namespace fintamath; E c; Integer i; -TEST(CoreUtilsTests, isTest) { +TEST(MathObjectUtilsTests, isTest) { EXPECT_TRUE(is(i)); EXPECT_FALSE(is(c)); @@ -35,7 +35,7 @@ TEST(CoreUtilsTests, isTest) { EXPECT_FALSE(is(std::reference_wrapper(c))); } -TEST(CoreUtilsTests, castTest) { +TEST(MathObjectUtilsTests, castTest) { EXPECT_NO_THROW(cast(i)); EXPECT_THROW(cast(cast(c)), std::bad_cast); diff --git a/tests/src/core/IArithmeticTests.cpp b/tests/src/core/IArithmeticTests.cpp index 0b7aa8079..7f7b948ca 100644 --- a/tests/src/core/IArithmeticTests.cpp +++ b/tests/src/core/IArithmeticTests.cpp @@ -3,6 +3,7 @@ #include "fintamath/core/IArithmetic.hpp" #include "fintamath/exceptions/InvalidInputException.hpp" +#include "fintamath/expressions/IExpression.hpp" #include "fintamath/numbers/Integer.hpp" #include "fintamath/numbers/Rational.hpp" @@ -11,10 +12,7 @@ using namespace fintamath; namespace { class TestArithmetic final : public IArithmeticCRTP { -public: - static constexpr MathObjectType getTypeStatic() { - return {static_cast(MathObjectType::IArithmetic) + 999, "TestArithmetic"}; - } + FINTAMATH_CLASS_BODY(TestArithmetic) protected: TestArithmetic &add(const TestArithmetic & /* rhs */) override { @@ -38,6 +36,15 @@ class TestArithmetic final : public IArithmeticCRTP { } }; +[[maybe_unused]] const auto config = [] { + IArithmetic::registerType(); + return 0; +}(); + +} + +TEST(IArithmeticTests, parseTest) { + EXPECT_TRUE(is(*IArithmetic::parseFirst("TestArithmetic"))); } TEST(IArithmeticTests, addTest) { @@ -198,6 +205,7 @@ TEST(IArithmeticTests, negateTest) { EXPECT_EQ((-Integer(1)).toString(), "-1"); } -TEST(IArithmeticTests, getTypeTest) { - EXPECT_EQ(IArithmetic::getTypeStatic(), MathObjectType(MathObjectType::IArithmetic, "IArithmetic")); +TEST(IArithmeticTests, getClassTest) { + EXPECT_EQ(IArithmetic::getClassStatic(), MathObjectClass("IArithmetic")); + EXPECT_EQ(IArithmetic::getClassStatic().getParent(), IMathObject::getClassStatic()); } diff --git a/tests/src/core/IComparableTests.cpp b/tests/src/core/IComparableTests.cpp index 8702e3422..c9290aa6f 100644 --- a/tests/src/core/IComparableTests.cpp +++ b/tests/src/core/IComparableTests.cpp @@ -11,14 +11,11 @@ using namespace fintamath; namespace { class TestComparable final : public IComparableCRTP { -public: - static constexpr MathObjectType getTypeStatic() { - return {static_cast(MathObjectType::IComparable) + 998, "TestComparable"}; - } + FINTAMATH_CLASS_BODY(TestComparable) protected: std::strong_ordering compare(const TestComparable & /* rhs */) const override { - return 0 <=> 1; + return std::strong_ordering::less; } TestComparable &add(const TestComparable &rhs) override { @@ -42,6 +39,15 @@ class TestComparable final : public IComparableCRTP { } }; +[[maybe_unused]] const auto config = [] { + IComparable::registerType(); + return 0; +}(); + +} + +TEST(IComparableTests, parseTest) { + EXPECT_TRUE(is(*IComparable::parseFirst("TestComparable"))); } TEST(IComparableTests, lessTest) { @@ -144,6 +150,7 @@ TEST(IComparableTests, moreEqualsTest) { EXPECT_TRUE(1 >= Integer()); } -TEST(IComparableTests, getTypeTest) { - EXPECT_EQ(IComparable::getTypeStatic(), MathObjectType(MathObjectType::IComparable, "IComparable")); +TEST(IComparableTests, getClassTest) { + EXPECT_EQ(IComparable::getClassStatic(), MathObjectClass("IComparable")); + EXPECT_EQ(IComparable::getClassStatic().getParent(), IArithmetic::getClassStatic()); } diff --git a/tests/src/core/IMathObjectTests.cpp b/tests/src/core/IMathObjectTests.cpp index 63c43faae..35d24f007 100644 --- a/tests/src/core/IMathObjectTests.cpp +++ b/tests/src/core/IMathObjectTests.cpp @@ -2,6 +2,7 @@ #include "fintamath/core/IMathObject.hpp" +#include "fintamath/expressions/IExpression.hpp" #include "fintamath/literals/Variable.hpp" #include "fintamath/numbers/Integer.hpp" #include "fintamath/numbers/Rational.hpp" @@ -11,12 +12,18 @@ using namespace fintamath; namespace { class TestMathObject final : public IMathObjectCRTP { -public: - static constexpr MathObjectType getTypeStatic() { - return {MathObjectType::IArithmetic, "TestMathObject"}; - } + FINTAMATH_CLASS_BODY(TestMathObject) }; +[[maybe_unused]] const auto config = [] { + IMathObject::registerType(); + return 0; +}(); + +} + +TEST(IMathObjectTests, parseTest) { + EXPECT_TRUE(is(*IMathObject::parseFirst("TestMathObject"))); } TEST(IMathObjectTests, toStringTest) { @@ -102,6 +109,10 @@ TEST(IMathObjectTests, outputTest) { EXPECT_EQ(out.str(), "123"); } -TEST(IMathObjectTests, getTypeTest) { - EXPECT_EQ(IMathObject::getTypeStatic(), MathObjectType(MathObjectType::IMathObject, "IMathObject")); +TEST(IMathObjectTests, getClassTest) { + EXPECT_EQ(IMathObject::getClassStatic(), MathObjectClass("IMathObject")); + EXPECT_FALSE(IMathObject::getClassStatic().getParent()); + + EXPECT_EQ(TestMathObject().getClass(), MathObjectClass("TestMathObject")); + EXPECT_EQ(TestMathObject().getClass().getParent(), IMathObject::getClassStatic()); } diff --git a/tests/src/core/MathObjectBoundTypesTests.cpp b/tests/src/core/MathObjectBoundTypesTests.cpp deleted file mode 100644 index bdd4819ac..000000000 --- a/tests/src/core/MathObjectBoundTypesTests.cpp +++ /dev/null @@ -1,52 +0,0 @@ -#include - -#include "fintamath/core/MathObjectBoundTypes.hpp" - -#include "fintamath/literals/ILiteral.hpp" -#include "fintamath/literals/Variable.hpp" -#include "fintamath/literals/constants/E.hpp" -#include "fintamath/literals/constants/IConstant.hpp" -#include "fintamath/literals/constants/True.hpp" -#include "fintamath/numbers/Integer.hpp" -#include "fintamath/numbers/Rational.hpp" - -using namespace fintamath; -using namespace detail; - -TEST(MathObjectBoundTypesTests, bindTypesTest) { - // TODO: implement -} - -TEST(MathObjectBoundTypesTests, isBaseOfTest) { - EXPECT_TRUE(isBaseOf(INumber::getTypeStatic(), Integer::getTypeStatic())); - EXPECT_TRUE(isBaseOf(INumber::getTypeStatic(), Rational::getTypeStatic())); - EXPECT_TRUE(isBaseOf(IArithmetic::getTypeStatic(), Integer::getTypeStatic())); - EXPECT_TRUE(isBaseOf(IMathObject::getTypeStatic(), Integer::getTypeStatic())); - EXPECT_TRUE(isBaseOf(IArithmetic::getTypeStatic(), INumber::getTypeStatic())); - EXPECT_TRUE(isBaseOf(IMathObject::getTypeStatic(), INumber::getTypeStatic())); - EXPECT_TRUE(isBaseOf(IMathObject::getTypeStatic(), IArithmetic::getTypeStatic())); - EXPECT_TRUE(isBaseOf(IConstant::getTypeStatic(), True::getTypeStatic())); - EXPECT_TRUE(isBaseOf(ILiteral::getTypeStatic(), Variable::getTypeStatic())); - EXPECT_TRUE(isBaseOf(ILiteral::getTypeStatic(), IConstant::getTypeStatic())); - EXPECT_TRUE(isBaseOf(ILiteral::getTypeStatic(), True::getTypeStatic())); - EXPECT_TRUE(isBaseOf(ILiteral::getTypeStatic(), E::getTypeStatic())); - - EXPECT_FALSE(isBaseOf(Integer::getTypeStatic(), INumber::getTypeStatic())); - EXPECT_FALSE(isBaseOf(Rational::getTypeStatic(), INumber::getTypeStatic())); - EXPECT_FALSE(isBaseOf(Integer::getTypeStatic(), IArithmetic::getTypeStatic())); - EXPECT_FALSE(isBaseOf(Integer::getTypeStatic(), IMathObject::getTypeStatic())); - EXPECT_FALSE(isBaseOf(INumber::getTypeStatic(), IArithmetic::getTypeStatic())); - EXPECT_FALSE(isBaseOf(INumber::getTypeStatic(), IMathObject::getTypeStatic())); - EXPECT_FALSE(isBaseOf(IArithmetic::getTypeStatic(), IMathObject::getTypeStatic())); - EXPECT_FALSE(isBaseOf(True::getTypeStatic(), IConstant::getTypeStatic())); - EXPECT_FALSE(isBaseOf(Variable::getTypeStatic(), ILiteral::getTypeStatic())); - EXPECT_FALSE(isBaseOf(IConstant::getTypeStatic(), ILiteral::getTypeStatic())); - EXPECT_FALSE(isBaseOf(True::getTypeStatic(), ILiteral::getTypeStatic())); - EXPECT_FALSE(isBaseOf(E::getTypeStatic(), ILiteral::getTypeStatic())); - - EXPECT_FALSE(isBaseOf(ILiteral::getTypeStatic(), Integer::getTypeStatic())); - EXPECT_FALSE(isBaseOf(ILiteral::getTypeStatic(), Rational::getTypeStatic())); - EXPECT_FALSE(isBaseOf(ILiteral::getTypeStatic(), INumber::getTypeStatic())); - EXPECT_FALSE(isBaseOf(IConstant::getTypeStatic(), INumber::getTypeStatic())); - EXPECT_FALSE(isBaseOf(Boolean::getTypeStatic(), INumber::getTypeStatic())); -} diff --git a/tests/src/core/MathObjectClassTests.cpp b/tests/src/core/MathObjectClassTests.cpp new file mode 100644 index 000000000..60162da72 --- /dev/null +++ b/tests/src/core/MathObjectClassTests.cpp @@ -0,0 +1,132 @@ +#include + +#include "fintamath/core/MathObjectBody.hpp" + +using namespace fintamath; +using namespace detail; + +namespace { + +class ISuperParentTest { + FINTAMATH_PARENT_CLASS_BODY(ISuperParentTest) +}; + +FINTAMATH_PARENT_CLASS_IMPLEMENTATION(ISuperParentTest) + +class IParentTest1 : public ISuperParentTest { + FINTAMATH_PARENT_CLASS_BODY(IParentTest1) +}; + +FINTAMATH_PARENT_CLASS_IMPLEMENTATION(IParentTest1) + +class IParentTest2 : public ISuperParentTest { + FINTAMATH_PARENT_CLASS_BODY(IParentTest2) +}; + +FINTAMATH_PARENT_CLASS_IMPLEMENTATION(IParentTest2) + +class ChildTest1 : public IParentTest1 { + FINTAMATH_CLASS_BODY(ChildTest1) +}; + +class ChildTest2 : public IParentTest1 { + FINTAMATH_CLASS_BODY(ChildTest2) +}; + +class ChildTest3 : public IParentTest2 { + FINTAMATH_CLASS_BODY(ChildTest3) +}; + +class OtherChildTest : public IParentTest2 { + FINTAMATH_CLASS_BODY(OtherChildTest) +}; + +[[maybe_unused]] const auto config = [] { + ISuperParentTest::registerType(); + IParentTest1::registerType(); + IParentTest1::registerType(); + IParentTest2::registerType(); + ISuperParentTest::registerType(); + return 0; +}(); + +} + +TEST(MathObjectClassTests, constructorTest) { + { + constexpr MathObjectClass t("Test"); + EXPECT_EQ(t.getName(), "Test"); + } + { + MathObjectClass t("Test"); + EXPECT_EQ(t.getName(), "Test"); + } +} + +TEST(MathObjectClassTests, equalsTest) { + EXPECT_TRUE(ChildTest1::getClassStatic() == ChildTest1::getClassStatic()); + EXPECT_FALSE(ChildTest1::getClassStatic() == ChildTest2::getClassStatic()); + EXPECT_FALSE(ChildTest2::getClassStatic() == ChildTest1::getClassStatic()); +} + +TEST(MathObjectClassTests, compareTest) { + EXPECT_EQ(ChildTest1::getClassStatic() <=> ChildTest1::getClassStatic(), std::strong_ordering::equal); + EXPECT_EQ(ChildTest1::getClassStatic() <=> ChildTest2::getClassStatic(), std::strong_ordering::less); + EXPECT_EQ(ChildTest2::getClassStatic() <=> ChildTest1::getClassStatic(), std::strong_ordering::greater); +} + +TEST(MathObjectClassTests, getNameTest) { + EXPECT_EQ(ChildTest1::getClassStatic().getName(), "ChildTest1"); +} + +TEST(MathObjectClassTests, getParentTest) { + EXPECT_FALSE(MathObjectClass("Test").getParent()); + + EXPECT_FALSE(ISuperParentTest::getClassStatic().getParent()); + + EXPECT_EQ(IParentTest1::getClassStatic().getParent(), ISuperParentTest::getClassStatic()); + EXPECT_EQ(IParentTest2::getClassStatic().getParent(), ISuperParentTest::getClassStatic()); + + EXPECT_EQ(ChildTest1::getClassStatic().getParent(), IParentTest1::getClassStatic()); + EXPECT_EQ(ChildTest2::getClassStatic().getParent(), IParentTest1::getClassStatic()); + EXPECT_EQ(ChildTest3::getClassStatic().getParent(), IParentTest2::getClassStatic()); +} + +TEST(MathObjectClassTests, getChildrenTest) { + EXPECT_EQ(MathObjectClass("Test").getChildren().size(), 0); + + EXPECT_EQ(ISuperParentTest::getClassStatic().getChildren().size(), 2); + + EXPECT_EQ(IParentTest1::getClassStatic().getChildren().size(), 2); + EXPECT_EQ(IParentTest2::getClassStatic().getChildren().size(), 1); + + EXPECT_EQ(ChildTest1::getClassStatic().getChildren().size(), 0); + EXPECT_EQ(ChildTest2::getClassStatic().getChildren().size(), 0); + EXPECT_EQ(ChildTest3::getClassStatic().getChildren().size(), 0); +} + +TEST(MathObjectClassTests, getChildrenRecursiveTest) { + EXPECT_EQ(MathObjectClass("Test").getChildren(true).size(), 0); + + EXPECT_EQ(ISuperParentTest::getClassStatic().getChildren(true).size(), 5); + + EXPECT_EQ(IParentTest1::getClassStatic().getChildren(true).size(), 2); + EXPECT_EQ(IParentTest2::getClassStatic().getChildren(true).size(), 1); + + EXPECT_EQ(ChildTest1::getClassStatic().getChildren(true).size(), 0); + EXPECT_EQ(ChildTest2::getClassStatic().getChildren(true).size(), 0); + EXPECT_EQ(ChildTest3::getClassStatic().getChildren(true).size(), 0); +} + +TEST(MathObjectClassTests, bindTypesTest) { + EXPECT_FALSE(OtherChildTest::getClassStatic().getParent()); + + MathObjectClass::bindTypes(); + + EXPECT_EQ(OtherChildTest::getClassStatic().getParent(), IParentTest2::getClassStatic()); +} + +TEST(MathObjectClassTests, hashTest) { + EXPECT_EQ(boost::hash{}(MathObjectClass("Test")), + boost::hash{}("Test")); +} diff --git a/tests/src/core/MathObjectTypeTests.cpp b/tests/src/core/MathObjectTypeTests.cpp deleted file mode 100644 index 31b82b1d7..000000000 --- a/tests/src/core/MathObjectTypeTests.cpp +++ /dev/null @@ -1,60 +0,0 @@ -#include - -#include "fintamath/core/MathObjectType.hpp" - -#include "fintamath/literals/ILiteral.hpp" -#include "fintamath/literals/constants/E.hpp" -#include "fintamath/literals/constants/IConstant.hpp" -#include "fintamath/literals/constants/True.hpp" -#include "fintamath/numbers/Integer.hpp" -#include "fintamath/numbers/Rational.hpp" - -using namespace fintamath; -using namespace detail; - -TEST(MathObjectTypeTests, constructorTest) { - { - constexpr MathObjectType t(MathObjectType::Integer, "Int"); - EXPECT_EQ(t.getId(), static_cast(MathObjectType::Integer)); - EXPECT_EQ(t.getName(), "Int"); - } - { - constexpr MathObjectType t(123, "NotInt"); - EXPECT_EQ(t.getId(), 123); - EXPECT_EQ(t.getName(), "NotInt"); - } - - { - const MathObjectType t(MathObjectType::Integer, "Int"); - EXPECT_EQ(t.getId(), static_cast(MathObjectType::Integer)); - EXPECT_EQ(t.getName(), "Int"); - } - { - const MathObjectType t(123, "NotInt"); - EXPECT_EQ(t.getId(), 123); - EXPECT_EQ(t.getName(), "NotInt"); - } -} - -TEST(MathObjectTypeTests, compareTest) { - EXPECT_EQ(Integer::getTypeStatic() <=> Integer::getTypeStatic(), std::strong_ordering::equal); - EXPECT_EQ(Rational::getTypeStatic() <=> Integer::getTypeStatic(), std::strong_ordering::less); - EXPECT_EQ(Integer::getTypeStatic() <=> Rational::getTypeStatic(), std::strong_ordering::greater); -} - -TEST(MathObjectTypeTests, getIdTest) { - EXPECT_EQ(Integer::getTypeStatic().getId(), static_cast(MathObjectType::Integer)); -} - -TEST(MathObjectTypeTests, getNameTest) { - EXPECT_EQ(Integer::getTypeStatic().getName(), "Integer"); -} - -TEST(MathObjectTypeTests, hashTest) { - EXPECT_EQ(boost::hash{}(IMathObject::getTypeStatic()), static_cast(MathObjectType::IMathObject)); - EXPECT_EQ(boost::hash{}(INumber::getTypeStatic()), static_cast(MathObjectType::INumber)); - EXPECT_EQ(boost::hash{}(Integer::getTypeStatic()), static_cast(MathObjectType::Integer)); - EXPECT_EQ(boost::hash{}(ILiteral::getTypeStatic()), static_cast(MathObjectType::ILiteral)); - EXPECT_EQ(boost::hash{}(IConstant::getTypeStatic()), static_cast(MathObjectType::IConstant)); - EXPECT_EQ(boost::hash{}(Boolean::getTypeStatic()), static_cast(MathObjectType::Boolean)); -} diff --git a/tests/src/core/ParseTests.cpp b/tests/src/core/ParseTests.cpp deleted file mode 100644 index b6effad91..000000000 --- a/tests/src/core/ParseTests.cpp +++ /dev/null @@ -1,295 +0,0 @@ -#include - -#include "fintamath/core/Parser.hpp" -#include "fintamath/expressions/Expression.hpp" -#include "fintamath/expressions/IExpression.hpp" -#include "fintamath/functions/IFunction.hpp" -#include "fintamath/functions/IOperator.hpp" -#include "fintamath/functions/arithmetic/Abs.hpp" -#include "fintamath/functions/arithmetic/Add.hpp" -#include "fintamath/functions/arithmetic/Div.hpp" -#include "fintamath/functions/arithmetic/Frac.hpp" -#include "fintamath/functions/arithmetic/FracMixed.hpp" -#include "fintamath/functions/arithmetic/Mul.hpp" -#include "fintamath/functions/arithmetic/Neg.hpp" -#include "fintamath/functions/arithmetic/Sign.hpp" -#include "fintamath/functions/arithmetic/Sub.hpp" -#include "fintamath/functions/arithmetic/UnaryPlus.hpp" -#include "fintamath/functions/calculus/Derivative.hpp" -#include "fintamath/functions/calculus/Integral.hpp" -#include "fintamath/functions/comparison/Eqv.hpp" -#include "fintamath/functions/comparison/Less.hpp" -#include "fintamath/functions/comparison/LessEqv.hpp" -#include "fintamath/functions/comparison/More.hpp" -#include "fintamath/functions/comparison/MoreEqv.hpp" -#include "fintamath/functions/comparison/Neqv.hpp" -#include "fintamath/functions/hyperbolic/Acosh.hpp" -#include "fintamath/functions/hyperbolic/Acoth.hpp" -#include "fintamath/functions/hyperbolic/Acsch.hpp" -#include "fintamath/functions/hyperbolic/Asech.hpp" -#include "fintamath/functions/hyperbolic/Asinh.hpp" -#include "fintamath/functions/hyperbolic/Atanh.hpp" -#include "fintamath/functions/hyperbolic/Cosh.hpp" -#include "fintamath/functions/hyperbolic/Coth.hpp" -#include "fintamath/functions/hyperbolic/Csch.hpp" -#include "fintamath/functions/hyperbolic/Sech.hpp" -#include "fintamath/functions/hyperbolic/Sinh.hpp" -#include "fintamath/functions/hyperbolic/Tanh.hpp" -#include "fintamath/functions/logarithms/Lb.hpp" -#include "fintamath/functions/logarithms/Lg.hpp" -#include "fintamath/functions/logarithms/Ln.hpp" -#include "fintamath/functions/logarithms/Log.hpp" -#include "fintamath/functions/logic/And.hpp" -#include "fintamath/functions/logic/Equiv.hpp" -#include "fintamath/functions/logic/Impl.hpp" -#include "fintamath/functions/logic/Nequiv.hpp" -#include "fintamath/functions/logic/Not.hpp" -#include "fintamath/functions/logic/Or.hpp" -#include "fintamath/functions/ntheory/Ceil.hpp" -#include "fintamath/functions/ntheory/Floor.hpp" -#include "fintamath/functions/other/Deg.hpp" -#include "fintamath/functions/other/Factorial.hpp" -#include "fintamath/functions/other/Index.hpp" -#include "fintamath/functions/other/Percent.hpp" -#include "fintamath/functions/powers/Exp.hpp" -#include "fintamath/functions/powers/Pow.hpp" -#include "fintamath/functions/powers/PowFunction.hpp" -#include "fintamath/functions/powers/Root.hpp" -#include "fintamath/functions/powers/Sqrt.hpp" -#include "fintamath/functions/trigonometry/Acos.hpp" -#include "fintamath/functions/trigonometry/Acot.hpp" -#include "fintamath/functions/trigonometry/Acsc.hpp" -#include "fintamath/functions/trigonometry/Asec.hpp" -#include "fintamath/functions/trigonometry/Asin.hpp" -#include "fintamath/functions/trigonometry/Atan.hpp" -#include "fintamath/functions/trigonometry/Cos.hpp" -#include "fintamath/functions/trigonometry/Cot.hpp" -#include "fintamath/functions/trigonometry/Csc.hpp" -#include "fintamath/functions/trigonometry/Sec.hpp" -#include "fintamath/functions/trigonometry/Sin.hpp" -#include "fintamath/functions/trigonometry/Tan.hpp" -#include "fintamath/literals/ILiteral.hpp" -#include "fintamath/literals/Variable.hpp" -#include "fintamath/literals/constants/ComplexInf.hpp" -#include "fintamath/literals/constants/E.hpp" -#include "fintamath/literals/constants/False.hpp" -#include "fintamath/literals/constants/I.hpp" -#include "fintamath/literals/constants/IConstant.hpp" -#include "fintamath/literals/constants/Inf.hpp" -#include "fintamath/literals/constants/NegInf.hpp" -#include "fintamath/literals/constants/Pi.hpp" -#include "fintamath/literals/constants/True.hpp" -#include "fintamath/literals/constants/Undefined.hpp" -#include "fintamath/numbers/INumber.hpp" -#include "fintamath/numbers/Integer.hpp" -#include "fintamath/numbers/Rational.hpp" - -using namespace fintamath; - -TEST(ParseTests, parseMathObjectTest) { - EXPECT_TRUE(is(IMathObject::parse("a+1"))); - EXPECT_TRUE(is(IMathObject::parse("a"))); - EXPECT_TRUE(is(IMathObject::parse("sin"))); - EXPECT_TRUE(is(IMathObject::parse("a+1"))); - - EXPECT_FALSE(is(IMathObject::parse("a"))); - EXPECT_FALSE(is(IMathObject::parse("sin"))); - EXPECT_FALSE(is(IMathObject::parse("123"))); - EXPECT_FALSE(is(IMathObject::parse("sin"))); - - EXPECT_EQ(IMathObject::parse("x+"), nullptr); -} - -TEST(ParseTests, parseArithmeticTest) { - EXPECT_TRUE(is(IArithmetic::parse("1231412736.218731623872183"))); - EXPECT_TRUE(is(IArithmetic::parse("1231412736218731623872183"))); - EXPECT_TRUE(is(IArithmetic::parse("1231412736218731623872183"))); - EXPECT_TRUE(is(IArithmetic::parse("a"))); - - EXPECT_FALSE(is(IArithmetic::parse("True"))); - EXPECT_FALSE(is(IArithmetic::parse("E"))); - EXPECT_FALSE(is(IArithmetic::parse("12314127362187.31623872183"))); - EXPECT_FALSE(is(IArithmetic::parse("a"))); - EXPECT_FALSE(is(IArithmetic::parse("123"))); - - EXPECT_EQ(IArithmetic::parse("x+"), nullptr); -} - -TEST(ParseTests, parseComparableTest) { - EXPECT_TRUE(is(IComparable::parse("12314127362.18731623872183"))); - - EXPECT_EQ(IComparable::parse("x"), nullptr); -} - -TEST(ParseTests, parseIntegerTest) { - EXPECT_TRUE(is(IInteger::parse("1231412736218731623872183"))); - - EXPECT_EQ(IInteger::parse("x"), nullptr); -} - -TEST(ParseTests, parseModularTest) { - EXPECT_TRUE(is(IInteger::parse("18731623872183"))); - - EXPECT_EQ(IInteger::parse("123.123"), nullptr); -} - -TEST(ParseTests, parseNumberTest) { - EXPECT_EQ(INumber::parse("1231412736218731623872183")->toString(), "1231412736218731623872183"); - EXPECT_TRUE(is(INumber::parse("1231412736218731623872183"))); - - EXPECT_EQ(INumber::parse("-1231412736218731623872183")->toString(), "-1231412736218731623872183"); - EXPECT_TRUE(is(INumber::parse("-1231412736218731623872183"))); - - EXPECT_EQ(INumber::parse("0")->toString(), "0"); - EXPECT_TRUE(is(INumber::parse("0"))); - - EXPECT_EQ(INumber::parse("0.1")->toString(), "1/10"); - EXPECT_TRUE(is(INumber::parse("0.1"))); - - EXPECT_EQ(INumber::parse(".1")->toString(), "1/10"); - EXPECT_TRUE(is(INumber::parse(".1"))); - - EXPECT_EQ(INumber::parse("1.")->toString(), "1"); - EXPECT_TRUE(is(INumber::parse("1."))); - - EXPECT_EQ(INumber::parse("12323231498721983.12323432432")->toString(), "77020196867012394520214527/6250000000"); - EXPECT_TRUE(is(INumber::parse("12323231498721983.12323432432"))); - - EXPECT_EQ(INumber::parse("-12323231498721983.12323432432")->toString(), "-77020196867012394520214527/6250000000"); - EXPECT_TRUE(is(INumber::parse("-12323231498721983.12323432432"))); - - EXPECT_EQ(INumber::parse("--10"), nullptr); - EXPECT_EQ(INumber::parse("test"), nullptr); - EXPECT_EQ(INumber::parse(""), nullptr); - EXPECT_EQ(INumber::parse("+"), nullptr); - EXPECT_EQ(INumber::parse("939849.0-0023"), nullptr); - EXPECT_EQ(INumber::parse("a"), nullptr); - EXPECT_EQ(INumber::parse("a.1"), nullptr); - EXPECT_EQ(INumber::parse("1.a"), nullptr); - EXPECT_EQ(INumber::parse("1a.1"), nullptr); - EXPECT_EQ(INumber::parse("1.1a"), nullptr); - EXPECT_EQ(INumber::parse("--10.-1"), nullptr); - EXPECT_EQ(INumber::parse("10.-1"), nullptr); - EXPECT_EQ(INumber::parse("1-0.1"), nullptr); - EXPECT_EQ(INumber::parse("10-.1"), nullptr); - EXPECT_EQ(INumber::parse("10.--1"), nullptr); -} - -TEST(ParseTests, parseLiteralTest) { - EXPECT_TRUE(is(ILiteral::parse("E"))); - EXPECT_TRUE(is(ILiteral::parse("a"))); - EXPECT_TRUE(is(ILiteral::parse("z"))); - - EXPECT_EQ(ILiteral::parse("1"), nullptr); - EXPECT_EQ(ILiteral::parse("a_"), nullptr); - EXPECT_EQ(ILiteral::parse("a1"), nullptr); - EXPECT_EQ(ILiteral::parse("aa"), nullptr); - EXPECT_EQ(ILiteral::parse("A"), nullptr); - EXPECT_EQ(ILiteral::parse("Z"), nullptr); -} - -TEST(ParseTests, parseConstantTest) { - EXPECT_TRUE(is(IConstant::parse("E"))); - EXPECT_TRUE(is(IConstant::parse("Pi"))); - EXPECT_TRUE(is(IConstant::parse("True"))); - EXPECT_TRUE(is(IConstant::parse("False"))); - EXPECT_TRUE(is(IConstant::parse("I"))); - EXPECT_TRUE(is(IConstant::parse("Inf"))); - EXPECT_TRUE(is(IConstant::parse("-Inf"))); - EXPECT_TRUE(is(IConstant::parse("ComplexInf"))); - EXPECT_TRUE(is(IConstant::parse("Undefined"))); - - EXPECT_EQ(IConstant::parse("a"), nullptr); - EXPECT_EQ(IConstant::parse("z"), nullptr); - EXPECT_EQ(IConstant::parse("1"), nullptr); - EXPECT_EQ(IConstant::parse("a_"), nullptr); - EXPECT_EQ(IConstant::parse("a1"), nullptr); - EXPECT_EQ(IConstant::parse("aa"), nullptr); -} - -TEST(ParseTests, parseFunctionTest) { - EXPECT_TRUE(is(IFunction::parse("sqrt"))); - EXPECT_TRUE(is(IFunction::parse("root"))); - EXPECT_TRUE(is(IFunction::parse("exp"))); - EXPECT_TRUE(is(IFunction::parse("log"))); - EXPECT_TRUE(is(IFunction::parse("ln"))); - EXPECT_TRUE(is(IFunction::parse("lb"))); - EXPECT_TRUE(is(IFunction::parse("lg"))); - EXPECT_TRUE(is(IFunction::parse("sin"))); - EXPECT_TRUE(is(IFunction::parse("cos"))); - EXPECT_TRUE(is(IFunction::parse("tan"))); - EXPECT_TRUE(is(IFunction::parse("cot"))); - EXPECT_TRUE(is(IFunction::parse("sec"))); - EXPECT_TRUE(is(IFunction::parse("csc"))); - EXPECT_TRUE(is(IFunction::parse("asin"))); - EXPECT_TRUE(is(IFunction::parse("acos"))); - EXPECT_TRUE(is(IFunction::parse("atan"))); - EXPECT_TRUE(is(IFunction::parse("acot"))); - EXPECT_TRUE(is(IFunction::parse("asec"))); - EXPECT_TRUE(is(IFunction::parse("acsc"))); - EXPECT_TRUE(is(IFunction::parse("abs"))); - EXPECT_TRUE(is(IFunction::parse("sign"))); - EXPECT_TRUE(is(IFunction::parse("sinh"))); - EXPECT_TRUE(is(IFunction::parse("cosh"))); - EXPECT_TRUE(is(IFunction::parse("tanh"))); - EXPECT_TRUE(is(IFunction::parse("coth"))); - EXPECT_TRUE(is(IFunction::parse("sech"))); - EXPECT_TRUE(is(IFunction::parse("csch"))); - EXPECT_TRUE(is(IFunction::parse("asinh"))); - EXPECT_TRUE(is(IFunction::parse("acosh"))); - EXPECT_TRUE(is(IFunction::parse("atanh"))); - EXPECT_TRUE(is(IFunction::parse("acoth"))); - EXPECT_TRUE(is(IFunction::parse("asech"))); - EXPECT_TRUE(is(IFunction::parse("acsch"))); - EXPECT_TRUE(is(IFunction::parse("derivative"))); - EXPECT_TRUE(is(IFunction::parse("integral"))); - EXPECT_TRUE(is(IFunction::parse("frac", 2))); - EXPECT_TRUE(is(IFunction::parse("frac", 3))); - EXPECT_TRUE(is(IFunction::parse("pow"))); - EXPECT_TRUE(is(IFunction::parse("floor"))); - EXPECT_TRUE(is(IFunction::parse("ceil"))); - - EXPECT_EQ(IFunction::parse("asdgewfe"), nullptr); - EXPECT_EQ(IFunction::parse("1224"), nullptr); -} - -TEST(ParseTests, parseOperatorTest) { - EXPECT_TRUE(is(IOperator::parse("+", IOperator::Priority::Addition))); - EXPECT_TRUE(is(IOperator::parse("+", IOperator::Priority::PrefixUnary))); - EXPECT_TRUE(is(IOperator::parse("+", 2))); - EXPECT_TRUE(is(IOperator::parse("+", 1))); - EXPECT_TRUE(is(IOperator::parse("-", IOperator::Priority::Addition))); - EXPECT_TRUE(is(IOperator::parse("-", IOperator::Priority::PrefixUnary))); - EXPECT_TRUE(is(IOperator::parse("-", 2))); - EXPECT_TRUE(is(IOperator::parse("-", 1))); - EXPECT_TRUE(is(IOperator::parse("*"))); - EXPECT_TRUE(is
(IOperator::parse("/"))); - EXPECT_TRUE(is(IOperator::parse("^"))); - EXPECT_TRUE(is(IOperator::parse("%"))); - EXPECT_TRUE(is(IOperator::parse("!"))); - EXPECT_TRUE(is(IOperator::parse("="))); - EXPECT_TRUE(is(IOperator::parse("!="))); - EXPECT_TRUE(is(IOperator::parse("<"))); - EXPECT_TRUE(is(IOperator::parse(">"))); - EXPECT_TRUE(is(IOperator::parse("<="))); - EXPECT_TRUE(is(IOperator::parse(">="))); - EXPECT_TRUE(is(IOperator::parse("~"))); - EXPECT_TRUE(is(IOperator::parse("&"))); - EXPECT_TRUE(is(IOperator::parse("|"))); - EXPECT_TRUE(is(IOperator::parse("->"))); - EXPECT_TRUE(is(IOperator::parse("<->"))); - EXPECT_TRUE(is(IOperator::parse("!<->"))); - EXPECT_TRUE(is(IOperator::parse("_"))); - EXPECT_TRUE(is(IOperator::parse("deg"))); - - EXPECT_EQ(IOperator::parse("asdgewfe"), nullptr); - EXPECT_EQ(IOperator::parse("1224"), nullptr); -} - -TEST(ParseTests, parseExpressionTest) { - EXPECT_TRUE(is(IExpression::parse("x+1"))); - EXPECT_TRUE(is(IExpression::parse("x*1"))); - - EXPECT_EQ(IExpression::parse("x+"), nullptr); - EXPECT_EQ(IExpression::parse("^x"), nullptr); -} diff --git a/tests/src/core/ParserTests.cpp b/tests/src/core/ParserTests.cpp index b02e81790..50d5ee4e2 100644 --- a/tests/src/core/ParserTests.cpp +++ b/tests/src/core/ParserTests.cpp @@ -2,12 +2,61 @@ #include "fintamath/core/Parser.hpp" +#include "fintamath/expressions/Expression.hpp" +#include "fintamath/functions/IFunction.hpp" +#include "fintamath/functions/arithmetic/Add.hpp" +#include "fintamath/literals/constants/E.hpp" +#include "fintamath/numbers/INumber.hpp" +#include "fintamath/numbers/Integer.hpp" + using namespace fintamath; -TEST(ParserTests, parseTest) { - // TODO: implement +template +size_t countParseredValues(String &&str) { + size_t count = 0; + + for (const auto &_ : Class::parse(std::forward(str))) { + count++; + } + + return count; +} + +TEST(ParserTests, parseLvalueTest) { + std::string str; + + str = "123"; + EXPECT_EQ(countParseredValues(str), 4); + + str = "+"; + EXPECT_EQ(countParseredValues(str), 2); + + str = "E"; + EXPECT_EQ(countParseredValues(str), 1); + + str = "1+2"; + EXPECT_EQ(countParseredValues(str), 1); + + str = "1*)"; + EXPECT_EQ(countParseredValues(str), 0); +} + +TEST(ParserTests, parseRvalueTest) { + EXPECT_EQ(countParseredValues("123"), 4); + EXPECT_EQ(countParseredValues("+"), 2); + EXPECT_EQ(countParseredValues("E"), 1); + EXPECT_EQ(countParseredValues("1+2"), 1); + EXPECT_EQ(countParseredValues("1*)"), 0); +} + +TEST(ParserTests, parseFirstTest) { + EXPECT_EQ(IMathObject::parseFirst("123").value()->getClass(), Integer::getClassStatic()); + EXPECT_EQ(IMathObject::parseFirst("+").value()->getClass(), Add::getClassStatic()); + EXPECT_EQ(IMathObject::parseFirst("E").value()->getClass(), E::getClassStatic()); + EXPECT_EQ(IMathObject::parseFirst("1+1").value()->getClass(), Expression::getClassStatic()); + EXPECT_FALSE(IMathObject::parseFirst("1*)")); } TEST(ParserTests, registerTypeTest) { // TODO: implement -} +} \ No newline at end of file diff --git a/tests/src/expressions/ExpressionTests.cpp b/tests/src/expressions/ExpressionTests.cpp index c690d5d93..d620f58be 100644 --- a/tests/src/expressions/ExpressionTests.cpp +++ b/tests/src/expressions/ExpressionTests.cpp @@ -97,9 +97,9 @@ TEST(ExpressionTests, equalsTest) { // TODO: implement more tests } -TEST(ExpressionTests, getTypeTest) { - EXPECT_EQ(Expression::getTypeStatic(), MathObjectType(MathObjectType::Expression, "Expression")); - EXPECT_EQ(Expression().getType(), MathObjectType(MathObjectType::Expression, "Expression")); +TEST(ExpressionTests, getClassTest) { + EXPECT_EQ(Expression::getClassStatic(), MathObjectClass("Expression")); + EXPECT_EQ(Expression::getClassStatic().getParent(), IExpression::getClassStatic()); } TEST(ExpressionTests, variableVariablePlusOperatorTest) { diff --git a/tests/src/expressions/FunctionExpressionTests.cpp b/tests/src/expressions/FunctionExpressionTests.cpp index 8909cf352..733989e57 100644 --- a/tests/src/expressions/FunctionExpressionTests.cpp +++ b/tests/src/expressions/FunctionExpressionTests.cpp @@ -9,18 +9,12 @@ using namespace detail; namespace { -class TestBinaryOperator final : public IOperatorCRTP { +class TestUnaryFunction final : public IFunctionCRTP { + FINTAMATH_CLASS_BODY(TestUnaryFunction) + public: std::string toString() const override { - return "$"; - } - - static constexpr Priority getPriorityStatic() { - return Priority::Exponentiation; - } - - static constexpr MathObjectType getTypeStatic() { - return {static_cast(MathObjectType::IOperator) + 999, "TestBinaryOperator"}; + return "testfunction"; } protected: @@ -29,18 +23,12 @@ class TestBinaryOperator final : public IOperatorCRTP { +class TestBinaryFunction final : public IFunctionCRTP { + FINTAMATH_CLASS_BODY(TestBinaryFunction) + public: std::string toString() const override { - return "$"; - } - - static constexpr Priority getPriorityStatic() { - return Priority::PrefixUnary; - } - - static constexpr MathObjectType getTypeStatic() { - return {static_cast(MathObjectType::IOperator) + 998, "TestUnaryPrefixOperator"}; + return "testfunction"; } protected: @@ -49,18 +37,16 @@ class TestUnaryPrefixOperator final : public IOperatorCRTP { +class TestBinaryOperator final : public IOperatorCRTP { + FINTAMATH_CLASS_BODY(TestBinaryOperator) + public: std::string toString() const override { return "$"; } static constexpr Priority getPriorityStatic() { - return Priority::PostfixUnary; - } - - static constexpr MathObjectType getTypeStatic() { - return {static_cast(MathObjectType::IOperator) + 997, "TestUnaryPostfixOperator"}; + return Priority::Exponentiation; } protected: @@ -69,14 +55,16 @@ class TestUnaryPostfixOperator final : public IOperatorCRTP { +class TestUnaryPrefixOperator final : public IOperatorCRTP { + FINTAMATH_CLASS_BODY(TestUnaryPrefixOperator) + public: std::string toString() const override { - return "testfunction"; + return "$"; } - static constexpr MathObjectType getTypeStatic() { - return {static_cast(MathObjectType::IFunction) + 996, "TestUnaryFunction"}; + static constexpr Priority getPriorityStatic() { + return Priority::PrefixUnary; } protected: @@ -85,14 +73,16 @@ class TestUnaryFunction final : public IFunctionCRTP { +class TestUnaryPostfixOperator final : public IOperatorCRTP { + FINTAMATH_CLASS_BODY(TestUnaryPostfixOperator) + public: std::string toString() const override { - return "testfunction"; + return "$"; } - static constexpr MathObjectType getTypeStatic() { - return {static_cast(MathObjectType::IFunction) + 995, "TestBinaryFunction"}; + static constexpr Priority getPriorityStatic() { + return Priority::PostfixUnary; } protected: @@ -101,19 +91,16 @@ class TestBinaryFunction final : public IFunctionCRTP(); - IOperator::registerType(); - IOperator::registerType(); +[[maybe_unused]] const auto config = [] { + IFunction::registerType(); + IFunction::registerType(); - IFunction::registerType(); - IFunction::registerType(); - } -}; + IOperator::registerType(); + IOperator::registerType(); + IOperator::registerType(); -[[maybe_unused]] const FunctionExpressionConfig testOperatorConfig; + return 0; +}(); } @@ -138,6 +125,6 @@ TEST(FunctionExpressionTests, stringConstructorTest) { EXPECT_EQ(Expression("testfunction(a+1,b+1)").toString(), "testfunction(a + 1, b + 1)"); } -TEST(FunctionExpressionTests, getTypeTest) { - EXPECT_EQ(makeExpr(TestBinaryOperator(), Integer(0), Integer(0))->getType(), MathObjectType(MathObjectType::FunctionExpression, "FunctionExpression")); +TEST(FunctionExpressionTests, getClassTest) { + EXPECT_EQ(makeExpr(TestBinaryOperator(), Integer(0), Integer(0))->getClass(), MathObjectClass("FunctionExpression")); } diff --git a/tests/src/expressions/IExpressionTests.cpp b/tests/src/expressions/IExpressionTests.cpp index 8ba023c3d..83f04f723 100644 --- a/tests/src/expressions/IExpressionTests.cpp +++ b/tests/src/expressions/IExpressionTests.cpp @@ -12,7 +12,9 @@ using namespace fintamath; namespace { -class TestIExpression final : public IExpressionCRTP { +class TestExpression final : public IExpressionCRTP { + FINTAMATH_CLASS_BODY(TestExpression) + public: const std::shared_ptr &getFunction() const override { static const std::shared_ptr func = cast(Add().clone()); @@ -45,6 +47,15 @@ class TestIExpression final : public IExpressionCRTP { } }; +[[maybe_unused]] const auto config = [] { + IExpression::registerType(); + return 0; +}(); + +} + +TEST(IExpressionTests, parseTest) { + EXPECT_TRUE(is(*IExpression::parseFirst("TestExpression"))); } TEST(IExpressionTests, getFunctionTest) { @@ -85,14 +96,15 @@ TEST(IExpressionTests, setVariablesTest) { } TEST(IExpressionTests, toMinimalObjectTest) { - const TestIExpression a; + const TestExpression a; EXPECT_EQ(*a.toMinimalObject(), a); // TODO: implement more tests } -TEST(IExpressionTests, getTypeTest) { - EXPECT_EQ(IExpression::getTypeStatic(), MathObjectType(MathObjectType::IExpression, "IExpression")); +TEST(IExpressionTests, getClassTest) { + EXPECT_EQ(IExpression::getClassStatic(), MathObjectClass("IExpression")); + EXPECT_EQ(IExpression::getClassStatic().getParent(), IArithmetic::getClassStatic()); } TEST(IExpressionTests, arithmeticTest) { diff --git a/tests/src/expressions/binary/CompExprTests.cpp b/tests/src/expressions/binary/CompExprTests.cpp index 474c5705e..0ef05a2e7 100644 --- a/tests/src/expressions/binary/CompExprTests.cpp +++ b/tests/src/expressions/binary/CompExprTests.cpp @@ -2,10 +2,14 @@ #include "fintamath/expressions/Expression.hpp" #include "fintamath/expressions/ExpressionUtils.hpp" +#include "fintamath/expressions/interfaces/IBinaryExpression.hpp" #include "fintamath/functions/comparison/Eqv.hpp" using namespace fintamath; -TEST(CompExprTests, getTypeTest) { - EXPECT_EQ(eqvExpr(Integer(0), Integer(0))->getType(), MathObjectType(MathObjectType::CompExpr, "CompExpr")); +TEST(CompExprTests, getClassTest) { + const auto expr = eqvExpr(Integer(0), Integer(0)); + + EXPECT_EQ(expr->getClass(), MathObjectClass("CompExpr")); + EXPECT_EQ(expr->getClass().getParent(), IBinaryExpression::getClassStatic()); } diff --git a/tests/src/expressions/binary/DerivativeExprTests.cpp b/tests/src/expressions/binary/DerivativeExprTests.cpp index 89bc6617e..d5594f7dc 100644 --- a/tests/src/expressions/binary/DerivativeExprTests.cpp +++ b/tests/src/expressions/binary/DerivativeExprTests.cpp @@ -2,10 +2,14 @@ #include "fintamath/expressions/Expression.hpp" #include "fintamath/expressions/ExpressionUtils.hpp" +#include "fintamath/expressions/interfaces/IBinaryExpression.hpp" #include "fintamath/functions/calculus/Derivative.hpp" using namespace fintamath; -TEST(DerivativeExprTests, getTypeTest) { - EXPECT_EQ(derivativeExpr(Integer(0), Variable("x"))->getType(), MathObjectType(MathObjectType::DerivativeExpr, "DerivativeExpr")); +TEST(DerivativeExprTests, getClassTest) { + const auto expr = derivativeExpr(Integer(0), Variable("x")); + + EXPECT_EQ(expr->getClass(), MathObjectClass("DerivativeExpr")); + EXPECT_EQ(expr->getClass().getParent(), IBinaryExpression::getClassStatic()); } diff --git a/tests/src/expressions/binary/DivExprTests.cpp b/tests/src/expressions/binary/DivExprTests.cpp index f81e42c91..17dd94dba 100644 --- a/tests/src/expressions/binary/DivExprTests.cpp +++ b/tests/src/expressions/binary/DivExprTests.cpp @@ -2,10 +2,14 @@ #include "fintamath/expressions/Expression.hpp" #include "fintamath/expressions/ExpressionUtils.hpp" +#include "fintamath/expressions/interfaces/IBinaryExpression.hpp" #include "fintamath/functions/arithmetic/Div.hpp" using namespace fintamath; -TEST(DivExprTests, getTypeTest) { - EXPECT_EQ(divExpr(Integer(0), Integer(0))->getType(), MathObjectType(MathObjectType::DivExpr, "DivExpr")); +TEST(DivExprTests, getClassTest) { + const auto expr = divExpr(Integer(0), Integer(0)); + + EXPECT_EQ(expr->getClass(), MathObjectClass("DivExpr")); + EXPECT_EQ(expr->getClass().getParent(), IBinaryExpression::getClassStatic()); } diff --git a/tests/src/expressions/binary/IntegralExprTests.cpp b/tests/src/expressions/binary/IntegralExprTests.cpp index 759722501..e2828cd87 100644 --- a/tests/src/expressions/binary/IntegralExprTests.cpp +++ b/tests/src/expressions/binary/IntegralExprTests.cpp @@ -2,10 +2,14 @@ #include "fintamath/expressions/Expression.hpp" #include "fintamath/expressions/ExpressionUtils.hpp" +#include "fintamath/expressions/interfaces/IBinaryExpression.hpp" #include "fintamath/functions/calculus/Integral.hpp" using namespace fintamath; -TEST(IntegralExprTests, getTypeTest) { - EXPECT_EQ(integralExpr(Integer(0), Variable("x"))->getType(), MathObjectType(MathObjectType::IntegralExpr, "IntegralExpr")); +TEST(IntegralExprTests, getClassTest) { + const auto expr = integralExpr(Integer(0), Variable("x")); + + EXPECT_EQ(expr->getClass(), MathObjectClass("IntegralExpr")); + EXPECT_EQ(expr->getClass().getParent(), IBinaryExpression::getClassStatic()); } diff --git a/tests/src/expressions/binary/LogExprTests.cpp b/tests/src/expressions/binary/LogExprTests.cpp index 7ac04d96e..fb641475a 100644 --- a/tests/src/expressions/binary/LogExprTests.cpp +++ b/tests/src/expressions/binary/LogExprTests.cpp @@ -2,10 +2,14 @@ #include "fintamath/expressions/Expression.hpp" #include "fintamath/expressions/ExpressionUtils.hpp" +#include "fintamath/expressions/interfaces/IBinaryExpression.hpp" #include "fintamath/functions/logarithms/Log.hpp" using namespace fintamath; -TEST(LogExprTests, getTypeTest) { - EXPECT_EQ(logExpr(Integer(0), Integer(0))->getType(), MathObjectType(MathObjectType::LogExpr, "LogExpr")); +TEST(LogExprTests, getClassTest) { + const auto expr = logExpr(Integer(0), Integer(0)); + + EXPECT_EQ(expr->getClass(), MathObjectClass("LogExpr")); + EXPECT_EQ(expr->getClass().getParent(), IBinaryExpression::getClassStatic()); } diff --git a/tests/src/expressions/binary/PowExprTests.cpp b/tests/src/expressions/binary/PowExprTests.cpp index 47a56041d..59b1ed296 100644 --- a/tests/src/expressions/binary/PowExprTests.cpp +++ b/tests/src/expressions/binary/PowExprTests.cpp @@ -2,10 +2,14 @@ #include "fintamath/expressions/Expression.hpp" #include "fintamath/expressions/ExpressionUtils.hpp" +#include "fintamath/expressions/interfaces/IBinaryExpression.hpp" #include "fintamath/functions/powers/Pow.hpp" using namespace fintamath; -TEST(PowExprTests, getTypeTest) { - EXPECT_EQ(powExpr(Integer(0), Integer(0))->getType(), MathObjectType(MathObjectType::PowExpr, "PowExpr")); +TEST(PowExprTests, getClassTest) { + const auto expr = powExpr(Integer(0), Integer(0)); + + EXPECT_EQ(expr->getClass(), MathObjectClass("PowExpr")); + EXPECT_EQ(expr->getClass().getParent(), IBinaryExpression::getClassStatic()); } diff --git a/tests/src/expressions/interfaces/IBinaryExpressionTests.cpp b/tests/src/expressions/interfaces/IBinaryExpressionTests.cpp index 4b07788bd..581d1dc8d 100644 --- a/tests/src/expressions/interfaces/IBinaryExpressionTests.cpp +++ b/tests/src/expressions/interfaces/IBinaryExpressionTests.cpp @@ -11,16 +11,23 @@ const Add f; namespace { class TestBinaryExpression final : public IBinaryExpressionCRTP { + FINTAMATH_CLASS_BODY(TestBinaryExpression) + public: explicit TestBinaryExpression(ArgumentPtr inLhsChild, ArgumentPtr inRhsChild) : IBinaryExpressionCRTP(f, std::move(inLhsChild), std::move(inRhsChild)) { } - - static constexpr MathObjectType getTypeStatic() { - return {static_cast(MathObjectType::IBinaryExpression) + 999, "TestBinaryExpression"}; - } }; +[[maybe_unused]] const auto config = [] { + IBinaryExpression::registerType(); + return 0; +}(); + +} + +TEST(IBinaryExpressionTests, parseTest) { + EXPECT_FALSE(IBinaryExpression::parseFirst("1*)")); } TEST(IBinaryExpressionTests, toStringTest) { @@ -63,6 +70,7 @@ TEST(IBinaryExpressionTests, toMinimalObjectTest) { EXPECT_EQ(expr2.toMinimalObject()->toString(), "1 + a"); } -TEST(IBinaryExpressionTests, getTypeTest) { - EXPECT_EQ(IBinaryExpression::getTypeStatic(), MathObjectType(MathObjectType::IBinaryExpression, "IBinaryExpression")); +TEST(IBinaryExpressionTests, getClassTest) { + EXPECT_EQ(IBinaryExpression::getClassStatic(), MathObjectClass("IBinaryExpression")); + EXPECT_EQ(IBinaryExpression::getClassStatic().getParent(), IExpression::getClassStatic()); } diff --git a/tests/src/expressions/interfaces/IPolynomExpressionTests.cpp b/tests/src/expressions/interfaces/IPolynomExpressionTests.cpp index 0185cef2f..8478c8000 100644 --- a/tests/src/expressions/interfaces/IPolynomExpressionTests.cpp +++ b/tests/src/expressions/interfaces/IPolynomExpressionTests.cpp @@ -13,15 +13,22 @@ const Mul f; namespace { class TestPolynomExpression final : public IPolynomExpressionCRTP { + FINTAMATH_CLASS_BODY(TestPolynomExpression) + public: explicit TestPolynomExpression(ArgumentPtrVector args) : IPolynomExpressionCRTP(f, std::move(args)) { } - - static constexpr MathObjectType getTypeStatic() { - return {static_cast(MathObjectType::IPolynomExpression) + 999, "TestPolynomExpression"}; - } }; +[[maybe_unused]] const auto config = [] { + IPolynomExpression::registerType(); + return 0; +}(); + +} + +TEST(IPolynomExpressionTests, parseTest) { + EXPECT_FALSE(IPolynomExpression::parseFirst("1*)")); } TEST(IPolynomExpressionTests, toStringTest) { @@ -71,6 +78,7 @@ TEST(IPolynomExpressionTests, toMinimalObjectTest) { EXPECT_EQ(expr.toMinimalObject()->toString(), "a * 2"); } -TEST(IPolynomExpressionTests, getTypeTest) { - EXPECT_EQ(IPolynomExpression::getTypeStatic(), MathObjectType(MathObjectType::IPolynomExpression, "IPolynomExpression")); +TEST(IPolynomExpressionTests, getClassTest) { + EXPECT_EQ(IPolynomExpression::getClassStatic(), MathObjectClass("IPolynomExpression")); + EXPECT_EQ(IPolynomExpression::getClassStatic().getParent(), IExpression::getClassStatic()); } diff --git a/tests/src/expressions/interfaces/IUnaryExpressionTests.cpp b/tests/src/expressions/interfaces/IUnaryExpressionTests.cpp index 74aacc033..cafa0c6b3 100644 --- a/tests/src/expressions/interfaces/IUnaryExpressionTests.cpp +++ b/tests/src/expressions/interfaces/IUnaryExpressionTests.cpp @@ -11,16 +11,23 @@ const Factorial f; namespace { class TestUnaryExpression final : public IUnaryExpressionCRTP { + FINTAMATH_CLASS_BODY(TestUnaryExpression) + public: explicit TestUnaryExpression(ArgumentPtr inRhsChild) : IUnaryExpressionCRTP(f, std::move(inRhsChild)) { } - - static constexpr MathObjectType getTypeStatic() { - return {static_cast(MathObjectType::IUnaryExpression) + 999, "TestUnaryExpression"}; - } }; +[[maybe_unused]] const auto config = [] { + IUnaryExpression::registerType(); + return 0; +}(); + +} + +TEST(IUnaryExpressionTests, parseTest) { + EXPECT_FALSE(IUnaryExpression::parseFirst("1*)")); } TEST(IUnaryExpressionTests, toStringTest) { @@ -62,6 +69,7 @@ TEST(IUnaryExpressionTests, toMinimalObjectTest) { EXPECT_EQ(expr3.toMinimalObject()->toString(), "(a!)!"); } -TEST(IUnaryExpressionTests, getTypeTest) { - EXPECT_EQ(IUnaryExpression::getTypeStatic(), MathObjectType(MathObjectType::IUnaryExpression, "IUnaryExpression")); +TEST(IUnaryExpressionTests, getClassTest) { + EXPECT_EQ(IUnaryExpression::getClassStatic(), MathObjectClass("IUnaryExpression")); + EXPECT_EQ(IUnaryExpression::getClassStatic().getParent(), IExpression::getClassStatic()); } diff --git a/tests/src/expressions/polynomial/AddExprTests.cpp b/tests/src/expressions/polynomial/AddExprTests.cpp index 05f6c89ee..5d30d03a0 100644 --- a/tests/src/expressions/polynomial/AddExprTests.cpp +++ b/tests/src/expressions/polynomial/AddExprTests.cpp @@ -2,10 +2,14 @@ #include "fintamath/expressions/Expression.hpp" #include "fintamath/expressions/ExpressionUtils.hpp" +#include "fintamath/expressions/interfaces/IPolynomExpression.hpp" #include "fintamath/functions/arithmetic/Add.hpp" using namespace fintamath; -TEST(AddExprTests, getTypeTest) { - EXPECT_EQ(addExpr(Integer(0), Integer(0))->getType(), MathObjectType(MathObjectType::AddExpr, "AddExpr")); +TEST(AddExprTests, getClassTest) { + const auto expr = addExpr(Integer(0), Integer(0)); + + EXPECT_EQ(expr->getClass(), MathObjectClass("AddExpr")); + EXPECT_EQ(expr->getClass().getParent(), IPolynomExpression::getClassStatic()); } diff --git a/tests/src/expressions/polynomial/AndExprTests.cpp b/tests/src/expressions/polynomial/AndExprTests.cpp index 8d10d7f0b..a41b50205 100644 --- a/tests/src/expressions/polynomial/AndExprTests.cpp +++ b/tests/src/expressions/polynomial/AndExprTests.cpp @@ -2,10 +2,14 @@ #include "fintamath/expressions/Expression.hpp" #include "fintamath/expressions/ExpressionUtils.hpp" +#include "fintamath/expressions/interfaces/IPolynomExpression.hpp" #include "fintamath/functions/logic/And.hpp" using namespace fintamath; -TEST(AndExprTests, getTypeTest) { - EXPECT_EQ(andExpr(Boolean(), Boolean())->getType(), MathObjectType(MathObjectType::AndExpr, "AndExpr")); +TEST(AndExprTests, getClassTest) { + const auto expr = andExpr(Boolean(), Boolean()); + + EXPECT_EQ(expr->getClass(), MathObjectClass("AndExpr")); + EXPECT_EQ(expr->getClass().getParent(), IPolynomExpression::getClassStatic()); } diff --git a/tests/src/expressions/polynomial/MinMaxExprTests.cpp b/tests/src/expressions/polynomial/MinMaxExprTests.cpp index 068985189..033722309 100644 --- a/tests/src/expressions/polynomial/MinMaxExprTests.cpp +++ b/tests/src/expressions/polynomial/MinMaxExprTests.cpp @@ -2,10 +2,14 @@ #include "fintamath/expressions/Expression.hpp" #include "fintamath/expressions/ExpressionUtils.hpp" +#include "fintamath/expressions/interfaces/IPolynomExpression.hpp" #include "fintamath/functions/calculus/Min.hpp" using namespace fintamath; -TEST(MinMaxExprTests, getTypeTest) { - EXPECT_EQ(minExpr(Integer(0), Integer(0))->getType(), MathObjectType(MathObjectType::MinMaxExpr, "MinMaxExpr")); +TEST(MinMaxExprTests, getClassTest) { + const auto expr = minExpr(Integer(0), Integer(0)); + + EXPECT_EQ(expr->getClass(), MathObjectClass("MinMaxExpr")); + EXPECT_EQ(expr->getClass().getParent(), IPolynomExpression::getClassStatic()); } diff --git a/tests/src/expressions/polynomial/MulExprTests.cpp b/tests/src/expressions/polynomial/MulExprTests.cpp index 157b2aaf1..6f97e33d1 100644 --- a/tests/src/expressions/polynomial/MulExprTests.cpp +++ b/tests/src/expressions/polynomial/MulExprTests.cpp @@ -2,10 +2,14 @@ #include "fintamath/expressions/Expression.hpp" #include "fintamath/expressions/ExpressionUtils.hpp" +#include "fintamath/expressions/interfaces/IPolynomExpression.hpp" #include "fintamath/functions/arithmetic/Mul.hpp" using namespace fintamath; -TEST(MulExprTests, getTypeTest) { - EXPECT_EQ(mulExpr(Integer(0), Integer(0))->getType(), MathObjectType(MathObjectType::MulExpr, "MulExpr")); +TEST(MulExprTests, getClassTest) { + const auto expr = mulExpr(Integer(0), Integer(0)); + + EXPECT_EQ(expr->getClass(), MathObjectClass("MulExpr")); + EXPECT_EQ(expr->getClass().getParent(), IPolynomExpression::getClassStatic()); } diff --git a/tests/src/expressions/polynomial/OrExprTests.cpp b/tests/src/expressions/polynomial/OrExprTests.cpp index ebb861417..57fba1558 100644 --- a/tests/src/expressions/polynomial/OrExprTests.cpp +++ b/tests/src/expressions/polynomial/OrExprTests.cpp @@ -2,10 +2,14 @@ #include "fintamath/expressions/Expression.hpp" #include "fintamath/expressions/ExpressionUtils.hpp" +#include "fintamath/expressions/interfaces/IPolynomExpression.hpp" #include "fintamath/functions/logic/Or.hpp" using namespace fintamath; -TEST(OrExprTests, getTypeTest) { - EXPECT_EQ(orExpr(Boolean(), Boolean())->getType(), MathObjectType(MathObjectType::OrExpr, "OrExpr")); +TEST(OrExprTests, getClassTest) { + const auto expr = orExpr(Boolean(), Boolean()); + + EXPECT_EQ(expr->getClass(), MathObjectClass("OrExpr")); + EXPECT_EQ(expr->getClass().getParent(), IPolynomExpression::getClassStatic()); } diff --git a/tests/src/expressions/unary/AbsExprTests.cpp b/tests/src/expressions/unary/AbsExprTests.cpp index 3e062dae7..2f8717073 100644 --- a/tests/src/expressions/unary/AbsExprTests.cpp +++ b/tests/src/expressions/unary/AbsExprTests.cpp @@ -1,10 +1,11 @@ #include +#include "fintamath/expressions/interfaces/IUnaryExpression.hpp" #include "fintamath/functions/arithmetic/Abs.hpp" #include "fintamath/numbers/Integer.hpp" using namespace fintamath; -TEST(AbsExprTests, getTypeTest) { - EXPECT_EQ(absExpr(Integer(0).clone())->getType(), MathObjectType(MathObjectType::AbsExpr, "AbsExpr")); +TEST(AbsExprTests, getClassTest) { + EXPECT_EQ(absExpr(Integer(0).clone())->getClass(), MathObjectClass("AbsExpr")); } diff --git a/tests/src/expressions/unary/FloorCeilExprTests.cpp b/tests/src/expressions/unary/FloorCeilExprTests.cpp index 093bde36f..39753ca30 100644 --- a/tests/src/expressions/unary/FloorCeilExprTests.cpp +++ b/tests/src/expressions/unary/FloorCeilExprTests.cpp @@ -1,10 +1,14 @@ #include +#include "fintamath/expressions/interfaces/IUnaryExpression.hpp" #include "fintamath/functions/ntheory/Floor.hpp" #include "fintamath/numbers/Integer.hpp" using namespace fintamath; -TEST(FloorCeilExprTests, getTypeTest) { - EXPECT_EQ(floorExpr(Integer(0).clone())->getType(), MathObjectType(MathObjectType::FloorCeilExpr, "FloorCeilExpr")); +TEST(FloorCeilExprTests, getClassTest) { + const auto expr = floorExpr(Integer(0).clone()); + + EXPECT_EQ(expr->getClass(), MathObjectClass("FloorCeilExpr")); + EXPECT_EQ(expr->getClass().getParent(), IUnaryExpression::getClassStatic()); } diff --git a/tests/src/expressions/unary/HyperbExprTests.cpp b/tests/src/expressions/unary/HyperbExprTests.cpp index 26cdc4c90..f0c19a10f 100644 --- a/tests/src/expressions/unary/HyperbExprTests.cpp +++ b/tests/src/expressions/unary/HyperbExprTests.cpp @@ -2,10 +2,14 @@ #include "fintamath/expressions/Expression.hpp" #include "fintamath/expressions/ExpressionUtils.hpp" +#include "fintamath/expressions/interfaces/IUnaryExpression.hpp" #include "fintamath/functions/hyperbolic/Sinh.hpp" using namespace fintamath; -TEST(HyperbExprTests, getTypeTest) { - EXPECT_EQ(sinhExpr(Integer(0).clone())->getType(), MathObjectType(MathObjectType::HyperbExpr, "HyperbExpr")); +TEST(HyperbExprTests, getClassTest) { + const auto expr = sinhExpr(Integer(0).clone()); + + EXPECT_EQ(expr->getClass(), MathObjectClass("HyperbExpr")); + EXPECT_EQ(expr->getClass().getParent(), IUnaryExpression::getClassStatic()); } diff --git a/tests/src/expressions/unary/InvHyperbExprTests.cpp b/tests/src/expressions/unary/InvHyperbExprTests.cpp index de39b1f80..668a50b62 100644 --- a/tests/src/expressions/unary/InvHyperbExprTests.cpp +++ b/tests/src/expressions/unary/InvHyperbExprTests.cpp @@ -2,10 +2,14 @@ #include "fintamath/expressions/Expression.hpp" #include "fintamath/expressions/ExpressionUtils.hpp" +#include "fintamath/expressions/interfaces/IUnaryExpression.hpp" #include "fintamath/functions/hyperbolic/Asinh.hpp" using namespace fintamath; -TEST(InvHyperbExprTests, getTypeTest) { - EXPECT_EQ(asinhExpr(Integer(0).clone())->getType(), MathObjectType(MathObjectType::InvHyperbExpr, "InvHyperbExpr")); +TEST(InvHyperbExprTests, getClassTest) { + const auto expr = asinhExpr(Integer(0).clone()); + + EXPECT_EQ(expr->getClass(), MathObjectClass("InvHyperbExpr")); + EXPECT_EQ(expr->getClass().getParent(), IUnaryExpression::getClassStatic()); } diff --git a/tests/src/expressions/unary/InvTrigExprTests.cpp b/tests/src/expressions/unary/InvTrigExprTests.cpp index 85ce98d32..b5513c262 100644 --- a/tests/src/expressions/unary/InvTrigExprTests.cpp +++ b/tests/src/expressions/unary/InvTrigExprTests.cpp @@ -2,10 +2,14 @@ #include "fintamath/expressions/Expression.hpp" #include "fintamath/expressions/ExpressionUtils.hpp" +#include "fintamath/expressions/interfaces/IUnaryExpression.hpp" #include "fintamath/functions/trigonometry/Asin.hpp" using namespace fintamath; -TEST(InvTrigExprTests, getTypeTest) { - EXPECT_EQ(asinExpr(Integer(0).clone())->getType(), MathObjectType(MathObjectType::InvTrigExpr, "InvTrigExpr")); +TEST(InvTrigExprTests, getClassTest) { + const auto expr = asinExpr(Integer(0).clone()); + + EXPECT_EQ(expr->getClass(), MathObjectClass("InvTrigExpr")); + EXPECT_EQ(expr->getClass().getParent(), IUnaryExpression::getClassStatic()); } diff --git a/tests/src/expressions/unary/NotExprTests.cpp b/tests/src/expressions/unary/NotExprTests.cpp index 755c2045a..f4ed5cdf9 100644 --- a/tests/src/expressions/unary/NotExprTests.cpp +++ b/tests/src/expressions/unary/NotExprTests.cpp @@ -2,10 +2,14 @@ #include "fintamath/expressions/Expression.hpp" #include "fintamath/expressions/ExpressionUtils.hpp" +#include "fintamath/expressions/interfaces/IUnaryExpression.hpp" #include "fintamath/functions/logic/Not.hpp" using namespace fintamath; -TEST(NotExprTests, getTypeTest) { - EXPECT_EQ(notExpr(Boolean())->getType(), MathObjectType(MathObjectType::NotExpr, "NotExpr")); +TEST(NotExprTests, getClassTest) { + const auto expr = notExpr(Boolean()); + + EXPECT_EQ(expr->getClass(), MathObjectClass("NotExpr")); + EXPECT_EQ(expr->getClass().getParent(), IUnaryExpression::getClassStatic()); } diff --git a/tests/src/expressions/unary/SignExprTests.cpp b/tests/src/expressions/unary/SignExprTests.cpp index 3e867e7aa..68754079e 100644 --- a/tests/src/expressions/unary/SignExprTests.cpp +++ b/tests/src/expressions/unary/SignExprTests.cpp @@ -1,10 +1,14 @@ #include +#include "fintamath/expressions/interfaces/IUnaryExpression.hpp" #include "fintamath/functions/arithmetic/Sign.hpp" #include "fintamath/numbers/Integer.hpp" using namespace fintamath; -TEST(SignExprTests, getTypeTest) { - EXPECT_EQ(signExpr(Integer(0).clone())->getType(), MathObjectType(MathObjectType::SignExpr, "SignExpr")); +TEST(SignExprTests, getClassTest) { + const auto expr = signExpr(Integer(0).clone()); + + EXPECT_EQ(expr->getClass(), MathObjectClass("SignExpr")); + EXPECT_EQ(expr->getClass().getParent(), IUnaryExpression::getClassStatic()); } diff --git a/tests/src/expressions/unary/TrigExprTests.cpp b/tests/src/expressions/unary/TrigExprTests.cpp index bf7502857..09bb2734f 100644 --- a/tests/src/expressions/unary/TrigExprTests.cpp +++ b/tests/src/expressions/unary/TrigExprTests.cpp @@ -1,11 +1,14 @@ #include #include "fintamath/expressions/Expression.hpp" -#include "fintamath/expressions/ExpressionUtils.hpp" +#include "fintamath/expressions/interfaces/IUnaryExpression.hpp" #include "fintamath/functions/trigonometry/Sin.hpp" using namespace fintamath; -TEST(TrigExprTests, getTypeTest) { - EXPECT_EQ(sinExpr(Integer(0).clone())->getType(), MathObjectType(MathObjectType::TrigExpr, "TrigExpr")); +TEST(TrigExprTests, getClassTest) { + const auto expr = sinExpr(Integer(0).clone()); + + EXPECT_EQ(expr->getClass(), MathObjectClass("TrigExpr")); + EXPECT_EQ(expr->getClass().getParent(), IUnaryExpression::getClassStatic()); } diff --git a/tests/src/functions/IFunctionTests.cpp b/tests/src/functions/IFunctionTests.cpp index 4add7c030..b8bf41ba7 100644 --- a/tests/src/functions/IFunctionTests.cpp +++ b/tests/src/functions/IFunctionTests.cpp @@ -14,6 +14,28 @@ using namespace fintamath; +namespace { + +class TestFunction final : public IFunctionCRTP { + FINTAMATH_CLASS_BODY(TestFunction) + +protected: + std::unique_ptr call(const ArgumentRefVector &argVect) const override { + return {}; + } +}; + +[[maybe_unused]] const auto config = [] { + IFunction::registerType(); + return 0; +}(); + +} + +TEST(IFunctionTests, parseTest) { + EXPECT_TRUE(is(*IFunction::parseFirst("TestFunction"))); +} + TEST(IFunctionTests, callTest) { std::unique_ptr f = std::make_unique(); Integer a = 3; @@ -33,7 +55,7 @@ TEST(IFunctionTests, callTest) { EXPECT_THROW((*f)(a, a, a, a, a, a, a), InvalidInputFunctionException); } -TEST(IFunctionTests, calVectTest) { +TEST(IFunctionTests, callVectTest) { std::unique_ptr f = std::make_unique(); Integer a = 3; Rational b(1, 2); @@ -62,16 +84,16 @@ TEST(IFunctionTests, equalsTest) { EXPECT_NE(Sin(), Add()); } -TEST(IFunctionTests, getArgumentTypesTest) { - EXPECT_THAT(Add().getArgumentTypes(), testing::ElementsAre(IArithmetic::getTypeStatic(), IArithmetic::getTypeStatic())); - EXPECT_THAT(Neg().getArgumentTypes(), testing::ElementsAre(IArithmetic::getTypeStatic())); - EXPECT_THAT(Sin().getArgumentTypes(), testing::ElementsAre(INumber::getTypeStatic())); +TEST(IFunctionTests, getArgumentClassesTest) { + EXPECT_THAT(Add().getArgumentClasses(), testing::ElementsAre(IArithmetic::getClassStatic(), IArithmetic::getClassStatic())); + EXPECT_THAT(Neg().getArgumentClasses(), testing::ElementsAre(IArithmetic::getClassStatic())); + EXPECT_THAT(Sin().getArgumentClasses(), testing::ElementsAre(INumber::getClassStatic())); } -TEST(IFunctionTests, getReturnTypeTest) { - EXPECT_EQ(Add().getReturnType(), IArithmetic::getTypeStatic()); - EXPECT_EQ(Neg().getReturnType(), IArithmetic::getTypeStatic()); - EXPECT_EQ(Sin().getReturnType(), INumber::getTypeStatic()); +TEST(IFunctionTests, getReturnClassTest) { + EXPECT_EQ(Add().getReturnClass(), IArithmetic::getClassStatic()); + EXPECT_EQ(Neg().getReturnClass(), IArithmetic::getClassStatic()); + EXPECT_EQ(Sin().getReturnClass(), INumber::getClassStatic()); } TEST(IFunctionTests, doArgsMatchTest) { @@ -89,6 +111,7 @@ TEST(IFunctionTests, doArgsMatchTest) { EXPECT_FALSE(Add().doArgsMatch({a, b, a, b})); } -TEST(IFunctionTests, getTypeTest) { - EXPECT_EQ(IFunction::getTypeStatic(), MathObjectType(MathObjectType::IFunction, "IFunction")); +TEST(IFunctionTests, getClassTest) { + EXPECT_EQ(IFunction::getClassStatic(), MathObjectClass("IFunction")); + EXPECT_EQ(IFunction::getClassStatic().getParent(), IMathObject::getClassStatic()); } diff --git a/tests/src/functions/IOperatorTests.cpp b/tests/src/functions/IOperatorTests.cpp index 202cce0ae..3fcba96da 100644 --- a/tests/src/functions/IOperatorTests.cpp +++ b/tests/src/functions/IOperatorTests.cpp @@ -10,6 +10,33 @@ using namespace fintamath; +namespace { + +class TestOperator final : public IOperatorCRTP { + FINTAMATH_CLASS_BODY(TestOperator) + +public: + static constexpr Priority getPriorityStatic() { + return Priority::Addition; + } + +protected: + std::unique_ptr call(const ArgumentRefVector &argVect) const override { + return {}; + } +}; + +[[maybe_unused]] const auto config = [] { + IOperator::registerType(); + return 0; +}(); + +} + +TEST(IOperatorTests, parseTest) { + EXPECT_TRUE(is(*IOperator::parseFirst("TestOperator"))); +} + TEST(IOperatorTests, getPriorityTest) { EXPECT_EQ(Add().getPriority(), IOperator::Priority::Addition); EXPECT_EQ(Neg().getPriority(), IOperator::Priority::PrefixUnary); @@ -24,6 +51,7 @@ TEST(IOperatorTests, isAssociativeTest) { EXPECT_FALSE(Pow().isAssociative()); } -TEST(IOperatorTests, getTypeTest) { - EXPECT_EQ(IOperator::getTypeStatic(), MathObjectType(MathObjectType::IOperator, "IOperator")); +TEST(IOperatorTests, getClassTest) { + EXPECT_EQ(IOperator::getClassStatic(), MathObjectClass("IOperator")); + EXPECT_EQ(IOperator::getClassStatic().getParent(), IFunction::getClassStatic()); } diff --git a/tests/src/functions/arithmetic/AbsTests.cpp b/tests/src/functions/arithmetic/AbsTests.cpp index 818695d3b..1aca686dc 100644 --- a/tests/src/functions/arithmetic/AbsTests.cpp +++ b/tests/src/functions/arithmetic/AbsTests.cpp @@ -17,12 +17,12 @@ TEST(AbsTests, toStringTest) { EXPECT_EQ(f.toString(), "abs"); } -TEST(AbsTests, getArgumentTypesTest) { - EXPECT_THAT(f.getArgumentTypes(), testing::ElementsAre(INumber::getTypeStatic())); +TEST(AbsTests, getArgumentClassesTest) { + EXPECT_THAT(f.getArgumentClasses(), testing::ElementsAre(INumber::getClassStatic())); } -TEST(AbsTests, getReturnTypeTest) { - EXPECT_EQ(f.getReturnType(), INumber::getTypeStatic()); +TEST(AbsTests, getReturnClassTest) { + EXPECT_EQ(f.getReturnClass(), INumber::getClassStatic()); } TEST(AbsTests, isVariadicTest) { @@ -71,7 +71,7 @@ TEST(AbsTests, exprTest) { EXPECT_EQ(absExpr(Integer(10))->toString(), "abs(10)"); } -TEST(AbsTests, getTypeTest) { - EXPECT_EQ(F::getTypeStatic(), MathObjectType(MathObjectType::Abs, "Abs")); - EXPECT_EQ(f.getType(), MathObjectType(MathObjectType::Abs, "Abs")); +TEST(AbsTests, getClassTest) { + EXPECT_EQ(F::getClassStatic(), MathObjectClass("Abs")); + EXPECT_EQ(F::getClassStatic().getParent(), IFunction::getClassStatic()); } diff --git a/tests/src/functions/arithmetic/AddTests.cpp b/tests/src/functions/arithmetic/AddTests.cpp index 2fe9654ea..7f535a8c1 100644 --- a/tests/src/functions/arithmetic/AddTests.cpp +++ b/tests/src/functions/arithmetic/AddTests.cpp @@ -16,12 +16,12 @@ TEST(AddTests, toStringTest) { EXPECT_EQ(f.toString(), "+"); } -TEST(AddTests, getArgumentTypesTest) { - EXPECT_THAT(f.getArgumentTypes(), testing::ElementsAre(IArithmetic::getTypeStatic(), IArithmetic::getTypeStatic())); +TEST(AddTests, getArgumentClassesTest) { + EXPECT_THAT(f.getArgumentClasses(), testing::ElementsAre(IArithmetic::getClassStatic(), IArithmetic::getClassStatic())); } -TEST(AddTests, getReturnTypeTest) { - EXPECT_EQ(f.getReturnType(), IArithmetic::getTypeStatic()); +TEST(AddTests, getReturnClassTest) { + EXPECT_EQ(f.getReturnClass(), IArithmetic::getClassStatic()); } TEST(AddTests, isVariadicTest) { @@ -63,7 +63,7 @@ TEST(AddTests, exprTest) { EXPECT_EQ(addExpr(Integer(10), Integer(10))->toString(), "10 + 10"); } -TEST(AddTests, getTypeTest) { - EXPECT_EQ(F::getTypeStatic(), MathObjectType(MathObjectType::Add, "Add")); - EXPECT_EQ(f.getType(), MathObjectType(MathObjectType::Add, "Add")); +TEST(AddTests, getClassTest) { + EXPECT_EQ(F::getClassStatic(), MathObjectClass("Add")); + EXPECT_EQ(F::getClassStatic().getParent(), IOperator::getClassStatic()); } diff --git a/tests/src/functions/arithmetic/DivTests.cpp b/tests/src/functions/arithmetic/DivTests.cpp index 659950181..0177fcdb7 100644 --- a/tests/src/functions/arithmetic/DivTests.cpp +++ b/tests/src/functions/arithmetic/DivTests.cpp @@ -16,12 +16,12 @@ TEST(DivTests, toStringTest) { EXPECT_EQ(f.toString(), "/"); } -TEST(DivTests, getArgumentTypesTest) { - EXPECT_THAT(f.getArgumentTypes(), testing::ElementsAre(IArithmetic::getTypeStatic(), IArithmetic::getTypeStatic())); +TEST(DivTests, getArgumentClassesTest) { + EXPECT_THAT(f.getArgumentClasses(), testing::ElementsAre(IArithmetic::getClassStatic(), IArithmetic::getClassStatic())); } -TEST(DivTests, getReturnTypeTest) { - EXPECT_EQ(f.getReturnType(), IArithmetic::getTypeStatic()); +TEST(DivTests, getReturnClassTest) { + EXPECT_EQ(f.getReturnClass(), IArithmetic::getClassStatic()); } TEST(DivTests, isVariadicTest) { @@ -65,7 +65,7 @@ TEST(DivTests, exprTest) { EXPECT_EQ(divExpr(Integer(10), Integer(10))->toString(), "10/10"); } -TEST(DivTests, getTypeTest) { - EXPECT_EQ(F::getTypeStatic(), MathObjectType(MathObjectType::Div, "Div")); - EXPECT_EQ(f.getType(), MathObjectType(MathObjectType::Div, "Div")); +TEST(DivTests, getClassTest) { + EXPECT_EQ(F::getClassStatic(), MathObjectClass("Div")); + EXPECT_EQ(F::getClassStatic().getParent(), IOperator::getClassStatic()); } diff --git a/tests/src/functions/arithmetic/FracMixedTests.cpp b/tests/src/functions/arithmetic/FracMixedTests.cpp index a5358d76d..1b4ecbe2f 100644 --- a/tests/src/functions/arithmetic/FracMixedTests.cpp +++ b/tests/src/functions/arithmetic/FracMixedTests.cpp @@ -16,12 +16,12 @@ TEST(FracMixedTests, toStringTest) { EXPECT_EQ(f.toString(), "frac"); } -TEST(FracMixedTests, getArgumentTypesTest) { - EXPECT_THAT(f.getArgumentTypes(), testing::ElementsAre(IArithmetic::getTypeStatic(), IArithmetic::getTypeStatic(), IArithmetic::getTypeStatic())); +TEST(FracMixedTests, getArgumentClassesTest) { + EXPECT_THAT(f.getArgumentClasses(), testing::ElementsAre(IArithmetic::getClassStatic(), IArithmetic::getClassStatic(), IArithmetic::getClassStatic())); } -TEST(FracMixedTests, getReturnTypeTest) { - EXPECT_EQ(f.getReturnType(), IArithmetic::getTypeStatic()); +TEST(FracMixedTests, getReturnClassTest) { + EXPECT_EQ(f.getReturnClass(), IArithmetic::getClassStatic()); } TEST(FracMixedTests, isVariadicTest) { @@ -55,7 +55,7 @@ TEST(FracMixedTests, callTest) { EXPECT_THROW(f(Integer(1), Integer(1), Integer(1), Integer(1)), InvalidInputFunctionException); } -TEST(FracMixedTests, getTypeTest) { - EXPECT_EQ(F::getTypeStatic(), MathObjectType(MathObjectType::FracMixed, "FracMixed")); - EXPECT_EQ(f.getType(), MathObjectType(MathObjectType::FracMixed, "FracMixed")); +TEST(FracMixedTests, getClassTest) { + EXPECT_EQ(F::getClassStatic(), MathObjectClass("FracMixed")); + EXPECT_EQ(F::getClassStatic().getParent(), IFunction::getClassStatic()); } diff --git a/tests/src/functions/arithmetic/FracTests.cpp b/tests/src/functions/arithmetic/FracTests.cpp index 374a97193..ee6c7bb2d 100644 --- a/tests/src/functions/arithmetic/FracTests.cpp +++ b/tests/src/functions/arithmetic/FracTests.cpp @@ -16,12 +16,12 @@ TEST(FracTests, toStringTest) { EXPECT_EQ(f.toString(), "frac"); } -TEST(FracTests, getArgumentTypesTest) { - EXPECT_THAT(f.getArgumentTypes(), testing::ElementsAre(IArithmetic::getTypeStatic(), IArithmetic::getTypeStatic())); +TEST(FracTests, getArgumentClassesTest) { + EXPECT_THAT(f.getArgumentClasses(), testing::ElementsAre(IArithmetic::getClassStatic(), IArithmetic::getClassStatic())); } -TEST(FracTests, getReturnTypeTest) { - EXPECT_EQ(f.getReturnType(), IArithmetic::getTypeStatic()); +TEST(FracTests, getReturnClassTest) { + EXPECT_EQ(f.getReturnClass(), IArithmetic::getClassStatic()); } TEST(FracTests, isVariadicTest) { @@ -48,7 +48,7 @@ TEST(FracTests, callTest) { EXPECT_THROW(f(Integer(1), Integer(1), Integer(1)), InvalidInputFunctionException); } -TEST(FracTests, getTypeTest) { - EXPECT_EQ(F::getTypeStatic(), MathObjectType(MathObjectType::Frac, "Frac")); - EXPECT_EQ(f.getType(), MathObjectType(MathObjectType::Frac, "Frac")); +TEST(FracTests, getClassTest) { + EXPECT_EQ(F::getClassStatic(), MathObjectClass("Frac")); + EXPECT_EQ(F::getClassStatic().getParent(), IFunction::getClassStatic()); } diff --git a/tests/src/functions/arithmetic/MulTests.cpp b/tests/src/functions/arithmetic/MulTests.cpp index 6975d50f2..c0c5c3b9b 100644 --- a/tests/src/functions/arithmetic/MulTests.cpp +++ b/tests/src/functions/arithmetic/MulTests.cpp @@ -15,12 +15,12 @@ TEST(MulTests, toStringTest) { EXPECT_EQ(f.toString(), "*"); } -TEST(MulTests, getArgumentTypesTest) { - EXPECT_THAT(f.getArgumentTypes(), testing::ElementsAre(IArithmetic::getTypeStatic(), IArithmetic::getTypeStatic())); +TEST(MulTests, getArgumentClassesTest) { + EXPECT_THAT(f.getArgumentClasses(), testing::ElementsAre(IArithmetic::getClassStatic(), IArithmetic::getClassStatic())); } -TEST(MulTests, getReturnTypeTest) { - EXPECT_EQ(f.getReturnType(), IArithmetic::getTypeStatic()); +TEST(MulTests, getReturnClassTest) { + EXPECT_EQ(f.getReturnClass(), IArithmetic::getClassStatic()); } TEST(MulTests, isVariadicTest) { @@ -61,7 +61,7 @@ TEST(MulTests, exprTest) { EXPECT_EQ(mulExpr(Integer(10), Integer(10))->toString(), "10*10"); } -TEST(MulTests, getTypeTest) { - EXPECT_EQ(F::getTypeStatic(), MathObjectType(MathObjectType::Mul, "Mul")); - EXPECT_EQ(f.getType(), MathObjectType(MathObjectType::Mul, "Mul")); +TEST(MulTests, getClassTest) { + EXPECT_EQ(F::getClassStatic(), MathObjectClass("Mul")); + EXPECT_EQ(F::getClassStatic().getParent(), IOperator::getClassStatic()); } diff --git a/tests/src/functions/arithmetic/NegTests.cpp b/tests/src/functions/arithmetic/NegTests.cpp index d5efa47b2..5d856c788 100644 --- a/tests/src/functions/arithmetic/NegTests.cpp +++ b/tests/src/functions/arithmetic/NegTests.cpp @@ -15,12 +15,12 @@ TEST(NegTests, toStringTest) { EXPECT_EQ(f.toString(), "-"); } -TEST(NegTests, getArgumentTypesTest) { - EXPECT_THAT(f.getArgumentTypes(), testing::ElementsAre(IArithmetic::getTypeStatic())); +TEST(NegTests, getArgumentClassesTest) { + EXPECT_THAT(f.getArgumentClasses(), testing::ElementsAre(IArithmetic::getClassStatic())); } -TEST(NegTests, getReturnTypeTest) { - EXPECT_EQ(f.getReturnType(), IArithmetic::getTypeStatic()); +TEST(NegTests, getReturnClassTest) { + EXPECT_EQ(f.getReturnClass(), IArithmetic::getClassStatic()); } TEST(NegTests, isVariadicTest) { @@ -59,7 +59,7 @@ TEST(NegTests, exprTest) { EXPECT_EQ(negExpr(Integer(10))->toString(), "-10"); } -TEST(NegTests, getTypeTest) { - EXPECT_EQ(F::getTypeStatic(), MathObjectType(MathObjectType::Neg, "Neg")); - EXPECT_EQ(f.getType(), MathObjectType(MathObjectType::Neg, "Neg")); +TEST(NegTests, getClassTest) { + EXPECT_EQ(F::getClassStatic(), MathObjectClass("Neg")); + EXPECT_EQ(F::getClassStatic().getParent(), IOperator::getClassStatic()); } diff --git a/tests/src/functions/arithmetic/SignTests.cpp b/tests/src/functions/arithmetic/SignTests.cpp index 3ed2e971b..5a302da02 100644 --- a/tests/src/functions/arithmetic/SignTests.cpp +++ b/tests/src/functions/arithmetic/SignTests.cpp @@ -17,12 +17,12 @@ TEST(SignTests, toStringTest) { EXPECT_EQ(f.toString(), "sign"); } -TEST(SignTests, getArgumentTypesTest) { - EXPECT_THAT(f.getArgumentTypes(), testing::ElementsAre(INumber::getTypeStatic())); +TEST(SignTests, getArgumentClassesTest) { + EXPECT_THAT(f.getArgumentClasses(), testing::ElementsAre(INumber::getClassStatic())); } -TEST(SignTests, getReturnTypeTest) { - EXPECT_EQ(f.getReturnType(), INumber::getTypeStatic()); +TEST(SignTests, getReturnClassTest) { + EXPECT_EQ(f.getReturnClass(), INumber::getClassStatic()); } TEST(SignTests, isVariadicTest) { @@ -69,7 +69,7 @@ TEST(SignTests, exprTest) { EXPECT_EQ(signExpr(Integer(10))->toString(), "sign(10)"); } -TEST(SignTests, getTypeTest) { - EXPECT_EQ(F::getTypeStatic(), MathObjectType(MathObjectType::Sign, "Sign")); - EXPECT_EQ(f.getType(), MathObjectType(MathObjectType::Sign, "Sign")); +TEST(SignTests, getClassTest) { + EXPECT_EQ(F::getClassStatic(), MathObjectClass("Sign")); + EXPECT_EQ(F::getClassStatic().getParent(), IFunction::getClassStatic()); } diff --git a/tests/src/functions/arithmetic/SubTests.cpp b/tests/src/functions/arithmetic/SubTests.cpp index c7d32abdc..535821191 100644 --- a/tests/src/functions/arithmetic/SubTests.cpp +++ b/tests/src/functions/arithmetic/SubTests.cpp @@ -16,12 +16,12 @@ TEST(SubTests, toStringTest) { EXPECT_EQ(f.toString(), "-"); } -TEST(SubTests, getArgumentTypesTest) { - EXPECT_THAT(f.getArgumentTypes(), testing::ElementsAre(IArithmetic::getTypeStatic(), IArithmetic::getTypeStatic())); +TEST(SubTests, getArgumentClassesTest) { + EXPECT_THAT(f.getArgumentClasses(), testing::ElementsAre(IArithmetic::getClassStatic(), IArithmetic::getClassStatic())); } -TEST(SubTests, getReturnTypeTest) { - EXPECT_EQ(f.getReturnType(), IArithmetic::getTypeStatic()); +TEST(SubTests, getReturnClassTest) { + EXPECT_EQ(f.getReturnClass(), IArithmetic::getClassStatic()); } TEST(SubTests, isVariadicTest) { @@ -63,7 +63,7 @@ TEST(SubTests, exprTest) { EXPECT_EQ(subExpr(Integer(10), Integer(10))->toString(), "10 - 10"); } -TEST(SubTests, getTypeTest) { - EXPECT_EQ(F::getTypeStatic(), MathObjectType(MathObjectType::Sub, "Sub")); - EXPECT_EQ(f.getType(), MathObjectType(MathObjectType::Sub, "Sub")); +TEST(SubTests, getClassTest) { + EXPECT_EQ(F::getClassStatic(), MathObjectClass("Sub")); + EXPECT_EQ(F::getClassStatic().getParent(), IOperator::getClassStatic()); } diff --git a/tests/src/functions/arithmetic/UnaryPlusTests.cpp b/tests/src/functions/arithmetic/UnaryPlusTests.cpp index 3ab7572ad..d554b5fb7 100644 --- a/tests/src/functions/arithmetic/UnaryPlusTests.cpp +++ b/tests/src/functions/arithmetic/UnaryPlusTests.cpp @@ -16,12 +16,12 @@ TEST(UnaryPlusTests, toStringTest) { EXPECT_EQ(f.toString(), "+"); } -TEST(UnaryPlusTests, getArgumentTypesTest) { - EXPECT_THAT(f.getArgumentTypes(), testing::ElementsAre(IArithmetic::getTypeStatic())); +TEST(UnaryPlusTests, getArgumentClassesTest) { + EXPECT_THAT(f.getArgumentClasses(), testing::ElementsAre(IArithmetic::getClassStatic())); } -TEST(UnaryPlusTests, getReturnTypeTest) { - EXPECT_EQ(f.getReturnType(), IArithmetic::getTypeStatic()); +TEST(UnaryPlusTests, getReturnClassTest) { + EXPECT_EQ(f.getReturnClass(), IArithmetic::getClassStatic()); } TEST(UnaryPlusTests, isVariadicTest) { @@ -56,7 +56,7 @@ TEST(UnaryPlusTests, callTest) { EXPECT_THROW(f(Integer(1), Integer(1), Integer(1)), InvalidInputFunctionException); } -TEST(UnaryPlusTests, getTypeTest) { - EXPECT_EQ(F::getTypeStatic(), MathObjectType(MathObjectType::UnaryPlus, "UnaryPlus")); - EXPECT_EQ(f.getType(), MathObjectType(MathObjectType::UnaryPlus, "UnaryPlus")); +TEST(UnaryPlusTests, getClassTest) { + EXPECT_EQ(F::getClassStatic(), MathObjectClass("UnaryPlus")); + EXPECT_EQ(F::getClassStatic().getParent(), IOperator::getClassStatic()); } diff --git a/tests/src/functions/calculus/DerivativeTests.cpp b/tests/src/functions/calculus/DerivativeTests.cpp index 274b1bf6d..853b80f01 100644 --- a/tests/src/functions/calculus/DerivativeTests.cpp +++ b/tests/src/functions/calculus/DerivativeTests.cpp @@ -15,54 +15,57 @@ const F f; namespace { -class TestDerivative final : public IComparableCRTP { +class TestComparable final : public IComparableCRTP { + FINTAMATH_CLASS_BODY(TestComparable) + public: std::string toString() const override { return "testderivative"; } - static constexpr MathObjectType getTypeStatic() { - return {static_cast(MathObjectType::IComparable) + 997, "TestDerivative"}; - } - protected: - std::strong_ordering compare(const TestDerivative & /* rhs */) const override { - return 0 <=> 1; + std::strong_ordering compare(const TestComparable & /* rhs */) const override { + return std::strong_ordering::less; } - TestDerivative &add(const TestDerivative & /* rhs */) override { + TestComparable &add(const TestComparable & /* rhs */) override { return *this; } - TestDerivative &substract(const TestDerivative & /* rhs */) override { + TestComparable &substract(const TestComparable & /* rhs */) override { return *this; } - TestDerivative &multiply(const TestDerivative & /* rhs */) override { + TestComparable &multiply(const TestComparable & /* rhs */) override { return *this; } - TestDerivative ÷(const TestDerivative & /* rhs */) override { + TestComparable ÷(const TestComparable & /* rhs */) override { return *this; } - TestDerivative &negate() override { + TestComparable &negate() override { return *this; } }; +[[maybe_unused]] const auto config = [] { + IComparable::registerType(); + return 0; +}(); + } TEST(DerivativeTests, toStringTest) { EXPECT_EQ(f.toString(), "derivative"); } -TEST(DerivativeTests, getArgumentTypesTest) { - EXPECT_THAT(f.getArgumentTypes(), testing::ElementsAre(IComparable::getTypeStatic(), Variable::getTypeStatic())); +TEST(DerivativeTests, getArgumentClassesTest) { + EXPECT_THAT(f.getArgumentClasses(), testing::ElementsAre(IComparable::getClassStatic(), Variable::getClassStatic())); } -TEST(DerivativeTests, getReturnTypeTest) { - EXPECT_EQ(f.getReturnType(), IComparable::getTypeStatic()); +TEST(DerivativeTests, getReturnClassTest) { + EXPECT_EQ(f.getReturnClass(), IComparable::getClassStatic()); } TEST(DerivativeTests, isVariadicTest) { @@ -81,7 +84,7 @@ TEST(DerivativeTests, callTest) { EXPECT_EQ(f(Variable("a"), Variable("b"))->toString(), "0"); EXPECT_EQ(f(Expression("a+a"), Variable("a"))->toString(), "2"); - EXPECT_EQ(f(TestDerivative(), Variable("a"))->toString(), "derivative(testderivative, a)"); + EXPECT_EQ(f(TestComparable(), Variable("a"))->toString(), "derivative(testderivative, a)"); EXPECT_THROW(f(Integer(5), Integer(1)), InvalidInputException); EXPECT_THROW(f(Variable("a"), Integer(1)), InvalidInputException); @@ -96,7 +99,7 @@ TEST(DerivativeTests, exprTest) { EXPECT_EQ(derivativeExpr(Variable("a"), Variable("a"))->toString(), "derivative(a, a)"); } -TEST(DerivativeTests, getTypeTest) { - EXPECT_EQ(F::getTypeStatic(), MathObjectType(MathObjectType::Derivative, "Derivative")); - EXPECT_EQ(f.getType(), MathObjectType(MathObjectType::Derivative, "Derivative")); +TEST(DerivativeTests, getClassTest) { + EXPECT_EQ(F::getClassStatic(), MathObjectClass("Derivative")); + EXPECT_EQ(F::getClassStatic().getParent(), IFunction::getClassStatic()); } diff --git a/tests/src/functions/calculus/IntegralTests.cpp b/tests/src/functions/calculus/IntegralTests.cpp index 4e7636caa..fa9493ac6 100644 --- a/tests/src/functions/calculus/IntegralTests.cpp +++ b/tests/src/functions/calculus/IntegralTests.cpp @@ -17,12 +17,12 @@ TEST(IntegralTests, toStringTest) { EXPECT_EQ(f.toString(), "integral"); } -TEST(IntegralTests, getArgumentTypesTest) { - EXPECT_THAT(f.getArgumentTypes(), testing::ElementsAre(IComparable::getTypeStatic(), Variable::getTypeStatic())); +TEST(IntegralTests, getArgumentClassesTest) { + EXPECT_THAT(f.getArgumentClasses(), testing::ElementsAre(IComparable::getClassStatic(), Variable::getClassStatic())); } -TEST(IntegralTests, getReturnTypeTest) { - EXPECT_EQ(f.getReturnType(), IComparable::getTypeStatic()); +TEST(IntegralTests, getReturnClassTest) { + EXPECT_EQ(f.getReturnClass(), IComparable::getClassStatic()); } TEST(IntegralTests, isVariadicTest) { @@ -55,7 +55,7 @@ TEST(IntegralTests, exprTest) { EXPECT_EQ(integralExpr(Variable("a"), Variable("a"))->toString(), "integral(a, a)"); } -TEST(IntegralTests, getTypeTest) { - EXPECT_EQ(F::getTypeStatic(), MathObjectType(MathObjectType::Integral, "Integral")); - EXPECT_EQ(f.getType(), MathObjectType(MathObjectType::Integral, "Integral")); +TEST(IntegralTests, getClassTest) { + EXPECT_EQ(F::getClassStatic(), MathObjectClass("Integral")); + EXPECT_EQ(F::getClassStatic().getParent(), IFunction::getClassStatic()); } diff --git a/tests/src/functions/calculus/MaxTests.cpp b/tests/src/functions/calculus/MaxTests.cpp index 0f3310712..d9cc608a5 100644 --- a/tests/src/functions/calculus/MaxTests.cpp +++ b/tests/src/functions/calculus/MaxTests.cpp @@ -18,12 +18,12 @@ TEST(MaxTests, toStringTest) { EXPECT_EQ(f.toString(), "max"); } -TEST(MaxTests, getArgumentTypesTest) { - EXPECT_THAT(f.getArgumentTypes(), testing::ElementsAre(IComparable::getTypeStatic())); +TEST(MaxTests, getArgumentClassesTest) { + EXPECT_THAT(f.getArgumentClasses(), testing::ElementsAre(IComparable::getClassStatic())); } -TEST(MaxTests, getReturnTypeTest) { - EXPECT_EQ(f.getReturnType(), IComparable::getTypeStatic()); +TEST(MaxTests, getReturnClassTest) { + EXPECT_EQ(f.getReturnClass(), IComparable::getClassStatic()); } TEST(MaxTests, isVariadicTest) { @@ -60,7 +60,7 @@ TEST(MaxTests, exprTest) { EXPECT_EQ(maxExpr(Variable("a"), Variable("a"))->toString(), "max(a, a)"); } -TEST(MaxTests, getTypeTest) { - EXPECT_EQ(F::getTypeStatic(), MathObjectType(MathObjectType::Max, "Max")); - EXPECT_EQ(f.getType(), MathObjectType(MathObjectType::Max, "Max")); +TEST(MaxTests, getClassTest) { + EXPECT_EQ(F::getClassStatic(), MathObjectClass("Max")); + EXPECT_EQ(F::getClassStatic().getParent(), IFunction::getClassStatic()); } diff --git a/tests/src/functions/calculus/MinTests.cpp b/tests/src/functions/calculus/MinTests.cpp index 579fcfa48..10e47aa6b 100644 --- a/tests/src/functions/calculus/MinTests.cpp +++ b/tests/src/functions/calculus/MinTests.cpp @@ -18,12 +18,12 @@ TEST(MinTests, toStringTest) { EXPECT_EQ(f.toString(), "min"); } -TEST(MinTests, getArgumentTypesTest) { - EXPECT_THAT(f.getArgumentTypes(), testing::ElementsAre(IComparable::getTypeStatic())); +TEST(MinTests, getArgumentClassesTest) { + EXPECT_THAT(f.getArgumentClasses(), testing::ElementsAre(IComparable::getClassStatic())); } -TEST(MinTests, getReturnTypeTest) { - EXPECT_EQ(f.getReturnType(), IComparable::getTypeStatic()); +TEST(MinTests, getReturnClassTest) { + EXPECT_EQ(f.getReturnClass(), IComparable::getClassStatic()); } TEST(MinTests, isVariadicTest) { @@ -60,7 +60,7 @@ TEST(MinTests, exprTest) { EXPECT_EQ(minExpr(Variable("a"), Variable("a"))->toString(), "min(a, a)"); } -TEST(MinTests, getTypeTest) { - EXPECT_EQ(F::getTypeStatic(), MathObjectType(MathObjectType::Min, "Min")); - EXPECT_EQ(f.getType(), MathObjectType(MathObjectType::Min, "Min")); +TEST(MinTests, getClassTest) { + EXPECT_EQ(F::getClassStatic(), MathObjectClass("Min")); + EXPECT_EQ(F::getClassStatic().getParent(), IFunction::getClassStatic()); } diff --git a/tests/src/functions/comparison/EqvTests.cpp b/tests/src/functions/comparison/EqvTests.cpp index 5b045fa08..24ad4f56c 100644 --- a/tests/src/functions/comparison/EqvTests.cpp +++ b/tests/src/functions/comparison/EqvTests.cpp @@ -16,12 +16,12 @@ TEST(EqvTests, toStringTest) { EXPECT_EQ(f.toString(), "="); } -TEST(EqvTests, getArgumentTypesTest) { - EXPECT_THAT(f.getArgumentTypes(), testing::ElementsAre(IComparable::getTypeStatic(), IComparable::getTypeStatic())); +TEST(EqvTests, getArgumentClassesTest) { + EXPECT_THAT(f.getArgumentClasses(), testing::ElementsAre(IComparable::getClassStatic(), IComparable::getClassStatic())); } -TEST(EqvTests, getReturnTypeTest) { - EXPECT_EQ(f.getReturnType(), Boolean::getTypeStatic()); +TEST(EqvTests, getReturnClassTest) { + EXPECT_EQ(f.getReturnClass(), Boolean::getClassStatic()); } TEST(EqvTests, isVariadicTest) { @@ -69,7 +69,7 @@ TEST(EqvTests, exprTest) { EXPECT_EQ(eqvExpr(Integer(10), Integer(10))->toString(), "10 = 10"); } -TEST(EqvTests, getTypeTest) { - EXPECT_EQ(F::getTypeStatic(), MathObjectType(MathObjectType::Eqv, "Eqv")); - EXPECT_EQ(f.getType(), MathObjectType(MathObjectType::Eqv, "Eqv")); +TEST(EqvTests, getClassTest) { + EXPECT_EQ(F::getClassStatic(), MathObjectClass("Eqv")); + EXPECT_EQ(F::getClassStatic().getParent(), IOperator::getClassStatic()); } diff --git a/tests/src/functions/comparison/LessEqvTests.cpp b/tests/src/functions/comparison/LessEqvTests.cpp index daa254c38..4d1958435 100644 --- a/tests/src/functions/comparison/LessEqvTests.cpp +++ b/tests/src/functions/comparison/LessEqvTests.cpp @@ -16,12 +16,12 @@ TEST(LessEqvTests, toStringTest) { EXPECT_EQ(f.toString(), "<="); } -TEST(LessEqvTests, getArgumentTypesTest) { - EXPECT_THAT(f.getArgumentTypes(), testing::ElementsAre(IComparable::getTypeStatic(), IComparable::getTypeStatic())); +TEST(LessEqvTests, getArgumentClassesTest) { + EXPECT_THAT(f.getArgumentClasses(), testing::ElementsAre(IComparable::getClassStatic(), IComparable::getClassStatic())); } -TEST(LessEqvTests, getReturnTypeTest) { - EXPECT_EQ(f.getReturnType(), Boolean::getTypeStatic()); +TEST(LessEqvTests, getReturnClassTest) { + EXPECT_EQ(f.getReturnClass(), Boolean::getClassStatic()); } TEST(LessEqvTests, isVariadicTest) { @@ -69,7 +69,7 @@ TEST(LessEqvTests, exprTest) { EXPECT_EQ(lessEqvExpr(Integer(10), Integer(10))->toString(), "10 <= 10"); } -TEST(LessEqvTests, getTypeTest) { - EXPECT_EQ(F::getTypeStatic(), MathObjectType(MathObjectType::LessEqv, "LessEqv")); - EXPECT_EQ(f.getType(), MathObjectType(MathObjectType::LessEqv, "LessEqv")); +TEST(LessEqvTests, getClassTest) { + EXPECT_EQ(F::getClassStatic(), MathObjectClass("LessEqv")); + EXPECT_EQ(F::getClassStatic().getParent(), IOperator::getClassStatic()); } diff --git a/tests/src/functions/comparison/LessTests.cpp b/tests/src/functions/comparison/LessTests.cpp index 845637ace..5d41ea705 100644 --- a/tests/src/functions/comparison/LessTests.cpp +++ b/tests/src/functions/comparison/LessTests.cpp @@ -16,12 +16,12 @@ TEST(LessTests, toStringTest) { EXPECT_EQ(f.toString(), "<"); } -TEST(LessTests, getArgumentTypesTest) { - EXPECT_THAT(f.getArgumentTypes(), testing::ElementsAre(IComparable::getTypeStatic(), IComparable::getTypeStatic())); +TEST(LessTests, getArgumentClassesTest) { + EXPECT_THAT(f.getArgumentClasses(), testing::ElementsAre(IComparable::getClassStatic(), IComparable::getClassStatic())); } -TEST(LessTests, getReturnTypeTest) { - EXPECT_EQ(f.getReturnType(), Boolean::getTypeStatic()); +TEST(LessTests, getReturnClassTest) { + EXPECT_EQ(f.getReturnClass(), Boolean::getClassStatic()); } TEST(LessTests, isVariadicTest) { @@ -69,7 +69,7 @@ TEST(LessTests, exprTest) { EXPECT_EQ(lessExpr(Integer(10), Integer(10))->toString(), "10 < 10"); } -TEST(LessTests, getTypeTest) { - EXPECT_EQ(F::getTypeStatic(), MathObjectType(MathObjectType::Less, "Less")); - EXPECT_EQ(f.getType(), MathObjectType(MathObjectType::Less, "Less")); +TEST(LessTests, getClassTest) { + EXPECT_EQ(F::getClassStatic(), MathObjectClass("Less")); + EXPECT_EQ(F::getClassStatic().getParent(), IOperator::getClassStatic()); } diff --git a/tests/src/functions/comparison/MoreEqvTests.cpp b/tests/src/functions/comparison/MoreEqvTests.cpp index 7b91a5a40..f0d6e9ca8 100644 --- a/tests/src/functions/comparison/MoreEqvTests.cpp +++ b/tests/src/functions/comparison/MoreEqvTests.cpp @@ -16,12 +16,12 @@ TEST(MoreEqvTests, toStringTest) { EXPECT_EQ(f.toString(), ">="); } -TEST(MoreEqvTests, getArgumentTypesTest) { - EXPECT_THAT(f.getArgumentTypes(), testing::ElementsAre(IComparable::getTypeStatic(), IComparable::getTypeStatic())); +TEST(MoreEqvTests, getArgumentClassesTest) { + EXPECT_THAT(f.getArgumentClasses(), testing::ElementsAre(IComparable::getClassStatic(), IComparable::getClassStatic())); } -TEST(MoreEqvTests, getReturnTypeTest) { - EXPECT_EQ(f.getReturnType(), Boolean::getTypeStatic()); +TEST(MoreEqvTests, getReturnClassTest) { + EXPECT_EQ(f.getReturnClass(), Boolean::getClassStatic()); } TEST(MoreEqvTests, isVariadicTest) { @@ -69,7 +69,7 @@ TEST(MoreEqvTests, exprTest) { EXPECT_EQ(moreEqvExpr(Integer(10), Integer(10))->toString(), "10 >= 10"); } -TEST(MoreEqvTests, getTypeTest) { - EXPECT_EQ(F::getTypeStatic(), MathObjectType(MathObjectType::MoreEqv, "MoreEqv")); - EXPECT_EQ(f.getType(), MathObjectType(MathObjectType::MoreEqv, "MoreEqv")); +TEST(MoreEqvTests, getClassTest) { + EXPECT_EQ(F::getClassStatic(), MathObjectClass("MoreEqv")); + EXPECT_EQ(F::getClassStatic().getParent(), IOperator::getClassStatic()); } diff --git a/tests/src/functions/comparison/MoreTests.cpp b/tests/src/functions/comparison/MoreTests.cpp index a5dc4b3b4..158f0c77b 100644 --- a/tests/src/functions/comparison/MoreTests.cpp +++ b/tests/src/functions/comparison/MoreTests.cpp @@ -16,12 +16,12 @@ TEST(MoreTests, toStringTest) { EXPECT_EQ(f.toString(), ">"); } -TEST(MoreTests, getArgumentTypesTest) { - EXPECT_THAT(f.getArgumentTypes(), testing::ElementsAre(IComparable::getTypeStatic(), IComparable::getTypeStatic())); +TEST(MoreTests, getArgumentClassesTest) { + EXPECT_THAT(f.getArgumentClasses(), testing::ElementsAre(IComparable::getClassStatic(), IComparable::getClassStatic())); } -TEST(MoreTests, getReturnTypeTest) { - EXPECT_EQ(f.getReturnType(), Boolean::getTypeStatic()); +TEST(MoreTests, getReturnClassTest) { + EXPECT_EQ(f.getReturnClass(), Boolean::getClassStatic()); } TEST(MoreTests, isVariadicTest) { @@ -69,7 +69,7 @@ TEST(MoreTests, exprTest) { EXPECT_EQ(moreExpr(Integer(10), Integer(10))->toString(), "10 > 10"); } -TEST(MoreTests, getTypeTest) { - EXPECT_EQ(F::getTypeStatic(), MathObjectType(MathObjectType::More, "More")); - EXPECT_EQ(f.getType(), MathObjectType(MathObjectType::More, "More")); +TEST(MoreTests, getClassTest) { + EXPECT_EQ(F::getClassStatic(), MathObjectClass("More")); + EXPECT_EQ(F::getClassStatic().getParent(), IOperator::getClassStatic()); } diff --git a/tests/src/functions/comparison/NeqvTests.cpp b/tests/src/functions/comparison/NeqvTests.cpp index b9d716ca6..1ba7ddb82 100644 --- a/tests/src/functions/comparison/NeqvTests.cpp +++ b/tests/src/functions/comparison/NeqvTests.cpp @@ -16,12 +16,12 @@ TEST(NeqvTests, toStringTest) { EXPECT_EQ(f.toString(), "!="); } -TEST(NeqvTests, getArgumentTypesTest) { - EXPECT_THAT(f.getArgumentTypes(), testing::ElementsAre(IComparable::getTypeStatic(), IComparable::getTypeStatic())); +TEST(NeqvTests, getArgumentClassesTest) { + EXPECT_THAT(f.getArgumentClasses(), testing::ElementsAre(IComparable::getClassStatic(), IComparable::getClassStatic())); } -TEST(NeqvTests, getReturnTypeTest) { - EXPECT_EQ(f.getReturnType(), Boolean::getTypeStatic()); +TEST(NeqvTests, getReturnClassTest) { + EXPECT_EQ(f.getReturnClass(), Boolean::getClassStatic()); } TEST(NeqvTests, isVariadicTest) { @@ -69,7 +69,7 @@ TEST(NeqvTests, exprTest) { EXPECT_EQ(neqvExpr(Integer(10), Integer(10))->toString(), "10 != 10"); } -TEST(NeqvTests, getTypeTest) { - EXPECT_EQ(F::getTypeStatic(), MathObjectType(MathObjectType::Neqv, "Neqv")); - EXPECT_EQ(f.getType(), MathObjectType(MathObjectType::Neqv, "Neqv")); +TEST(NeqvTests, getClassTest) { + EXPECT_EQ(F::getClassStatic(), MathObjectClass("Neqv")); + EXPECT_EQ(F::getClassStatic().getParent(), IOperator::getClassStatic()); } diff --git a/tests/src/functions/hyperbolic/AcoshTests.cpp b/tests/src/functions/hyperbolic/AcoshTests.cpp index 8d29c4edd..542eb6e4c 100644 --- a/tests/src/functions/hyperbolic/AcoshTests.cpp +++ b/tests/src/functions/hyperbolic/AcoshTests.cpp @@ -17,12 +17,12 @@ TEST(AcoshTests, toStringTest) { EXPECT_EQ(f.toString(), "acosh"); } -TEST(AcoshTests, getArgumentTypesTest) { - EXPECT_THAT(f.getArgumentTypes(), testing::ElementsAre(INumber::getTypeStatic())); +TEST(AcoshTests, getArgumentClassesTest) { + EXPECT_THAT(f.getArgumentClasses(), testing::ElementsAre(INumber::getClassStatic())); } -TEST(AcoshTests, getReturnTypeTest) { - EXPECT_EQ(f.getReturnType(), INumber::getTypeStatic()); +TEST(AcoshTests, getReturnClassTest) { + EXPECT_EQ(f.getReturnClass(), INumber::getClassStatic()); } TEST(AcoshTests, isVariadicTest) { @@ -59,7 +59,7 @@ TEST(AcoshTests, exprTest) { EXPECT_EQ(acoshExpr(Integer(10))->toString(), "acosh(10)"); } -TEST(AcoshTests, getTypeTest) { - EXPECT_EQ(F::getTypeStatic(), MathObjectType(MathObjectType::Acosh, "Acosh")); - EXPECT_EQ(f.getType(), MathObjectType(MathObjectType::Acosh, "Acosh")); +TEST(AcoshTests, getClassTest) { + EXPECT_EQ(F::getClassStatic(), MathObjectClass("Acosh")); + EXPECT_EQ(F::getClassStatic().getParent(), IFunction::getClassStatic()); } diff --git a/tests/src/functions/hyperbolic/AcothTests.cpp b/tests/src/functions/hyperbolic/AcothTests.cpp index 9a404dc28..d4cbbc230 100644 --- a/tests/src/functions/hyperbolic/AcothTests.cpp +++ b/tests/src/functions/hyperbolic/AcothTests.cpp @@ -17,12 +17,12 @@ TEST(AcothTests, toStringTest) { EXPECT_EQ(f.toString(), "acoth"); } -TEST(AcothTests, getArgumentTypesTest) { - EXPECT_THAT(f.getArgumentTypes(), testing::ElementsAre(INumber::getTypeStatic())); +TEST(AcothTests, getArgumentClassesTest) { + EXPECT_THAT(f.getArgumentClasses(), testing::ElementsAre(INumber::getClassStatic())); } -TEST(AcothTests, getReturnTypeTest) { - EXPECT_EQ(f.getReturnType(), INumber::getTypeStatic()); +TEST(AcothTests, getReturnClassTest) { + EXPECT_EQ(f.getReturnClass(), INumber::getClassStatic()); } TEST(AcothTests, isVariadicTest) { @@ -59,7 +59,7 @@ TEST(AcothTests, exprTest) { EXPECT_EQ(acothExpr(Integer(10))->toString(), "acoth(10)"); } -TEST(AcothTests, getTypeTest) { - EXPECT_EQ(F::getTypeStatic(), MathObjectType(MathObjectType::Acoth, "Acoth")); - EXPECT_EQ(f.getType(), MathObjectType(MathObjectType::Acoth, "Acoth")); +TEST(AcothTests, getClassTest) { + EXPECT_EQ(F::getClassStatic(), MathObjectClass("Acoth")); + EXPECT_EQ(F::getClassStatic().getParent(), IFunction::getClassStatic()); } diff --git a/tests/src/functions/hyperbolic/AcschTests.cpp b/tests/src/functions/hyperbolic/AcschTests.cpp index 7e94c71f3..766a8561f 100644 --- a/tests/src/functions/hyperbolic/AcschTests.cpp +++ b/tests/src/functions/hyperbolic/AcschTests.cpp @@ -17,12 +17,12 @@ TEST(AcschTests, toStringTest) { EXPECT_EQ(f.toString(), "acsch"); } -TEST(AcschTests, getArgumentTypesTest) { - EXPECT_THAT(f.getArgumentTypes(), testing::ElementsAre(INumber::getTypeStatic())); +TEST(AcschTests, getArgumentClassesTest) { + EXPECT_THAT(f.getArgumentClasses(), testing::ElementsAre(INumber::getClassStatic())); } -TEST(AcschTests, getReturnTypeTest) { - EXPECT_EQ(f.getReturnType(), INumber::getTypeStatic()); +TEST(AcschTests, getReturnClassTest) { + EXPECT_EQ(f.getReturnClass(), INumber::getClassStatic()); } TEST(AcschTests, isVariadicTest) { @@ -58,7 +58,7 @@ TEST(AcschTests, exprTest) { EXPECT_EQ(acschExpr(Integer(10))->toString(), "acsch(10)"); } -TEST(AcschTests, getTypeTest) { - EXPECT_EQ(F::getTypeStatic(), MathObjectType(MathObjectType::Acsch, "Acsch")); - EXPECT_EQ(f.getType(), MathObjectType(MathObjectType::Acsch, "Acsch")); +TEST(AcschTests, getClassTest) { + EXPECT_EQ(F::getClassStatic(), MathObjectClass("Acsch")); + EXPECT_EQ(F::getClassStatic().getParent(), IFunction::getClassStatic()); } diff --git a/tests/src/functions/hyperbolic/AsechTests.cpp b/tests/src/functions/hyperbolic/AsechTests.cpp index 72b33a33a..4c26d8d42 100644 --- a/tests/src/functions/hyperbolic/AsechTests.cpp +++ b/tests/src/functions/hyperbolic/AsechTests.cpp @@ -17,12 +17,12 @@ TEST(AsechTests, toStringTest) { EXPECT_EQ(f.toString(), "asech"); } -TEST(AsechTests, getArgumentTypesTest) { - EXPECT_THAT(f.getArgumentTypes(), testing::ElementsAre(INumber::getTypeStatic())); +TEST(AsechTests, getArgumentClassesTest) { + EXPECT_THAT(f.getArgumentClasses(), testing::ElementsAre(INumber::getClassStatic())); } -TEST(AsechTests, getReturnTypeTest) { - EXPECT_EQ(f.getReturnType(), INumber::getTypeStatic()); +TEST(AsechTests, getReturnClassTest) { + EXPECT_EQ(f.getReturnClass(), INumber::getClassStatic()); } TEST(AsechTests, isVariadicTest) { @@ -59,7 +59,7 @@ TEST(AsechTests, exprTest) { EXPECT_EQ(asechExpr(Integer(10))->toString(), "asech(10)"); } -TEST(AsechTests, getTypeTest) { - EXPECT_EQ(F::getTypeStatic(), MathObjectType(MathObjectType::Asech, "Asech")); - EXPECT_EQ(f.getType(), MathObjectType(MathObjectType::Asech, "Asech")); +TEST(AsechTests, getClassTest) { + EXPECT_EQ(F::getClassStatic(), MathObjectClass("Asech")); + EXPECT_EQ(F::getClassStatic().getParent(), IFunction::getClassStatic()); } diff --git a/tests/src/functions/hyperbolic/AsinhTests.cpp b/tests/src/functions/hyperbolic/AsinhTests.cpp index dacf9a084..8ffd3dabd 100644 --- a/tests/src/functions/hyperbolic/AsinhTests.cpp +++ b/tests/src/functions/hyperbolic/AsinhTests.cpp @@ -17,12 +17,12 @@ TEST(AsinhTests, toStringTest) { EXPECT_EQ(f.toString(), "asinh"); } -TEST(AsinhTests, getArgumentTypesTest) { - EXPECT_THAT(f.getArgumentTypes(), testing::ElementsAre(INumber::getTypeStatic())); +TEST(AsinhTests, getArgumentClassesTest) { + EXPECT_THAT(f.getArgumentClasses(), testing::ElementsAre(INumber::getClassStatic())); } -TEST(AsinhTests, getReturnTypeTest) { - EXPECT_EQ(f.getReturnType(), INumber::getTypeStatic()); +TEST(AsinhTests, getReturnClassTest) { + EXPECT_EQ(f.getReturnClass(), INumber::getClassStatic()); } TEST(AsinhTests, isVariadicTest) { @@ -56,7 +56,7 @@ TEST(AsinhTests, exprTest) { EXPECT_EQ(asinhExpr(Integer(10))->toString(), "asinh(10)"); } -TEST(AsinhTests, getTypeTest) { - EXPECT_EQ(F::getTypeStatic(), MathObjectType(MathObjectType::Asinh, "Asinh")); - EXPECT_EQ(f.getType(), MathObjectType(MathObjectType::Asinh, "Asinh")); +TEST(AsinhTests, getClassTest) { + EXPECT_EQ(F::getClassStatic(), MathObjectClass("Asinh")); + EXPECT_EQ(F::getClassStatic().getParent(), IFunction::getClassStatic()); } diff --git a/tests/src/functions/hyperbolic/AtanhTests.cpp b/tests/src/functions/hyperbolic/AtanhTests.cpp index d85584bae..c85195f65 100644 --- a/tests/src/functions/hyperbolic/AtanhTests.cpp +++ b/tests/src/functions/hyperbolic/AtanhTests.cpp @@ -17,12 +17,12 @@ TEST(AtanhTests, toStringTest) { EXPECT_EQ(f.toString(), "atanh"); } -TEST(AtanhTests, getArgumentTypesTest) { - EXPECT_THAT(f.getArgumentTypes(), testing::ElementsAre(INumber::getTypeStatic())); +TEST(AtanhTests, getArgumentClassesTest) { + EXPECT_THAT(f.getArgumentClasses(), testing::ElementsAre(INumber::getClassStatic())); } -TEST(AtanhTests, getReturnTypeTest) { - EXPECT_EQ(f.getReturnType(), INumber::getTypeStatic()); +TEST(AtanhTests, getReturnClassTest) { + EXPECT_EQ(f.getReturnClass(), INumber::getClassStatic()); } TEST(AtanhTests, isVariadicTest) { @@ -59,7 +59,7 @@ TEST(AtanhTests, exprTest) { EXPECT_EQ(atanhExpr(Integer(10))->toString(), "atanh(10)"); } -TEST(AtanhTests, getTypeTest) { - EXPECT_EQ(F::getTypeStatic(), MathObjectType(MathObjectType::Atanh, "Atanh")); - EXPECT_EQ(f.getType(), MathObjectType(MathObjectType::Atanh, "Atanh")); +TEST(AtanhTests, getClassTest) { + EXPECT_EQ(F::getClassStatic(), MathObjectClass("Atanh")); + EXPECT_EQ(F::getClassStatic().getParent(), IFunction::getClassStatic()); } diff --git a/tests/src/functions/hyperbolic/CoshTests.cpp b/tests/src/functions/hyperbolic/CoshTests.cpp index 73b1db689..6565c9ad9 100644 --- a/tests/src/functions/hyperbolic/CoshTests.cpp +++ b/tests/src/functions/hyperbolic/CoshTests.cpp @@ -17,12 +17,12 @@ TEST(CoshTests, toStringTest) { EXPECT_EQ(f.toString(), "cosh"); } -TEST(CoshTests, getArgumentTypesTest) { - EXPECT_THAT(f.getArgumentTypes(), testing::ElementsAre(INumber::getTypeStatic())); +TEST(CoshTests, getArgumentClassesTest) { + EXPECT_THAT(f.getArgumentClasses(), testing::ElementsAre(INumber::getClassStatic())); } -TEST(CoshTests, getReturnTypeTest) { - EXPECT_EQ(f.getReturnType(), INumber::getTypeStatic()); +TEST(CoshTests, getReturnClassTest) { + EXPECT_EQ(f.getReturnClass(), INumber::getClassStatic()); } TEST(CoshTests, isVariadicTest) { @@ -56,7 +56,7 @@ TEST(CoshTests, exprTest) { EXPECT_EQ(coshExpr(Integer(10))->toString(), "cosh(10)"); } -TEST(CoshTests, getTypeTest) { - EXPECT_EQ(F::getTypeStatic(), MathObjectType(MathObjectType::Cosh, "Cosh")); - EXPECT_EQ(f.getType(), MathObjectType(MathObjectType::Cosh, "Cosh")); +TEST(CoshTests, getClassTest) { + EXPECT_EQ(F::getClassStatic(), MathObjectClass("Cosh")); + EXPECT_EQ(F::getClassStatic().getParent(), IFunction::getClassStatic()); } diff --git a/tests/src/functions/hyperbolic/CothTests.cpp b/tests/src/functions/hyperbolic/CothTests.cpp index cc1554e66..4d2e18e70 100644 --- a/tests/src/functions/hyperbolic/CothTests.cpp +++ b/tests/src/functions/hyperbolic/CothTests.cpp @@ -17,12 +17,12 @@ TEST(CothTests, toStringTest) { EXPECT_EQ(f.toString(), "coth"); } -TEST(CothTests, getArgumentTypesTest) { - EXPECT_THAT(f.getArgumentTypes(), testing::ElementsAre(INumber::getTypeStatic())); +TEST(CothTests, getArgumentClassesTest) { + EXPECT_THAT(f.getArgumentClasses(), testing::ElementsAre(INumber::getClassStatic())); } -TEST(CothTests, getReturnTypeTest) { - EXPECT_EQ(f.getReturnType(), INumber::getTypeStatic()); +TEST(CothTests, getReturnClassTest) { + EXPECT_EQ(f.getReturnClass(), INumber::getClassStatic()); } TEST(CothTests, isVariadicTest) { @@ -57,7 +57,7 @@ TEST(CothTests, exprTest) { EXPECT_EQ(cothExpr(Integer(10))->toString(), "coth(10)"); } -TEST(CothTests, getTypeTest) { - EXPECT_EQ(F::getTypeStatic(), MathObjectType(MathObjectType::Coth, "Coth")); - EXPECT_EQ(f.getType(), MathObjectType(MathObjectType::Coth, "Coth")); +TEST(CothTests, getClassTest) { + EXPECT_EQ(F::getClassStatic(), MathObjectClass("Coth")); + EXPECT_EQ(F::getClassStatic().getParent(), IFunction::getClassStatic()); } diff --git a/tests/src/functions/hyperbolic/CschTests.cpp b/tests/src/functions/hyperbolic/CschTests.cpp index 60bff58b1..076eb1f89 100644 --- a/tests/src/functions/hyperbolic/CschTests.cpp +++ b/tests/src/functions/hyperbolic/CschTests.cpp @@ -17,12 +17,12 @@ TEST(CschTests, toStringTest) { EXPECT_EQ(f.toString(), "csch"); } -TEST(CschTests, getArgumentTypesTest) { - EXPECT_THAT(f.getArgumentTypes(), testing::ElementsAre(INumber::getTypeStatic())); +TEST(CschTests, getArgumentClassesTest) { + EXPECT_THAT(f.getArgumentClasses(), testing::ElementsAre(INumber::getClassStatic())); } -TEST(CschTests, getReturnTypeTest) { - EXPECT_EQ(f.getReturnType(), INumber::getTypeStatic()); +TEST(CschTests, getReturnClassTest) { + EXPECT_EQ(f.getReturnClass(), INumber::getClassStatic()); } TEST(CschTests, isVariadicTest) { @@ -56,7 +56,7 @@ TEST(CschTests, exprTest) { EXPECT_EQ(cschExpr(Integer(10))->toString(), "csch(10)"); } -TEST(CschTests, getTypeTest) { - EXPECT_EQ(F::getTypeStatic(), MathObjectType(MathObjectType::Csch, "Csch")); - EXPECT_EQ(f.getType(), MathObjectType(MathObjectType::Csch, "Csch")); +TEST(CschTests, getClassTest) { + EXPECT_EQ(F::getClassStatic(), MathObjectClass("Csch")); + EXPECT_EQ(F::getClassStatic().getParent(), IFunction::getClassStatic()); } diff --git a/tests/src/functions/hyperbolic/SechTests.cpp b/tests/src/functions/hyperbolic/SechTests.cpp index bba89f850..fdc886686 100644 --- a/tests/src/functions/hyperbolic/SechTests.cpp +++ b/tests/src/functions/hyperbolic/SechTests.cpp @@ -17,12 +17,12 @@ TEST(SechTests, toStringTest) { EXPECT_EQ(f.toString(), "sech"); } -TEST(SechTests, getArgumentTypesTest) { - EXPECT_THAT(f.getArgumentTypes(), testing::ElementsAre(INumber::getTypeStatic())); +TEST(SechTests, getArgumentClassesTest) { + EXPECT_THAT(f.getArgumentClasses(), testing::ElementsAre(INumber::getClassStatic())); } -TEST(SechTests, getReturnTypeTest) { - EXPECT_EQ(f.getReturnType(), INumber::getTypeStatic()); +TEST(SechTests, getReturnClassTest) { + EXPECT_EQ(f.getReturnClass(), INumber::getClassStatic()); } TEST(SechTests, isVariadicTest) { @@ -57,7 +57,7 @@ TEST(SechTests, exprTest) { EXPECT_EQ(sechExpr(Integer(10))->toString(), "sech(10)"); } -TEST(SechTests, getTypeTest) { - EXPECT_EQ(F::getTypeStatic(), MathObjectType(MathObjectType::Sech, "Sech")); - EXPECT_EQ(f.getType(), MathObjectType(MathObjectType::Sech, "Sech")); +TEST(SechTests, getClassTest) { + EXPECT_EQ(F::getClassStatic(), MathObjectClass("Sech")); + EXPECT_EQ(F::getClassStatic().getParent(), IFunction::getClassStatic()); } diff --git a/tests/src/functions/hyperbolic/SinhTests.cpp b/tests/src/functions/hyperbolic/SinhTests.cpp index 1c8c6f77f..ad6eb6cf0 100644 --- a/tests/src/functions/hyperbolic/SinhTests.cpp +++ b/tests/src/functions/hyperbolic/SinhTests.cpp @@ -17,12 +17,12 @@ TEST(SinhTests, toStringTest) { EXPECT_EQ(f.toString(), "sinh"); } -TEST(SinhTests, getArgumentTypesTest) { - EXPECT_THAT(f.getArgumentTypes(), testing::ElementsAre(INumber::getTypeStatic())); +TEST(SinhTests, getArgumentClassesTest) { + EXPECT_THAT(f.getArgumentClasses(), testing::ElementsAre(INumber::getClassStatic())); } -TEST(SinhTests, getReturnTypeTest) { - EXPECT_EQ(f.getReturnType(), INumber::getTypeStatic()); +TEST(SinhTests, getReturnClassTest) { + EXPECT_EQ(f.getReturnClass(), INumber::getClassStatic()); } TEST(SinhTests, isVariadicTest) { @@ -56,7 +56,7 @@ TEST(SinhTests, exprTest) { EXPECT_EQ(sinhExpr(Integer(10))->toString(), "sinh(10)"); } -TEST(SinhTests, getTypeTest) { - EXPECT_EQ(F::getTypeStatic(), MathObjectType(MathObjectType::Sinh, "Sinh")); - EXPECT_EQ(f.getType(), MathObjectType(MathObjectType::Sinh, "Sinh")); +TEST(SinhTests, getClassTest) { + EXPECT_EQ(F::getClassStatic(), MathObjectClass("Sinh")); + EXPECT_EQ(F::getClassStatic().getParent(), IFunction::getClassStatic()); } diff --git a/tests/src/functions/hyperbolic/TanhTests.cpp b/tests/src/functions/hyperbolic/TanhTests.cpp index 597761db7..bfbd7ad1c 100644 --- a/tests/src/functions/hyperbolic/TanhTests.cpp +++ b/tests/src/functions/hyperbolic/TanhTests.cpp @@ -17,12 +17,12 @@ TEST(TanhTests, toStringTest) { EXPECT_EQ(f.toString(), "tanh"); } -TEST(TanhTests, getArgumentTypesTest) { - EXPECT_THAT(f.getArgumentTypes(), testing::ElementsAre(INumber::getTypeStatic())); +TEST(TanhTests, getArgumentClassesTest) { + EXPECT_THAT(f.getArgumentClasses(), testing::ElementsAre(INumber::getClassStatic())); } -TEST(TanhTests, getReturnTypeTest) { - EXPECT_EQ(f.getReturnType(), INumber::getTypeStatic()); +TEST(TanhTests, getReturnClassTest) { + EXPECT_EQ(f.getReturnClass(), INumber::getClassStatic()); } TEST(TanhTests, isVariadicTest) { @@ -56,7 +56,7 @@ TEST(TanhTests, exprTest) { EXPECT_EQ(tanhExpr(Integer(10))->toString(), "tanh(10)"); } -TEST(TanhTests, getTypeTest) { - EXPECT_EQ(F::getTypeStatic(), MathObjectType(MathObjectType::Tanh, "Tanh")); - EXPECT_EQ(f.getType(), MathObjectType(MathObjectType::Tanh, "Tanh")); +TEST(TanhTests, getClassTest) { + EXPECT_EQ(F::getClassStatic(), MathObjectClass("Tanh")); + EXPECT_EQ(F::getClassStatic().getParent(), IFunction::getClassStatic()); } diff --git a/tests/src/functions/logarithms/LbTests.cpp b/tests/src/functions/logarithms/LbTests.cpp index 23a0b9d75..114528724 100644 --- a/tests/src/functions/logarithms/LbTests.cpp +++ b/tests/src/functions/logarithms/LbTests.cpp @@ -15,12 +15,12 @@ TEST(LbTests, toStringTest) { EXPECT_EQ(f.toString(), "lb"); } -TEST(LbTests, getArgumentTypesTest) { - EXPECT_THAT(f.getArgumentTypes(), testing::ElementsAre(INumber::getTypeStatic())); +TEST(LbTests, getArgumentClassesTest) { + EXPECT_THAT(f.getArgumentClasses(), testing::ElementsAre(INumber::getClassStatic())); } -TEST(LbTests, getReturnTypeTest) { - EXPECT_EQ(f.getReturnType(), INumber::getTypeStatic()); +TEST(LbTests, getReturnClassTest) { + EXPECT_EQ(f.getReturnClass(), INumber::getClassStatic()); } TEST(LbTests, isVariadicTest) { @@ -52,7 +52,7 @@ TEST(LbTests, exprTest) { EXPECT_EQ(lbExpr(Integer(10))->toString(), "log(2, 10)"); } -TEST(LbTests, getTypeTest) { - EXPECT_EQ(F::getTypeStatic(), MathObjectType(MathObjectType::Lb, "Lb")); - EXPECT_EQ(f.getType(), MathObjectType(MathObjectType::Lb, "Lb")); +TEST(LbTests, getClassTest) { + EXPECT_EQ(F::getClassStatic(), MathObjectClass("Lb")); + EXPECT_EQ(F::getClassStatic().getParent(), IFunction::getClassStatic()); } diff --git a/tests/src/functions/logarithms/LgTests.cpp b/tests/src/functions/logarithms/LgTests.cpp index 8efb30160..259faa4b6 100644 --- a/tests/src/functions/logarithms/LgTests.cpp +++ b/tests/src/functions/logarithms/LgTests.cpp @@ -15,12 +15,12 @@ TEST(LgTests, toStringTest) { EXPECT_EQ(f.toString(), "lg"); } -TEST(LgTests, getArgumentTypesTest) { - EXPECT_THAT(f.getArgumentTypes(), testing::ElementsAre(INumber::getTypeStatic())); +TEST(LgTests, getArgumentClassesTest) { + EXPECT_THAT(f.getArgumentClasses(), testing::ElementsAre(INumber::getClassStatic())); } -TEST(LgTests, getReturnTypeTest) { - EXPECT_EQ(f.getReturnType(), INumber::getTypeStatic()); +TEST(LgTests, getReturnClassTest) { + EXPECT_EQ(f.getReturnClass(), INumber::getClassStatic()); } TEST(LgTests, isVariadicTest) { @@ -52,7 +52,7 @@ TEST(LgTests, exprTest) { EXPECT_EQ(lgExpr(Integer(10))->toString(), "log(10, 10)"); } -TEST(LgTests, getTypeTest) { - EXPECT_EQ(F::getTypeStatic(), MathObjectType(MathObjectType::Lg, "Lg")); - EXPECT_EQ(f.getType(), MathObjectType(MathObjectType::Lg, "Lg")); +TEST(LgTests, getClassTest) { + EXPECT_EQ(F::getClassStatic(), MathObjectClass("Lg")); + EXPECT_EQ(F::getClassStatic().getParent(), IFunction::getClassStatic()); } diff --git a/tests/src/functions/logarithms/LnTests.cpp b/tests/src/functions/logarithms/LnTests.cpp index 576c6e26e..2484bc035 100644 --- a/tests/src/functions/logarithms/LnTests.cpp +++ b/tests/src/functions/logarithms/LnTests.cpp @@ -17,12 +17,12 @@ TEST(LnTests, toStringTest) { EXPECT_EQ(f.toString(), "ln"); } -TEST(LnTests, getArgumentTypesTest) { - EXPECT_THAT(f.getArgumentTypes(), testing::ElementsAre(INumber::getTypeStatic())); +TEST(LnTests, getArgumentClassesTest) { + EXPECT_THAT(f.getArgumentClasses(), testing::ElementsAre(INumber::getClassStatic())); } -TEST(LnTests, getReturnTypeTest) { - EXPECT_EQ(f.getReturnType(), INumber::getTypeStatic()); +TEST(LnTests, getReturnClassTest) { + EXPECT_EQ(f.getReturnClass(), INumber::getClassStatic()); } TEST(LnTests, isVariadicTest) { @@ -54,7 +54,7 @@ TEST(LnTests, exprTest) { EXPECT_EQ(lnExpr(Integer(10))->toString(), "ln(10)"); } -TEST(LnTests, getTypeTest) { - EXPECT_EQ(F::getTypeStatic(), MathObjectType(MathObjectType::Ln, "Ln")); - EXPECT_EQ(f.getType(), MathObjectType(MathObjectType::Ln, "Ln")); +TEST(LnTests, getClassTest) { + EXPECT_EQ(F::getClassStatic(), MathObjectClass("Ln")); + EXPECT_EQ(F::getClassStatic().getParent(), IFunction::getClassStatic()); } diff --git a/tests/src/functions/logarithms/LogTests.cpp b/tests/src/functions/logarithms/LogTests.cpp index d5e9484fc..e22127545 100644 --- a/tests/src/functions/logarithms/LogTests.cpp +++ b/tests/src/functions/logarithms/LogTests.cpp @@ -16,12 +16,12 @@ TEST(LogTests, toStringTest) { EXPECT_EQ(f.toString(), "log"); } -TEST(LogTests, getArgumentTypesTest) { - EXPECT_THAT(f.getArgumentTypes(), testing::ElementsAre(INumber::getTypeStatic(), INumber::getTypeStatic())); +TEST(LogTests, getArgumentClassesTest) { + EXPECT_THAT(f.getArgumentClasses(), testing::ElementsAre(INumber::getClassStatic(), INumber::getClassStatic())); } -TEST(LogTests, getReturnTypeTest) { - EXPECT_EQ(f.getReturnType(), INumber::getTypeStatic()); +TEST(LogTests, getReturnClassTest) { + EXPECT_EQ(f.getReturnClass(), INumber::getClassStatic()); } TEST(LogTests, isVariadicTest) { @@ -134,7 +134,7 @@ TEST(LogTests, exprTest) { "log(10, 10)"); } -TEST(LogTests, getTypeTest) { - EXPECT_EQ(F::getTypeStatic(), MathObjectType(MathObjectType::Log, "Log")); - EXPECT_EQ(f.getType(), MathObjectType(MathObjectType::Log, "Log")); +TEST(LogTests, getClassTest) { + EXPECT_EQ(F::getClassStatic(), MathObjectClass("Log")); + EXPECT_EQ(F::getClassStatic().getParent(), IFunction::getClassStatic()); } diff --git a/tests/src/functions/logic/AndTests.cpp b/tests/src/functions/logic/AndTests.cpp index 523327cb8..f0c4aee4b 100644 --- a/tests/src/functions/logic/AndTests.cpp +++ b/tests/src/functions/logic/AndTests.cpp @@ -15,12 +15,12 @@ TEST(AndTests, toStringTest) { EXPECT_EQ(f.toString(), "&"); } -TEST(AndTests, getArgumentTypesTest) { - EXPECT_THAT(f.getArgumentTypes(), testing::ElementsAre(Boolean::getTypeStatic(), Boolean::getTypeStatic())); +TEST(AndTests, getArgumentClassesTest) { + EXPECT_THAT(f.getArgumentClasses(), testing::ElementsAre(Boolean::getClassStatic(), Boolean::getClassStatic())); } -TEST(AndTests, getReturnTypeTest) { - EXPECT_EQ(f.getReturnType(), Boolean::getTypeStatic()); +TEST(AndTests, getReturnClassTest) { + EXPECT_EQ(f.getReturnClass(), Boolean::getClassStatic()); } TEST(AndTests, isVariadicTest) { @@ -60,7 +60,7 @@ TEST(AndTests, exprTest) { EXPECT_EQ(andExpr(Boolean(true), Boolean(false))->toString(), "True & False"); } -TEST(AndTests, getTypeTest) { - EXPECT_EQ(F::getTypeStatic(), MathObjectType(MathObjectType::And, "And")); - EXPECT_EQ(f.getType(), MathObjectType(MathObjectType::And, "And")); +TEST(AndTests, getClassTest) { + EXPECT_EQ(F::getClassStatic(), MathObjectClass("And")); + EXPECT_EQ(F::getClassStatic().getParent(), IOperator::getClassStatic()); } diff --git a/tests/src/functions/logic/EquivTests.cpp b/tests/src/functions/logic/EquivTests.cpp index a7d5a4b5e..99d620f39 100644 --- a/tests/src/functions/logic/EquivTests.cpp +++ b/tests/src/functions/logic/EquivTests.cpp @@ -15,12 +15,12 @@ TEST(EquivTests, toStringTest) { EXPECT_EQ(f.toString(), "<->"); } -TEST(EquivTests, getArgumentTypesTest) { - EXPECT_THAT(f.getArgumentTypes(), testing::ElementsAre(Boolean::getTypeStatic(), Boolean::getTypeStatic())); +TEST(EquivTests, getArgumentClassesTest) { + EXPECT_THAT(f.getArgumentClasses(), testing::ElementsAre(Boolean::getClassStatic(), Boolean::getClassStatic())); } -TEST(EquivTests, getReturnTypeTest) { - EXPECT_EQ(f.getReturnType(), Boolean::getTypeStatic()); +TEST(EquivTests, getReturnClassTest) { + EXPECT_EQ(f.getReturnClass(), Boolean::getClassStatic()); } TEST(EquivTests, isVariadicTest) { @@ -60,7 +60,7 @@ TEST(EquivTests, exprTest) { EXPECT_EQ(equivExpr(Boolean(true), Boolean(false))->toString(), "(True & False) | (~True & ~False)"); } -TEST(EquivTests, getTypeTest) { - EXPECT_EQ(F::getTypeStatic(), MathObjectType(MathObjectType::Equiv, "Equiv")); - EXPECT_EQ(f.getType(), MathObjectType(MathObjectType::Equiv, "Equiv")); +TEST(EquivTests, getClassTest) { + EXPECT_EQ(F::getClassStatic(), MathObjectClass("Equiv")); + EXPECT_EQ(F::getClassStatic().getParent(), IOperator::getClassStatic()); } diff --git a/tests/src/functions/logic/ImplTests.cpp b/tests/src/functions/logic/ImplTests.cpp index b2accac86..3fad5eb04 100644 --- a/tests/src/functions/logic/ImplTests.cpp +++ b/tests/src/functions/logic/ImplTests.cpp @@ -15,12 +15,12 @@ TEST(ImplTests, toStringTest) { EXPECT_EQ(f.toString(), "->"); } -TEST(ImplTests, getArgumentTypesTest) { - EXPECT_THAT(f.getArgumentTypes(), testing::ElementsAre(Boolean::getTypeStatic(), Boolean::getTypeStatic())); +TEST(ImplTests, getArgumentClassesTest) { + EXPECT_THAT(f.getArgumentClasses(), testing::ElementsAre(Boolean::getClassStatic(), Boolean::getClassStatic())); } -TEST(ImplTests, getReturnTypeTest) { - EXPECT_EQ(f.getReturnType(), Boolean::getTypeStatic()); +TEST(ImplTests, getReturnClassTest) { + EXPECT_EQ(f.getReturnClass(), Boolean::getClassStatic()); } TEST(ImplTests, isVariadicTest) { @@ -60,7 +60,7 @@ TEST(ImplTests, exprTest) { EXPECT_EQ(implExpr(Boolean(true), Boolean(false))->toString(), "~True | False"); } -TEST(ImplTests, getTypeTest) { - EXPECT_EQ(F::getTypeStatic(), MathObjectType(MathObjectType::Impl, "Impl")); - EXPECT_EQ(f.getType(), MathObjectType(MathObjectType::Impl, "Impl")); +TEST(ImplTests, getClassTest) { + EXPECT_EQ(F::getClassStatic(), MathObjectClass("Impl")); + EXPECT_EQ(F::getClassStatic().getParent(), IOperator::getClassStatic()); } diff --git a/tests/src/functions/logic/NequivTests.cpp b/tests/src/functions/logic/NequivTests.cpp index fd3d6c935..eacbb400c 100644 --- a/tests/src/functions/logic/NequivTests.cpp +++ b/tests/src/functions/logic/NequivTests.cpp @@ -15,12 +15,12 @@ TEST(NequivTests, toStringTest) { EXPECT_EQ(f.toString(), "!<->"); } -TEST(NequivTests, getArgumentTypesTest) { - EXPECT_THAT(f.getArgumentTypes(), testing::ElementsAre(Boolean::getTypeStatic(), Boolean::getTypeStatic())); +TEST(NequivTests, getArgumentClassesTest) { + EXPECT_THAT(f.getArgumentClasses(), testing::ElementsAre(Boolean::getClassStatic(), Boolean::getClassStatic())); } -TEST(NequivTests, getReturnTypeTest) { - EXPECT_EQ(f.getReturnType(), Boolean::getTypeStatic()); +TEST(NequivTests, getReturnClassTest) { + EXPECT_EQ(f.getReturnClass(), Boolean::getClassStatic()); } TEST(NequivTests, isVariadicTest) { @@ -60,7 +60,7 @@ TEST(NequivTests, exprTest) { EXPECT_EQ(nequivExpr(Boolean(true), Boolean(false))->toString(), "(~True & False) | (True & ~False)"); } -TEST(NequivTests, getTypeTest) { - EXPECT_EQ(F::getTypeStatic(), MathObjectType(MathObjectType::Nequiv, "Nequiv")); - EXPECT_EQ(f.getType(), MathObjectType(MathObjectType::Nequiv, "Nequiv")); +TEST(NequivTests, getClassTest) { + EXPECT_EQ(F::getClassStatic(), MathObjectClass("Nequiv")); + EXPECT_EQ(F::getClassStatic().getParent(), IOperator::getClassStatic()); } diff --git a/tests/src/functions/logic/NotTests.cpp b/tests/src/functions/logic/NotTests.cpp index 0d91b0447..4796c91ff 100644 --- a/tests/src/functions/logic/NotTests.cpp +++ b/tests/src/functions/logic/NotTests.cpp @@ -15,12 +15,12 @@ TEST(NotTests, toStringTest) { EXPECT_EQ(f.toString(), "~"); } -TEST(NotTests, getArgumentTypesTest) { - EXPECT_THAT(f.getArgumentTypes(), testing::ElementsAre(Boolean::getTypeStatic())); +TEST(NotTests, getArgumentClassesTest) { + EXPECT_THAT(f.getArgumentClasses(), testing::ElementsAre(Boolean::getClassStatic())); } -TEST(NotTests, getReturnTypeTest) { - EXPECT_EQ(f.getReturnType(), Boolean::getTypeStatic()); +TEST(NotTests, getReturnClassTest) { + EXPECT_EQ(f.getReturnClass(), Boolean::getClassStatic()); } TEST(NotTests, isVariadicTest) { @@ -58,7 +58,7 @@ TEST(NotTests, exprTest) { EXPECT_EQ(notExpr(Boolean(true))->toString(), "~True"); } -TEST(NotTests, getTypeTest) { - EXPECT_EQ(F::getTypeStatic(), MathObjectType(MathObjectType::Not, "Not")); - EXPECT_EQ(f.getType(), MathObjectType(MathObjectType::Not, "Not")); +TEST(NotTests, getClassTest) { + EXPECT_EQ(F::getClassStatic(), MathObjectClass("Not")); + EXPECT_EQ(F::getClassStatic().getParent(), IOperator::getClassStatic()); } diff --git a/tests/src/functions/logic/OrTests.cpp b/tests/src/functions/logic/OrTests.cpp index 647fe84dd..e3f903a10 100644 --- a/tests/src/functions/logic/OrTests.cpp +++ b/tests/src/functions/logic/OrTests.cpp @@ -15,12 +15,12 @@ TEST(OrTests, toStringTest) { EXPECT_EQ(f.toString(), "|"); } -TEST(OrTests, getArgumentTypesTest) { - EXPECT_THAT(f.getArgumentTypes(), testing::ElementsAre(Boolean::getTypeStatic(), Boolean::getTypeStatic())); +TEST(OrTests, getArgumentClassesTest) { + EXPECT_THAT(f.getArgumentClasses(), testing::ElementsAre(Boolean::getClassStatic(), Boolean::getClassStatic())); } -TEST(OrTests, getReturnTypeTest) { - EXPECT_EQ(f.getReturnType(), Boolean::getTypeStatic()); +TEST(OrTests, getReturnClassTest) { + EXPECT_EQ(f.getReturnClass(), Boolean::getClassStatic()); } TEST(OrTests, isVariadicTest) { @@ -60,7 +60,7 @@ TEST(OrTests, exprTest) { EXPECT_EQ(orExpr(Boolean(true), Boolean(false))->toString(), "True | False"); } -TEST(OrTests, getTypeTest) { - EXPECT_EQ(F::getTypeStatic(), MathObjectType(MathObjectType::Or, "Or")); - EXPECT_EQ(f.getType(), MathObjectType(MathObjectType::Or, "Or")); +TEST(OrTests, getClassTest) { + EXPECT_EQ(F::getClassStatic(), MathObjectClass("Or")); + EXPECT_EQ(F::getClassStatic().getParent(), IOperator::getClassStatic()); } diff --git a/tests/src/functions/ntheory/CeilTests.cpp b/tests/src/functions/ntheory/CeilTests.cpp index 97bc09fcb..0a979df42 100644 --- a/tests/src/functions/ntheory/CeilTests.cpp +++ b/tests/src/functions/ntheory/CeilTests.cpp @@ -17,12 +17,12 @@ TEST(CeilTests, toStringTest) { EXPECT_EQ(f.toString(), "ceil"); } -TEST(CeilTests, getArgumentTypesTest) { - EXPECT_THAT(f.getArgumentTypes(), testing::ElementsAre(INumber::getTypeStatic())); +TEST(CeilTests, getArgumentClassesTest) { + EXPECT_THAT(f.getArgumentClasses(), testing::ElementsAre(INumber::getClassStatic())); } -TEST(CeilTests, getReturnTypeTest) { - EXPECT_EQ(f.getReturnType(), INumber::getTypeStatic()); +TEST(CeilTests, getReturnClassTest) { + EXPECT_EQ(f.getReturnClass(), INumber::getClassStatic()); } TEST(CeilTests, isVariadicTest) { @@ -82,7 +82,7 @@ TEST(CeilTests, exprTest) { EXPECT_EQ(ceilExpr(Integer(10))->toString(), "ceil(10)"); } -TEST(CeilTests, getTypeTest) { - EXPECT_EQ(F::getTypeStatic(), MathObjectType(MathObjectType::Ceil, "Ceil")); - EXPECT_EQ(f.getType(), MathObjectType(MathObjectType::Ceil, "Ceil")); +TEST(CeilTests, getClassTest) { + EXPECT_EQ(F::getClassStatic(), MathObjectClass("Ceil")); + EXPECT_EQ(F::getClassStatic().getParent(), IFunction::getClassStatic()); } diff --git a/tests/src/functions/ntheory/FloorTests.cpp b/tests/src/functions/ntheory/FloorTests.cpp index 5aa564a64..4e772d1bb 100644 --- a/tests/src/functions/ntheory/FloorTests.cpp +++ b/tests/src/functions/ntheory/FloorTests.cpp @@ -17,12 +17,12 @@ TEST(FloorTests, toStringTest) { EXPECT_EQ(f.toString(), "floor"); } -TEST(FloorTests, getArgumentTypesTest) { - EXPECT_THAT(f.getArgumentTypes(), testing::ElementsAre(INumber::getTypeStatic())); +TEST(FloorTests, getArgumentClassesTest) { + EXPECT_THAT(f.getArgumentClasses(), testing::ElementsAre(INumber::getClassStatic())); } -TEST(FloorTests, getReturnTypeTest) { - EXPECT_EQ(f.getReturnType(), INumber::getTypeStatic()); +TEST(FloorTests, getReturnClassTest) { + EXPECT_EQ(f.getReturnClass(), INumber::getClassStatic()); } TEST(FloorTests, isVariadicTest) { @@ -82,7 +82,7 @@ TEST(FloorTests, exprTest) { EXPECT_EQ(floorExpr(Integer(10))->toString(), "floor(10)"); } -TEST(FloorTests, getTypeTest) { - EXPECT_EQ(F::getTypeStatic(), MathObjectType(MathObjectType::Floor, "Floor")); - EXPECT_EQ(f.getType(), MathObjectType(MathObjectType::Floor, "Floor")); +TEST(FloorTests, getClassTest) { + EXPECT_EQ(F::getClassStatic(), MathObjectClass("Floor")); + EXPECT_EQ(F::getClassStatic().getParent(), IFunction::getClassStatic()); } diff --git a/tests/src/functions/ntheory/ModTests.cpp b/tests/src/functions/ntheory/ModTests.cpp index 171c93af7..2fe0fc11d 100644 --- a/tests/src/functions/ntheory/ModTests.cpp +++ b/tests/src/functions/ntheory/ModTests.cpp @@ -16,12 +16,12 @@ TEST(ModTests, toStringTest) { EXPECT_EQ(f.toString(), "mod"); } -TEST(ModTests, getArgumentTypesTest) { - EXPECT_THAT(f.getArgumentTypes(), testing::ElementsAre(INumber::getTypeStatic(), INumber::getTypeStatic())); +TEST(ModTests, getArgumentClassesTest) { + EXPECT_THAT(f.getArgumentClasses(), testing::ElementsAre(INumber::getClassStatic(), INumber::getClassStatic())); } -TEST(ModTests, getReturnTypeTest) { - EXPECT_EQ(f.getReturnType(), INumber::getTypeStatic()); +TEST(ModTests, getReturnClassTest) { + EXPECT_EQ(f.getReturnClass(), INumber::getClassStatic()); } TEST(ModTests, isVariadicTest) { @@ -103,7 +103,7 @@ TEST(ModTests, exprTest) { EXPECT_EQ(modExpr(Integer(10), Integer(10))->toString(), "10 mod 10"); } -TEST(ModTests, getTypeTest) { - EXPECT_EQ(F::getTypeStatic(), MathObjectType(MathObjectType::Mod, "Mod")); - EXPECT_EQ(f.getType(), MathObjectType(MathObjectType::Mod, "Mod")); +TEST(ModTests, getClassTest) { + EXPECT_EQ(F::getClassStatic(), MathObjectClass("Mod")); + EXPECT_EQ(F::getClassStatic().getParent(), IOperator::getClassStatic()); } diff --git a/tests/src/functions/other/CommaTests.cpp b/tests/src/functions/other/CommaTests.cpp index 825f0b0c9..f9cfea216 100644 --- a/tests/src/functions/other/CommaTests.cpp +++ b/tests/src/functions/other/CommaTests.cpp @@ -16,12 +16,12 @@ TEST(CommaTests, toStringTest) { EXPECT_EQ(f.toString(), ","); } -TEST(CommaTests, getArgumentTypesTest) { - EXPECT_THAT(f.getArgumentTypes(), testing::ElementsAre(IMathObject::getTypeStatic(), IMathObject::getTypeStatic())); +TEST(CommaTests, getArgumentClassesTest) { + EXPECT_THAT(f.getArgumentClasses(), testing::ElementsAre(IMathObject::getClassStatic(), IMathObject::getClassStatic())); } -TEST(CommaTests, getReturnTypeTest) { - EXPECT_EQ(f.getReturnType(), IMathObject::getTypeStatic()); +TEST(CommaTests, getReturnClassTest) { + EXPECT_EQ(f.getReturnClass(), IMathObject::getClassStatic()); } TEST(CommaTests, isVariadicTest) { @@ -55,7 +55,7 @@ TEST(CommaTests, exprTest) { EXPECT_EQ(commaExpr(Variable("a"), Integer(1))->toString(), "a , 1"); } -TEST(CommaTests, getTypeTest) { - EXPECT_EQ(F::getTypeStatic(), MathObjectType(MathObjectType::Comma, "Comma")); - EXPECT_EQ(f.getType(), MathObjectType(MathObjectType::Comma, "Comma")); +TEST(CommaTests, getClassTest) { + EXPECT_EQ(F::getClassStatic(), MathObjectClass("Comma")); + EXPECT_EQ(F::getClassStatic().getParent(), IOperator::getClassStatic()); } diff --git a/tests/src/functions/other/DegTests.cpp b/tests/src/functions/other/DegTests.cpp index 6817609cf..c4d78862d 100644 --- a/tests/src/functions/other/DegTests.cpp +++ b/tests/src/functions/other/DegTests.cpp @@ -15,12 +15,12 @@ TEST(DegTests, toStringTest) { EXPECT_EQ(f.toString(), "deg"); } -TEST(DegTests, getArgumentTypesTest) { - EXPECT_THAT(f.getArgumentTypes(), testing::ElementsAre(INumber::getTypeStatic())); +TEST(DegTests, getArgumentClassesTest) { + EXPECT_THAT(f.getArgumentClasses(), testing::ElementsAre(INumber::getClassStatic())); } -TEST(DegTests, getReturnTypeTest) { - EXPECT_EQ(f.getReturnType(), INumber::getTypeStatic()); +TEST(DegTests, getReturnClassTest) { + EXPECT_EQ(f.getReturnClass(), INumber::getClassStatic()); } TEST(DegTests, isVariadicTest) { @@ -60,7 +60,7 @@ TEST(DegTests, degTest) { EXPECT_EQ(degExpr(Integer(10))->toString(), "10 Pi/180"); } -TEST(DegTests, getTypeTest) { - EXPECT_EQ(F::getTypeStatic(), MathObjectType(MathObjectType::Deg, "Deg")); - EXPECT_EQ(f.getType(), MathObjectType(MathObjectType::Deg, "Deg")); +TEST(DegTests, getClassTest) { + EXPECT_EQ(F::getClassStatic(), MathObjectClass("Deg")); + EXPECT_EQ(F::getClassStatic().getParent(), IOperator::getClassStatic()); } diff --git a/tests/src/functions/other/FactorialTests.cpp b/tests/src/functions/other/FactorialTests.cpp index c717575bc..a3e9bc8ed 100644 --- a/tests/src/functions/other/FactorialTests.cpp +++ b/tests/src/functions/other/FactorialTests.cpp @@ -19,12 +19,12 @@ TEST(FactorialTests, toStringTest) { EXPECT_EQ(f.toString(), "!"); } -TEST(FactorialTests, getArgumentTypesTest) { - EXPECT_THAT(f.getArgumentTypes(), testing::ElementsAre(INumber::getTypeStatic())); +TEST(FactorialTests, getArgumentClassesTest) { + EXPECT_THAT(f.getArgumentClasses(), testing::ElementsAre(INumber::getClassStatic())); } -TEST(FactorialTests, getReturnTypeTest) { - EXPECT_EQ(f.getReturnType(), INumber::getTypeStatic()); +TEST(FactorialTests, getReturnClassTest) { + EXPECT_EQ(f.getReturnClass(), INumber::getClassStatic()); } TEST(FactorialTests, isVariadicTest) { @@ -142,7 +142,7 @@ TEST(FactorialTests, exprTest) { EXPECT_EQ(factorialExpr(Integer(10))->toString(), "10!"); } -TEST(FactorialTests, getTypeTest) { - EXPECT_EQ(F::getTypeStatic(), MathObjectType(MathObjectType::Factorial, "Factorial")); - EXPECT_EQ(f.getType(), MathObjectType(MathObjectType::Factorial, "Factorial")); +TEST(FactorialTests, getClassTest) { + EXPECT_EQ(F::getClassStatic(), MathObjectClass("Factorial")); + EXPECT_EQ(F::getClassStatic().getParent(), IOperator::getClassStatic()); } diff --git a/tests/src/functions/other/IndexTests.cpp b/tests/src/functions/other/IndexTests.cpp index da1017ab7..782aa75f5 100644 --- a/tests/src/functions/other/IndexTests.cpp +++ b/tests/src/functions/other/IndexTests.cpp @@ -16,12 +16,12 @@ TEST(IndexTests, toStringTest) { EXPECT_EQ(f.toString(), "_"); } -TEST(IndexTests, getArgumentTypesTest) { - EXPECT_THAT(f.getArgumentTypes(), testing::ElementsAre(Variable::getTypeStatic(), Integer::getTypeStatic())); +TEST(IndexTests, getArgumentClassesTest) { + EXPECT_THAT(f.getArgumentClasses(), testing::ElementsAre(Variable::getClassStatic(), Integer::getClassStatic())); } -TEST(IndexTests, getReturnTypeTest) { - EXPECT_EQ(f.getReturnType(), Variable::getTypeStatic()); +TEST(IndexTests, getReturnClassTest) { + EXPECT_EQ(f.getReturnClass(), Variable::getClassStatic()); } TEST(IndexTests, isVariadicTest) { @@ -67,7 +67,7 @@ TEST(IndexTests, exprTest) { EXPECT_EQ(indexExpr(Variable("a"), Integer(1))->toString(), "a_1"); } -TEST(IndexTests, getTypeTest) { - EXPECT_EQ(F::getTypeStatic(), MathObjectType(MathObjectType::Index, "Index")); - EXPECT_EQ(f.getType(), MathObjectType(MathObjectType::Index, "Index")); +TEST(IndexTests, getClassTest) { + EXPECT_EQ(F::getClassStatic(), MathObjectClass("Index")); + EXPECT_EQ(F::getClassStatic().getParent(), IOperator::getClassStatic()); } diff --git a/tests/src/functions/other/PercentTests.cpp b/tests/src/functions/other/PercentTests.cpp index 4405fba00..41d1d9433 100644 --- a/tests/src/functions/other/PercentTests.cpp +++ b/tests/src/functions/other/PercentTests.cpp @@ -15,12 +15,12 @@ TEST(PercentTests, toStringTest) { EXPECT_EQ(f.toString(), "%"); } -TEST(PercentTests, getArgumentTypesTest) { - EXPECT_THAT(f.getArgumentTypes(), testing::ElementsAre(INumber::getTypeStatic())); +TEST(PercentTests, getArgumentClassesTest) { + EXPECT_THAT(f.getArgumentClasses(), testing::ElementsAre(INumber::getClassStatic())); } -TEST(PercentTests, getReturnTypeTest) { - EXPECT_EQ(f.getReturnType(), INumber::getTypeStatic()); +TEST(PercentTests, getReturnClassTest) { + EXPECT_EQ(f.getReturnClass(), INumber::getClassStatic()); } TEST(PercentTests, isVariadicTest) { @@ -59,7 +59,7 @@ TEST(PercentTests, degTest) { EXPECT_EQ(percentExpr(Integer(10))->toString(), "10/100"); } -TEST(PercentTests, getTypeTest) { - EXPECT_EQ(F::getTypeStatic(), MathObjectType(MathObjectType::Percent, "Percent")); - EXPECT_EQ(f.getType(), MathObjectType(MathObjectType::Percent, "Percent")); +TEST(PercentTests, getClassTest) { + EXPECT_EQ(F::getClassStatic(), MathObjectClass("Percent")); + EXPECT_EQ(F::getClassStatic().getParent(), IOperator::getClassStatic()); } diff --git a/tests/src/functions/powers/ExpTests.cpp b/tests/src/functions/powers/ExpTests.cpp index 7db26ec9b..c858d2f40 100644 --- a/tests/src/functions/powers/ExpTests.cpp +++ b/tests/src/functions/powers/ExpTests.cpp @@ -15,12 +15,12 @@ TEST(ExpTests, toStringTest) { EXPECT_EQ(f.toString(), "exp"); } -TEST(ExpTests, getArgumentTypesTest) { - EXPECT_THAT(f.getArgumentTypes(), testing::ElementsAre(INumber::getTypeStatic())); +TEST(ExpTests, getArgumentClassesTest) { + EXPECT_THAT(f.getArgumentClasses(), testing::ElementsAre(INumber::getClassStatic())); } -TEST(ExpTests, getReturnTypeTest) { - EXPECT_EQ(f.getReturnType(), INumber::getTypeStatic()); +TEST(ExpTests, getReturnClassTest) { + EXPECT_EQ(f.getReturnClass(), INumber::getClassStatic()); } TEST(ExpTests, isVariadicTest) { @@ -48,7 +48,7 @@ TEST(ExpTests, exprTest) { EXPECT_EQ(expExpr(Integer(10))->toString(), "E^10"); } -TEST(ExpTests, getTypeTest) { - EXPECT_EQ(F::getTypeStatic(), MathObjectType(MathObjectType::Exp, "Exp")); - EXPECT_EQ(f.getType(), MathObjectType(MathObjectType::Exp, "Exp")); +TEST(ExpTests, getClassTest) { + EXPECT_EQ(F::getClassStatic(), MathObjectClass("Exp")); + EXPECT_EQ(F::getClassStatic().getParent(), IFunction::getClassStatic()); } diff --git a/tests/src/functions/powers/PowFunctionTests.cpp b/tests/src/functions/powers/PowFunctionTests.cpp index ecec32aaf..8fc345bda 100644 --- a/tests/src/functions/powers/PowFunctionTests.cpp +++ b/tests/src/functions/powers/PowFunctionTests.cpp @@ -16,12 +16,12 @@ TEST(PowFunctionTests, toStringTest) { EXPECT_EQ(f.toString(), "pow"); } -TEST(PowFunctionTests, getArgumentTypesTest) { - EXPECT_THAT(f.getArgumentTypes(), testing::ElementsAre(IArithmetic::getTypeStatic(), IArithmetic::getTypeStatic())); +TEST(PowFunctionTests, getArgumentClassesTest) { + EXPECT_THAT(f.getArgumentClasses(), testing::ElementsAre(IArithmetic::getClassStatic(), IArithmetic::getClassStatic())); } -TEST(PowFunctionTests, getReturnTypeTest) { - EXPECT_EQ(f.getReturnType(), IArithmetic::getTypeStatic()); +TEST(PowFunctionTests, getReturnClassTest) { + EXPECT_EQ(f.getReturnClass(), IArithmetic::getClassStatic()); } TEST(PowFunctionTests, isVariadicTest) { @@ -48,7 +48,7 @@ TEST(PowFunctionTests, callTest) { EXPECT_THROW(f(Integer(1), Integer(1), Integer(1)), InvalidInputFunctionException); } -TEST(PowFunctionTests, getTypeTest) { - EXPECT_EQ(F::getTypeStatic(), MathObjectType(MathObjectType::PowFunction, "PowFunction")); - EXPECT_EQ(f.getType(), MathObjectType(MathObjectType::PowFunction, "PowFunction")); +TEST(PowFunctionTests, getClassTest) { + EXPECT_EQ(F::getClassStatic(), MathObjectClass("PowFunction")); + EXPECT_EQ(F::getClassStatic().getParent(), IFunction::getClassStatic()); } diff --git a/tests/src/functions/powers/PowTests.cpp b/tests/src/functions/powers/PowTests.cpp index 5bf2b8653..0ec202346 100644 --- a/tests/src/functions/powers/PowTests.cpp +++ b/tests/src/functions/powers/PowTests.cpp @@ -17,12 +17,12 @@ TEST(PowTests, toStringTest) { EXPECT_EQ(f.toString(), "^"); } -TEST(PowTests, getArgumentTypesTest) { - EXPECT_THAT(f.getArgumentTypes(), testing::ElementsAre(INumber::getTypeStatic(), INumber::getTypeStatic())); +TEST(PowTests, getArgumentClassesTest) { + EXPECT_THAT(f.getArgumentClasses(), testing::ElementsAre(INumber::getClassStatic(), INumber::getClassStatic())); } -TEST(PowTests, getReturnTypeTest) { - EXPECT_EQ(f.getReturnType(), INumber::getTypeStatic()); +TEST(PowTests, getReturnClassTest) { + EXPECT_EQ(f.getReturnClass(), INumber::getClassStatic()); } TEST(PowTests, isVariadicTest) { @@ -173,7 +173,7 @@ TEST(PowTests, exprTest) { "10^10"); } -TEST(PowTests, getTypeTest) { - EXPECT_EQ(F::getTypeStatic(), MathObjectType(MathObjectType::Pow, "Pow")); - EXPECT_EQ(f.getType(), MathObjectType(MathObjectType::Pow, "Pow")); +TEST(PowTests, getClassTest) { + EXPECT_EQ(F::getClassStatic(), MathObjectClass("Pow")); + EXPECT_EQ(F::getClassStatic().getParent(), IOperator::getClassStatic()); } diff --git a/tests/src/functions/powers/RootTests.cpp b/tests/src/functions/powers/RootTests.cpp index 0818849c8..3b1020926 100644 --- a/tests/src/functions/powers/RootTests.cpp +++ b/tests/src/functions/powers/RootTests.cpp @@ -16,12 +16,12 @@ TEST(RootTests, toStringTest) { EXPECT_EQ(f.toString(), "root"); } -TEST(RootTests, getArgumentTypesTest) { - EXPECT_THAT(f.getArgumentTypes(), testing::ElementsAre(INumber::getTypeStatic(), INumber::getTypeStatic())); +TEST(RootTests, getArgumentClassesTest) { + EXPECT_THAT(f.getArgumentClasses(), testing::ElementsAre(INumber::getClassStatic(), INumber::getClassStatic())); } -TEST(RootTests, getReturnTypeTest) { - EXPECT_EQ(f.getReturnType(), INumber::getTypeStatic()); +TEST(RootTests, getReturnClassTest) { + EXPECT_EQ(f.getReturnClass(), INumber::getClassStatic()); } TEST(RootTests, isVariadicTest) { @@ -184,7 +184,7 @@ TEST(RootTests, exprTest) { EXPECT_EQ(rootExpr(Integer(10), Integer(10))->toString(), "root(10, 10)"); } -TEST(RootTests, getTypeTest) { - EXPECT_EQ(F::getTypeStatic(), MathObjectType(MathObjectType::Root, "Root")); - EXPECT_EQ(f.getType(), MathObjectType(MathObjectType::Root, "Root")); +TEST(RootTests, getClassTest) { + EXPECT_EQ(F::getClassStatic(), MathObjectClass("Root")); + EXPECT_EQ(F::getClassStatic().getParent(), IFunction::getClassStatic()); } diff --git a/tests/src/functions/powers/SqrTests.cpp b/tests/src/functions/powers/SqrTests.cpp index 58ca76a41..cf2485729 100644 --- a/tests/src/functions/powers/SqrTests.cpp +++ b/tests/src/functions/powers/SqrTests.cpp @@ -16,12 +16,12 @@ TEST(SqrTests, toStringTest) { EXPECT_EQ(f.toString(), "sqr"); } -TEST(SqrTests, getArgumentTypesTest) { - EXPECT_THAT(f.getArgumentTypes(), testing::ElementsAre(INumber::getTypeStatic())); +TEST(SqrTests, getArgumentClassesTest) { + EXPECT_THAT(f.getArgumentClasses(), testing::ElementsAre(INumber::getClassStatic())); } -TEST(SqrTests, getReturnTypeTest) { - EXPECT_EQ(f.getReturnType(), INumber::getTypeStatic()); +TEST(SqrTests, getReturnClassTest) { + EXPECT_EQ(f.getReturnClass(), INumber::getClassStatic()); } TEST(SqrTests, isVariadicTest) { @@ -53,7 +53,7 @@ TEST(SqrTests, exprTest) { EXPECT_EQ(sqrExpr(Integer(10))->toString(), "10^2"); } -TEST(SqrTests, getTypeTest) { - EXPECT_EQ(F::getTypeStatic(), MathObjectType(MathObjectType::Sqr, "Sqr")); - EXPECT_EQ(f.getType(), MathObjectType(MathObjectType::Sqr, "Sqr")); +TEST(SqrTests, getClassTest) { + EXPECT_EQ(F::getClassStatic(), MathObjectClass("Sqr")); + EXPECT_EQ(F::getClassStatic().getParent(), IFunction::getClassStatic()); } diff --git a/tests/src/functions/powers/SqrtTests.cpp b/tests/src/functions/powers/SqrtTests.cpp index dbb9ec9e3..6c5e63c90 100644 --- a/tests/src/functions/powers/SqrtTests.cpp +++ b/tests/src/functions/powers/SqrtTests.cpp @@ -16,12 +16,12 @@ TEST(SqrtTests, toStringTest) { EXPECT_EQ(f.toString(), "sqrt"); } -TEST(SqrtTests, getArgumentTypesTest) { - EXPECT_THAT(f.getArgumentTypes(), testing::ElementsAre(INumber::getTypeStatic())); +TEST(SqrtTests, getArgumentClassesTest) { + EXPECT_THAT(f.getArgumentClasses(), testing::ElementsAre(INumber::getClassStatic())); } -TEST(SqrtTests, getReturnTypeTest) { - EXPECT_EQ(f.getReturnType(), INumber::getTypeStatic()); +TEST(SqrtTests, getReturnClassTest) { + EXPECT_EQ(f.getReturnClass(), INumber::getClassStatic()); } TEST(SqrtTests, isVariadicTest) { @@ -72,7 +72,7 @@ TEST(SqrtTests, exprTest) { EXPECT_EQ(sqrtExpr(Integer(10))->toString(), "sqrt(10)"); } -TEST(SqrtTests, getTypeTest) { - EXPECT_EQ(F::getTypeStatic(), MathObjectType(MathObjectType::Sqrt, "Sqrt")); - EXPECT_EQ(f.getType(), MathObjectType(MathObjectType::Sqrt, "Sqrt")); +TEST(SqrtTests, getClassTest) { + EXPECT_EQ(F::getClassStatic(), MathObjectClass("Sqrt")); + EXPECT_EQ(F::getClassStatic().getParent(), IFunction::getClassStatic()); } diff --git a/tests/src/functions/trigonometry/AcosTests.cpp b/tests/src/functions/trigonometry/AcosTests.cpp index 395f18328..61858e853 100644 --- a/tests/src/functions/trigonometry/AcosTests.cpp +++ b/tests/src/functions/trigonometry/AcosTests.cpp @@ -17,12 +17,12 @@ TEST(AcosTests, toStringTest) { EXPECT_EQ(f.toString(), "acos"); } -TEST(AcosTests, getArgumentTypesTest) { - EXPECT_THAT(f.getArgumentTypes(), testing::ElementsAre(INumber::getTypeStatic())); +TEST(AcosTests, getArgumentClassesTest) { + EXPECT_THAT(f.getArgumentClasses(), testing::ElementsAre(INumber::getClassStatic())); } -TEST(AcosTests, getReturnTypeTest) { - EXPECT_EQ(f.getReturnType(), INumber::getTypeStatic()); +TEST(AcosTests, getReturnClassTest) { + EXPECT_EQ(f.getReturnClass(), INumber::getClassStatic()); } TEST(AcosTests, isVariadicTest) { @@ -59,7 +59,7 @@ TEST(AcosTests, exprTest) { EXPECT_EQ(acosExpr(Integer(10))->toString(), "acos(10)"); } -TEST(AcosTests, getTypeTest) { - EXPECT_EQ(F::getTypeStatic(), MathObjectType(MathObjectType::Acos, "Acos")); - EXPECT_EQ(f.getType(), MathObjectType(MathObjectType::Acos, "Acos")); +TEST(AcosTests, getClassTest) { + EXPECT_EQ(F::getClassStatic(), MathObjectClass("Acos")); + EXPECT_EQ(F::getClassStatic().getParent(), IFunction::getClassStatic()); } diff --git a/tests/src/functions/trigonometry/AcotTests.cpp b/tests/src/functions/trigonometry/AcotTests.cpp index 1c8818021..e9e930664 100644 --- a/tests/src/functions/trigonometry/AcotTests.cpp +++ b/tests/src/functions/trigonometry/AcotTests.cpp @@ -17,12 +17,12 @@ TEST(AcotTests, toStringTest) { EXPECT_EQ(f.toString(), "acot"); } -TEST(AcotTests, getArgumentTypesTest) { - EXPECT_THAT(f.getArgumentTypes(), testing::ElementsAre(INumber::getTypeStatic())); +TEST(AcotTests, getArgumentClassesTest) { + EXPECT_THAT(f.getArgumentClasses(), testing::ElementsAre(INumber::getClassStatic())); } -TEST(AcotTests, getReturnTypeTest) { - EXPECT_EQ(f.getReturnType(), INumber::getTypeStatic()); +TEST(AcotTests, getReturnClassTest) { + EXPECT_EQ(f.getReturnClass(), INumber::getClassStatic()); } TEST(AcotTests, isVariadicTest) { @@ -59,7 +59,7 @@ TEST(AcotTests, exprTest) { EXPECT_EQ(acotExpr(Integer(10))->toString(), "acot(10)"); } -TEST(AcotTests, getTypeTest) { - EXPECT_EQ(F::getTypeStatic(), MathObjectType(MathObjectType::Acot, "Acot")); - EXPECT_EQ(f.getType(), MathObjectType(MathObjectType::Acot, "Acot")); +TEST(AcotTests, getClassTest) { + EXPECT_EQ(F::getClassStatic(), MathObjectClass("Acot")); + EXPECT_EQ(F::getClassStatic().getParent(), IFunction::getClassStatic()); } diff --git a/tests/src/functions/trigonometry/AcscTests.cpp b/tests/src/functions/trigonometry/AcscTests.cpp index 70b3a7552..9e42be876 100644 --- a/tests/src/functions/trigonometry/AcscTests.cpp +++ b/tests/src/functions/trigonometry/AcscTests.cpp @@ -17,12 +17,12 @@ TEST(AcscTests, toStringTest) { EXPECT_EQ(f.toString(), "acsc"); } -TEST(AcscTests, getArgumentTypesTest) { - EXPECT_THAT(f.getArgumentTypes(), testing::ElementsAre(INumber::getTypeStatic())); +TEST(AcscTests, getArgumentClassesTest) { + EXPECT_THAT(f.getArgumentClasses(), testing::ElementsAre(INumber::getClassStatic())); } -TEST(AcscTests, getReturnTypeTest) { - EXPECT_EQ(f.getReturnType(), INumber::getTypeStatic()); +TEST(AcscTests, getReturnClassTest) { + EXPECT_EQ(f.getReturnClass(), INumber::getClassStatic()); } TEST(AcscTests, isVariadicTest) { @@ -60,7 +60,7 @@ TEST(AcscTests, exprTest) { EXPECT_EQ(acscExpr(Integer(10))->toString(), "acsc(10)"); } -TEST(AcscTests, getTypeTest) { - EXPECT_EQ(F::getTypeStatic(), MathObjectType(MathObjectType::Acsc, "Acsc")); - EXPECT_EQ(f.getType(), MathObjectType(MathObjectType::Acsc, "Acsc")); +TEST(AcscTests, getClassTest) { + EXPECT_EQ(F::getClassStatic(), MathObjectClass("Acsc")); + EXPECT_EQ(F::getClassStatic().getParent(), IFunction::getClassStatic()); } diff --git a/tests/src/functions/trigonometry/AsecTests.cpp b/tests/src/functions/trigonometry/AsecTests.cpp index 151c2a568..85b5a3afb 100644 --- a/tests/src/functions/trigonometry/AsecTests.cpp +++ b/tests/src/functions/trigonometry/AsecTests.cpp @@ -17,12 +17,12 @@ TEST(AsecTests, toStringTest) { EXPECT_EQ(f.toString(), "asec"); } -TEST(AsecTests, getArgumentTypesTest) { - EXPECT_THAT(f.getArgumentTypes(), testing::ElementsAre(INumber::getTypeStatic())); +TEST(AsecTests, getArgumentClassesTest) { + EXPECT_THAT(f.getArgumentClasses(), testing::ElementsAre(INumber::getClassStatic())); } -TEST(AsecTests, getReturnTypeTest) { - EXPECT_EQ(f.getReturnType(), INumber::getTypeStatic()); +TEST(AsecTests, getReturnClassTest) { + EXPECT_EQ(f.getReturnClass(), INumber::getClassStatic()); } TEST(AsecTests, isVariadicTest) { @@ -60,7 +60,7 @@ TEST(AsecTests, exprTest) { EXPECT_EQ(asecExpr(Integer(10))->toString(), "asec(10)"); } -TEST(AsecTests, getTypeTest) { - EXPECT_EQ(F::getTypeStatic(), MathObjectType(MathObjectType::Asec, "Asec")); - EXPECT_EQ(f.getType(), MathObjectType(MathObjectType::Asec, "Asec")); +TEST(AsecTests, getClassTest) { + EXPECT_EQ(F::getClassStatic(), MathObjectClass("Asec")); + EXPECT_EQ(F::getClassStatic().getParent(), IFunction::getClassStatic()); } diff --git a/tests/src/functions/trigonometry/AsinTests.cpp b/tests/src/functions/trigonometry/AsinTests.cpp index 890f5e787..a05985e54 100644 --- a/tests/src/functions/trigonometry/AsinTests.cpp +++ b/tests/src/functions/trigonometry/AsinTests.cpp @@ -17,12 +17,12 @@ TEST(AsinTests, toStringTest) { EXPECT_EQ(f.toString(), "asin"); } -TEST(AsinTests, getArgumentTypesTest) { - EXPECT_THAT(f.getArgumentTypes(), testing::ElementsAre(INumber::getTypeStatic())); +TEST(AsinTests, getArgumentClassesTest) { + EXPECT_THAT(f.getArgumentClasses(), testing::ElementsAre(INumber::getClassStatic())); } -TEST(AsinTests, getReturnTypeTest) { - EXPECT_EQ(f.getReturnType(), INumber::getTypeStatic()); +TEST(AsinTests, getReturnClassTest) { + EXPECT_EQ(f.getReturnClass(), INumber::getClassStatic()); } TEST(AsinTests, isVariadicTest) { @@ -59,7 +59,7 @@ TEST(AsinTests, exprTest) { EXPECT_EQ(asinExpr(Integer(10))->toString(), "asin(10)"); } -TEST(AsinTests, getTypeTest) { - EXPECT_EQ(F::getTypeStatic(), MathObjectType(MathObjectType::Asin, "Asin")); - EXPECT_EQ(f.getType(), MathObjectType(MathObjectType::Asin, "Asin")); +TEST(AsinTests, getClassTest) { + EXPECT_EQ(F::getClassStatic(), MathObjectClass("Asin")); + EXPECT_EQ(F::getClassStatic().getParent(), IFunction::getClassStatic()); } diff --git a/tests/src/functions/trigonometry/AtanTests.cpp b/tests/src/functions/trigonometry/AtanTests.cpp index faa475825..46e6122b0 100644 --- a/tests/src/functions/trigonometry/AtanTests.cpp +++ b/tests/src/functions/trigonometry/AtanTests.cpp @@ -17,12 +17,12 @@ TEST(AtanTests, toStringTest) { EXPECT_EQ(f.toString(), "atan"); } -TEST(AtanTests, getArgumentTypesTest) { - EXPECT_THAT(f.getArgumentTypes(), testing::ElementsAre(INumber::getTypeStatic())); +TEST(AtanTests, getArgumentClassesTest) { + EXPECT_THAT(f.getArgumentClasses(), testing::ElementsAre(INumber::getClassStatic())); } -TEST(AtanTests, getReturnTypeTest) { - EXPECT_EQ(f.getReturnType(), INumber::getTypeStatic()); +TEST(AtanTests, getReturnClassTest) { + EXPECT_EQ(f.getReturnClass(), INumber::getClassStatic()); } TEST(AtanTests, isVariadicTest) { @@ -59,7 +59,7 @@ TEST(AtanTests, exprTest) { EXPECT_EQ(atanExpr(Integer(10))->toString(), "atan(10)"); } -TEST(AtanTests, getTypeTest) { - EXPECT_EQ(F::getTypeStatic(), MathObjectType(MathObjectType::Atan, "Atan")); - EXPECT_EQ(f.getType(), MathObjectType(MathObjectType::Atan, "Atan")); +TEST(AtanTests, getClassTest) { + EXPECT_EQ(F::getClassStatic(), MathObjectClass("Atan")); + EXPECT_EQ(F::getClassStatic().getParent(), IFunction::getClassStatic()); } diff --git a/tests/src/functions/trigonometry/CosTests.cpp b/tests/src/functions/trigonometry/CosTests.cpp index 3b95f8928..9d09804b6 100644 --- a/tests/src/functions/trigonometry/CosTests.cpp +++ b/tests/src/functions/trigonometry/CosTests.cpp @@ -17,12 +17,12 @@ TEST(CosTests, toStringTest) { EXPECT_EQ(f.toString(), "cos"); } -TEST(CosTests, getArgumentTypesTest) { - EXPECT_THAT(f.getArgumentTypes(), testing::ElementsAre(INumber::getTypeStatic())); +TEST(CosTests, getArgumentClassesTest) { + EXPECT_THAT(f.getArgumentClasses(), testing::ElementsAre(INumber::getClassStatic())); } -TEST(CosTests, getReturnTypeTest) { - EXPECT_EQ(f.getReturnType(), INumber::getTypeStatic()); +TEST(CosTests, getReturnClassTest) { + EXPECT_EQ(f.getReturnClass(), INumber::getClassStatic()); } TEST(CosTests, isVariadicTest) { @@ -56,7 +56,7 @@ TEST(CosTests, exprTest) { EXPECT_EQ(cosExpr(Integer(10))->toString(), "cos(10)"); } -TEST(CosTests, getTypeTest) { - EXPECT_EQ(F::getTypeStatic(), MathObjectType(MathObjectType::Cos, "Cos")); - EXPECT_EQ(f.getType(), MathObjectType(MathObjectType::Cos, "Cos")); +TEST(CosTests, getClassTest) { + EXPECT_EQ(F::getClassStatic(), MathObjectClass("Cos")); + EXPECT_EQ(F::getClassStatic().getParent(), IFunction::getClassStatic()); } diff --git a/tests/src/functions/trigonometry/CotTests.cpp b/tests/src/functions/trigonometry/CotTests.cpp index b587c940c..806305355 100644 --- a/tests/src/functions/trigonometry/CotTests.cpp +++ b/tests/src/functions/trigonometry/CotTests.cpp @@ -17,12 +17,12 @@ TEST(CotTests, toStringTest) { EXPECT_EQ(f.toString(), "cot"); } -TEST(CotTests, getArgumentTypesTest) { - EXPECT_THAT(f.getArgumentTypes(), testing::ElementsAre(INumber::getTypeStatic())); +TEST(CotTests, getArgumentClassesTest) { + EXPECT_THAT(f.getArgumentClasses(), testing::ElementsAre(INumber::getClassStatic())); } -TEST(CotTests, getReturnTypeTest) { - EXPECT_EQ(f.getReturnType(), INumber::getTypeStatic()); +TEST(CotTests, getReturnClassTest) { + EXPECT_EQ(f.getReturnClass(), INumber::getClassStatic()); } TEST(CotTests, isVariadicTest) { @@ -57,7 +57,7 @@ TEST(CotTests, exprTest) { EXPECT_EQ(cotExpr(Integer(10))->toString(), "cot(10)"); } -TEST(CotTests, getTypeTest) { - EXPECT_EQ(F::getTypeStatic(), MathObjectType(MathObjectType::Cot, "Cot")); - EXPECT_EQ(f.getType(), MathObjectType(MathObjectType::Cot, "Cot")); +TEST(CotTests, getClassTest) { + EXPECT_EQ(F::getClassStatic(), MathObjectClass("Cot")); + EXPECT_EQ(F::getClassStatic().getParent(), IFunction::getClassStatic()); } diff --git a/tests/src/functions/trigonometry/CscTests.cpp b/tests/src/functions/trigonometry/CscTests.cpp index 1c2acc545..643955e75 100644 --- a/tests/src/functions/trigonometry/CscTests.cpp +++ b/tests/src/functions/trigonometry/CscTests.cpp @@ -17,12 +17,12 @@ TEST(CscTests, toStringTest) { EXPECT_EQ(f.toString(), "csc"); } -TEST(CscTests, getArgumentTypesTest) { - EXPECT_THAT(f.getArgumentTypes(), testing::ElementsAre(INumber::getTypeStatic())); +TEST(CscTests, getArgumentClassesTest) { + EXPECT_THAT(f.getArgumentClasses(), testing::ElementsAre(INumber::getClassStatic())); } -TEST(CscTests, getReturnTypeTest) { - EXPECT_EQ(f.getReturnType(), INumber::getTypeStatic()); +TEST(CscTests, getReturnClassTest) { + EXPECT_EQ(f.getReturnClass(), INumber::getClassStatic()); } TEST(CscTests, isVariadicTest) { @@ -56,7 +56,7 @@ TEST(CscTests, exprTest) { EXPECT_EQ(cscExpr(Integer(10))->toString(), "csc(10)"); } -TEST(CscTests, getTypeTest) { - EXPECT_EQ(F::getTypeStatic(), MathObjectType(MathObjectType::Csc, "Csc")); - EXPECT_EQ(f.getType(), MathObjectType(MathObjectType::Csc, "Csc")); +TEST(CscTests, getClassTest) { + EXPECT_EQ(F::getClassStatic(), MathObjectClass("Csc")); + EXPECT_EQ(F::getClassStatic().getParent(), IFunction::getClassStatic()); } diff --git a/tests/src/functions/trigonometry/SecTests.cpp b/tests/src/functions/trigonometry/SecTests.cpp index 0f984400c..05f8ac784 100644 --- a/tests/src/functions/trigonometry/SecTests.cpp +++ b/tests/src/functions/trigonometry/SecTests.cpp @@ -17,12 +17,12 @@ TEST(SecTests, toStringTest) { EXPECT_EQ(f.toString(), "sec"); } -TEST(SecTests, getArgumentTypesTest) { - EXPECT_THAT(f.getArgumentTypes(), testing::ElementsAre(INumber::getTypeStatic())); +TEST(SecTests, getArgumentClassesTest) { + EXPECT_THAT(f.getArgumentClasses(), testing::ElementsAre(INumber::getClassStatic())); } -TEST(SecTests, getReturnTypeTest) { - EXPECT_EQ(f.getReturnType(), INumber::getTypeStatic()); +TEST(SecTests, getReturnClassTest) { + EXPECT_EQ(f.getReturnClass(), INumber::getClassStatic()); } TEST(SecTests, isVariadicTest) { @@ -56,7 +56,7 @@ TEST(SecTests, exprTest) { EXPECT_EQ(secExpr(Integer(10))->toString(), "sec(10)"); } -TEST(SecTests, getTypeTest) { - EXPECT_EQ(F::getTypeStatic(), MathObjectType(MathObjectType::Sec, "Sec")); - EXPECT_EQ(f.getType(), MathObjectType(MathObjectType::Sec, "Sec")); +TEST(SecTests, getClassTest) { + EXPECT_EQ(F::getClassStatic(), MathObjectClass("Sec")); + EXPECT_EQ(F::getClassStatic().getParent(), IFunction::getClassStatic()); } diff --git a/tests/src/functions/trigonometry/SinTests.cpp b/tests/src/functions/trigonometry/SinTests.cpp index 93bcaad77..a0ea6d3da 100644 --- a/tests/src/functions/trigonometry/SinTests.cpp +++ b/tests/src/functions/trigonometry/SinTests.cpp @@ -17,12 +17,12 @@ TEST(SinTests, toStringTest) { EXPECT_EQ(f.toString(), "sin"); } -TEST(SinTests, getArgumentTypesTest) { - EXPECT_THAT(f.getArgumentTypes(), testing::ElementsAre(INumber::getTypeStatic())); +TEST(SinTests, getArgumentClassesTest) { + EXPECT_THAT(f.getArgumentClasses(), testing::ElementsAre(INumber::getClassStatic())); } -TEST(SinTests, getReturnTypeTest) { - EXPECT_EQ(f.getReturnType(), INumber::getTypeStatic()); +TEST(SinTests, getReturnClassTest) { + EXPECT_EQ(f.getReturnClass(), INumber::getClassStatic()); } TEST(SinTests, isVariadicTest) { @@ -56,7 +56,7 @@ TEST(SinTests, exprTest) { EXPECT_EQ(sinExpr(Integer(10))->toString(), "sin(10)"); } -TEST(SinTests, getTypeTest) { - EXPECT_EQ(F::getTypeStatic(), MathObjectType(MathObjectType::Sin, "Sin")); - EXPECT_EQ(f.getType(), MathObjectType(MathObjectType::Sin, "Sin")); +TEST(SinTests, getClassTest) { + EXPECT_EQ(F::getClassStatic(), MathObjectClass("Sin")); + EXPECT_EQ(F::getClassStatic().getParent(), IFunction::getClassStatic()); } diff --git a/tests/src/functions/trigonometry/TanTests.cpp b/tests/src/functions/trigonometry/TanTests.cpp index 5d54f0768..97d2eb8d9 100644 --- a/tests/src/functions/trigonometry/TanTests.cpp +++ b/tests/src/functions/trigonometry/TanTests.cpp @@ -17,12 +17,12 @@ TEST(TanTests, toStringTest) { EXPECT_EQ(f.toString(), "tan"); } -TEST(TanTests, getArgumentTypesTest) { - EXPECT_THAT(f.getArgumentTypes(), testing::ElementsAre(INumber::getTypeStatic())); +TEST(TanTests, getArgumentClassesTest) { + EXPECT_THAT(f.getArgumentClasses(), testing::ElementsAre(INumber::getClassStatic())); } -TEST(TanTests, getReturnTypeTest) { - EXPECT_EQ(f.getReturnType(), INumber::getTypeStatic()); +TEST(TanTests, getReturnClassTest) { + EXPECT_EQ(f.getReturnClass(), INumber::getClassStatic()); } TEST(TanTests, isVariadicTest) { @@ -57,7 +57,7 @@ TEST(TanTests, exprTest) { EXPECT_EQ(tanExpr(Integer(10))->toString(), "tan(10)"); } -TEST(TanTests, getTypeTest) { - EXPECT_EQ(F::getTypeStatic(), MathObjectType(MathObjectType::Tan, "Tan")); - EXPECT_EQ(f.getType(), MathObjectType(MathObjectType::Tan, "Tan")); +TEST(TanTests, getClassTest) { + EXPECT_EQ(F::getClassStatic(), MathObjectClass("Tan")); + EXPECT_EQ(F::getClassStatic().getParent(), IFunction::getClassStatic()); } diff --git a/tests/src/literals/BooleanTests.cpp b/tests/src/literals/BooleanTests.cpp index 571b5fe98..c869ef12e 100644 --- a/tests/src/literals/BooleanTests.cpp +++ b/tests/src/literals/BooleanTests.cpp @@ -44,7 +44,7 @@ TEST(BooleanTests, opearatorsTest) { EXPECT_EQ(Boolean(true) || Boolean(true), true); } -TEST(BooleanTest, getTypeTest) { - EXPECT_EQ(Boolean::getTypeStatic(), MathObjectType(MathObjectType::Boolean, "Boolean")); - EXPECT_EQ(Boolean().getType(), MathObjectType(MathObjectType::Boolean, "Boolean")); +TEST(BooleanTest, getClassTest) { + EXPECT_EQ(Boolean::getClassStatic(), MathObjectClass("Boolean")); + EXPECT_EQ(Boolean::getClassStatic().getParent(), ILiteral::getClassStatic()); } diff --git a/tests/src/literals/ILiteralTests.cpp b/tests/src/literals/ILiteralTests.cpp index 0a563fdb5..688a2a23b 100644 --- a/tests/src/literals/ILiteralTests.cpp +++ b/tests/src/literals/ILiteralTests.cpp @@ -8,6 +8,23 @@ using namespace fintamath; +namespace { + +class TestLiteral final : public ILiteralCRTP { + FINTAMATH_CLASS_BODY(TestLiteral) +}; + +[[maybe_unused]] const auto config = [] { + ILiteral::registerType(); + return 0; +}(); + +} + +TEST(ILiteralTests, parseTest) { + EXPECT_TRUE(is(*ILiteral::parseFirst("TestLiteral"))); +} + TEST(ILiteralTests, equalsTest) { const std::unique_ptr c1 = std::make_unique(); const std::unique_ptr c2 = std::make_unique(); @@ -28,6 +45,6 @@ TEST(ILiteralTests, equalsTest) { EXPECT_NE(*c1, *v1); } -TEST(ILiteralTests, getTypeTest) { - EXPECT_EQ(ILiteral::getTypeStatic(), MathObjectType(MathObjectType::ILiteral, "ILiteral")); +TEST(ILiteralTests, getClassTest) { + EXPECT_EQ(ILiteral::getClassStatic(), MathObjectClass("ILiteral")); } diff --git a/tests/src/literals/VariableTests.cpp b/tests/src/literals/VariableTests.cpp index 1020fedfa..4467d22d4 100644 --- a/tests/src/literals/VariableTests.cpp +++ b/tests/src/literals/VariableTests.cpp @@ -38,7 +38,7 @@ TEST(VariableTest, stringIntegerConstructorTest) { EXPECT_THROW(Variable("a", Integer("-100000000000000000000000000000000000000")), InvalidInputException); } -TEST(VariableTest, getTypeTest) { - EXPECT_EQ(Variable::getTypeStatic(), MathObjectType(MathObjectType::Variable, "Variable")); - EXPECT_EQ(Variable("a").getType(), MathObjectType(MathObjectType::Variable, "Variable")); +TEST(VariableTest, getClassTest) { + EXPECT_EQ(Variable::getClassStatic(), MathObjectClass("Variable")); + EXPECT_EQ(Variable::getClassStatic().getParent(), ILiteral::getClassStatic()); } diff --git a/tests/src/literals/constants/ComplexInfTests.cpp b/tests/src/literals/constants/ComplexInfTests.cpp index 9b20dab33..e12a144d6 100644 --- a/tests/src/literals/constants/ComplexInfTests.cpp +++ b/tests/src/literals/constants/ComplexInfTests.cpp @@ -15,7 +15,7 @@ TEST(ComplexInfTests, callTest) { EXPECT_EQ(c()->toString(), "ComplexInf"); } -TEST(ComplexInfTests, getTypeTest) { - EXPECT_EQ(ComplexInf::getTypeStatic(), MathObjectType(MathObjectType::ComplexInf, "ComplexInf")); - EXPECT_EQ(ComplexInf().getType(), MathObjectType(MathObjectType::ComplexInf, "ComplexInf")); +TEST(ComplexInfTests, getClassTest) { + EXPECT_EQ(ComplexInf::getClassStatic(), MathObjectClass("ComplexInf")); + EXPECT_EQ(ComplexInf::getClassStatic().getParent(), IConstant::getClassStatic()); } diff --git a/tests/src/literals/constants/ETests.cpp b/tests/src/literals/constants/ETests.cpp index 3ab542b03..8b8d43dbe 100644 --- a/tests/src/literals/constants/ETests.cpp +++ b/tests/src/literals/constants/ETests.cpp @@ -15,7 +15,7 @@ TEST(ETests, callTest) { EXPECT_EQ(c()->toString(), "2.7182818284590452354"); } -TEST(ETests, getTypeTest) { - EXPECT_EQ(E::getTypeStatic(), MathObjectType(MathObjectType::E, "E")); - EXPECT_EQ(E().getType(), MathObjectType(MathObjectType::E, "E")); +TEST(ETests, getClassTest) { + EXPECT_EQ(E::getClassStatic(), MathObjectClass("E")); + EXPECT_EQ(E::getClassStatic().getParent(), IConstant::getClassStatic()); } diff --git a/tests/src/literals/constants/FalseTests.cpp b/tests/src/literals/constants/FalseTests.cpp index 291c367da..7998c1d5b 100644 --- a/tests/src/literals/constants/FalseTests.cpp +++ b/tests/src/literals/constants/FalseTests.cpp @@ -17,7 +17,7 @@ TEST(FalseTests, callTest) { EXPECT_TRUE(is(c())); } -TEST(FalseTests, getTypeTest) { - EXPECT_EQ(False::getTypeStatic(), MathObjectType(MathObjectType::False, "False")); - EXPECT_EQ(False().getType(), MathObjectType(MathObjectType::False, "False")); +TEST(FalseTests, getClassTest) { + EXPECT_EQ(False::getClassStatic(), MathObjectClass("False")); + EXPECT_EQ(False::getClassStatic().getParent(), IConstant::getClassStatic()); } diff --git a/tests/src/literals/constants/IConstantTests.cpp b/tests/src/literals/constants/IConstantTests.cpp index 7e9717961..4723395e8 100644 --- a/tests/src/literals/constants/IConstantTests.cpp +++ b/tests/src/literals/constants/IConstantTests.cpp @@ -7,6 +7,28 @@ using namespace fintamath; +namespace { + +class TestConstant final : public IConstantCRTP { + FINTAMATH_CLASS_BODY(TestConstant) + +protected: + std::unique_ptr call() const override { + return {}; + } +}; + +[[maybe_unused]] const auto config = [] { + IConstant::registerType(); + return 0; +}(); + +} + +TEST(IConstantTests, parseTest) { + EXPECT_TRUE(is(*IConstant::parseFirst("TestConstant"))); +} + TEST(IConstantTests, callTest) { const std::unique_ptr c1 = std::make_unique(); const std::unique_ptr c2 = std::make_unique(); @@ -15,6 +37,6 @@ TEST(IConstantTests, callTest) { EXPECT_EQ((*c2)()->toString(), "3.1415926535897932385"); } -TEST(IConstantTests, getTypeTest) { - EXPECT_EQ(IConstant::getTypeStatic(), MathObjectType(MathObjectType::IConstant, "IConstant")); +TEST(IConstantTests, getClassTest) { + EXPECT_EQ(IConstant::getClassStatic(), MathObjectClass("IConstant")); } diff --git a/tests/src/literals/constants/ITests.cpp b/tests/src/literals/constants/ITests.cpp index 303dc593b..87dd68b5e 100644 --- a/tests/src/literals/constants/ITests.cpp +++ b/tests/src/literals/constants/ITests.cpp @@ -15,7 +15,7 @@ TEST(ITests, callTest) { EXPECT_EQ(c()->toString(), "I"); } -TEST(ITests, getTypeTest) { - EXPECT_EQ(I::getTypeStatic(), MathObjectType(MathObjectType::I, "I")); - EXPECT_EQ(I().getType(), MathObjectType(MathObjectType::I, "I")); +TEST(ITests, getClassTest) { + EXPECT_EQ(I::getClassStatic(), MathObjectClass("I")); + EXPECT_EQ(I::getClassStatic().getParent(), IConstant::getClassStatic()); } diff --git a/tests/src/literals/constants/InfTests.cpp b/tests/src/literals/constants/InfTests.cpp index d01de8a84..0c28080c3 100644 --- a/tests/src/literals/constants/InfTests.cpp +++ b/tests/src/literals/constants/InfTests.cpp @@ -15,7 +15,7 @@ TEST(InfTests, callTest) { EXPECT_EQ(c()->toString(), "Inf"); } -TEST(InfTests, getTypeTest) { - EXPECT_EQ(Inf::getTypeStatic(), MathObjectType(MathObjectType::Inf, "Inf")); - EXPECT_EQ(Inf().getType(), MathObjectType(MathObjectType::Inf, "Inf")); +TEST(InfTests, getClassTest) { + EXPECT_EQ(Inf::getClassStatic(), MathObjectClass("Inf")); + EXPECT_EQ(Inf::getClassStatic().getParent(), IConstant::getClassStatic()); } diff --git a/tests/src/literals/constants/NegInfTests.cpp b/tests/src/literals/constants/NegInfTests.cpp index 112f30675..1cf6a8602 100644 --- a/tests/src/literals/constants/NegInfTests.cpp +++ b/tests/src/literals/constants/NegInfTests.cpp @@ -15,7 +15,7 @@ TEST(NegInfTests, callTest) { EXPECT_EQ(c()->toString(), "-Inf"); } -TEST(NegInfTests, getTypeTest) { - EXPECT_EQ(NegInf::getTypeStatic(), MathObjectType(MathObjectType::NegInf, "NegInf")); - EXPECT_EQ(NegInf().getType(), MathObjectType(MathObjectType::NegInf, "NegInf")); +TEST(NegInfTests, getClassTest) { + EXPECT_EQ(NegInf::getClassStatic(), MathObjectClass("NegInf")); + EXPECT_EQ(NegInf::getClassStatic().getParent(), IConstant::getClassStatic()); } diff --git a/tests/src/literals/constants/PiTests.cpp b/tests/src/literals/constants/PiTests.cpp index 312186748..d2bc996f8 100644 --- a/tests/src/literals/constants/PiTests.cpp +++ b/tests/src/literals/constants/PiTests.cpp @@ -15,7 +15,7 @@ TEST(PiTests, callTest) { EXPECT_EQ(c()->toString(), "3.1415926535897932385"); } -TEST(PiTests, getTypeTest) { - EXPECT_EQ(Pi::getTypeStatic(), MathObjectType(MathObjectType::Pi, "Pi")); - EXPECT_EQ(Pi().getType(), MathObjectType(MathObjectType::Pi, "Pi")); +TEST(PiTests, getClassTest) { + EXPECT_EQ(Pi::getClassStatic(), MathObjectClass("Pi")); + EXPECT_EQ(Pi::getClassStatic().getParent(), IConstant::getClassStatic()); } diff --git a/tests/src/literals/constants/TrueTests.cpp b/tests/src/literals/constants/TrueTests.cpp index c202312b9..1a2ddb547 100644 --- a/tests/src/literals/constants/TrueTests.cpp +++ b/tests/src/literals/constants/TrueTests.cpp @@ -17,7 +17,7 @@ TEST(TrueTests, callTest) { EXPECT_TRUE(is(c())); } -TEST(TrueTests, getTypeTest) { - EXPECT_EQ(True::getTypeStatic(), MathObjectType(MathObjectType::True, "True")); - EXPECT_EQ(True().getType(), MathObjectType(MathObjectType::True, "True")); +TEST(TrueTests, getClassTest) { + EXPECT_EQ(True::getClassStatic(), MathObjectClass("True")); + EXPECT_EQ(True::getClassStatic().getParent(), IConstant::getClassStatic()); } diff --git a/tests/src/literals/constants/UndefinedTests.cpp b/tests/src/literals/constants/UndefinedTests.cpp index aca259f12..c78ccddd7 100644 --- a/tests/src/literals/constants/UndefinedTests.cpp +++ b/tests/src/literals/constants/UndefinedTests.cpp @@ -15,7 +15,7 @@ TEST(UndefinedTests, callTest) { EXPECT_EQ(c()->toString(), "Undefined"); } -TEST(UndefinedTests, getTypeTest) { - EXPECT_EQ(Undefined::getTypeStatic(), MathObjectType(MathObjectType::Undefined, "Undefined")); - EXPECT_EQ(Undefined().getType(), MathObjectType(MathObjectType::Undefined, "Undefined")); +TEST(UndefinedTests, getClassTest) { + EXPECT_EQ(Undefined::getClassStatic(), MathObjectClass("Undefined")); + EXPECT_EQ(Undefined::getClassStatic().getParent(), IConstant::getClassStatic()); } diff --git a/tests/src/numbers/ComplexTests.cpp b/tests/src/numbers/ComplexTests.cpp index 1c0869d61..c10e60759 100644 --- a/tests/src/numbers/ComplexTests.cpp +++ b/tests/src/numbers/ComplexTests.cpp @@ -905,7 +905,7 @@ TEST(ComplexTests, isComplexTest) { EXPECT_FALSE(Complex(1, 0).isComplex()); } -TEST(ComplexTests, getTypeTest) { - EXPECT_EQ(Complex::getTypeStatic(), MathObjectType(MathObjectType::Complex, "Complex")); - EXPECT_EQ(Complex().getType(), MathObjectType(MathObjectType::Complex, "Complex")); +TEST(ComplexTests, getClassTest) { + EXPECT_EQ(Complex::getClassStatic(), MathObjectClass("Complex")); + EXPECT_EQ(Complex::getClassStatic().getParent(), INumber::getClassStatic()); } diff --git a/tests/src/numbers/IIntegerTests.cpp b/tests/src/numbers/IIntegerTests.cpp index 19000ad0c..e3ebacfcf 100644 --- a/tests/src/numbers/IIntegerTests.cpp +++ b/tests/src/numbers/IIntegerTests.cpp @@ -3,9 +3,7 @@ #include "fintamath/numbers/IInteger.hpp" #include "fintamath/exceptions/InvalidInputException.hpp" -#include "fintamath/literals/ILiteral.hpp" #include "fintamath/numbers/Integer.hpp" -#include "fintamath/numbers/Rational.hpp" using namespace fintamath; using namespace detail; @@ -13,14 +11,7 @@ using namespace detail; namespace { class TestInteger : public IIntegerCRTP { -public: - std::string toString() const override { - return "test"; - } - - static constexpr MathObjectType getTypeStatic() { - return {static_cast(IInteger::getTypeStatic().getId()) + 998, "TestInteger"}; - } + FINTAMATH_PARENT_CLASS_BODY(TestInteger) protected: TestInteger &mod(const TestInteger & /* rhs */) override { @@ -72,7 +63,7 @@ class TestInteger : public IIntegerCRTP { } std::strong_ordering compare(const TestInteger &rhs) const override { - return 0 <=> 1; + return std::strong_ordering::less; } TestInteger &increase() override { @@ -84,7 +75,11 @@ class TestInteger : public IIntegerCRTP { } }; +FINTAMATH_PARENT_CLASS_IMPLEMENTATION(TestInteger) + class TestIntegerConvertible final : public TestInteger { + FINTAMATH_CLASS_BODY(TestIntegerConvertible) + public: TestIntegerConvertible() : TestInteger() { } @@ -92,35 +87,31 @@ class TestIntegerConvertible final : public TestInteger { TestIntegerConvertible(const Integer &) : TestIntegerConvertible() { } - static constexpr MathObjectType getTypeStatic() { - return {static_cast(IInteger::getTypeStatic().getId()) + 999, "TestIntegerConvertible"}; - } - - MathObjectType getType() const override { - return getTypeStatic(); + MathObjectClass getClass() const override { + return getClassStatic(); } }; -struct TestIntegerConvertableConfig final { - TestIntegerConvertableConfig() { - MathObjectBoundTypes::bindTypes( - TestInteger::getTypeStatic(), - ILiteral::getTypeStatic()); - - Converter::add( - [](const TestIntegerConvertible & /*type*/, const TestIntegerConvertible &value) { - return std::make_unique(value); - }); - - Converter::add( - [](const TestIntegerConvertible & /*type*/, const Integer &value) { - return std::make_unique(value); - }); - } -}; +[[maybe_unused]] const auto config = [] { + IInteger::registerType(); + TestInteger::registerType(); -[[maybe_unused]] const TestIntegerConvertableConfig config; + Converter::add( + [](const TestIntegerConvertible & /*type*/, const TestIntegerConvertible &value) { + return std::make_unique(value); + }); + Converter::add( + [](const TestIntegerConvertible & /*type*/, const Integer &value) { + return std::make_unique(value); + }); + + return 0; +}(); + +} +TEST(IIntegerTests, parseTest) { + EXPECT_TRUE(is(*IInteger::parseFirst("TestInteger"))); } TEST(IIntegerTests, modTest) { @@ -294,6 +285,7 @@ TEST(IIntegerTests, decTest) { EXPECT_EQ((Integer(1)--).toString(), "1"); } -TEST(IIntegerTests, getTypeTest) { - EXPECT_EQ(IInteger::getTypeStatic(), MathObjectType(MathObjectType::IInteger, "IInteger")); +TEST(IIntegerTests, getClassTest) { + EXPECT_EQ(IInteger::getClassStatic(), MathObjectClass("IInteger")); + EXPECT_EQ(IInteger::getClassStatic().getParent(), INumber::getClassStatic()); } diff --git a/tests/src/numbers/INumberTests.cpp b/tests/src/numbers/INumberTests.cpp index fda52f36d..72bb21d86 100644 --- a/tests/src/numbers/INumberTests.cpp +++ b/tests/src/numbers/INumberTests.cpp @@ -7,6 +7,48 @@ using namespace fintamath; +namespace { + +class TestNumber final : public INumberCRTP { + FINTAMATH_CLASS_BODY(TestNumber) + +protected: + TestNumber &add(const TestNumber &rhs) override { + return *this; + } + + TestNumber &substract(const TestNumber &rhs) override { + return *this; + } + + TestNumber &multiply(const TestNumber &rhs) override { + return *this; + } + + TestNumber ÷(const TestNumber &rhs) override { + return *this; + } + + TestNumber &negate() override { + return *this; + } + + std::strong_ordering compare(const TestNumber &rhs) const override { + return std::strong_ordering::less; + } +}; + +[[maybe_unused]] const auto config = [] { + INumber::registerType(); + return 0; +}(); + +} + +TEST(INumberTests, parseTest) { + EXPECT_TRUE(is(*INumber::parseFirst("TestNumber"))); +} + TEST(INumberTests, addTest) { const std::unique_ptr m1 = std::make_unique(1); const std::unique_ptr m2 = std::make_unique(2); @@ -86,6 +128,7 @@ TEST(INumberTests, negateTest) { EXPECT_TRUE(is(+*m1)); } -TEST(INumberTests, getTypeTest) { - EXPECT_EQ(INumber::getTypeStatic(), MathObjectType(MathObjectType::INumber, "INumber")); +TEST(INumberTests, getClassTest) { + EXPECT_EQ(INumber::getClassStatic(), MathObjectClass("INumber")); + EXPECT_EQ(INumber::getClassStatic().getParent(), IComparable::getClassStatic()); } diff --git a/tests/src/numbers/IntegerTests.cpp b/tests/src/numbers/IntegerTests.cpp index 6642e65f5..c46280ae0 100644 --- a/tests/src/numbers/IntegerTests.cpp +++ b/tests/src/numbers/IntegerTests.cpp @@ -109,234 +109,22 @@ TEST(IntegerTests, multiplyAssignmentOperatorTest) { EXPECT_EQ(Integer("1000000000000000000000000000000000000000000000000000000000000000000000") *= Integer("100000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000"), Integer("100000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000")); EXPECT_EQ(Integer("100000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000") *= Integer("1000000000000000000000000000000000000000000000000000000000000000000000"), Integer("100000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000")); EXPECT_EQ(Integer("123") *= Integer("29837492356328746293432095803247329462387463287462347628437"), Integer("3670011559828435794092147783799421523873657984357868758297751")); - EXPECT_EQ( - Integer("123") *= - Integer("35076306156968495558690448186617350649863928832630116915388712481414348622203874495792275483460150356035" - "01276296494442204769872208628882685816583149015034150490829747567986311156822048603845157334656209386816" - "06309504393946821608023000179649439040025214237505334658151077308804228029083539590525897027612757867042" - "47252371131156418814797920314344275960809082275514891887764761455548832577594052452971505417598416718197" - "27944845899493678892840111830112509529920517471699237861267263602427655073892668208557712684031475765670" - "95701074005469808857005026436237359557162582162903447744543426516804140575697566432786005731286883595917" - "8663661834688407715795207372052181069795781487373087361"), - Integer("43143856573071249537189251269539341299332632464135043805928116352139648805310765629824498844655984937923" - "06569844688163911866942816613525703554397273288492005103720589508623162722891119782729543521627137545783" - "75760690404554590577868290220968810019231013512131561629525825089829200475772753696346853343963692176462" - "24120416491322395142201441986643459431795171198883317021950656590325064070440684517154951663646052563382" - "65372160456377225038193337551038386721802236490190062569358734230986015740887981896525986601358715191775" - "27712321026727864894116182516571952255309976060371240725788414615669092908108006712326787049482866822978" - "975630405666674149042810506762418271584881122946889745403")); - - Integer bigNum( - "3507630615696849555869044818661735064986392883263011691538871248141434862220387449579227548346015035603" - "5012762964944422047698722086288826858165831490150341504908297475679863111568220486038451573346562093868" - "1606309504393946821608023000179649439040025214237505334658151077308804228029083539590525897027612757867" - "0424725237113115641881479792031434427596080908227551489188776476145554883257759405245297150541759841671" - "8197279448458994936788928401118301125095299205174716992378612672636024276550738926682085577126840314757" - "6567095701074005469808857005026436237359557162582162903447744543426516804140575697566432786005731286883" - "5959178663661834688407715795207372052181069795781487373087361"); + EXPECT_EQ(Integer("123") *= Integer("3507630615696849555869044818661735064986392883263011691538871248141434862220387449579227548346015035603501276296494442204769872208628882685816583149015034150490829747567986311156822048603845157334656209386816063095043939468216080230001796494390400252142375053346581510773088042280290835395905258970276127578670424725237113115641881479792031434427596080908227551489188776476145554883257759405245297150541759841671819727944845899493678892840111830112509529920517471699237861267263602427655073892668208557712684031475765670957010740054698088570050264362373595571625821629034477445434265168041405756975664327860057312868835959178663661834688407715795207372052181069795781487373087361"), + Integer("431438565730712495371892512695393412993326324641350438059281163521396488053107656298244988446559849379230656984468816391186694281661352570355439727328849200510372058950862316272289111978272954352162713754578375760690404554590577868290220968810019231013512131561629525825089829200475772753696346853343963692176462241204164913223951422014419866434594317951711988833170219506565903250640704406845171549516636460525633826537216045637722503819333755103838672180223649019006256935873423098601574088798189652598660135871519177527712321026727864894116182516571952255309976060371240725788414615669092908108006712326787049482866822978975630405666674149042810506762418271584881122946889745403")); + + Integer bigNum("3507630615696849555869044818661735064986392883263011691538871248141434862220387449579227548346015035603501276296494442204769872208628882685816583149015034150490829747567986311156822048603845157334656209386816063095043939468216080230001796494390400252142375053346581510773088042280290835395905258970276127578670424725237113115641881479792031434427596080908227551489188776476145554883257759405245297150541759841671819727944845899493678892840111830112509529920517471699237861267263602427655073892668208557712684031475765670957010740054698088570050264362373595571625821629034477445434265168041405756975664327860057312868835959178663661834688407715795207372052181069795781487373087361"); EXPECT_EQ( bigNum *= bigNum, - Integer( - "123034725361738598979164283770049355020047829194730577188718850431217810300982817809626374999697401300344567" - "965004975099674523845827180745690042264848382795392578400958031494791019020721078375851313382307340544849217" - "355699523919372342689285638936307771428509883450247175430883074528018112106366377740035024455587351458743428" - "829345450790279704812162125516571396127361899444119205840737974805786683088726378370012263539336952982586230" - "520772431463209761528900461839369599097080811508633180730360435860932099113897002260498118666082984580250846" - "321418231548895423124902116577960700356171936511708514149353490197576217413415815424532672100407710015895201" - "204906251779841980755441870010779349840410739656612996294403929246397191497653045355788968513517965668573144" - "062261105158768820130671666660816190907738397367398011380955812694554206393194756249523627348492244870151305" - "002744620369856700284373011535701457868392370978780947012753172594225559926916527436295353173751857054744633" - "035233918756780916086599851272312050215060894199333990155802741210929882813526429754905691695652607632302924" - "450306025851469834273868330173794436522216548637093155834932235086867295108597201199535700443685578531192951" - "096702122394420354260042787250225021154643825874604948530751147789317178574819936624193584242706759360187966" - "08915343974203803928220416770794160300461016974165792937944321")); + Integer("12303472536173859897916428377004935502004782919473057718871885043121781030098281780962637499969740130034456796500497509967452384582718074569004226484838279539257840095803149479101902072107837585131338230734054484921735569952391937234268928563893630777142850988345024717543088307452801811210636637774003502445558735145874342882934545079027970481216212551657139612736189944411920584073797480578668308872637837001226353933695298258623052077243146320976152890046183936959909708081150863318073036043586093209911389700226049811866608298458025084632141823154889542312490211657796070035617193651170851414935349019757621741341581542453267210040771001589520120490625177984198075544187001077934984041073965661299629440392924639719149765304535578896851351796566857314406226110515876882013067166666081619090773839736739801138095581269455420639319475624952362734849224487015130500274462036985670028437301153570145786839237097878094701275317259422555992691652743629535317375185705474463303523391875678091608659985127231205021506089419933399015580274121092988281352642975490569169565260763230292445030602585146983427386833017379443652221654863709315583493223508686729510859720119953570044368557853119295109670212239442035426004278725022502115464382587460494853075114778931717857481993662419358424270675936018796608915343974203803928220416770794160300461016974165792937944321")); EXPECT_EQ( bigNum *= bigNum, - Integer( - "151375436448384432254283307583486066667042190660677620373123854553192330171309426231376077199633148394587309" - "320500780366596644977921667705846188987094209368940524153866159642542317461838630631239213601469094819727267" - "931442110409869192021916471495566770793968771356423244153613116589891384095154889897447129616495361921128483" - "415008013000809960124014824730978336773349172340512505436233122012217784681438531620807943478571185612552450" - "478078388300936606517852653888025048589518914846487741067060341531436357187268537672362009339521911619031150" - "310962055950155717666529133873841751541637455255626595846380131842901830415858642992816729709654251950863750" - "665357762009085810629217917751342352313325984460629046549764303679784381441423865043453230665790947214415711" - "707134874389436507764444241582593434407423309392527966674580478029178887423061253968562091672677599167671594" - "875604798350156550372883311207885282088863879202461885968408041715086679139981263812558960095695476485505356" - "891618587969820162186732250377710432275819830606562398013148854467177307257792538812521105073250276853587043" - "874285676126878294501204134744955080973659170543493289121184558611797400317932087143639362969152630394559727" - "560144885191109167802199267405992294077943816747815152047986153974462696242579776353456270439825236419290517" - "542215340162294579962815285992414141725975115146703976251490225724031898802682695139379699275083967566953749" - "280275248401215696451748644475142038613799290222798072247498886364828935253690749237820783821104282786528804" - "685820847939317976725694662661166127380194678954930597817803996943971279795062385881705273889663480715671471" - "466170947086809281202777180196503031441640466417520512377184927727082258708265839007600152745143501419320905" - "768663557824966355252526518492368909694102745402184718285534458364891811419700240301070527639998721161225798" - "676121766517224180501332030635179372072827350327920970532916699374836128894515290852189101489989500779928531" - "013587309296296610484631205391906273047197136471856730859350878848416701953443562929378684861312928240015961" - "371220036087605180304967215500558598031593601273862799041607646012945892188848304803064939675273843852174253" - "591780671275868647310004309203524619697995493946647868123514739427870390608088912784755244273289213735492487" - "806711200286298562110855389881142350728943050786535546037005625779944656488759175679073720657521788460803169" - "399098915443582503593087698432551216543011752197660404175871840418634933566440380132475375830576077689889610" - "555877165396071750587143416063996020201199751972410003093042374458757966810782966064384827015516919398703986" - "180788431985196032764700920816810628506882704347513628278314226925268661535156504738466810090463408594081517" - "474013296151041")); + Integer("151375436448384432254283307583486066667042190660677620373123854553192330171309426231376077199633148394587309320500780366596644977921667705846188987094209368940524153866159642542317461838630631239213601469094819727267931442110409869192021916471495566770793968771356423244153613116589891384095154889897447129616495361921128483415008013000809960124014824730978336773349172340512505436233122012217784681438531620807943478571185612552450478078388300936606517852653888025048589518914846487741067060341531436357187268537672362009339521911619031150310962055950155717666529133873841751541637455255626595846380131842901830415858642992816729709654251950863750665357762009085810629217917751342352313325984460629046549764303679784381441423865043453230665790947214415711707134874389436507764444241582593434407423309392527966674580478029178887423061253968562091672677599167671594875604798350156550372883311207885282088863879202461885968408041715086679139981263812558960095695476485505356891618587969820162186732250377710432275819830606562398013148854467177307257792538812521105073250276853587043874285676126878294501204134744955080973659170543493289121184558611797400317932087143639362969152630394559727560144885191109167802199267405992294077943816747815152047986153974462696242579776353456270439825236419290517542215340162294579962815285992414141725975115146703976251490225724031898802682695139379699275083967566953749280275248401215696451748644475142038613799290222798072247498886364828935253690749237820783821104282786528804685820847939317976725694662661166127380194678954930597817803996943971279795062385881705273889663480715671471466170947086809281202777180196503031441640466417520512377184927727082258708265839007600152745143501419320905768663557824966355252526518492368909694102745402184718285534458364891811419700240301070527639998721161225798676121766517224180501332030635179372072827350327920970532916699374836128894515290852189101489989500779928531013587309296296610484631205391906273047197136471856730859350878848416701953443562929378684861312928240015961371220036087605180304967215500558598031593601273862799041607646012945892188848304803064939675273843852174253591780671275868647310004309203524619697995493946647868123514739427870390608088912784755244273289213735492487806711200286298562110855389881142350728943050786535546037005625779944656488759175679073720657521788460803169399098915443582503593087698432551216543011752197660404175871840418634933566440380132475375830576077689889610555877165396071750587143416063996020201199751972410003093042374458757966810782966064384827015516919398703986180788431985196032764700920816810628506882704347513628278314226925268661535156504738466810090463408594081517474013296151041")); EXPECT_EQ( bigNum *= bigNum, - Integer( - "229145227599388740572577961939405964237625425637398798191873937162289276749671023202591409719700396811919535" - "218451070038197225776758526481305828965238484893004016186051441221787149637753151218130162338454226666223919" - "670709412227999912951488316049720149215486699881369105505834291964395648361923242085363900753467252703078811" - "011361260669559308130059770042950486333676614932129479062740004631201973906319760694678887603024806742784631" - "148911485642445602918044255584196372884914005631812164594053319100108199181371141695626426863659139094453664" - "082216005363268508703198726417961884604779127541304758450192212443508023971258046167539416776898921862548522" - "388198797110774665942702332759701842070892419593076064528881219460699734731871784296218509230358036985846050" - "047600571939079914283495161736544831880347354433706084249524372875743736259616838581805454594557311130367408" - "035403462954781911374017426265996851086893051226880336250915001921494334716067581871113366236958363241497981" - "099575304889294462378766117015789036326569887046019911707003186990909944435697370068860004560732868568325417" - "551470320070238485441438683442866881749204902270196703573317441862406394348201245328923524958376282044448657" - "686283150037276670590646013504763060193441858356101369998050721629723965334440185432349457057858018211945447" - "958939100839140653803745819060403677979232698280974443590832144269246958267592224224011870305258484392853255" - "909045323576226847591680838837239525283537706512929123532392887106182089326797141477597984962339361621521719" - "059764112579914460042445312431266515141697755664084124165114448111091038993442939643795159011275153204762821" - "769142096303502563343881052774922456019710837482594393268826331223900952629591807435404077336755272952794999" - "916317175280760287206774036817698744129937564160286955098465678797368294256093381223667823439426502493323101" - "005479177567642087344318463618751500225471957308768606798113700742625725574272403584463006072385836977609350" - "317837393098629487339457302956725335577277715374948822395683295635767705706063296848804972609391874254708738" - "671434882733890963942439984956196336868673467437692281601900837124001238489536500784240711694807375808611367" - "154797141277462303843828659507654974801093526614805550067312639457431830343012384102369796262913110328148997" - "393820047923405287149153307122663766500021226635692324555381196470249178927346013621573769093537263192817907" - "381779489291453332507777839781765412973947279067302993831466164481807338890682685992618100177818389191801386" - "620940813851922581742615458719528758013081905383173562273391884863537463309239735302017400728040146578474449" - "880892841441704531896546035789542046269246430998161448861474590889490927840338929787875750626235030618896527" - "079993922923474739529575327952354010478008644054358533998803887159114685035251718192811182837260594207066665" - "528653282665334706360565194205734791399239150431331118649403161526824132419176661151714017911400326280910191" - "093355536291070706207494152939363393486297473156569639878758722504999274622523675123429700154550711011124169" - "239884586949716744013549459104768373080827589703415314361267686140922843523967935702173625323584919217451665" - "152351528984974069584861629023542271087868313723517653433479049841587708951419525885926522999819287100735522" - "164361893020693134102258213224335647031825743880107628106847229158097825510971891319420381895636114368520045" - "877488079507586552802773911968502854914554161857981155052371756775069016026689046188261659119514956330180906" - "065117745576893339412167685443159147366433727448283672040019125101974274094488315527510420004220390041498026" - "114303408714957908589978524798261939643902482512804777640076980469823943414680127287936978281229993887060642" - "604266927742103282263393413794384112063989317970515855215268073171015240090573710161321125451997649435499433" - "264446462356695069560429086645994584975474567498767948595378862817685960293037237203327054556656348580996420" - "144232051437395243867585492205212348308392089657223640986576998181923946999433642223439412234790601184523990" - "615207222979625106249780489817153393098752747896654466353665894945971388649013931773199191523603931109444587" - "118155295669704403790456601066579419059852156230213705120881330195896378616835935251024969373407845750148927" - "867559771831927649119043515288999312781437968138331720833557056866816595222508625533254486828540990482304879" - "152521665216399725647714332682627961403309857712265864029234046062579214031313629923583935185637735239254877" - "349495361270437418291529813258760122324408054500765162254515403721224078921374823173632056776710741870155246" - "092638735846163176720158015494375432676474520115441214909208401996420822306955568130955180354640954329974107" - "724535975873860721151541481075672034578913467375907945972927044359984781674995572594584571631197748322004817" - "307167821582508237893046486875117877148977849580914359121463214824065796588450797192728368927504186674273545" - "808142330720157774255861672637548437856170947071439271794618929722943570129923651044470707058742086713482112" - "454124521165781499298262224751813076075019617309383281157661772644578137808946070798029085277804724380614009" - "519469748727191859350724279589369027480970459699060624466072023590568937002058262432880623917609063222334648" - "015172444066434730419603331132510246052724726203919409685193344436030575793472159309390983260140604187020275" - "994153726066798525393806056148356738952848704107088961945776280049732691756676069600649702077714887169192685" - "51306001746368500505085383681")); + Integer("22914522759938874057257796193940596423762542563739879819187393716228927674967102320259140971970039681191953521845107003819722577675852648130582896523848489300401618605144122178714963775315121813016233845422666622391967070941222799991295148831604972014921548669988136910550583429196439564836192324208536390075346725270307881101136126066955930813005977004295048633367661493212947906274000463120197390631976069467888760302480674278463114891148564244560291804425558419637288491400563181216459405331910010819918137114169562642686365913909445366408221600536326850870319872641796188460477912754130475845019221244350802397125804616753941677689892186254852238819879711077466594270233275970184207089241959307606452888121946069973473187178429621850923035803698584605004760057193907991428349516173654483188034735443370608424952437287574373625961683858180545459455731113036740803540346295478191137401742626599685108689305122688033625091500192149433471606758187111336623695836324149798109957530488929446237876611701578903632656988704601991170700318699090994443569737006886000456073286856832541755147032007023848544143868344286688174920490227019670357331744186240639434820124532892352495837628204444865768628315003727667059064601350476306019344185835610136999805072162972396533444018543234945705785801821194544795893910083914065380374581906040367797923269828097444359083214426924695826759222422401187030525848439285325590904532357622684759168083883723952528353770651292912353239288710618208932679714147759798496233936162152171905976411257991446004244531243126651514169775566408412416511444811109103899344293964379515901127515320476282176914209630350256334388105277492245601971083748259439326882633122390095262959180743540407733675527295279499991631717528076028720677403681769874412993756416028695509846567879736829425609338122366782343942650249332310100547917756764208734431846361875150022547195730876860679811370074262572557427240358446300607238583697760935031783739309862948733945730295672533557727771537494882239568329563576770570606329684880497260939187425470873867143488273389096394243998495619633686867346743769228160190083712400123848953650078424071169480737580861136715479714127746230384382865950765497480109352661480555006731263945743183034301238410236979626291311032814899739382004792340528714915330712266376650002122663569232455538119647024917892734601362157376909353726319281790738177948929145333250777783978176541297394727906730299383146616448180733889068268599261810017781838919180138662094081385192258174261545871952875801308190538317356227339188486353746330923973530201740072804014657847444988089284144170453189654603578954204626924643099816144886147459088949092784033892978787575062623503061889652707999392292347473952957532795235401047800864405435853399880388715911468503525171819281118283726059420706666552865328266533470636056519420573479139923915043133111864940316152682413241917666115171401791140032628091019109335553629107070620749415293936339348629747315656963987875872250499927462252367512342970015455071101112416923988458694971674401354945910476837308082758970341531436126768614092284352396793570217362532358491921745166515235152898497406958486162902354227108786831372351765343347904984158770895141952588592652299981928710073552216436189302069313410225821322433564703182574388010762810684722915809782551097189131942038189563611436852004587748807950758655280277391196850285491455416185798115505237175677506901602668904618826165911951495633018090606511774557689333941216768544315914736643372744828367204001912510197427409448831552751042000422039004149802611430340871495790858997852479826193964390248251280477764007698046982394341468012728793697828122999388706064260426692774210328226339341379438411206398931797051585521526807317101524009057371016132112545199764943549943326444646235669506956042908664599458497547456749876794859537886281768596029303723720332705455665634858099642014423205143739524386758549220521234830839208965722364098657699818192394699943364222343941223479060118452399061520722297962510624978048981715339309875274789665446635366589494597138864901393177319919152360393110944458711815529566970440379045660106657941905985215623021370512088133019589637861683593525102496937340784575014892786755977183192764911904351528899931278143796813833172083355705686681659522250862553325448682854099048230487915252166521639972564771433268262796140330985771226586402923404606257921403131362992358393518563773523925487734949536127043741829152981325876012232440805450076516225451540372122407892137482317363205677671074187015524609263873584616317672015801549437543267647452011544121490920840199642082230695556813095518035464095432997410772453597587386072115154148107567203457891346737590794597292704435998478167499557259458457163119774832200481730716782158250823789304648687511787714897784958091435912146321482406579658845079719272836892750418667427354580814233072015777425586167263754843785617094707143927179461892972294357012992365104447070705874208671348211245412452116578149929826222475181307607501961730938328115766177264457813780894607079802908527780472438061400951946974872719185935072427958936902748097045969906062446607202359056893700205826243288062391760906322233464801517244406643473041960333113251024605272472620391940968519334443603057579347215930939098326014060418702027599415372606679852539380605614835673895284870410708896194577628004973269175667606960064970207771488716919268551306001746368500505085383681")); EXPECT_EQ( bigNum *= bigNum, - Integer( - "525075353315756673987618364527862464858716372017412885232571478560168577552209070511173433565235955940364560" - "952860656397837830394604637877201606477680271846821784909835242978112259166132208524924371648278765953812076" - "911502580473519197862690332109930354425292582838847304211721368377024071571024407564655862023623582785542891" - "295169805475740236707532369847647160352595561399174226161372051119367964038413514796750032120455727324186149" - "712584011077192245186945541229988604036892860284188482193277127170215420012582011112036715313180465998072023" - "464100003713416938236616004168899320316839467590116601389187047878469071367161056823939650210465397815615597" - "446976774529260839387016814553478936129356930887953193690505163691453503861735210235948342724886085807456292" - "589191359800580376022351805601942695143564683078028295583869318805512467023663787323317724850556307061760008" - "730844382571845690381429431428069844374228399683130459382924309222707554640404717393785442614523565363121404" - "370242009703671940044418512035745065429309883708579915497932725860094821724795303758838910625487782173119919" - "216349329132068166657584939969081037646017819721196787342928377382488352866314556440200216960855423459540535" - "978088959749396077685648336789277868136546135389801645652736482147965516245998418297439365831698615078556680" - "015084742463574896059538336809285860015649813246655901546424402916873513079542350464414355328507053386377289" - "360562135812157949213621273789622610851546572940940266442838367314772058531652940537902779247352033821267988" - "111366161726953439264776175337211674025972709622461859859669381264026406916182825306650874382453789863499797" - "648559340902745209243319387265607551166691648364483889028843962175563092239789826528062149461078094499127106" - "117771100473287337155018275978015580024920678769041767385184723781015538143092147637625197771971723604938366" - "108165768288391374919944812915666066799654179578072062195349281603083993828127738839238238659251366674702054" - "074262900682547657200000859878461992913998240124974252120816160534031574133749686183834162937299307302725926" - "433190615071123808547577208494330171188656297049145976208286879876129406757662106973024660216895455977147734" - "405953610178246891263282261594031233674085339574304981172317700845321606952993609424793587876309390345099382" - "379035188708348138679973336159244663563744793331049992530061088629871008386844749932669008013727216327350161" - "061389033606939706275004632122401251122740736099510637739594430929719490265918643152921412072495781217406540" - "469185138825548184989058911183569847303792839920513469663788124531433355682992291463444807316721390064812904" - "712941785290633523647084996791706557448701382325960475660048561675767919364598651758367276616933631674225370" - "132050716810773636418447517799431986508269948832893618550253900094016562859802441412434562565766030741277482" - "133930968353549550315582616706002737317541556722471866931277674872751050406685192150104668791849178350013296" - "372518506450153161649770857168801536454075240511220431245474533706817622903745335817600547636690696256452875" - "281358536643727688483097449339123033027260140628052526172530234626680697704913073492025678344122142772514923" - "761791200093419079356280283648119280857202306189979538818598329663265822394044482653084672658606183662599235" - "626397648062587254925013618451314703520753086840309352274432406492485686029137036085326501117284165451719931" - "597019319684593970034477606801750176622212236473166420105977544570073434738997380085658275644171346821845532" - "738847215699501809642064493592669480898207041305631717657969732074872468803536005458671257609610852633409668" - "856553509125697513192231447443131746616953384410706678631268949624865474289113819418373999407633292855662737" - "878765993029417087207959889515315452933504030428664798256259414653908774703682809006926497009584012082724453" - "910245356601156916366083495783068922940641472466048641578463464892844501460667299570052794177880506351138130" - "523817247338403035678745336098371836315418775428020124793558500934001772214752333961310267621362252617684894" - "960119016690569699123655471513974952925508694750492080810823344275851513387794990204687695673011847169848995" - "219282391362362339131013291775654057383785423640585148195121914498275218438302525126573227100575001740983727" - "707669096625707914588059911504831480638139061560295121679804521657768055614015091437485681689086419261599223" - "472443886584652448808235095285534066651138993954965313295519655208338300767897261119303484943657111771172192" - "833933307752290935398300876853849454482620894161226863560809415132749665404913265676690102022997597966256646" - "351582215099452782525505135029945775939193620154493271081788802951835908247250628078673663308143962473139129" - "591507074619771199406429104620297725152587440996233578277369149321213655413829719984245773745267853037287695" - "097583967966905763984375463306983952548195606590815490671153229773602186393940874255149044744976942492699395" - "393325071974619197602821558044196278697884718114465622126251745855059203612647573705891131313316421774138495" - "800552379635170509097566160259791415259830835226608489176959856445436969045023501348219310838768240408165382" - "826275009942861253719719531832747070084673476271624183685963639612061391886072913996863237764630580879370239" - "551187240132494944685531582811784143827837105534017958825465791108732628186088484006690731597117089266033508" - "597841418714345819569016442937499563423997698578393270432352885335924095484562284154359045466224797484593823" - "207543788244541185662201875304057485292030507417454010592001520129739124185997180661397699345717097539662749" - "330639502216007335018498564555378227937603279949983925641000940152397036713073444333366931349050064744300330" - "033058918403228693399623811113254566920933807536518355228543913382981841497691561916952265920231330756270658" - "147873743172886300568831197683112643325886246567922048333391808812200219558307281308888496836417464630527152" - "193185179154836730104679322521490923834208200642101851260187883405377916781905355733533082703245059144726524" - "120545922163654204970506770854094822827087288192990555593749164296444198196112515796115036170886553001191091" - "014711477592966832412412395131786254019901961511973943480164362208147683400378344665066549209892098054542481" - "454731127264027359336344574718430440262580260412005882564900597051874843228978824506422646767162694551369756" - "470030387773591193311635253168823679898907885852046674494676851673345178876824583520181875809284046172493900" - "582861874455577160944122690597719972546261194473607000285296133281163483054968200617383169665728265448969708" - "194181807219307771722715379969913714215109895806854117505396588426465845511706883667938673904517415181299036" - "854841913818170413576571482702051034475497124137650803665704304818071824059979473144898706484278261322319954" - "181748083155910248365779976924454460562447046465257509770510397673977739157371881574104652306714007208095619" - "978502621690781249771964340449663183430484570494456781672407437199438567416737768819329579632497745690074591" - "949654084298416319789264471419531839499576655712436221533893769277247292025837494520816793046055730955263931" - "617024711147033181287029822052440119691229346224448633529892161743767554557111529031937873427853540712225973" - "420368466692812400378892098219817693929605399543992607241922351591775221893754698738365973580538040105891490" - "353934003827740354602307899409923517743764081462495439306859332473483662123846334053725067114506414490855645" - "232670464725616633016909127428704523494874088285841696376035865234837005623814190056761810644063797460425676" - "898204366569273562337457382750078343095731459612952417145995042869758205308314159344928884188506745133124880" - "941046263278283565853783610230805500193523082332247572532394281976697288988764646763673337672281862087937684" - "322466856005950361098646512865199381542942670006951849511892508341594164830143201451859620892460990612613377" - "187456280324124110545347047853923268370125737507075498790507164704797846753656435887128026945764750182084756" - "718845692706340151314175123289294628378396365876381378173109675695264889221708824920571769882141470739824827" - "749221268338203742767505294406618135611657174547075581233072466023066124038338435412635230983394554384953778" - "300407259687648443515470204723825916171594517902342586149143655042361903300375456931499997522159779991577547" - "292813073697009088735089061023530906373974105270684428174109860820199028456312448574213702168482555659668995" - "130163990647511426431888970109123765942300839055779598067338542073051246311570678598527616314449766851282142" - "845070073361103187662858802053013654734458206767897552976640822559598818245455394779247516263574648226664346" - "236551508702679083410016278869995994060435331540325672022513021479422312979712385317000169053048071561851447" - "695143844851283249830456895626179072165200509905225261746909288726299887356441471923143953484462493176001670" - "411860274102892740447720037821993967439540002177852007379653726200397180606830200464336727913726057000435818" - "060038141627719459438535148533180556382971831138530184113148751201274456906148407002112965308464200869659663" - "800924510271118270253547817692214329226444698373644992831169365954282311459343787760019842742268228114575225" - "014765326691171155942106032930738538485214275197826606171007274432422147327734928642478655312652124817665119" - "261080347747454026341242124337631046995193881546946579378917993093301616893051090016635865578611748575115441" - "432557247810134804756157628006413600655027201493261157165070135491076039905304502614717823693292626326609571" - "626638080809687246864700316951722810325833194726229292587054056791885294417734789272804200827758259781528645" - "238700414063833093095281483089913730990690638307371919875661563050717963498646198893571318794098759955001140" - "362148262519261037837015035243359364476296102715468614047737336450771691747186870301981790380912839918048286" - "023064226484733749405982026685682893902900705711207899504387905988214693522369292360746014624164732048241406" - "798782632934661157099415619954855413917237889477351899485852638485624349706454648835190464996690342216094734" - "288703900942777884244520854062658764228247343256443286202882064035552413867580110446571711031696206295404899" - "192522768540407161137320732919347841392014962878706097079470555912173163437138767759383691371529737677448521" - "710703438560293409811559466136416706663738455954156557979888543673781192761780623419404598391260144581043707" - "596545482362298237262689094674452239002072487348812153201280571935376691292142097136332249842271008619134945" - "668397449003661477459397828280249836195177557873354496650101252149620963022402320837724722221521355457738829" - "403774528586763001984673142693533057996208909790775600257616624887416254259829992772490203085569404796254996" - "239858440041433274200690837181845702296096899881452319022399743878664475279581420130632815890324906120799587" - "196239625285537049703745880213074847992463253073407426073938512212379965366695424855366627524513096871821462" - "780954251198329876879475643655179996936141808182981109761")); + Integer("525075353315756673987618364527862464858716372017412885232571478560168577552209070511173433565235955940364560952860656397837830394604637877201606477680271846821784909835242978112259166132208524924371648278765953812076911502580473519197862690332109930354425292582838847304211721368377024071571024407564655862023623582785542891295169805475740236707532369847647160352595561399174226161372051119367964038413514796750032120455727324186149712584011077192245186945541229988604036892860284188482193277127170215420012582011112036715313180465998072023464100003713416938236616004168899320316839467590116601389187047878469071367161056823939650210465397815615597446976774529260839387016814553478936129356930887953193690505163691453503861735210235948342724886085807456292589191359800580376022351805601942695143564683078028295583869318805512467023663787323317724850556307061760008730844382571845690381429431428069844374228399683130459382924309222707554640404717393785442614523565363121404370242009703671940044418512035745065429309883708579915497932725860094821724795303758838910625487782173119919216349329132068166657584939969081037646017819721196787342928377382488352866314556440200216960855423459540535978088959749396077685648336789277868136546135389801645652736482147965516245998418297439365831698615078556680015084742463574896059538336809285860015649813246655901546424402916873513079542350464414355328507053386377289360562135812157949213621273789622610851546572940940266442838367314772058531652940537902779247352033821267988111366161726953439264776175337211674025972709622461859859669381264026406916182825306650874382453789863499797648559340902745209243319387265607551166691648364483889028843962175563092239789826528062149461078094499127106117771100473287337155018275978015580024920678769041767385184723781015538143092147637625197771971723604938366108165768288391374919944812915666066799654179578072062195349281603083993828127738839238238659251366674702054074262900682547657200000859878461992913998240124974252120816160534031574133749686183834162937299307302725926433190615071123808547577208494330171188656297049145976208286879876129406757662106973024660216895455977147734405953610178246891263282261594031233674085339574304981172317700845321606952993609424793587876309390345099382379035188708348138679973336159244663563744793331049992530061088629871008386844749932669008013727216327350161061389033606939706275004632122401251122740736099510637739594430929719490265918643152921412072495781217406540469185138825548184989058911183569847303792839920513469663788124531433355682992291463444807316721390064812904712941785290633523647084996791706557448701382325960475660048561675767919364598651758367276616933631674225370132050716810773636418447517799431986508269948832893618550253900094016562859802441412434562565766030741277482133930968353549550315582616706002737317541556722471866931277674872751050406685192150104668791849178350013296372518506450153161649770857168801536454075240511220431245474533706817622903745335817600547636690696256452875281358536643727688483097449339123033027260140628052526172530234626680697704913073492025678344122142772514923761791200093419079356280283648119280857202306189979538818598329663265822394044482653084672658606183662599235626397648062587254925013618451314703520753086840309352274432406492485686029137036085326501117284165451719931597019319684593970034477606801750176622212236473166420105977544570073434738997380085658275644171346821845532738847215699501809642064493592669480898207041305631717657969732074872468803536005458671257609610852633409668856553509125697513192231447443131746616953384410706678631268949624865474289113819418373999407633292855662737878765993029417087207959889515315452933504030428664798256259414653908774703682809006926497009584012082724453910245356601156916366083495783068922940641472466048641578463464892844501460667299570052794177880506351138130523817247338403035678745336098371836315418775428020124793558500934001772214752333961310267621362252617684894960119016690569699123655471513974952925508694750492080810823344275851513387794990204687695673011847169848995219282391362362339131013291775654057383785423640585148195121914498275218438302525126573227100575001740983727707669096625707914588059911504831480638139061560295121679804521657768055614015091437485681689086419261599223472443886584652448808235095285534066651138993954965313295519655208338300767897261119303484943657111771172192833933307752290935398300876853849454482620894161226863560809415132749665404913265676690102022997597966256646351582215099452782525505135029945775939193620154493271081788802951835908247250628078673663308143962473139129591507074619771199406429104620297725152587440996233578277369149321213655413829719984245773745267853037287695097583967966905763984375463306983952548195606590815490671153229773602186393940874255149044744976942492699395393325071974619197602821558044196278697884718114465622126251745855059203612647573705891131313316421774138495800552379635170509097566160259791415259830835226608489176959856445436969045023501348219310838768240408165382826275009942861253719719531832747070084673476271624183685963639612061391886072913996863237764630580879370239551187240132494944685531582811784143827837105534017958825465791108732628186088484006690731597117089266033508597841418714345819569016442937499563423997698578393270432352885335924095484562284154359045466224797484593823207543788244541185662201875304057485292030507417454010592001520129739124185997180661397699345717097539662749330639502216007335018498564555378227937603279949983925641000940152397036713073444333366931349050064744300330033058918403228693399623811113254566920933807536518355228543913382981841497691561916952265920231330756270658147873743172886300568831197683112643325886246567922048333391808812200219558307281308888496836417464630527152193185179154836730104679322521490923834208200642101851260187883405377916781905355733533082703245059144726524120545922163654204970506770854094822827087288192990555593749164296444198196112515796115036170886553001191091014711477592966832412412395131786254019901961511973943480164362208147683400378344665066549209892098054542481454731127264027359336344574718430440262580260412005882564900597051874843228978824506422646767162694551369756470030387773591193311635253168823679898907885852046674494676851673345178876824583520181875809284046172493900582861874455577160944122690597719972546261194473607000285296133281163483054968200617383169665728265448969708194181807219307771722715379969913714215109895806854117505396588426465845511706883667938673904517415181299036854841913818170413576571482702051034475497124137650803665704304818071824059979473144898706484278261322319954181748083155910248365779976924454460562447046465257509770510397673977739157371881574104652306714007208095619978502621690781249771964340449663183430484570494456781672407437199438567416737768819329579632497745690074591949654084298416319789264471419531839499576655712436221533893769277247292025837494520816793046055730955263931617024711147033181287029822052440119691229346224448633529892161743767554557111529031937873427853540712225973420368466692812400378892098219817693929605399543992607241922351591775221893754698738365973580538040105891490353934003827740354602307899409923517743764081462495439306859332473483662123846334053725067114506414490855645232670464725616633016909127428704523494874088285841696376035865234837005623814190056761810644063797460425676898204366569273562337457382750078343095731459612952417145995042869758205308314159344928884188506745133124880941046263278283565853783610230805500193523082332247572532394281976697288988764646763673337672281862087937684322466856005950361098646512865199381542942670006951849511892508341594164830143201451859620892460990612613377187456280324124110545347047853923268370125737507075498790507164704797846753656435887128026945764750182084756718845692706340151314175123289294628378396365876381378173109675695264889221708824920571769882141470739824827749221268338203742767505294406618135611657174547075581233072466023066124038338435412635230983394554384953778300407259687648443515470204723825916171594517902342586149143655042361903300375456931499997522159779991577547292813073697009088735089061023530906373974105270684428174109860820199028456312448574213702168482555659668995130163990647511426431888970109123765942300839055779598067338542073051246311570678598527616314449766851282142845070073361103187662858802053013654734458206767897552976640822559598818245455394779247516263574648226664346236551508702679083410016278869995994060435331540325672022513021479422312979712385317000169053048071561851447695143844851283249830456895626179072165200509905225261746909288726299887356441471923143953484462493176001670411860274102892740447720037821993967439540002177852007379653726200397180606830200464336727913726057000435818060038141627719459438535148533180556382971831138530184113148751201274456906148407002112965308464200869659663800924510271118270253547817692214329226444698373644992831169365954282311459343787760019842742268228114575225014765326691171155942106032930738538485214275197826606171007274432422147327734928642478655312652124817665119261080347747454026341242124337631046995193881546946579378917993093301616893051090016635865578611748575115441432557247810134804756157628006413600655027201493261157165070135491076039905304502614717823693292626326609571626638080809687246864700316951722810325833194726229292587054056791885294417734789272804200827758259781528645238700414063833093095281483089913730990690638307371919875661563050717963498646198893571318794098759955001140362148262519261037837015035243359364476296102715468614047737336450771691747186870301981790380912839918048286023064226484733749405982026685682893902900705711207899504387905988214693522369292360746014624164732048241406798782632934661157099415619954855413917237889477351899485852638485624349706454648835190464996690342216094734288703900942777884244520854062658764228247343256443286202882064035552413867580110446571711031696206295404899192522768540407161137320732919347841392014962878706097079470555912173163437138767759383691371529737677448521710703438560293409811559466136416706663738455954156557979888543673781192761780623419404598391260144581043707596545482362298237262689094674452239002072487348812153201280571935376691292142097136332249842271008619134945668397449003661477459397828280249836195177557873354496650101252149620963022402320837724722221521355457738829403774528586763001984673142693533057996208909790775600257616624887416254259829992772490203085569404796254996239858440041433274200690837181845702296096899881452319022399743878664475279581420130632815890324906120799587196239625285537049703745880213074847992463253073407426073938512212379965366695424855366627524513096871821462780954251198329876879475643655179996936141808182981109761")); } TEST(IntegerTests, intMultiplyAssignmentOperatorTest) { @@ -380,64 +168,27 @@ TEST(IntegerTests, divideAssignmentOperatorTest) { Integer("7182818284590452353602874713526624977572470936999595749669676277240766335354759"), 13); - EXPECT_EQ(Integer("100000000000000000000000000000000000000000000000000000000000000000000000000000000000000") /= - Integer("10000000000000000000000000000000000000000000"), - Integer("10000000000000000000000000000000000000000000")); - EXPECT_EQ(Integer("10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" - "000000000000000000000000000000000000000000000000000000000000000000000000000") /= - Integer("100000000000000000000000000000000000000000000000000000000000000000000000000000000000000"), - Integer("100000000000000000000000000000000000000000000000000000000000000000000000000000000000000")); EXPECT_EQ( - Integer("10000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000" - "0000000000000000000000000000000000000000000000000000000000000000000000") /= + Integer("100000000000000000000000000000000000000000000000000000000000000000000000000000000000000") /= + Integer("10000000000000000000000000000000000000000000"), + Integer("10000000000000000000000000000000000000000000")); + EXPECT_EQ( + Integer("10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000") /= + Integer("100000000000000000000000000000000000000000000000000000000000000000000000000000000000000"), + Integer("100000000000000000000000000000000000000000000000000000000000000000000000000000000000000")); + EXPECT_EQ( + Integer("100000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000") /= Integer("100000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000"), Integer("1000000000000000000000000000000000000000000000000000000000000000000000")); EXPECT_EQ( - Integer("10000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000" - "0000000000000000000000000000000000000000000000000000000000000000") /= + Integer("100000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000") /= Integer("1000000000000000000000000000000000000000000000000000000000000000000000"), Integer("100000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000")); - Integer bigA("12303472536173859897916428377004935502004782919473057718871885043121781030098281780962637499969740130" - "03445679650" - "04975099674523845827180745690042264848382795392578400958031494791019020721078375851313382307340544849" - "21735569952" - "39193723426892856389363077714285098834502471754308830745280181121063663777400350244555873514587434288" - "29345450790" - "27970481216212551657139612736189944411920584073797480578668308872637837001226353933695298258623052077" - "24314632097" - "61528900461839369599097080811508633180730360435860932099113897002260498118666082984580250846321418231" - "54889542312" - "49021165779607003561719365117085141493534901975762174134158154245326721004077100158952012049062517798" - "41980755441" - "87001077934984041073965661299629440392924639719149765304535578896851351796566857314406226110515876882" - "01306716666" - "60816190907738397367398011380955812694554206393194756249523627348492244870151305002744620369856700284" - "37301153570" - "14578683923709787809470127531725942255599269165274362953531737518570547446330352339187567809160865998" - "51272312050" - "21506089419933399015580274121092988281352642975490569169565260763230292445030602585146983427386833017" - "37944365222" - "16548637093155834932235086867295108597201199535700443685578531192951096702122394420354260042787250225" - "02115464382" - "58746049485307511477893171785748199366241935842427067593601879660891534397420380392822041677079416030" - "04610169741" - "65792937944321"); + Integer bigA("12303472536173859897916428377004935502004782919473057718871885043121781030098281780962637499969740130034456796500497509967452384582718074569004226484838279539257840095803149479101902072107837585131338230734054484921735569952391937234268928563893630777142850988345024717543088307452801811210636637774003502445558735145874342882934545079027970481216212551657139612736189944411920584073797480578668308872637837001226353933695298258623052077243146320976152890046183936959909708081150863318073036043586093209911389700226049811866608298458025084632141823154889542312490211657796070035617193651170851414935349019757621741341581542453267210040771001589520120490625177984198075544187001077934984041073965661299629440392924639719149765304535578896851351796566857314406226110515876882013067166666081619090773839736739801138095581269455420639319475624952362734849224487015130500274462036985670028437301153570145786839237097878094701275317259422555992691652743629535317375185705474463303523391875678091608659985127231205021506089419933399015580274121092988281352642975490569169565260763230292445030602585146983427386833017379443652221654863709315583493223508686729510859720119953570044368557853119295109670212239442035426004278725022502115464382587460494853075114778931717857481993662419358424270675936018796608915343974203803928220416770794160300461016974165792937944321"); EXPECT_EQ(bigA /= - Integer("35076306156968495558690448186617350649863928832630116915388712481414348622203874495792275483460150" - "35603501276296494442204769872208628882685816583149015034150490829747567986311156822048603845157334" - "65620938681606309504393946821608023000179649439040025214237505334658151077308804228029083539590525" - "89702761275786704247252371131156418814797920314344275960809082275514891887764761455548832577594052" - "45297150541759841671819727944845899493678892840111830112509529920517471699237861267263602427655073" - "89266820855771268403147576567095701074005469808857005026436237359557162582162903447744543426516804" - "1405756975664327860057312868835959178663661834688407715795207372052181069795781487373087361"), - Integer("35076306156968495558690448186617350649863928832630116915388712481414348622203874495792275483460150" - "35603501276296494442204769872208628882685816583149015034150490829747567986311156822048603845157334" - "65620938681606309504393946821608023000179649439040025214237505334658151077308804228029083539590525" - "89702761275786704247252371131156418814797920314344275960809082275514891887764761455548832577594052" - "45297150541759841671819727944845899493678892840111830112509529920517471699237861267263602427655073" - "89266820855771268403147576567095701074005469808857005026436237359557162582162903447744543426516804" - "1405756975664327860057312868835959178663661834688407715795207372052181069795781487373087361")); + Integer("3507630615696849555869044818661735064986392883263011691538871248141434862220387449579227548346015035603501276296494442204769872208628882685816583149015034150490829747567986311156822048603845157334656209386816063095043939468216080230001796494390400252142375053346581510773088042280290835395905258970276127578670424725237113115641881479792031434427596080908227551489188776476145554883257759405245297150541759841671819727944845899493678892840111830112509529920517471699237861267263602427655073892668208557712684031475765670957010740054698088570050264362373595571625821629034477445434265168041405756975664327860057312868835959178663661834688407715795207372052181069795781487373087361"), + Integer("3507630615696849555869044818661735064986392883263011691538871248141434862220387449579227548346015035603501276296494442204769872208628882685816583149015034150490829747567986311156822048603845157334656209386816063095043939468216080230001796494390400252142375053346581510773088042280290835395905258970276127578670424725237113115641881479792031434427596080908227551489188776476145554883257759405245297150541759841671819727944845899493678892840111830112509529920517471699237861267263602427655073892668208557712684031475765670957010740054698088570050264362373595571625821629034477445434265168041405756975664327860057312868835959178663661834688407715795207372052181069795781487373087361")); EXPECT_THROW(Integer(-25) /= Integer(0), UndefinedBinaryOperatorException); } @@ -494,12 +245,11 @@ TEST(IntegerTests, moduloAssignmentOperatorTest) { EXPECT_EQ(Integer(-2000) %= Integer(36), Integer(-20)); EXPECT_EQ(Integer(-2000) %= Integer(-36), Integer(-20)); - EXPECT_EQ(Integer(0) %= Integer("368273929654738476473823743829388329882"), 0); - EXPECT_EQ(Integer("54732897657873247528747287294738765738746547387476327946763287467387267328724673874") %= - Integer("47632837528673287446238746237943"), + EXPECT_EQ(Integer(0) %= Integer("368273929654738476473823743829388329882"), + 0); + EXPECT_EQ(Integer("54732897657873247528747287294738765738746547387476327946763287467387267328724673874") %= Integer("47632837528673287446238746237943"), Integer("25193809905191080888100466723580")); - EXPECT_EQ(Integer("54732897657873247528747287294738765738746547387476327946763287467388493894839489384938483948398493" - "83893847267328724673874") %= Integer("1738383928837528673287446238746237943"), + EXPECT_EQ(Integer("5473289765787324752874728729473876573874654738747632794676328746738849389483948938493848394839849383893847267328724673874") %= Integer("1738383928837528673287446238746237943"), Integer("1186817955126284001426922341829394317")); EXPECT_THROW(Integer(-25) %= Integer(0), UndefinedBinaryOperatorException); @@ -858,9 +608,9 @@ TEST(IntegerTests, equalsTest) { EXPECT_NE(c, a); } -TEST(IntegerTests, getTypeTest) { - EXPECT_EQ(Integer::getTypeStatic(), MathObjectType(MathObjectType::Integer, "Integer")); - EXPECT_EQ(Integer().getType(), MathObjectType(MathObjectType::Integer, "Integer")); +TEST(IntegerTests, getClassTest) { + EXPECT_EQ(Integer::getClassStatic(), MathObjectClass("Integer")); + EXPECT_EQ(Integer::getClassStatic().getParent(), IInteger::getClassStatic()); } TEST(IntegerTests, hashTest) { diff --git a/tests/src/numbers/RationalTests.cpp b/tests/src/numbers/RationalTests.cpp index f8c73e999..5fdd73e00 100644 --- a/tests/src/numbers/RationalTests.cpp +++ b/tests/src/numbers/RationalTests.cpp @@ -503,9 +503,9 @@ TEST(RationalTests, isComplexTest) { EXPECT_FALSE(Rational(1, 2).isComplex()); } -TEST(RationalTests, getTypeTest) { - EXPECT_EQ(Rational::getTypeStatic(), MathObjectType(MathObjectType::Rational, "Rational")); - EXPECT_EQ(Rational().getType(), MathObjectType(MathObjectType::Rational, "Rational")); +TEST(RationalTests, getClassTest) { + EXPECT_EQ(Rational::getClassStatic(), MathObjectClass("Rational")); + EXPECT_EQ(Rational::getClassStatic().getParent(), INumber::getClassStatic()); } TEST(RationalTests, hashTest) { diff --git a/tests/src/numbers/RealTests.cpp b/tests/src/numbers/RealTests.cpp index d13c7a9c3..9649a25c6 100644 --- a/tests/src/numbers/RealTests.cpp +++ b/tests/src/numbers/RealTests.cpp @@ -1043,9 +1043,9 @@ TEST(RealTests, isComplexTest) { EXPECT_FALSE(Real(2).isComplex()); } -TEST(RealTests, getTypeTest) { - EXPECT_EQ(Real::getTypeStatic(), MathObjectType(MathObjectType::Real, "Real")); - EXPECT_EQ(Real().getType(), MathObjectType(MathObjectType::Real, "Real")); +TEST(RealTests, getClassTest) { + EXPECT_EQ(Real::getClassStatic(), MathObjectClass("Real")); + EXPECT_EQ(Real::getClassStatic().getParent(), INumber::getClassStatic()); } TEST(RealTests, hashTest) { diff --git a/thirdparty/CMakeLists.txt b/thirdparty/CMakeLists.txt index a35b2d4d3..1bc20020d 100644 --- a/thirdparty/CMakeLists.txt +++ b/thirdparty/CMakeLists.txt @@ -1,6 +1,16 @@ -function(mark_include_directories_as_system lib) - get_target_property(lib_include_dir ${lib} INTERFACE_INCLUDE_DIRECTORIES) - target_include_directories(${lib} SYSTEM INTERFACE ${lib_include_dir}) +function(suppress_warnings lib) + get_target_property(lib_type ${lib} TYPE) + + if(${lib_type} STREQUAL "INTERFACE_LIBRARY") + get_target_property(lib_include_dir ${lib} INTERFACE_INCLUDE_DIRECTORIES) + target_include_directories(${lib} SYSTEM INTERFACE ${lib_include_dir}) + else() + if(MSVC) + target_compile_options(${lib} PRIVATE "/w") + else() + target_compile_options(${lib} PRIVATE "-w") + endif() + endif() endfunction() set(CMAKE_MODULE_PATH @@ -8,25 +18,28 @@ set(CMAKE_MODULE_PATH PARENT_SCOPE) add_subdirectory(boost-config) -mark_include_directories_as_system(boost_config) - +suppress_warnings(boost_config) + add_subdirectory(boost-mp11) -mark_include_directories_as_system(boost_mp11) +suppress_warnings(boost_mp11) add_subdirectory(boost-describe) -mark_include_directories_as_system(boost_describe) +suppress_warnings(boost_describe) add_subdirectory(boost-container-hash) -mark_include_directories_as_system(boost_container_hash) +suppress_warnings(boost_container_hash) add_subdirectory(boost-multiprecision) -mark_include_directories_as_system(boost_multiprecision) +suppress_warnings(boost_multiprecision) add_subdirectory(boost-math) -mark_include_directories_as_system(boost_math) +suppress_warnings(boost_math) add_subdirectory(fmt) -mark_include_directories_as_system(fmt) +suppress_warnings(fmt) + +add_subdirectory(cppcoro) +suppress_warnings(cppcoro) if(${PROJECT_NAME}_build_tests) add_subdirectory(googletest) diff --git a/thirdparty/cppcoro b/thirdparty/cppcoro new file mode 160000 index 000000000..244f83427 --- /dev/null +++ b/thirdparty/cppcoro @@ -0,0 +1 @@ +Subproject commit 244f834274a850eeca4cc5c86acbca1a0fbe9d95