From 9d598d0a9fdb1250a6126118481d11ac0f2e9177 Mon Sep 17 00:00:00 2001 From: fintarin Date: Fri, 22 Mar 2024 16:05:12 +0300 Subject: [PATCH] MathObjectClass, new Parser, class body macro --- .gitmodules | 3 + CMakeLists.txt | 3 +- cmake/Coverage.cmake | 10 +- include/fintamath/core/CoreUtils.hpp | 16 +- include/fintamath/core/IArithmetic.hpp | 24 +- include/fintamath/core/IComparable.hpp | 19 +- include/fintamath/core/IMathObject.hpp | 25 +- include/fintamath/core/IMathObjectCRTP.hpp | 4 +- include/fintamath/core/MathObjectBody.hpp | 33 + .../fintamath/core/MathObjectBoundTypes.hpp | 63 -- include/fintamath/core/MathObjectClass.hpp | 105 ++++ include/fintamath/core/MathObjectType.hpp | 197 ------ include/fintamath/core/MultiMethod.hpp | 10 +- include/fintamath/core/Parser.hpp | 85 +-- include/fintamath/expressions/Expression.hpp | 30 +- .../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 | 20 +- include/fintamath/numbers/INumber.hpp | 24 +- 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 | 45 +- .../{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 | 25 + src/fintamath/expressions/Expression.cpp | 105 ++-- .../expressions/ExpressionComparator.cpp | 6 +- src/fintamath/expressions/ExpressionUtils.cpp | 2 +- .../expressions/FunctionExpression.cpp | 2 +- .../expressions/FunctionExpression.hpp | 8 +- src/fintamath/expressions/IExpression.cpp | 7 +- src/fintamath/expressions/binary/CompExpr.hpp | 8 +- .../expressions/binary/DerivativeExpr.hpp | 8 +- src/fintamath/expressions/binary/DivExpr.hpp | 8 +- .../expressions/binary/IntegralExpr.hpp | 8 +- src/fintamath/expressions/binary/LogExpr.hpp | 8 +- src/fintamath/expressions/binary/PowExpr.hpp | 8 +- .../expressions/polynomial/AddExpr.hpp | 8 +- .../expressions/polynomial/AndExpr.hpp | 8 +- .../expressions/polynomial/MinMaxExpr.hpp | 8 +- .../expressions/polynomial/MulExpr.hpp | 8 +- .../expressions/polynomial/OrExpr.hpp | 8 +- src/fintamath/expressions/unary/AbsExpr.hpp | 8 +- .../expressions/unary/FloorCeilExpr.hpp | 8 +- .../expressions/unary/HyperbExpr.hpp | 8 +- .../expressions/unary/InvHyperbExpr.hpp | 8 +- .../expressions/unary/InvTrigExpr.hpp | 8 +- src/fintamath/expressions/unary/NotExpr.hpp | 8 +- src/fintamath/expressions/unary/SignExpr.hpp | 8 +- src/fintamath/expressions/unary/TrigExpr.hpp | 8 +- src/fintamath/functions/IFunction.cpp | 16 +- src/fintamath/functions/IOperator.cpp | 5 - 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 - tests/src/core/IArithmeticTests.cpp | 9 +- tests/src/core/IComparableTests.cpp | 11 +- tests/src/core/IMathObjectTests.cpp | 9 +- tests/src/core/MathObjectBoundTypesTests.cpp | 52 -- tests/src/core/MathObjectClassTests.cpp | 74 +++ tests/src/core/MathObjectTypeTests.cpp | 60 -- tests/src/core/ParseTests.cpp | 590 +++++++++--------- tests/src/expressions/ExpressionTests.cpp | 6 +- .../expressions/FunctionExpressionTests.cpp | 68 +- tests/src/expressions/IExpressionTests.cpp | 4 +- .../src/expressions/binary/CompExprTests.cpp | 4 +- .../binary/DerivativeExprTests.cpp | 4 +- tests/src/expressions/binary/DivExprTests.cpp | 4 +- .../expressions/binary/IntegralExprTests.cpp | 4 +- tests/src/expressions/binary/LogExprTests.cpp | 4 +- tests/src/expressions/binary/PowExprTests.cpp | 4 +- .../interfaces/IBinaryExpressionTests.cpp | 14 +- .../interfaces/IPolynomExpressionTests.cpp | 14 +- .../interfaces/IUnaryExpressionTests.cpp | 14 +- .../expressions/polynomial/AddExprTests.cpp | 4 +- .../expressions/polynomial/AndExprTests.cpp | 4 +- .../polynomial/MinMaxExprTests.cpp | 4 +- .../expressions/polynomial/MulExprTests.cpp | 4 +- .../expressions/polynomial/OrExprTests.cpp | 4 +- tests/src/expressions/unary/AbsExprTests.cpp | 4 +- .../expressions/unary/FloorCeilExprTests.cpp | 4 +- .../src/expressions/unary/HyperbExprTests.cpp | 4 +- .../expressions/unary/InvHyperbExprTests.cpp | 4 +- .../expressions/unary/InvTrigExprTests.cpp | 4 +- tests/src/expressions/unary/NotExprTests.cpp | 4 +- tests/src/expressions/unary/SignExprTests.cpp | 4 +- tests/src/expressions/unary/TrigExprTests.cpp | 4 +- tests/src/functions/IFunctionTests.cpp | 20 +- tests/src/functions/IOperatorTests.cpp | 4 +- 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 | 46 +- .../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 | 4 +- 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 | 4 +- 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 | 38 +- tests/src/numbers/INumberTests.cpp | 4 +- tests/src/numbers/IntegerTests.cpp | 6 +- tests/src/numbers/RationalTests.cpp | 6 +- tests/src/numbers/RealTests.cpp | 6 +- thirdparty/CMakeLists.txt | 3 + thirdparty/cppcoro | 1 + 275 files changed, 1835 insertions(+), 2371 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 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 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/CoreUtils.hpp b/include/fintamath/core/CoreUtils.hpp index 96b7eef1e..bec013bab 100644 --- a/include/fintamath/core/CoreUtils.hpp +++ b/include/fintamath/core/CoreUtils.hpp @@ -6,7 +6,7 @@ #include #include -#include "fintamath/core/MathObjectBoundTypes.hpp" +#include "fintamath/core/MathObjectClass.hpp" namespace fintamath { @@ -21,6 +21,16 @@ concept ConvertibleToAndNotSameAs = std::convertible_to && !std::same_ template concept SameAsUnqual = (std::same_as, std::remove_cvref_t>); +inline bool is(const MathObjectClass to, const MathObjectClass from) { + for (std::optional parent = from; parent; parent = parent->getParent()) { + if (parent == to) { + return true; + } + } + + return false; +} + template To, std::derived_from From> bool is(const From &from) { if constexpr (std::is_base_of_v) { @@ -30,7 +40,7 @@ bool is(const From &from) { return false; } else { - return isBaseOf(To::getTypeStatic(), from.getType()); + return is(To::getClassStatic(), from.getClass()); } } @@ -142,4 +152,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/IArithmetic.hpp b/include/fintamath/core/IArithmetic.hpp index 55f9b77cc..a84904695 100644 --- a/include/fintamath/core/IArithmetic.hpp +++ b/include/fintamath/core/IArithmetic.hpp @@ -7,13 +7,13 @@ #include "fintamath/core/CoreUtils.hpp" #include "fintamath/core/IMathObject.hpp" -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.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..6a5a205f2 100644 --- a/include/fintamath/core/IComparable.hpp +++ b/include/fintamath/core/IComparable.hpp @@ -8,36 +8,21 @@ #include "fintamath/core/CoreUtils.hpp" #include "fintamath/core/IArithmetic.hpp" -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.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..a4317ebb0 100644 --- a/include/fintamath/core/IMathObject.hpp +++ b/include/fintamath/core/IMathObject.hpp @@ -8,13 +8,14 @@ #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/Parser.hpp" namespace fintamath { class IMathObject { - using MathObjectParser = detail::Parser()>; + FINTAMATH_PARENT_CLASS_BODY(IMathObject) public: virtual ~IMathObject() = default; @@ -24,42 +25,28 @@ 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 class IMathObjectCRTP : public IMathObject { #define I_MATH_OBJECT_CRTP IMathObjectCRTP #include "fintamath/core/IMathObjectCRTP.hpp" + #undef I_MATH_OBJECT_CRTP }; 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..b39b7ff5b --- /dev/null +++ b/include/fintamath/core/MathObjectBody.hpp @@ -0,0 +1,33 @@ +#pragma once + +#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() { \ + static Class##Parser parser; \ + return parser; \ + } \ + \ +public: \ + static Class##Parser::Generator parse(const std::string &str) { \ + return getParser().parse(str); \ + } \ + \ + template T> \ + static void registerType() { \ + MathObjectClass::bindTypes(); \ + getParser().registerType(); \ + } \ + \ +private: 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..598f8a755 --- /dev/null +++ b/include/fintamath/core/MathObjectClass.hpp @@ -0,0 +1,105 @@ +#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<=>(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 getParent() const { + const auto iter = getChildToParentMap().find(name); + return iter != getChildToParentMap().end() ? iter->second : std::optional{}; + } + + const Children &getChildren() const { + return getParentToChildrenMap()[name]; + } + + template + static void bindTypes() { + getClassToIdMap()[Parent::getClassStatic()] = ++maxId; + getClassToIdMap()[Child::getClassStatic()] = ++maxId; + + getChildToParentMap().emplace(Child::getClassStatic(), Parent::getClassStatic()); + getParentToChildrenMap()[Parent::getClassStatic()].emplace(Child::getClassStatic()); + } + +private: + Id getId() const; + + static ClassToIdMap &getClassToIdMap(); + + static ChildToParentMap &getChildToParentMap(); + + static ParentToChildrenMap &getParentToChildrenMap(); + +private: + Name name; + + inline static Id maxId = 0; + + [[maybe_unused]] inline static const detail::Config config; +}; + +inline size_t hash_value(const MathObjectClass rhs) noexcept { + return boost::hash{}(rhs.getName()); +} + +} \ No newline at end of file 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/MultiMethod.hpp b/include/fintamath/core/MultiMethod.hpp index c267a23ab..0271cf598 100644 --- a/include/fintamath/core/MultiMethod.hpp +++ b/include/fintamath/core/MultiMethod.hpp @@ -7,7 +7,7 @@ #include #include "fintamath/core/CoreUtils.hpp" -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.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..9af9dc378 100644 --- a/include/fintamath/core/Parser.hpp +++ b/include/fintamath/core/Parser.hpp @@ -3,17 +3,23 @@ #include #include #include -#include #include #include #include +#include + #include "fintamath/core/CoreUtils.hpp" #include "fintamath/core/Tokenizer.hpp" #include "fintamath/exceptions/InvalidInputException.hpp" namespace fintamath::detail { +template +concept EmptyConstructable = requires { + T(); +}; + template concept StringConstructable = requires(const std::string &str, Args &&...args) { T(str, args...); @@ -25,50 +31,38 @@ class Parser; template class Parser final { public: - using Validator = std::function; - - using StringConstructor = std::function; + using Generator = cppcoro::generator; using Constructor = std::function; - using ConstructorVector = std::vector; +private: + 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)...); - } + using StringToConstructorMap = std::unordered_map>; +public: 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, ConstructorArgs &&...args) const { + if (const auto iter = stringToConstructorMap.find(str); iter != stringToConstructorMap.end()) { + for (const auto &constructor : iter->second) { + if (Return value = constructor(std::forward(args)...)) { + co_yield value; + } } } - for (const auto &constructor : extraConstructors) { - if (Return value = constructor(str, std::forward(args)...); - value && validator(value)) { - - return value; + for (const auto &constructor : generatorConstructors) { + for (Return &value : constructor(str, std::forward(args)...)) { + co_yield value; } } - - return Return{}; } template - requires(!StringConstructable) + requires(!std::is_abstract_v && !StringConstructable && EmptyConstructable) void registerType() { Constructor constructor = [](ConstructorArgs &&...args) -> Return { return std::make_unique(std::forward(args)...); @@ -78,37 +72,50 @@ class Parser final { } template - requires(!StringConstructable) + requires(!std::is_abstract_v && !StringConstructable && EmptyConstructable) void registerType(Constructor constructor) { static const std::string name = Type{}.toString(); - stringToConstructorMap.emplace(name, std::move(constructor)); + stringToConstructorMap[name].emplace_back(std::move(constructor)); Tokenizer::registerToken(name); } template - requires(StringConstructable) + requires(!std::is_abstract_v && StringConstructable) void registerType() { - StringConstructor constructor = [](const std::string &str, ConstructorArgs &&...args) -> Return { + GeneratorConstructor constructor = [](const std::string &str, ConstructorArgs &&...args) -> Generator { try { - return std::make_unique(str, std::forward(args)...); + co_yield std::make_unique(str, std::forward(args)...); } catch (const InvalidInputException &) { - return std::unique_ptr{}; + // Go to the next constructor } }; - registerType(std::move(constructor)); + generatorConstructors.emplace_back(std::move(constructor)); } - void registerType(StringConstructor constructor) { - extraConstructors.emplace_back(std::move(constructor)); + template + requires(std::is_abstract_v) + void registerType() { + GeneratorConstructor constructor = [](const std::string &str, ConstructorArgs &&...args) -> Generator { + for (auto &value : Type::parse(str, std::forward(args)...)) { + co_yield std::move(value); + } + }; + + generatorConstructors.emplace_back(std::move(constructor)); + } + + template + void registerType() { + // No object of this type can be constructed } private: StringToConstructorMap stringToConstructorMap; - ConstructorVector extraConstructors; + GeneratorConstructorVector generatorConstructors; }; } diff --git a/include/fintamath/expressions/Expression.hpp b/include/fintamath/expressions/Expression.hpp index 976a3e56f..3966dc5ba 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,10 +61,14 @@ using OperandStack = std::stack>; } class Expression final : public IExpressionCRTP { - using TermParser = detail::Parser()>; + FINTAMATH_CLASS_BODY(Expression) + using ExpressionParser = detail::Parser(ArgumentPtrVector &&)>; + using ExpressionMaker = std::function(ArgumentPtrVector &&)>; + using TermValueParser = detail::Parser()>; + public: Expression(); @@ -88,17 +92,9 @@ 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"}; - } - protected: Expression &add(const Expression &rhs) override; @@ -123,7 +119,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 +147,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,8 +159,6 @@ class Expression final : public IExpressionCRTP { friend Expression approximate(const Expression &rhs, unsigned precision); - static TermParser &getTermParser(); - static ExpressionParser &getExpressionParser(); private: @@ -198,7 +198,7 @@ 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(); + static const size_t argSize = Function{}.getArgumentClasses().size(); std::unique_ptr res; if constexpr (Function::isVariadicStatic()) { 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..92b3056ea 100644 --- a/include/fintamath/numbers/IInteger.hpp +++ b/include/fintamath/numbers/IInteger.hpp @@ -5,14 +5,14 @@ #include #include "fintamath/core/CoreUtils.hpp" -#include "fintamath/core/MathObjectType.hpp" +#include "fintamath/core/MathObjectClass.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..da5c36597 100644 --- a/include/fintamath/numbers/INumber.hpp +++ b/include/fintamath/numbers/INumber.hpp @@ -8,13 +8,13 @@ #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/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..f4ee2cd47 100644 --- a/src/fintamath/config/ExpressionConfig.cpp +++ b/src/fintamath/config/ExpressionConfig.cpp @@ -97,43 +97,7 @@ 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() { +ExpressionConfig::ExpressionConfig() { Expression::registerFunctionExpressionMaker([](ArgumentPtrVector &&args) { return AddExpr(std::move(args)).clone(); }); @@ -456,10 +420,3 @@ void registerFunctionExpressionMakers() { } } - -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..76fac2b88 100644 --- a/src/fintamath/core/IArithmetic.cpp +++ b/src/fintamath/core/IArithmetic.cpp @@ -2,9 +2,4 @@ namespace fintamath { -IArithmetic::ArithmeticParser &IArithmetic::getParser() { - static ArithmeticParser parser; - return parser; -} - } diff --git a/src/fintamath/core/IComparable.cpp b/src/fintamath/core/IComparable.cpp index 905a46088..1752f6de7 100644 --- a/src/fintamath/core/IComparable.cpp +++ b/src/fintamath/core/IComparable.cpp @@ -2,9 +2,4 @@ namespace fintamath { -IComparable::ComparableParser &IComparable::getParser() { - static ComparableParser parser; - return parser; -} - } diff --git a/src/fintamath/core/IMathObject.cpp b/src/fintamath/core/IMathObject.cpp index 7c62bbc70..a0b2b6258 100644 --- a/src/fintamath/core/IMathObject.cpp +++ b/src/fintamath/core/IMathObject.cpp @@ -2,9 +2,4 @@ namespace fintamath { -IMathObject::MathObjectParser &IMathObject::getParser() { - static MathObjectParser parser; - return parser; -} - } diff --git a/src/fintamath/core/MathObjectClass.cpp b/src/fintamath/core/MathObjectClass.cpp new file mode 100644 index 000000000..db181d594 --- /dev/null +++ b/src/fintamath/core/MathObjectClass.cpp @@ -0,0 +1,25 @@ +#include "fintamath/core/MathObjectClass.hpp" + +namespace fintamath { + +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; +} + +} diff --git a/src/fintamath/expressions/Expression.cpp b/src/fintamath/expressions/Expression.cpp index 534ee631e..b6b301f9a 100644 --- a/src/fintamath/expressions/Expression.cpp +++ b/src/fintamath/expressions/Expression.cpp @@ -14,7 +14,7 @@ #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/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,46 @@ 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 TermValueParser termValueParser = [] { + TermValueParser parser; + parser.registerType(); + parser.registerType(); + parser.registerType(); + return parser; + }(); + + Term term = {str, {}}; + + for (auto &termValue : termValueParser.parse(str)) { + term.value = std::move(termValue); + break; + } + + return term; +} + +void Expression::moveFunctionTermsToOperands(OperandStack &operands, std::stack &functions, const IOperator *nextOper) { if (isPrefixOperator(nextOper)) { return; } @@ -315,7 +349,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 +357,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 +377,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 +390,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 +432,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 +473,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; } 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 +499,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 +585,8 @@ 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; + for (auto &expr : Expression::getExpressionParser().parse(func.toString(), std::move(args))) { + return std::move(expr); } return FunctionExpression(func, std::move(args)).clone(); diff --git a/src/fintamath/expressions/ExpressionComparator.cpp b/src/fintamath/expressions/ExpressionComparator.cpp index c98c463c0..70f0b7261 100644 --- a/src/fintamath/expressions/ExpressionComparator.cpp +++ b/src/fintamath/expressions/ExpressionComparator.cpp @@ -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..840506d22 100644 --- a/src/fintamath/expressions/ExpressionUtils.cpp +++ b/src/fintamath/expressions/ExpressionUtils.cpp @@ -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..dcef8ca21 100644 --- a/src/fintamath/expressions/FunctionExpression.cpp +++ b/src/fintamath/expressions/FunctionExpression.cpp @@ -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..5ae15a994 100644 --- a/src/fintamath/expressions/IExpression.cpp +++ b/src/fintamath/expressions/IExpression.cpp @@ -323,7 +323,7 @@ ArgumentPtr IExpression::approximateSimplify() const { if (containsVar && (numberChildrenCount < 2 || - approxChildren.size() == getFunction()->getArgumentTypes().size())) { + approxChildren.size() == getFunction()->getArgumentClasses().size())) { return approxExpr; } @@ -359,9 +359,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.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.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.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.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.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/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.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.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.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.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.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.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.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.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.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..cdcbc79c1 100644 --- a/src/fintamath/functions/IFunction.cpp +++ b/src/fintamath/functions/IFunction.cpp @@ -9,7 +9,7 @@ namespace fintamath { 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 +22,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..bb935648f 100644 --- a/src/fintamath/functions/IOperator.cpp +++ b/src/fintamath/functions/IOperator.cpp @@ -2,9 +2,4 @@ namespace fintamath { -IOperator::OperatorParser &IOperator::getParser() { - static OperatorParser parser; - return parser; -} - } diff --git a/src/fintamath/literals/ILiteral.cpp b/src/fintamath/literals/ILiteral.cpp index 9a3719085..09677126a 100644 --- a/src/fintamath/literals/ILiteral.cpp +++ b/src/fintamath/literals/ILiteral.cpp @@ -2,9 +2,4 @@ namespace fintamath { -ILiteral::LiteralParser &ILiteral::getParser() { - static LiteralParser parser; - return parser; -} - } diff --git a/src/fintamath/literals/constants/IConstant.cpp b/src/fintamath/literals/constants/IConstant.cpp index 21917e619..80b488359 100644 --- a/src/fintamath/literals/constants/IConstant.cpp +++ b/src/fintamath/literals/constants/IConstant.cpp @@ -2,9 +2,4 @@ namespace fintamath { -IConstant::ConstantParser &IConstant::getParser() { - static ConstantParser parser; - return parser; -} - } diff --git a/src/fintamath/numbers/Complex.cpp b/src/fintamath/numbers/Complex.cpp index e52b8d22c..59e045926 100644 --- a/src/fintamath/numbers/Complex.cpp +++ b/src/fintamath/numbers/Complex.cpp @@ -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,20 @@ 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; + }(); + + for (auto &num : numberParser.parse(str)) { + return std::move(num); + } + + return {}; +} + } diff --git a/src/fintamath/numbers/IInteger.cpp b/src/fintamath/numbers/IInteger.cpp index e621d66ca..a149af41d 100644 --- a/src/fintamath/numbers/IInteger.cpp +++ b/src/fintamath/numbers/IInteger.cpp @@ -2,9 +2,4 @@ namespace fintamath { -IInteger::IntegerParser &IInteger::getParser() { - static IntegerParser parser; - return parser; -} - } diff --git a/src/fintamath/numbers/INumber.cpp b/src/fintamath/numbers/INumber.cpp index 9c99338e4..226a92204 100644 --- a/src/fintamath/numbers/INumber.cpp +++ b/src/fintamath/numbers/INumber.cpp @@ -2,9 +2,4 @@ namespace fintamath { -INumber::NumberParser &INumber::getParser() { - static NumberParser parser; - return parser; -} - } diff --git a/tests/src/core/IArithmeticTests.cpp b/tests/src/core/IArithmeticTests.cpp index 0b7aa8079..becd7c413 100644 --- a/tests/src/core/IArithmeticTests.cpp +++ b/tests/src/core/IArithmeticTests.cpp @@ -11,10 +11,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(TestComparable) protected: TestArithmetic &add(const TestArithmetic & /* rhs */) override { @@ -198,6 +195,6 @@ 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")); } diff --git a/tests/src/core/IComparableTests.cpp b/tests/src/core/IComparableTests.cpp index 8702e3422..a4b4b6c31 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 { @@ -144,6 +141,6 @@ 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")); } diff --git a/tests/src/core/IMathObjectTests.cpp b/tests/src/core/IMathObjectTests.cpp index 63c43faae..ef334b1cd 100644 --- a/tests/src/core/IMathObjectTests.cpp +++ b/tests/src/core/IMathObjectTests.cpp @@ -11,10 +11,7 @@ using namespace fintamath; namespace { class TestMathObject final : public IMathObjectCRTP { -public: - static constexpr MathObjectType getTypeStatic() { - return {MathObjectType::IArithmetic, "TestMathObject"}; - } + FINTAMATH_CLASS_BODY(TestMathObject) }; } @@ -102,6 +99,6 @@ 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")); } 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..e073156db --- /dev/null +++ b/tests/src/core/MathObjectClassTests.cpp @@ -0,0 +1,74 @@ +#include + +#include "fintamath/core/MathObjectClass.hpp" + +#include "fintamath/literals/ILiteral.hpp" +#include "fintamath/literals/constants/E.hpp" +#include "fintamath/literals/constants/True.hpp" +#include "fintamath/numbers/Integer.hpp" +#include "fintamath/numbers/Rational.hpp" + +using namespace fintamath; +using namespace detail; + +TEST(MathObjectClassTests, constructorTest) { + { + constexpr MathObjectClass t("Int"); + EXPECT_EQ(t.getName(), "Int"); + } + { + constexpr MathObjectClass t("NotInt"); + EXPECT_EQ(t.getName(), "NotInt"); + } + + { + MathObjectClass t("Int"); + EXPECT_EQ(t.getName(), "Int"); + } + { + MathObjectClass t("NotInt"); + EXPECT_EQ(t.getName(), "NotInt"); + } +} + +TEST(MathObjectClassTests, equalsTest) { + EXPECT_TRUE(Integer::getClassStatic() == Integer::getClassStatic()); + EXPECT_FALSE(Rational::getClassStatic() == Integer::getClassStatic()); + EXPECT_FALSE(Integer::getClassStatic() == Rational::getClassStatic()); +} + +TEST(MathObjectClassTests, compareTest) { + EXPECT_EQ(Integer::getClassStatic() <=> Integer::getClassStatic(), std::strong_ordering::equal); + EXPECT_EQ(Rational::getClassStatic() <=> Integer::getClassStatic(), std::strong_ordering::less); + EXPECT_EQ(Integer::getClassStatic() <=> Rational::getClassStatic(), std::strong_ordering::greater); +} + +TEST(MathObjectClassTests, getNameTest) { + EXPECT_EQ(Integer::getClassStatic().getName(), "Integer"); +} + +TEST(MathObjectClassTests, getParentTest) { + // TODO: implement +} + +TEST(MathObjectClassTests, getChildrenTest) { + // TODO: implement +} + +TEST(MathObjectClassTests, bindTypesTest) { + // TODO: implement +} + +TEST(MathObjectClassTests, hashTest) { + EXPECT_EQ(boost::hash{}(IMathObject::getClassStatic()), + boost::hash{}(IMathObject::getClassStatic().getName())); + + EXPECT_EQ(boost::hash{}(INumber::getClassStatic()), + boost::hash{}(INumber::getClassStatic().getName())); + + EXPECT_EQ(boost::hash{}(Integer::getClassStatic()), + boost::hash{}(Integer::getClassStatic().getName())); + + EXPECT_EQ(boost::hash{}(Boolean::getClassStatic()), + boost::hash{}(Boolean::getClassStatic().getName())); +} \ No newline at end of file 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 index b6effad91..6d65e26e3 100644 --- a/tests/src/core/ParseTests.cpp +++ b/tests/src/core/ParseTests.cpp @@ -1,295 +1,295 @@ -#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); -} +// #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").begin())); +// EXPECT_TRUE(is(IMathObject::parse("a").begin())); +// EXPECT_TRUE(is(IMathObject::parse("sin").begin())); +// EXPECT_TRUE(is(IMathObject::parse("a+1").begin())); +// +// EXPECT_FALSE(is(IMathObject::parse("a").begin())); +// EXPECT_FALSE(is(IMathObject::parse("sin").begin())); +// EXPECT_FALSE(is(IMathObject::parse("123").begin())); +// EXPECT_FALSE(is(IMathObject::parse("sin").begin())); +// +// EXPECT_EQ(IMathObject::parse("x+").begin(), cppcoro::detail::generator_sentinel{}); +// } +// +// 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+").begin(), cppcoro::detail::generator_sentinel{}); +// } +// +// TEST(ParseTests, parseComparableTest) { +// EXPECT_TRUE(is(IComparable::parse("12314127362.18731623872183"))); +// +// EXPECT_EQ(IComparable::parse("x").begin(), cppcoro::detail::generator_sentinel{}); +// } +// +// TEST(ParseTests, parseIntegerTest) { +// EXPECT_TRUE(is(IInteger::parse("1231412736218731623872183"))); +// +// EXPECT_EQ(IInteger::parse("x").begin(), cppcoro::detail::generator_sentinel{}); +// } +// +// TEST(ParseTests, parseModularTest) { +// EXPECT_TRUE(is(IInteger::parse("18731623872183"))); +// +// EXPECT_EQ(IInteger::parse("123.123").begin(), cppcoro::detail::generator_sentinel{}); +// } +// +// 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").begin(), cppcoro::detail::generator_sentinel{}); +// EXPECT_EQ(INumber::parse("test").begin(), cppcoro::detail::generator_sentinel{}); +// EXPECT_EQ(INumber::parse("").begin(), cppcoro::detail::generator_sentinel{}); +// EXPECT_EQ(INumber::parse("+").begin(), cppcoro::detail::generator_sentinel{}); +// EXPECT_EQ(INumber::parse("939849.0-0023").begin(), cppcoro::detail::generator_sentinel{}); +// EXPECT_EQ(INumber::parse("a").begin(), cppcoro::detail::generator_sentinel{}); +// EXPECT_EQ(INumber::parse("a.1").begin(), cppcoro::detail::generator_sentinel{}); +// EXPECT_EQ(INumber::parse("1.a").begin(), cppcoro::detail::generator_sentinel{}); +// EXPECT_EQ(INumber::parse("1a.1").begin(), cppcoro::detail::generator_sentinel{}); +// EXPECT_EQ(INumber::parse("1.1a").begin(), cppcoro::detail::generator_sentinel{}); +// EXPECT_EQ(INumber::parse("--10.-1").begin(), cppcoro::detail::generator_sentinel{}); +// EXPECT_EQ(INumber::parse("10.-1").begin(), cppcoro::detail::generator_sentinel{}); +// EXPECT_EQ(INumber::parse("1-0.1").begin(), cppcoro::detail::generator_sentinel{}); +// EXPECT_EQ(INumber::parse("10-.1").begin(), cppcoro::detail::generator_sentinel{}); +// EXPECT_EQ(INumber::parse("10.--1").begin(), cppcoro::detail::generator_sentinel{}); +// } +// +// 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").begin(), cppcoro::detail::generator_sentinel{}); +// EXPECT_EQ(ILiteral::parse("a_").begin(), cppcoro::detail::generator_sentinel{}); +// EXPECT_EQ(ILiteral::parse("a1").begin(), cppcoro::detail::generator_sentinel{}); +// EXPECT_EQ(ILiteral::parse("aa").begin(), cppcoro::detail::generator_sentinel{}); +// EXPECT_EQ(ILiteral::parse("A").begin(), cppcoro::detail::generator_sentinel{}); +// EXPECT_EQ(ILiteral::parse("Z").begin(), cppcoro::detail::generator_sentinel{}); +// } +// +// 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").begin(), cppcoro::detail::generator_sentinel{}); +// EXPECT_EQ(IConstant::parse("z").begin(), cppcoro::detail::generator_sentinel{}); +// EXPECT_EQ(IConstant::parse("1").begin(), cppcoro::detail::generator_sentinel{}); +// EXPECT_EQ(IConstant::parse("a_").begin(), cppcoro::detail::generator_sentinel{}); +// EXPECT_EQ(IConstant::parse("a1").begin(), cppcoro::detail::generator_sentinel{}); +// EXPECT_EQ(IConstant::parse("aa").begin(), cppcoro::detail::generator_sentinel{}); +// } +// +// 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").begin(), cppcoro::detail::generator_sentinel{}); +// EXPECT_EQ(IFunction::parse("1224").begin(), cppcoro::detail::generator_sentinel{}); +// } +// +// 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").begin(), cppcoro::detail::generator_sentinel{}); +// EXPECT_EQ(IOperator::parse("1224").begin(), cppcoro::detail::generator_sentinel{}); +// } +// +// TEST(ParseTests, parseExpressionTest) { +// EXPECT_TRUE(is(IExpression::parse("x+1"))); +// EXPECT_TRUE(is(IExpression::parse("x*1"))); +// +// EXPECT_EQ(IExpression::parse("x+").begin(), cppcoro::detail::generator_sentinel{}); +// EXPECT_EQ(IExpression::parse("^x").begin(), cppcoro::detail::generator_sentinel{}); +// } diff --git a/tests/src/expressions/ExpressionTests.cpp b/tests/src/expressions/ExpressionTests.cpp index c690d5d93..744679254 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().getClass(), MathObjectClass("Expression")); } TEST(ExpressionTests, variableVariablePlusOperatorTest) { diff --git a/tests/src/expressions/FunctionExpressionTests.cpp b/tests/src/expressions/FunctionExpressionTests.cpp index 8909cf352..6595d4703 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: @@ -104,12 +94,12 @@ class TestBinaryFunction final : public IFunctionCRTP(); + IFunction::registerType(); + IOperator::registerType(); IOperator::registerType(); IOperator::registerType(); - - IFunction::registerType(); - IFunction::registerType(); } }; @@ -138,6 +128,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..73f67b869 100644 --- a/tests/src/expressions/IExpressionTests.cpp +++ b/tests/src/expressions/IExpressionTests.cpp @@ -91,8 +91,8 @@ TEST(IExpressionTests, toMinimalObjectTest) { // TODO: implement more tests } -TEST(IExpressionTests, getTypeTest) { - EXPECT_EQ(IExpression::getTypeStatic(), MathObjectType(MathObjectType::IExpression, "IExpression")); +TEST(IExpressionTests, getClassTest) { + EXPECT_EQ(IExpression::getClassStatic(), MathObjectClass("IExpression")); } TEST(IExpressionTests, arithmeticTest) { diff --git a/tests/src/expressions/binary/CompExprTests.cpp b/tests/src/expressions/binary/CompExprTests.cpp index 474c5705e..133b81fcb 100644 --- a/tests/src/expressions/binary/CompExprTests.cpp +++ b/tests/src/expressions/binary/CompExprTests.cpp @@ -6,6 +6,6 @@ using namespace fintamath; -TEST(CompExprTests, getTypeTest) { - EXPECT_EQ(eqvExpr(Integer(0), Integer(0))->getType(), MathObjectType(MathObjectType::CompExpr, "CompExpr")); +TEST(CompExprTests, getClassTest) { + EXPECT_EQ(eqvExpr(Integer(0), Integer(0))->getClass(), MathObjectClass("CompExpr")); } diff --git a/tests/src/expressions/binary/DerivativeExprTests.cpp b/tests/src/expressions/binary/DerivativeExprTests.cpp index 89bc6617e..a53ced447 100644 --- a/tests/src/expressions/binary/DerivativeExprTests.cpp +++ b/tests/src/expressions/binary/DerivativeExprTests.cpp @@ -6,6 +6,6 @@ using namespace fintamath; -TEST(DerivativeExprTests, getTypeTest) { - EXPECT_EQ(derivativeExpr(Integer(0), Variable("x"))->getType(), MathObjectType(MathObjectType::DerivativeExpr, "DerivativeExpr")); +TEST(DerivativeExprTests, getClassTest) { + EXPECT_EQ(derivativeExpr(Integer(0), Variable("x"))->getClass(), MathObjectClass("DerivativeExpr")); } diff --git a/tests/src/expressions/binary/DivExprTests.cpp b/tests/src/expressions/binary/DivExprTests.cpp index f81e42c91..2d7ecc967 100644 --- a/tests/src/expressions/binary/DivExprTests.cpp +++ b/tests/src/expressions/binary/DivExprTests.cpp @@ -6,6 +6,6 @@ using namespace fintamath; -TEST(DivExprTests, getTypeTest) { - EXPECT_EQ(divExpr(Integer(0), Integer(0))->getType(), MathObjectType(MathObjectType::DivExpr, "DivExpr")); +TEST(DivExprTests, getClassTest) { + EXPECT_EQ(divExpr(Integer(0), Integer(0))->getClass(), MathObjectClass("DivExpr")); } diff --git a/tests/src/expressions/binary/IntegralExprTests.cpp b/tests/src/expressions/binary/IntegralExprTests.cpp index 759722501..cc2503941 100644 --- a/tests/src/expressions/binary/IntegralExprTests.cpp +++ b/tests/src/expressions/binary/IntegralExprTests.cpp @@ -6,6 +6,6 @@ using namespace fintamath; -TEST(IntegralExprTests, getTypeTest) { - EXPECT_EQ(integralExpr(Integer(0), Variable("x"))->getType(), MathObjectType(MathObjectType::IntegralExpr, "IntegralExpr")); +TEST(IntegralExprTests, getClassTest) { + EXPECT_EQ(integralExpr(Integer(0), Variable("x"))->getClass(), MathObjectClass("IntegralExpr")); } diff --git a/tests/src/expressions/binary/LogExprTests.cpp b/tests/src/expressions/binary/LogExprTests.cpp index 7ac04d96e..fa693adf9 100644 --- a/tests/src/expressions/binary/LogExprTests.cpp +++ b/tests/src/expressions/binary/LogExprTests.cpp @@ -6,6 +6,6 @@ using namespace fintamath; -TEST(LogExprTests, getTypeTest) { - EXPECT_EQ(logExpr(Integer(0), Integer(0))->getType(), MathObjectType(MathObjectType::LogExpr, "LogExpr")); +TEST(LogExprTests, getClassTest) { + EXPECT_EQ(logExpr(Integer(0), Integer(0))->getClass(), MathObjectClass("LogExpr")); } diff --git a/tests/src/expressions/binary/PowExprTests.cpp b/tests/src/expressions/binary/PowExprTests.cpp index 47a56041d..060ab9449 100644 --- a/tests/src/expressions/binary/PowExprTests.cpp +++ b/tests/src/expressions/binary/PowExprTests.cpp @@ -6,6 +6,6 @@ using namespace fintamath; -TEST(PowExprTests, getTypeTest) { - EXPECT_EQ(powExpr(Integer(0), Integer(0))->getType(), MathObjectType(MathObjectType::PowExpr, "PowExpr")); +TEST(PowExprTests, getClassTest) { + EXPECT_EQ(powExpr(Integer(0), Integer(0))->getClass(), MathObjectClass("PowExpr")); } diff --git a/tests/src/expressions/interfaces/IBinaryExpressionTests.cpp b/tests/src/expressions/interfaces/IBinaryExpressionTests.cpp index 4b07788bd..3a3b51e25 100644 --- a/tests/src/expressions/interfaces/IBinaryExpressionTests.cpp +++ b/tests/src/expressions/interfaces/IBinaryExpressionTests.cpp @@ -11,16 +11,22 @@ 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"}; +struct TestBinaryExpressionConfig final { + TestBinaryExpressionConfig() { + IBinaryExpression::registerType(); } }; +[[maybe_unused]] const TestBinaryExpressionConfig config; + } TEST(IBinaryExpressionTests, toStringTest) { @@ -63,6 +69,6 @@ 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")); } diff --git a/tests/src/expressions/interfaces/IPolynomExpressionTests.cpp b/tests/src/expressions/interfaces/IPolynomExpressionTests.cpp index 0185cef2f..6896373b3 100644 --- a/tests/src/expressions/interfaces/IPolynomExpressionTests.cpp +++ b/tests/src/expressions/interfaces/IPolynomExpressionTests.cpp @@ -13,15 +13,21 @@ 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"}; +struct TestPolynomExpressionConfig final { + TestPolynomExpressionConfig() { + IPolynomExpression::registerType(); } }; +[[maybe_unused]] const TestPolynomExpressionConfig config; + } TEST(IPolynomExpressionTests, toStringTest) { @@ -71,6 +77,6 @@ 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")); } diff --git a/tests/src/expressions/interfaces/IUnaryExpressionTests.cpp b/tests/src/expressions/interfaces/IUnaryExpressionTests.cpp index 74aacc033..a3b34fd50 100644 --- a/tests/src/expressions/interfaces/IUnaryExpressionTests.cpp +++ b/tests/src/expressions/interfaces/IUnaryExpressionTests.cpp @@ -11,16 +11,22 @@ 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"}; +struct TestUnaryExpressionConfig final { + TestUnaryExpressionConfig() { + IUnaryExpression::registerType(); } }; +[[maybe_unused]] const TestUnaryExpressionConfig config; + } TEST(IUnaryExpressionTests, toStringTest) { @@ -62,6 +68,6 @@ 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")); } diff --git a/tests/src/expressions/polynomial/AddExprTests.cpp b/tests/src/expressions/polynomial/AddExprTests.cpp index 05f6c89ee..078da3c68 100644 --- a/tests/src/expressions/polynomial/AddExprTests.cpp +++ b/tests/src/expressions/polynomial/AddExprTests.cpp @@ -6,6 +6,6 @@ using namespace fintamath; -TEST(AddExprTests, getTypeTest) { - EXPECT_EQ(addExpr(Integer(0), Integer(0))->getType(), MathObjectType(MathObjectType::AddExpr, "AddExpr")); +TEST(AddExprTests, getClassTest) { + EXPECT_EQ(addExpr(Integer(0), Integer(0))->getClass(), MathObjectClass("AddExpr")); } diff --git a/tests/src/expressions/polynomial/AndExprTests.cpp b/tests/src/expressions/polynomial/AndExprTests.cpp index 8d10d7f0b..b59bb131b 100644 --- a/tests/src/expressions/polynomial/AndExprTests.cpp +++ b/tests/src/expressions/polynomial/AndExprTests.cpp @@ -6,6 +6,6 @@ using namespace fintamath; -TEST(AndExprTests, getTypeTest) { - EXPECT_EQ(andExpr(Boolean(), Boolean())->getType(), MathObjectType(MathObjectType::AndExpr, "AndExpr")); +TEST(AndExprTests, getClassTest) { + EXPECT_EQ(andExpr(Boolean(), Boolean())->getClass(), MathObjectClass("AndExpr")); } diff --git a/tests/src/expressions/polynomial/MinMaxExprTests.cpp b/tests/src/expressions/polynomial/MinMaxExprTests.cpp index 068985189..f6d593c05 100644 --- a/tests/src/expressions/polynomial/MinMaxExprTests.cpp +++ b/tests/src/expressions/polynomial/MinMaxExprTests.cpp @@ -6,6 +6,6 @@ using namespace fintamath; -TEST(MinMaxExprTests, getTypeTest) { - EXPECT_EQ(minExpr(Integer(0), Integer(0))->getType(), MathObjectType(MathObjectType::MinMaxExpr, "MinMaxExpr")); +TEST(MinMaxExprTests, getClassTest) { + EXPECT_EQ(minExpr(Integer(0), Integer(0))->getClass(), MathObjectClass("MinMaxExpr")); } diff --git a/tests/src/expressions/polynomial/MulExprTests.cpp b/tests/src/expressions/polynomial/MulExprTests.cpp index 157b2aaf1..7c80c684f 100644 --- a/tests/src/expressions/polynomial/MulExprTests.cpp +++ b/tests/src/expressions/polynomial/MulExprTests.cpp @@ -6,6 +6,6 @@ using namespace fintamath; -TEST(MulExprTests, getTypeTest) { - EXPECT_EQ(mulExpr(Integer(0), Integer(0))->getType(), MathObjectType(MathObjectType::MulExpr, "MulExpr")); +TEST(MulExprTests, getClassTest) { + EXPECT_EQ(mulExpr(Integer(0), Integer(0))->getClass(), MathObjectClass("MulExpr")); } diff --git a/tests/src/expressions/polynomial/OrExprTests.cpp b/tests/src/expressions/polynomial/OrExprTests.cpp index ebb861417..e684bf33e 100644 --- a/tests/src/expressions/polynomial/OrExprTests.cpp +++ b/tests/src/expressions/polynomial/OrExprTests.cpp @@ -6,6 +6,6 @@ using namespace fintamath; -TEST(OrExprTests, getTypeTest) { - EXPECT_EQ(orExpr(Boolean(), Boolean())->getType(), MathObjectType(MathObjectType::OrExpr, "OrExpr")); +TEST(OrExprTests, getClassTest) { + EXPECT_EQ(orExpr(Boolean(), Boolean())->getClass(), MathObjectClass("OrExpr")); } diff --git a/tests/src/expressions/unary/AbsExprTests.cpp b/tests/src/expressions/unary/AbsExprTests.cpp index 3e062dae7..34767dded 100644 --- a/tests/src/expressions/unary/AbsExprTests.cpp +++ b/tests/src/expressions/unary/AbsExprTests.cpp @@ -5,6 +5,6 @@ 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..17606c1eb 100644 --- a/tests/src/expressions/unary/FloorCeilExprTests.cpp +++ b/tests/src/expressions/unary/FloorCeilExprTests.cpp @@ -5,6 +5,6 @@ using namespace fintamath; -TEST(FloorCeilExprTests, getTypeTest) { - EXPECT_EQ(floorExpr(Integer(0).clone())->getType(), MathObjectType(MathObjectType::FloorCeilExpr, "FloorCeilExpr")); +TEST(FloorCeilExprTests, getClassTest) { + EXPECT_EQ(floorExpr(Integer(0).clone())->getClass(), MathObjectClass("FloorCeilExpr")); } diff --git a/tests/src/expressions/unary/HyperbExprTests.cpp b/tests/src/expressions/unary/HyperbExprTests.cpp index 26cdc4c90..92180d2bb 100644 --- a/tests/src/expressions/unary/HyperbExprTests.cpp +++ b/tests/src/expressions/unary/HyperbExprTests.cpp @@ -6,6 +6,6 @@ using namespace fintamath; -TEST(HyperbExprTests, getTypeTest) { - EXPECT_EQ(sinhExpr(Integer(0).clone())->getType(), MathObjectType(MathObjectType::HyperbExpr, "HyperbExpr")); +TEST(HyperbExprTests, getClassTest) { + EXPECT_EQ(sinhExpr(Integer(0).clone())->getClass(), MathObjectClass("HyperbExpr")); } diff --git a/tests/src/expressions/unary/InvHyperbExprTests.cpp b/tests/src/expressions/unary/InvHyperbExprTests.cpp index de39b1f80..ac58d07a2 100644 --- a/tests/src/expressions/unary/InvHyperbExprTests.cpp +++ b/tests/src/expressions/unary/InvHyperbExprTests.cpp @@ -6,6 +6,6 @@ using namespace fintamath; -TEST(InvHyperbExprTests, getTypeTest) { - EXPECT_EQ(asinhExpr(Integer(0).clone())->getType(), MathObjectType(MathObjectType::InvHyperbExpr, "InvHyperbExpr")); +TEST(InvHyperbExprTests, getClassTest) { + EXPECT_EQ(asinhExpr(Integer(0).clone())->getClass(), MathObjectClass("InvHyperbExpr")); } diff --git a/tests/src/expressions/unary/InvTrigExprTests.cpp b/tests/src/expressions/unary/InvTrigExprTests.cpp index 85ce98d32..4c3f309f5 100644 --- a/tests/src/expressions/unary/InvTrigExprTests.cpp +++ b/tests/src/expressions/unary/InvTrigExprTests.cpp @@ -6,6 +6,6 @@ using namespace fintamath; -TEST(InvTrigExprTests, getTypeTest) { - EXPECT_EQ(asinExpr(Integer(0).clone())->getType(), MathObjectType(MathObjectType::InvTrigExpr, "InvTrigExpr")); +TEST(InvTrigExprTests, getClassTest) { + EXPECT_EQ(asinExpr(Integer(0).clone())->getClass(), MathObjectClass("InvTrigExpr")); } diff --git a/tests/src/expressions/unary/NotExprTests.cpp b/tests/src/expressions/unary/NotExprTests.cpp index 755c2045a..77b295b77 100644 --- a/tests/src/expressions/unary/NotExprTests.cpp +++ b/tests/src/expressions/unary/NotExprTests.cpp @@ -6,6 +6,6 @@ using namespace fintamath; -TEST(NotExprTests, getTypeTest) { - EXPECT_EQ(notExpr(Boolean())->getType(), MathObjectType(MathObjectType::NotExpr, "NotExpr")); +TEST(NotExprTests, getClassTest) { + EXPECT_EQ(notExpr(Boolean())->getClass(), MathObjectClass("NotExpr")); } diff --git a/tests/src/expressions/unary/SignExprTests.cpp b/tests/src/expressions/unary/SignExprTests.cpp index 3e867e7aa..6bc2c8013 100644 --- a/tests/src/expressions/unary/SignExprTests.cpp +++ b/tests/src/expressions/unary/SignExprTests.cpp @@ -5,6 +5,6 @@ using namespace fintamath; -TEST(SignExprTests, getTypeTest) { - EXPECT_EQ(signExpr(Integer(0).clone())->getType(), MathObjectType(MathObjectType::SignExpr, "SignExpr")); +TEST(SignExprTests, getClassTest) { + EXPECT_EQ(signExpr(Integer(0).clone())->getClass(), MathObjectClass("SignExpr")); } diff --git a/tests/src/expressions/unary/TrigExprTests.cpp b/tests/src/expressions/unary/TrigExprTests.cpp index bf7502857..f21ca5e60 100644 --- a/tests/src/expressions/unary/TrigExprTests.cpp +++ b/tests/src/expressions/unary/TrigExprTests.cpp @@ -6,6 +6,6 @@ using namespace fintamath; -TEST(TrigExprTests, getTypeTest) { - EXPECT_EQ(sinExpr(Integer(0).clone())->getType(), MathObjectType(MathObjectType::TrigExpr, "TrigExpr")); +TEST(TrigExprTests, getClassTest) { + EXPECT_EQ(sinExpr(Integer(0).clone())->getClass(), MathObjectClass("TrigExpr")); } diff --git a/tests/src/functions/IFunctionTests.cpp b/tests/src/functions/IFunctionTests.cpp index 4add7c030..c3afd2b28 100644 --- a/tests/src/functions/IFunctionTests.cpp +++ b/tests/src/functions/IFunctionTests.cpp @@ -62,16 +62,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 +89,6 @@ 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")); } diff --git a/tests/src/functions/IOperatorTests.cpp b/tests/src/functions/IOperatorTests.cpp index 202cce0ae..19c739a6f 100644 --- a/tests/src/functions/IOperatorTests.cpp +++ b/tests/src/functions/IOperatorTests.cpp @@ -24,6 +24,6 @@ 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")); } diff --git a/tests/src/functions/arithmetic/AbsTests.cpp b/tests/src/functions/arithmetic/AbsTests.cpp index 818695d3b..932cfaaf5 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.getClass(), MathObjectClass("Abs")); } diff --git a/tests/src/functions/arithmetic/AddTests.cpp b/tests/src/functions/arithmetic/AddTests.cpp index 2fe9654ea..7092c4900 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.getClass(), MathObjectClass("Add")); } diff --git a/tests/src/functions/arithmetic/DivTests.cpp b/tests/src/functions/arithmetic/DivTests.cpp index 659950181..be1edacb3 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.getClass(), MathObjectClass("Div")); } diff --git a/tests/src/functions/arithmetic/FracMixedTests.cpp b/tests/src/functions/arithmetic/FracMixedTests.cpp index a5358d76d..4fa9256fc 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.getClass(), MathObjectClass("FracMixed")); } diff --git a/tests/src/functions/arithmetic/FracTests.cpp b/tests/src/functions/arithmetic/FracTests.cpp index 374a97193..0739b892b 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.getClass(), MathObjectClass("Frac")); } diff --git a/tests/src/functions/arithmetic/MulTests.cpp b/tests/src/functions/arithmetic/MulTests.cpp index 6975d50f2..a3fa182f5 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.getClass(), MathObjectClass("Mul")); } diff --git a/tests/src/functions/arithmetic/NegTests.cpp b/tests/src/functions/arithmetic/NegTests.cpp index d5efa47b2..fad99f87b 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.getClass(), MathObjectClass("Neg")); } diff --git a/tests/src/functions/arithmetic/SignTests.cpp b/tests/src/functions/arithmetic/SignTests.cpp index 3ed2e971b..c0d62aadc 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.getClass(), MathObjectClass("Sign")); } diff --git a/tests/src/functions/arithmetic/SubTests.cpp b/tests/src/functions/arithmetic/SubTests.cpp index c7d32abdc..67cbe56ec 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.getClass(), MathObjectClass("Sub")); } diff --git a/tests/src/functions/arithmetic/UnaryPlusTests.cpp b/tests/src/functions/arithmetic/UnaryPlusTests.cpp index 3ab7572ad..c5021e9a8 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.getClass(), MathObjectClass("UnaryPlus")); } diff --git a/tests/src/functions/calculus/DerivativeTests.cpp b/tests/src/functions/calculus/DerivativeTests.cpp index 274b1bf6d..206e2f521 100644 --- a/tests/src/functions/calculus/DerivativeTests.cpp +++ b/tests/src/functions/calculus/DerivativeTests.cpp @@ -15,54 +15,60 @@ 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; } }; +struct TestComparableConfig final { + TestComparableConfig() { + IComparable::registerType(); + } +}; + +[[maybe_unused]] const TestComparableConfig config; + } 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 +87,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 +102,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.getClass(), MathObjectClass("Derivative")); } diff --git a/tests/src/functions/calculus/IntegralTests.cpp b/tests/src/functions/calculus/IntegralTests.cpp index 4e7636caa..157a61bfc 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.getClass(), MathObjectClass("Integral")); } diff --git a/tests/src/functions/calculus/MaxTests.cpp b/tests/src/functions/calculus/MaxTests.cpp index 0f3310712..a6ac0817f 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.getClass(), MathObjectClass("Max")); } diff --git a/tests/src/functions/calculus/MinTests.cpp b/tests/src/functions/calculus/MinTests.cpp index 579fcfa48..32ec63002 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.getClass(), MathObjectClass("Min")); } diff --git a/tests/src/functions/comparison/EqvTests.cpp b/tests/src/functions/comparison/EqvTests.cpp index 5b045fa08..68df24686 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.getClass(), MathObjectClass("Eqv")); } diff --git a/tests/src/functions/comparison/LessEqvTests.cpp b/tests/src/functions/comparison/LessEqvTests.cpp index daa254c38..e8ea02ffd 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.getClass(), MathObjectClass("LessEqv")); } diff --git a/tests/src/functions/comparison/LessTests.cpp b/tests/src/functions/comparison/LessTests.cpp index 845637ace..726463e85 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.getClass(), MathObjectClass("Less")); } diff --git a/tests/src/functions/comparison/MoreEqvTests.cpp b/tests/src/functions/comparison/MoreEqvTests.cpp index 7b91a5a40..a1a8b8aeb 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.getClass(), MathObjectClass("MoreEqv")); } diff --git a/tests/src/functions/comparison/MoreTests.cpp b/tests/src/functions/comparison/MoreTests.cpp index a5dc4b3b4..5308243cb 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.getClass(), MathObjectClass("More")); } diff --git a/tests/src/functions/comparison/NeqvTests.cpp b/tests/src/functions/comparison/NeqvTests.cpp index b9d716ca6..3197c2654 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.getClass(), MathObjectClass("Neqv")); } diff --git a/tests/src/functions/hyperbolic/AcoshTests.cpp b/tests/src/functions/hyperbolic/AcoshTests.cpp index 8d29c4edd..71bb82335 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.getClass(), MathObjectClass("Acosh")); } diff --git a/tests/src/functions/hyperbolic/AcothTests.cpp b/tests/src/functions/hyperbolic/AcothTests.cpp index 9a404dc28..3d7a9a9a6 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.getClass(), MathObjectClass("Acoth")); } diff --git a/tests/src/functions/hyperbolic/AcschTests.cpp b/tests/src/functions/hyperbolic/AcschTests.cpp index 7e94c71f3..0060ff699 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.getClass(), MathObjectClass("Acsch")); } diff --git a/tests/src/functions/hyperbolic/AsechTests.cpp b/tests/src/functions/hyperbolic/AsechTests.cpp index 72b33a33a..ab36de79d 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.getClass(), MathObjectClass("Asech")); } diff --git a/tests/src/functions/hyperbolic/AsinhTests.cpp b/tests/src/functions/hyperbolic/AsinhTests.cpp index dacf9a084..f527fc80e 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.getClass(), MathObjectClass("Asinh")); } diff --git a/tests/src/functions/hyperbolic/AtanhTests.cpp b/tests/src/functions/hyperbolic/AtanhTests.cpp index d85584bae..c75e4f532 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.getClass(), MathObjectClass("Atanh")); } diff --git a/tests/src/functions/hyperbolic/CoshTests.cpp b/tests/src/functions/hyperbolic/CoshTests.cpp index 73b1db689..9b0518828 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.getClass(), MathObjectClass("Cosh")); } diff --git a/tests/src/functions/hyperbolic/CothTests.cpp b/tests/src/functions/hyperbolic/CothTests.cpp index cc1554e66..f4d6523a1 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.getClass(), MathObjectClass("Coth")); } diff --git a/tests/src/functions/hyperbolic/CschTests.cpp b/tests/src/functions/hyperbolic/CschTests.cpp index 60bff58b1..c4823b499 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.getClass(), MathObjectClass("Csch")); } diff --git a/tests/src/functions/hyperbolic/SechTests.cpp b/tests/src/functions/hyperbolic/SechTests.cpp index bba89f850..d2f778983 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.getClass(), MathObjectClass("Sech")); } diff --git a/tests/src/functions/hyperbolic/SinhTests.cpp b/tests/src/functions/hyperbolic/SinhTests.cpp index 1c8c6f77f..c9abdcbb9 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.getClass(), MathObjectClass("Sinh")); } diff --git a/tests/src/functions/hyperbolic/TanhTests.cpp b/tests/src/functions/hyperbolic/TanhTests.cpp index 597761db7..0c0ca3cfa 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.getClass(), MathObjectClass("Tanh")); } diff --git a/tests/src/functions/logarithms/LbTests.cpp b/tests/src/functions/logarithms/LbTests.cpp index 23a0b9d75..8ae3c543a 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.getClass(), MathObjectClass("Lb")); } diff --git a/tests/src/functions/logarithms/LgTests.cpp b/tests/src/functions/logarithms/LgTests.cpp index 8efb30160..f0ecb7a51 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.getClass(), MathObjectClass("Lg")); } diff --git a/tests/src/functions/logarithms/LnTests.cpp b/tests/src/functions/logarithms/LnTests.cpp index 576c6e26e..66204ad74 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.getClass(), MathObjectClass("Ln")); } diff --git a/tests/src/functions/logarithms/LogTests.cpp b/tests/src/functions/logarithms/LogTests.cpp index d5e9484fc..f02df05a3 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.getClass(), MathObjectClass("Log")); } diff --git a/tests/src/functions/logic/AndTests.cpp b/tests/src/functions/logic/AndTests.cpp index 523327cb8..3a4c0bcbb 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.getClass(), MathObjectClass("And")); } diff --git a/tests/src/functions/logic/EquivTests.cpp b/tests/src/functions/logic/EquivTests.cpp index a7d5a4b5e..3fa750ecd 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.getClass(), MathObjectClass("Equiv")); } diff --git a/tests/src/functions/logic/ImplTests.cpp b/tests/src/functions/logic/ImplTests.cpp index b2accac86..49a186a30 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.getClass(), MathObjectClass("Impl")); } diff --git a/tests/src/functions/logic/NequivTests.cpp b/tests/src/functions/logic/NequivTests.cpp index fd3d6c935..5dd168cfc 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.getClass(), MathObjectClass("Nequiv")); } diff --git a/tests/src/functions/logic/NotTests.cpp b/tests/src/functions/logic/NotTests.cpp index 0d91b0447..01022ebd9 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.getClass(), MathObjectClass("Not")); } diff --git a/tests/src/functions/logic/OrTests.cpp b/tests/src/functions/logic/OrTests.cpp index 647fe84dd..eb5f976c5 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.getClass(), MathObjectClass("Or")); } diff --git a/tests/src/functions/ntheory/CeilTests.cpp b/tests/src/functions/ntheory/CeilTests.cpp index 97bc09fcb..a6df8beed 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.getClass(), MathObjectClass("Ceil")); } diff --git a/tests/src/functions/ntheory/FloorTests.cpp b/tests/src/functions/ntheory/FloorTests.cpp index 5aa564a64..0cb0c4c30 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.getClass(), MathObjectClass("Floor")); } diff --git a/tests/src/functions/ntheory/ModTests.cpp b/tests/src/functions/ntheory/ModTests.cpp index 171c93af7..ad58f1850 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.getClass(), MathObjectClass("Mod")); } diff --git a/tests/src/functions/other/CommaTests.cpp b/tests/src/functions/other/CommaTests.cpp index 825f0b0c9..e701142c6 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.getClass(), MathObjectClass("Comma")); } diff --git a/tests/src/functions/other/DegTests.cpp b/tests/src/functions/other/DegTests.cpp index 6817609cf..1e24862e5 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.getClass(), MathObjectClass("Deg")); } diff --git a/tests/src/functions/other/FactorialTests.cpp b/tests/src/functions/other/FactorialTests.cpp index c717575bc..ab9f9f413 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.getClass(), MathObjectClass("Factorial")); } diff --git a/tests/src/functions/other/IndexTests.cpp b/tests/src/functions/other/IndexTests.cpp index da1017ab7..f99b82a27 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.getClass(), MathObjectClass("Index")); } diff --git a/tests/src/functions/other/PercentTests.cpp b/tests/src/functions/other/PercentTests.cpp index 4405fba00..c947d7823 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.getClass(), MathObjectClass("Percent")); } diff --git a/tests/src/functions/powers/ExpTests.cpp b/tests/src/functions/powers/ExpTests.cpp index 7db26ec9b..45f883320 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.getClass(), MathObjectClass("Exp")); } diff --git a/tests/src/functions/powers/PowFunctionTests.cpp b/tests/src/functions/powers/PowFunctionTests.cpp index ecec32aaf..9fb3873d2 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.getClass(), MathObjectClass("PowFunction")); } diff --git a/tests/src/functions/powers/PowTests.cpp b/tests/src/functions/powers/PowTests.cpp index 5bf2b8653..87c78f162 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.getClass(), MathObjectClass("Pow")); } diff --git a/tests/src/functions/powers/RootTests.cpp b/tests/src/functions/powers/RootTests.cpp index 0818849c8..0c4d9bded 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.getClass(), MathObjectClass("Root")); } diff --git a/tests/src/functions/powers/SqrTests.cpp b/tests/src/functions/powers/SqrTests.cpp index 58ca76a41..080ef2a70 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.getClass(), MathObjectClass("Sqr")); } diff --git a/tests/src/functions/powers/SqrtTests.cpp b/tests/src/functions/powers/SqrtTests.cpp index dbb9ec9e3..58baf465b 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.getClass(), MathObjectClass("Sqrt")); } diff --git a/tests/src/functions/trigonometry/AcosTests.cpp b/tests/src/functions/trigonometry/AcosTests.cpp index 395f18328..09d242ec2 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.getClass(), MathObjectClass("Acos")); } diff --git a/tests/src/functions/trigonometry/AcotTests.cpp b/tests/src/functions/trigonometry/AcotTests.cpp index 1c8818021..373f85b52 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.getClass(), MathObjectClass("Acot")); } diff --git a/tests/src/functions/trigonometry/AcscTests.cpp b/tests/src/functions/trigonometry/AcscTests.cpp index 70b3a7552..b943c9e7b 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.getClass(), MathObjectClass("Acsc")); } diff --git a/tests/src/functions/trigonometry/AsecTests.cpp b/tests/src/functions/trigonometry/AsecTests.cpp index 151c2a568..dd5129735 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.getClass(), MathObjectClass("Asec")); } diff --git a/tests/src/functions/trigonometry/AsinTests.cpp b/tests/src/functions/trigonometry/AsinTests.cpp index 890f5e787..a79d28035 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.getClass(), MathObjectClass("Asin")); } diff --git a/tests/src/functions/trigonometry/AtanTests.cpp b/tests/src/functions/trigonometry/AtanTests.cpp index faa475825..62d03a176 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.getClass(), MathObjectClass("Atan")); } diff --git a/tests/src/functions/trigonometry/CosTests.cpp b/tests/src/functions/trigonometry/CosTests.cpp index 3b95f8928..d4c08bd1e 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.getClass(), MathObjectClass("Cos")); } diff --git a/tests/src/functions/trigonometry/CotTests.cpp b/tests/src/functions/trigonometry/CotTests.cpp index b587c940c..dfbe47a51 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.getClass(), MathObjectClass("Cot")); } diff --git a/tests/src/functions/trigonometry/CscTests.cpp b/tests/src/functions/trigonometry/CscTests.cpp index 1c2acc545..6c6b067ee 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.getClass(), MathObjectClass("Csc")); } diff --git a/tests/src/functions/trigonometry/SecTests.cpp b/tests/src/functions/trigonometry/SecTests.cpp index 0f984400c..6f5ae4055 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.getClass(), MathObjectClass("Sec")); } diff --git a/tests/src/functions/trigonometry/SinTests.cpp b/tests/src/functions/trigonometry/SinTests.cpp index 93bcaad77..e7b1c8984 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.getClass(), MathObjectClass("Sin")); } diff --git a/tests/src/functions/trigonometry/TanTests.cpp b/tests/src/functions/trigonometry/TanTests.cpp index 5d54f0768..a8068a412 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.getClass(), MathObjectClass("Tan")); } diff --git a/tests/src/literals/BooleanTests.cpp b/tests/src/literals/BooleanTests.cpp index 571b5fe98..824b18804 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().getClass(), MathObjectClass("Boolean")); } diff --git a/tests/src/literals/ILiteralTests.cpp b/tests/src/literals/ILiteralTests.cpp index 0a563fdb5..77dfa7d23 100644 --- a/tests/src/literals/ILiteralTests.cpp +++ b/tests/src/literals/ILiteralTests.cpp @@ -28,6 +28,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..a0231d0f1 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("a").getClass(), MathObjectClass("Variable")); } diff --git a/tests/src/literals/constants/ComplexInfTests.cpp b/tests/src/literals/constants/ComplexInfTests.cpp index 9b20dab33..c58540f38 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().getClass(), MathObjectClass("ComplexInf")); } diff --git a/tests/src/literals/constants/ETests.cpp b/tests/src/literals/constants/ETests.cpp index 3ab542b03..ddeb96a11 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().getClass(), MathObjectClass("E")); } diff --git a/tests/src/literals/constants/FalseTests.cpp b/tests/src/literals/constants/FalseTests.cpp index 291c367da..7cc445b8d 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().getClass(), MathObjectClass("False")); } diff --git a/tests/src/literals/constants/IConstantTests.cpp b/tests/src/literals/constants/IConstantTests.cpp index 7e9717961..d73592f14 100644 --- a/tests/src/literals/constants/IConstantTests.cpp +++ b/tests/src/literals/constants/IConstantTests.cpp @@ -15,6 +15,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..28df27863 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().getClass(), MathObjectClass("I")); } diff --git a/tests/src/literals/constants/InfTests.cpp b/tests/src/literals/constants/InfTests.cpp index d01de8a84..a7e7333c1 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().getClass(), MathObjectClass("Inf")); } diff --git a/tests/src/literals/constants/NegInfTests.cpp b/tests/src/literals/constants/NegInfTests.cpp index 112f30675..c15e6f0b7 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().getClass(), MathObjectClass("NegInf")); } diff --git a/tests/src/literals/constants/PiTests.cpp b/tests/src/literals/constants/PiTests.cpp index 312186748..1722b7f81 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().getClass(), MathObjectClass("Pi")); } diff --git a/tests/src/literals/constants/TrueTests.cpp b/tests/src/literals/constants/TrueTests.cpp index c202312b9..f50e4e0b9 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().getClass(), MathObjectClass("True")); } diff --git a/tests/src/literals/constants/UndefinedTests.cpp b/tests/src/literals/constants/UndefinedTests.cpp index aca259f12..098f42069 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().getClass(), MathObjectClass("Undefined")); } diff --git a/tests/src/numbers/ComplexTests.cpp b/tests/src/numbers/ComplexTests.cpp index 1c0869d61..822c3e8b3 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().getClass(), MathObjectClass("Complex")); } diff --git a/tests/src/numbers/IIntegerTests.cpp b/tests/src/numbers/IIntegerTests.cpp index 19000ad0c..e0c32ac47 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,15 +11,13 @@ using namespace detail; namespace { class TestInteger : public IIntegerCRTP { + FINTAMATH_PARENT_CLASS_BODY(TestInteger) + public: std::string toString() const override { return "test"; } - static constexpr MathObjectType getTypeStatic() { - return {static_cast(IInteger::getTypeStatic().getId()) + 998, "TestInteger"}; - } - protected: TestInteger &mod(const TestInteger & /* rhs */) override { return *this; @@ -72,7 +68,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 { @@ -85,6 +81,8 @@ class TestInteger : public IIntegerCRTP { }; class TestIntegerConvertible final : public TestInteger { + FINTAMATH_CLASS_BODY(TestIntegerConvertible) + public: TestIntegerConvertible() : TestInteger() { } @@ -92,26 +90,20 @@ 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()); +struct TestIntegerConfig final { + TestIntegerConfig() { + IInteger::registerType(); + TestInteger::registerType(); 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); @@ -119,7 +111,7 @@ struct TestIntegerConvertableConfig final { } }; -[[maybe_unused]] const TestIntegerConvertableConfig config; +[[maybe_unused]] const TestIntegerConfig config; } @@ -294,6 +286,6 @@ 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")); +} \ No newline at end of file diff --git a/tests/src/numbers/INumberTests.cpp b/tests/src/numbers/INumberTests.cpp index fda52f36d..75b08ab6c 100644 --- a/tests/src/numbers/INumberTests.cpp +++ b/tests/src/numbers/INumberTests.cpp @@ -86,6 +86,6 @@ 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")); } diff --git a/tests/src/numbers/IntegerTests.cpp b/tests/src/numbers/IntegerTests.cpp index 6642e65f5..6e993d2ec 100644 --- a/tests/src/numbers/IntegerTests.cpp +++ b/tests/src/numbers/IntegerTests.cpp @@ -858,9 +858,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().getClass(), MathObjectClass("Integer")); } TEST(IntegerTests, hashTest) { diff --git a/tests/src/numbers/RationalTests.cpp b/tests/src/numbers/RationalTests.cpp index f8c73e999..8d231f4aa 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().getClass(), MathObjectClass("Rational")); } TEST(RationalTests, hashTest) { diff --git a/tests/src/numbers/RealTests.cpp b/tests/src/numbers/RealTests.cpp index d13c7a9c3..c322b0ab1 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().getClass(), MathObjectClass("Real")); } TEST(RealTests, hashTest) { diff --git a/thirdparty/CMakeLists.txt b/thirdparty/CMakeLists.txt index a35b2d4d3..ca2896d24 100644 --- a/thirdparty/CMakeLists.txt +++ b/thirdparty/CMakeLists.txt @@ -28,6 +28,9 @@ mark_include_directories_as_system(boost_math) add_subdirectory(fmt) mark_include_directories_as_system(fmt) +add_subdirectory(cppcoro) +mark_include_directories_as_system(cppcoro) + if(${PROJECT_NAME}_build_tests) add_subdirectory(googletest) endif() 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