diff --git a/src/language/ast/ASTNodeExpressionBuilder.cpp b/src/language/ast/ASTNodeExpressionBuilder.cpp index 78e192767fc869ed78a61c8c951e6bfd9c806f8d..72b385495582d381d7c0f395d0bc21f7f397c3a0 100644 --- a/src/language/ast/ASTNodeExpressionBuilder.cpp +++ b/src/language/ast/ASTNodeExpressionBuilder.cpp @@ -20,7 +20,6 @@ #include <language/node_processor/NameProcessor.hpp> #include <language/node_processor/TinyMatrixExpressionProcessor.hpp> #include <language/node_processor/TinyVectorExpressionProcessor.hpp> -#include <language/node_processor/TupleToTinyVectorProcessor.hpp> #include <language/node_processor/TupleToVectorProcessor.hpp> #include <language/node_processor/ValueProcessor.hpp> #include <language/node_processor/WhileProcessor.hpp> diff --git a/src/language/ast/ASTNodeFunctionExpressionBuilder.cpp b/src/language/ast/ASTNodeFunctionExpressionBuilder.cpp index 6a91a15d13978b423daa563c1b668c5fe0f93489..a836d24cde04b68aa547005b93a77a4daa41e4db 100644 --- a/src/language/ast/ASTNodeFunctionExpressionBuilder.cpp +++ b/src/language/ast/ASTNodeFunctionExpressionBuilder.cpp @@ -3,8 +3,6 @@ #include <language/PEGGrammar.hpp> #include <language/ast/ASTNodeDataTypeFlattener.hpp> #include <language/node_processor/FunctionProcessor.hpp> -#include <language/node_processor/TupleToTinyMatrixProcessor.hpp> -#include <language/node_processor/TupleToTinyVectorProcessor.hpp> #include <language/utils/ASTNodeNaturalConversionChecker.hpp> #include <language/utils/FunctionTable.hpp> #include <language/utils/SymbolTable.hpp> @@ -561,33 +559,7 @@ ASTNodeFunctionExpressionBuilder::ASTNodeFunctionExpressionBuilder(ASTNode& node ASTNodeNaturalConversionChecker<AllowRToR1Conversion>{function_expression, vector_type}; - if (function_expression.is_type<language::expression_list>()) { - Assert(vector_type.dimension() == function_expression.children.size()); - - for (size_t i = 0; i < vector_type.dimension(); ++i) { - function_processor->addFunctionExpressionProcessor( - this->_getFunctionProcessor(ASTNodeDataType::build<ASTNodeDataType::double_t>(), node, - *function_expression.children[i])); - } - - switch (vector_type.dimension()) { - case 2: { - node.m_node_processor = - std::make_unique<TupleToTinyVectorProcessor<FunctionProcessor, 2>>(node, std::move(function_processor)); - break; - } - case 3: { - node.m_node_processor = - std::make_unique<TupleToTinyVectorProcessor<FunctionProcessor, 3>>(node, std::move(function_processor)); - break; - } - // LCOV_EXCL_START - default: { - throw ParseError("unexpected error: invalid vector_t dimension", std::vector{node.begin()}); - } - // LCOV_EXCL_STOP - } - } else if (function_expression.is_type<language::integer>()) { + if (function_expression.is_type<language::integer>()) { if (std::stoi(function_expression.string()) == 0) { switch (vector_type.dimension()) { case 1: { @@ -628,33 +600,7 @@ ASTNodeFunctionExpressionBuilder::ASTNodeFunctionExpressionBuilder(ASTNode& node ASTNodeNaturalConversionChecker<AllowRToR1Conversion>{function_expression, matrix_type}; - if (function_expression.is_type<language::expression_list>()) { - Assert(matrix_type.numberOfRows() * matrix_type.numberOfColumns() == function_expression.children.size()); - - for (size_t i = 0; i < matrix_type.numberOfRows() * matrix_type.numberOfColumns(); ++i) { - function_processor->addFunctionExpressionProcessor( - this->_getFunctionProcessor(ASTNodeDataType::build<ASTNodeDataType::double_t>(), node, - *function_expression.children[i])); - } - - switch (matrix_type.numberOfRows()) { - case 2: { - node.m_node_processor = - std::make_unique<TupleToTinyMatrixProcessor<FunctionProcessor, 2>>(node, std::move(function_processor)); - break; - } - case 3: { - node.m_node_processor = - std::make_unique<TupleToTinyMatrixProcessor<FunctionProcessor, 3>>(node, std::move(function_processor)); - break; - } - // LCOV_EXCL_START - default: { - throw ParseError("unexpected error: invalid matrix_t dimensions", std::vector{node.begin()}); - } - // LCOV_EXCL_STOP - } - } else if (function_expression.is_type<language::integer>()) { + if (function_expression.is_type<language::integer>()) { if (std::stoi(function_expression.string()) == 0) { switch (matrix_type.numberOfRows()) { case 1: { diff --git a/src/language/node_processor/AffectationProcessor.hpp b/src/language/node_processor/AffectationProcessor.hpp index 6b764b8d8a0d013b1170f754cb6d551e68ab0fff..e12d985add1cc54dda9ff6bb090146bef692b434 100644 --- a/src/language/node_processor/AffectationProcessor.hpp +++ b/src/language/node_processor/AffectationProcessor.hpp @@ -123,43 +123,6 @@ class AffectationExecutor final : public IAffectationExecutor if constexpr (std::is_same_v<OperatorT, language::eq_op>) { if constexpr (std::is_convertible_v<DataT, ValueT>) { m_lhs = std::get<DataT>(rhs); - } else if constexpr (std::is_same_v<DataT, AggregateDataVariant>) { - const AggregateDataVariant& v = std::get<AggregateDataVariant>(rhs); - if constexpr (is_tiny_vector_v<ValueT>) { - for (size_t i = 0; i < m_lhs.dimension(); ++i) { - std::visit( - [&](auto&& vi) { - using Vi_T = std::decay_t<decltype(vi)>; - if constexpr (std::is_convertible_v<Vi_T, double>) { - m_lhs[i] = vi; - } else { - // LCOV_EXCL_START - throw UnexpectedError("unexpected rhs type in affectation"); - // LCOV_EXCL_STOP - } - }, - v[i]); - } - } else if constexpr (is_tiny_matrix_v<ValueT>) { - for (size_t i = 0, l = 0; i < m_lhs.numberOfRows(); ++i) { - for (size_t j = 0; j < m_lhs.numberOfColumns(); ++j, ++l) { - std::visit( - [&](auto&& Aij) { - using Aij_T = std::decay_t<decltype(Aij)>; - if constexpr (std::is_convertible_v<Aij_T, double>) { - m_lhs(i, j) = Aij; - } else { - // LCOV_EXCL_START - throw UnexpectedError("unexpected rhs type in affectation"); - // LCOV_EXCL_STOP - } - }, - v[l]); - } - } - } else { - static_assert(is_tiny_matrix_v<ValueT> or is_tiny_vector_v<ValueT>, "invalid rhs type"); - } } else if constexpr (std::is_same_v<TinyVector<1>, ValueT>) { std::visit( [&](auto&& v) { @@ -264,88 +227,6 @@ class AffectationToDataVariantProcessorBase : public INodeProcessor virtual ~AffectationToDataVariantProcessorBase() = default; }; -template <typename OperatorT, typename ValueT> -class AffectationToTinyVectorFromListProcessor final : public AffectationToDataVariantProcessorBase -{ - private: - ASTNode& m_rhs_node; - - public: - DataVariant - execute(ExecutionPolicy& exec_policy) - { - AggregateDataVariant children_values = std::get<AggregateDataVariant>(m_rhs_node.execute(exec_policy)); - - static_assert(std::is_same_v<OperatorT, language::eq_op>, "forbidden affection operator for list to vectors"); - - ValueT v; - for (size_t i = 0; i < v.dimension(); ++i) { - std::visit( - [&](auto&& child_value) { - using T = std::decay_t<decltype(child_value)>; - if constexpr (std::is_same_v<T, bool> or std::is_same_v<T, uint64_t> or std::is_same_v<T, int64_t> or - std::is_same_v<T, double>) { - v[i] = child_value; - } else { - // LCOV_EXCL_START - throw ParseError("unexpected error: unexpected right hand side type in affectation", m_rhs_node.begin()); - // LCOV_EXCL_STOP - } - }, - children_values[i]); - } - - *m_lhs = v; - return {}; - } - - AffectationToTinyVectorFromListProcessor(ASTNode& lhs_node, ASTNode& rhs_node) - : AffectationToDataVariantProcessorBase(lhs_node), m_rhs_node{rhs_node} - {} -}; - -template <typename OperatorT, typename ValueT> -class AffectationToTinyMatrixFromListProcessor final : public AffectationToDataVariantProcessorBase -{ - private: - ASTNode& m_rhs_node; - - public: - DataVariant - execute(ExecutionPolicy& exec_policy) - { - AggregateDataVariant children_values = std::get<AggregateDataVariant>(m_rhs_node.execute(exec_policy)); - - static_assert(std::is_same_v<OperatorT, language::eq_op>, "forbidden affection operator for list to vectors"); - - ValueT v; - for (size_t i = 0, l = 0; i < v.numberOfRows(); ++i) { - for (size_t j = 0; j < v.numberOfColumns(); ++j, ++l) { - std::visit( - [&](auto&& child_value) { - using T = std::decay_t<decltype(child_value)>; - if constexpr (std::is_same_v<T, bool> or std::is_same_v<T, uint64_t> or std::is_same_v<T, int64_t> or - std::is_same_v<T, double>) { - v(i, j) = child_value; - } else { - // LCOV_EXCL_START - throw ParseError("unexpected error: unexpected right hand side type in affectation", m_rhs_node.begin()); - // LCOV_EXCL_STOP - } - }, - children_values[l]); - } - } - - *m_lhs = v; - return {}; - } - - AffectationToTinyMatrixFromListProcessor(ASTNode& lhs_node, ASTNode& rhs_node) - : AffectationToDataVariantProcessorBase(lhs_node), m_rhs_node{rhs_node} - {} -}; - template <typename ValueT> class AffectationToTupleProcessor final : public AffectationToDataVariantProcessorBase { @@ -429,25 +310,7 @@ class AffectationToTupleFromListProcessor final : public AffectationToDataVarian tuple_value[i] = os.str(); } } else if constexpr (is_tiny_vector_v<ValueT>) { - if constexpr (std::is_same_v<T, AggregateDataVariant>) { - ValueT& v = tuple_value[i]; - Assert(ValueT::Dimension == child_value.size()); - for (size_t j = 0; j < ValueT::Dimension; ++j) { - std::visit( - [&](auto&& vj) { - using Ti = std::decay_t<decltype(vj)>; - if constexpr (std::is_convertible_v<Ti, typename ValueT::data_type>) { - v[j] = vj; - } else { - // LCOV_EXCL_START - throw ParseError("unexpected error: unexpected right hand side type in affectation", - m_rhs_node.children[i]->begin()); - // LCOV_EXCL_STOP - } - }, - child_value[j]); - } - } else if constexpr (std::is_arithmetic_v<T>) { + if constexpr (std::is_arithmetic_v<T>) { if constexpr (std::is_same_v<ValueT, TinyVector<1>>) { tuple_value[i][0] = child_value; } else { @@ -462,27 +325,7 @@ class AffectationToTupleFromListProcessor final : public AffectationToDataVarian // LCOV_EXCL_STOP } } else if constexpr (is_tiny_matrix_v<ValueT>) { - if constexpr (std::is_same_v<T, AggregateDataVariant>) { - ValueT& A = tuple_value[i]; - Assert(A.numberOfRows() * A.numberOfColumns() == child_value.size()); - for (size_t j = 0, l = 0; j < A.numberOfRows(); ++j) { - for (size_t k = 0; k < A.numberOfColumns(); ++k, ++l) { - std::visit( - [&](auto&& Ajk) { - using Ti = std::decay_t<decltype(Ajk)>; - if constexpr (std::is_convertible_v<Ti, typename ValueT::data_type>) { - A(j, k) = Ajk; - } else { - // LCOV_EXCL_START - throw ParseError("unexpected error: unexpected right hand side type in affectation", - m_rhs_node.children[i]->begin()); - // LCOV_EXCL_STOP - } - }, - child_value[l]); - } - } - } else if constexpr (std::is_arithmetic_v<T>) { + if constexpr (std::is_arithmetic_v<T>) { if constexpr (std::is_same_v<ValueT, TinyMatrix<1>>) { tuple_value[i](0, 0) = child_value; } else { diff --git a/src/language/node_processor/FunctionProcessor.hpp b/src/language/node_processor/FunctionProcessor.hpp index 16e65e6e1e1ca63a7e1fa57e109856b3da25610a..c5313a0ea3567f85d375ad107c5a9a183ac6cf23 100644 --- a/src/language/node_processor/FunctionProcessor.hpp +++ b/src/language/node_processor/FunctionProcessor.hpp @@ -20,38 +20,6 @@ class FunctionExpressionProcessor final : public INodeProcessor { if constexpr (std::is_same_v<ReturnType, ExpressionValueType>) { return m_function_expression.execute(exec_policy); - } else if constexpr (std::is_same_v<AggregateDataVariant, ExpressionValueType>) { - static_assert(is_tiny_vector_v<ReturnType> or is_tiny_matrix_v<ReturnType>, "unexpected return type"); - ReturnType return_value{}; - auto value = std::get<ExpressionValueType>(m_function_expression.execute(exec_policy)); - if constexpr (is_tiny_vector_v<ReturnType>) { - for (size_t i = 0; i < ReturnType::Dimension; ++i) { - std::visit( - [&](auto&& vi) { - using Vi_T = std::decay_t<decltype(vi)>; - if constexpr (std::is_convertible_v<Vi_T, double>) { - return_value[i] = vi; - } - }, - value[i]); - } - } else { - static_assert(is_tiny_matrix_v<ReturnType>); - - for (size_t i = 0, l = 0; i < return_value.numberOfRows(); ++i) { - for (size_t j = 0; j < return_value.numberOfColumns(); ++j, ++l) { - std::visit( - [&](auto&& Aij) { - using Vi_T = std::decay_t<decltype(Aij)>; - if constexpr (std::is_convertible_v<Vi_T, double>) { - return_value(i, j) = Aij; - } - }, - value[l]); - } - } - } - return return_value; } else if constexpr (std::is_same_v<ReturnType, std::string>) { return std::to_string(std::get<ExpressionValueType>(m_function_expression.execute(exec_policy))); } else if constexpr (std::is_same_v<ExpressionValueType, ZeroType>) { diff --git a/src/language/node_processor/TupleToTinyMatrixProcessor.hpp b/src/language/node_processor/TupleToTinyMatrixProcessor.hpp deleted file mode 100644 index 77bc45e8419f7d2e58447247aef3975c337813c5..0000000000000000000000000000000000000000 --- a/src/language/node_processor/TupleToTinyMatrixProcessor.hpp +++ /dev/null @@ -1,53 +0,0 @@ -#ifndef TUPLE_TO_TINY_MATRIX_PROCESSOR_HPP -#define TUPLE_TO_TINY_MATRIX_PROCESSOR_HPP - -#include <language/ast/ASTNode.hpp> -#include <language/node_processor/INodeProcessor.hpp> - -template <typename TupleProcessorT, size_t N> -class TupleToTinyMatrixProcessor final : public INodeProcessor -{ - private: - ASTNode& m_node; - - std::unique_ptr<TupleProcessorT> m_tuple_processor; - - public: - DataVariant - execute(ExecutionPolicy& exec_policy) - { - AggregateDataVariant v = std::get<AggregateDataVariant>(m_tuple_processor->execute(exec_policy)); - - Assert(v.size() == N * N); - - TinyMatrix<N> A; - - for (size_t i = 0, l = 0; i < N; ++i) { - for (size_t j = 0; j < N; ++j, ++l) { - std::visit( - [&](auto&& Aij) { - using ValueT = std::decay_t<decltype(Aij)>; - if constexpr (std::is_arithmetic_v<ValueT>) { - A(i, j) = Aij; - } else { - // LCOV_EXCL_START - Assert(false, "unexpected value type"); - // LCOV_EXCL_STOP - } - }, - v[l]); - } - } - - return DataVariant{std::move(A)}; - } - - TupleToTinyMatrixProcessor(ASTNode& node) : m_node{node}, m_tuple_processor{std::make_unique<TupleProcessorT>(node)} - {} - - TupleToTinyMatrixProcessor(ASTNode& node, std::unique_ptr<TupleProcessorT>&& tuple_processor) - : m_node{node}, m_tuple_processor{std::move(tuple_processor)} - {} -}; - -#endif // TUPLE_TO_TINY_MATRIX_PROCESSOR_HPP diff --git a/src/language/node_processor/TupleToTinyVectorProcessor.hpp b/src/language/node_processor/TupleToTinyVectorProcessor.hpp deleted file mode 100644 index da4f1e08dc0351e43df185e13415669f1ef26b44..0000000000000000000000000000000000000000 --- a/src/language/node_processor/TupleToTinyVectorProcessor.hpp +++ /dev/null @@ -1,51 +0,0 @@ -#ifndef TUPLE_TO_TINY_VECTOR_PROCESSOR_HPP -#define TUPLE_TO_TINY_VECTOR_PROCESSOR_HPP - -#include <language/ast/ASTNode.hpp> -#include <language/node_processor/INodeProcessor.hpp> - -template <typename TupleProcessorT, size_t N> -class TupleToTinyVectorProcessor final : public INodeProcessor -{ - private: - ASTNode& m_node; - - std::unique_ptr<TupleProcessorT> m_tuple_processor; - - public: - DataVariant - execute(ExecutionPolicy& exec_policy) - { - AggregateDataVariant v = std::get<AggregateDataVariant>(m_tuple_processor->execute(exec_policy)); - - Assert(v.size() == N); - - TinyVector<N> x; - - for (size_t i = 0; i < N; ++i) { - std::visit( - [&](auto&& v) { - using ValueT = std::decay_t<decltype(v)>; - if constexpr (std::is_arithmetic_v<ValueT>) { - x[i] = v; - } else { - // LCOV_EXCL_START - Assert(false, "unexpected value type"); - // LCOV_EXCL_STOP - } - }, - v[i]); - } - - return DataVariant{std::move(x)}; - } - - TupleToTinyVectorProcessor(ASTNode& node) : m_node{node}, m_tuple_processor{std::make_unique<TupleProcessorT>(node)} - {} - - TupleToTinyVectorProcessor(ASTNode& node, std::unique_ptr<TupleProcessorT>&& tuple_processor) - : m_node{node}, m_tuple_processor{std::move(tuple_processor)} - {} -}; - -#endif // TUPLE_TO_TINY_VECTOR_PROCESSOR_HPP diff --git a/src/language/utils/ASTNodeNaturalConversionChecker.cpp b/src/language/utils/ASTNodeNaturalConversionChecker.cpp index a05c5aa1b4fcc79d531ea51544fb47dc1b40698e..44182f0424f8c088b3d555ef467f1f4fede7d4f3 100644 --- a/src/language/utils/ASTNodeNaturalConversionChecker.cpp +++ b/src/language/utils/ASTNodeNaturalConversionChecker.cpp @@ -48,23 +48,9 @@ ASTNodeNaturalConversionChecker<RToR1Conversion>::_checkIsNaturalExpressionConve } else if (target_data_type == ASTNodeDataType::vector_t) { switch (data_type) { case ASTNodeDataType::list_t: { - const auto& content_type_list = data_type.contentTypeList(); - if (content_type_list.size() != target_data_type.dimension()) { - std::ostringstream os; - os << "incompatible dimensions in affectation: expecting " << target_data_type.dimension() << ", but provided " - << content_type_list.size(); - throw ParseError(os.str(), std::vector{node.begin()}); - } - - Assert(content_type_list.size() == node.children.size()); - for (size_t i = 0; i < content_type_list.size(); ++i) { - const auto& child_type = *content_type_list[i]; - const auto& child_node = *node.children[i]; - Assert(child_type == child_node.m_data_type); - this->_checkIsNaturalExpressionConversion(child_node, child_type, - ASTNodeDataType::build<ASTNodeDataType::double_t>()); - } - + std::ostringstream os; + os << "cannot convert list to " << dataTypeName(target_data_type); + throw ParseError(os.str(), std::vector{node.begin()}); break; } case ASTNodeDataType::vector_t: { @@ -92,24 +78,9 @@ ASTNodeNaturalConversionChecker<RToR1Conversion>::_checkIsNaturalExpressionConve } else if (target_data_type == ASTNodeDataType::matrix_t) { switch (data_type) { case ASTNodeDataType::list_t: { - const auto& content_type_list = data_type.contentTypeList(); - if (content_type_list.size() != (target_data_type.numberOfRows() * target_data_type.numberOfColumns())) { - std::ostringstream os; - os << "incompatible dimensions in affectation: expecting " - << target_data_type.numberOfRows() * target_data_type.numberOfColumns() << ", but provided " - << content_type_list.size(); - throw ParseError(os.str(), std::vector{node.begin()}); - } - - Assert(content_type_list.size() == node.children.size()); - for (size_t i = 0; i < content_type_list.size(); ++i) { - const auto& child_type = *content_type_list[i]; - const auto& child_node = *node.children[i]; - Assert(child_type == child_node.m_data_type); - this->_checkIsNaturalExpressionConversion(child_node, child_type, - ASTNodeDataType::build<ASTNodeDataType::double_t>()); - } - + std::ostringstream os; + os << "cannot convert list to " << dataTypeName(target_data_type); + throw ParseError(os.str(), std::vector{node.begin()}); break; } case ASTNodeDataType::matrix_t: { diff --git a/src/language/utils/AffectationProcessorBuilder.hpp b/src/language/utils/AffectationProcessorBuilder.hpp index 0e4b7ace65654b650989e817dbe2e4a545ae320f..ed1995106225f6c04ce583a4e8ef257fca54b038 100644 --- a/src/language/utils/AffectationProcessorBuilder.hpp +++ b/src/language/utils/AffectationProcessorBuilder.hpp @@ -56,30 +56,6 @@ class AffectationToTupleFromListProcessorBuilder final : public IAffectationProc } }; -template <typename OperatorT, typename ValueT> -class AffectationToTinyVectorFromListProcessorBuilder final : public IAffectationProcessorBuilder -{ - public: - AffectationToTinyVectorFromListProcessorBuilder() = default; - std::unique_ptr<INodeProcessor> - getNodeProcessor(ASTNode& lhs_node, ASTNode& rhs_node) const final - { - return std::make_unique<AffectationToTinyVectorFromListProcessor<OperatorT, ValueT>>(lhs_node, rhs_node); - } -}; - -template <typename OperatorT, typename ValueT> -class AffectationToTinyMatrixFromListProcessorBuilder final : public IAffectationProcessorBuilder -{ - public: - AffectationToTinyMatrixFromListProcessorBuilder() = default; - std::unique_ptr<INodeProcessor> - getNodeProcessor(ASTNode& lhs_node, ASTNode& rhs_node) const final - { - return std::make_unique<AffectationToTinyMatrixFromListProcessor<OperatorT, ValueT>>(lhs_node, rhs_node); - } -}; - template <typename OperatorT, typename ValueT> class AffectationFromZeroProcessorBuilder final : public IAffectationProcessorBuilder { diff --git a/src/language/utils/AffectationRegisterForRn.cpp b/src/language/utils/AffectationRegisterForRn.cpp index 7d38dc64c1d245d4d6c530e891ffd6eaecd63372..180bd5ebce8d19dd8aa6f4b628a700632ea44ab0 100644 --- a/src/language/utils/AffectationRegisterForRn.cpp +++ b/src/language/utils/AffectationRegisterForRn.cpp @@ -16,12 +16,6 @@ AffectationRegisterForRn<Dimension>::_register_eq_op() language::eq_op>(Rn, ASTNodeDataType::build<ASTNodeDataType::int_t>(), std::make_shared<AffectationFromZeroProcessorBuilder<language::eq_op, TinyVector<Dimension>>>()); - repository.addAffectation<language::eq_op>(Rn, - ASTNodeDataType::build<ASTNodeDataType::list_t>( - std::vector<std::shared_ptr<const ASTNodeDataType>>{}), - std::make_shared<AffectationToTinyVectorFromListProcessorBuilder< - language::eq_op, TinyVector<Dimension>>>()); - repository .addAffectation<language::eq_op>(ASTNodeDataType::build<ASTNodeDataType::tuple_t>(Rn), ASTNodeDataType::build<ASTNodeDataType::int_t>(), diff --git a/src/language/utils/AffectationRegisterForRnxn.cpp b/src/language/utils/AffectationRegisterForRnxn.cpp index efa95d92bbcfd32af37f6c3f69477d7ee985a560..0eaf1c6af2e0caccf0fa143208c774a047d6e550 100644 --- a/src/language/utils/AffectationRegisterForRnxn.cpp +++ b/src/language/utils/AffectationRegisterForRnxn.cpp @@ -16,12 +16,6 @@ AffectationRegisterForRnxn<Dimension>::_register_eq_op() language::eq_op>(Rnxn, ASTNodeDataType::build<ASTNodeDataType::int_t>(), std::make_shared<AffectationFromZeroProcessorBuilder<language::eq_op, TinyMatrix<Dimension>>>()); - repository.addAffectation<language::eq_op>(Rnxn, - ASTNodeDataType::build<ASTNodeDataType::list_t>( - std::vector<std::shared_ptr<const ASTNodeDataType>>{}), - std::make_shared<AffectationToTinyMatrixFromListProcessorBuilder< - language::eq_op, TinyMatrix<Dimension>>>()); - repository .addAffectation<language::eq_op>(ASTNodeDataType::build<ASTNodeDataType::tuple_t>(Rnxn), ASTNodeDataType::build<ASTNodeDataType::int_t>(), diff --git a/tests/test_ASTNodeAffectationExpressionBuilder.cpp b/tests/test_ASTNodeAffectationExpressionBuilder.cpp index 81ff4f95cffb91fe3352ff5560043d75a309e700..edd68ca67131579b980faa728959f854dea2dcf4 100644 --- a/tests/test_ASTNodeAffectationExpressionBuilder.cpp +++ b/tests/test_ASTNodeAffectationExpressionBuilder.cpp @@ -486,17 +486,17 @@ let y : R^2, y = x; CHECK_AST(data, result); } - SECTION("R^2 <- (.,.)") + SECTION("R^2 <- value") { std::string_view data = R"( -let y : R^2, y = (0,1); +let y : R^2, y = [0,1]; )"; std::string_view result = R"( (root:ASTNodeListProcessor) - `-(language::eq_op:AffectationToTinyVectorFromListProcessor<language::eq_op, TinyVector<2ul, double> >) + `-(language::eq_op:AffectationProcessor<language::eq_op, TinyVector<2ul, double>, TinyVector<2ul, double> >) +-(language::name:y:NameProcessor) - `-(language::expression_list:ASTNodeExpressionListProcessor) + `-(language::vector_expression:TinyVectorExpressionProcessor<2ul>) +-(language::integer:0:ValueProcessor) `-(language::integer:1:ValueProcessor) )"; @@ -553,17 +553,17 @@ let x : R^3, x = 0; CHECK_AST(data, result); } - SECTION("R^3 <- (.,.)") + SECTION("R^3 <- value") { std::string_view data = R"( -let y : R^3, y = (1,2,3); +let y : R^3, y = [1,2,3]; )"; std::string_view result = R"( (root:ASTNodeListProcessor) - `-(language::eq_op:AffectationToTinyVectorFromListProcessor<language::eq_op, TinyVector<3ul, double> >) + `-(language::eq_op:AffectationProcessor<language::eq_op, TinyVector<3ul, double>, TinyVector<3ul, double> >) +-(language::name:y:NameProcessor) - `-(language::expression_list:ASTNodeExpressionListProcessor) + `-(language::vector_expression:TinyVectorExpressionProcessor<3ul>) +-(language::integer:1:ValueProcessor) +-(language::integer:2:ValueProcessor) `-(language::integer:3:ValueProcessor) @@ -767,24 +767,24 @@ let t : (R), t = (2, 3.1, 5); SECTION("R^d tuples") { std::string_view data = R"( -let a : R^2, a = (2,3.1); -let t1 : (R^2), t1 = (a, (1,2), 0); +let a : R^2, a = [2,3.1]; +let t1 : (R^2), t1 = (a, [1,2], 0); let t2 : (R^3), t2 = (0, 0); let t3 : (R^1), t3 = (1, 2.3, 0); )"; std::string_view result = R"( (root:ASTNodeListProcessor) - +-(language::eq_op:AffectationToTinyVectorFromListProcessor<language::eq_op, TinyVector<2ul, double> >) + +-(language::eq_op:AffectationProcessor<language::eq_op, TinyVector<2ul, double>, TinyVector<2ul, double> >) | +-(language::name:a:NameProcessor) - | `-(language::expression_list:ASTNodeExpressionListProcessor) + | `-(language::vector_expression:TinyVectorExpressionProcessor<2ul>) | +-(language::integer:2:ValueProcessor) | `-(language::real:3.1:ValueProcessor) +-(language::eq_op:AffectationToTupleFromListProcessor<TinyVector<2ul, double> >) | +-(language::name:t1:NameProcessor) | `-(language::expression_list:ASTNodeExpressionListProcessor) | +-(language::name:a:NameProcessor) - | +-(language::tuple_expression:TupleToVectorProcessor<ASTNodeExpressionListProcessor>) + | +-(language::vector_expression:TinyVectorExpressionProcessor<2ul>) | | +-(language::integer:1:ValueProcessor) | | `-(language::integer:2:ValueProcessor) | `-(language::integer:0:ValueProcessor) @@ -800,7 +800,6 @@ let t3 : (R^1), t3 = (1, 2.3, 0); +-(language::real:2.3:ValueProcessor) `-(language::integer:0:ValueProcessor) )"; - CHECK_AST(data, result); } @@ -916,7 +915,7 @@ let t : (R), t = 3.1; SECTION("R^d tuples") { std::string_view data = R"( -let a : R^2, a = (2,3.1); +let a : R^2, a = [2,3.1]; let t1 : (R^2), t1 = a; let t2 : (R^3), t2 = 0; let t3 : (R^1), t3 = 2.3; @@ -924,9 +923,9 @@ let t3 : (R^1), t3 = 2.3; std::string_view result = R"( (root:ASTNodeListProcessor) - +-(language::eq_op:AffectationToTinyVectorFromListProcessor<language::eq_op, TinyVector<2ul, double> >) + +-(language::eq_op:AffectationProcessor<language::eq_op, TinyVector<2ul, double>, TinyVector<2ul, double> >) | +-(language::name:a:NameProcessor) - | `-(language::expression_list:ASTNodeExpressionListProcessor) + | `-(language::vector_expression:TinyVectorExpressionProcessor<2ul>) | +-(language::integer:2:ValueProcessor) | `-(language::real:3.1:ValueProcessor) +-(language::eq_op:AffectationToTupleProcessor<TinyVector<2ul, double> >) diff --git a/tests/test_ASTNodeBinaryOperatorExpressionBuilder.cpp b/tests/test_ASTNodeBinaryOperatorExpressionBuilder.cpp index 175093d61f214c4bf0d793a5ccf4fea26126f1d4..ee402307f95b0323bd726b0e093a1bb9af6e8f99 100644 --- a/tests/test_ASTNodeBinaryOperatorExpressionBuilder.cpp +++ b/tests/test_ASTNodeBinaryOperatorExpressionBuilder.cpp @@ -169,15 +169,15 @@ let x : R^1, x = 3.7; SECTION("R^2") { std::string_view data = R"( -let x : R^2, x = (3.2,6); +let x : R^2, x = [3.2,6]; 2*x; )"; std::string_view result = R"( (root:ASTNodeListProcessor) - +-(language::eq_op:AffectationToTinyVectorFromListProcessor<language::eq_op, TinyVector<2ul, double> >) + +-(language::eq_op:AffectationProcessor<language::eq_op, TinyVector<2ul, double>, TinyVector<2ul, double> >) | +-(language::name:x:NameProcessor) - | `-(language::expression_list:ASTNodeExpressionListProcessor) + | `-(language::vector_expression:TinyVectorExpressionProcessor<2ul>) | +-(language::real:3.2:ValueProcessor) | `-(language::integer:6:ValueProcessor) `-(language::multiply_op:BinaryExpressionProcessor<language::multiply_op, TinyVector<2ul, double>, long, TinyVector<2ul, double> >) @@ -191,15 +191,15 @@ let x : R^2, x = (3.2,6); SECTION("R^3") { std::string_view data = R"( -let x : R^3, x = (3.2,6,1.2); +let x : R^3, x = [3.2,6,1.2]; 2*x; )"; std::string_view result = R"( (root:ASTNodeListProcessor) - +-(language::eq_op:AffectationToTinyVectorFromListProcessor<language::eq_op, TinyVector<3ul, double> >) + +-(language::eq_op:AffectationProcessor<language::eq_op, TinyVector<3ul, double>, TinyVector<3ul, double> >) | +-(language::name:x:NameProcessor) - | `-(language::expression_list:ASTNodeExpressionListProcessor) + | `-(language::vector_expression:TinyVectorExpressionProcessor<3ul>) | +-(language::real:3.2:ValueProcessor) | +-(language::integer:6:ValueProcessor) | `-(language::real:1.2:ValueProcessor) @@ -381,7 +381,7 @@ a+3+a; CHECK_AST(data, result); } - SECTION("R^1") + SECTION("R^1 with variables") { std::string_view data = R"( let x : R^1, x = 1; @@ -405,24 +405,42 @@ x+y; CHECK_AST(data, result); } - SECTION("R^2") + SECTION("R^1 raw") + { + std::string_view data = R"( +[1]+[2]; +)"; + + std::string_view result = R"( +(root:ASTNodeListProcessor) + `-(language::plus_op:BinaryExpressionProcessor<language::plus_op, TinyVector<1ul, double>, TinyVector<1ul, double>, TinyVector<1ul, double> >) + +-(language::vector_expression:TinyVectorExpressionProcessor<1ul>) + | `-(language::integer:1:ValueProcessor) + `-(language::vector_expression:TinyVectorExpressionProcessor<1ul>) + `-(language::integer:2:ValueProcessor) +)"; + + CHECK_AST(data, result); + } + + SECTION("R^2 with variables") { std::string_view data = R"( -let x : R^2, x = (1,2); -let y : R^2, y = (0.3,0.7); +let x : R^2, x = [1,2]; +let y : R^2, y = [0.3,0.7]; x+y; )"; std::string_view result = R"( (root:ASTNodeListProcessor) - +-(language::eq_op:AffectationToTinyVectorFromListProcessor<language::eq_op, TinyVector<2ul, double> >) + +-(language::eq_op:AffectationProcessor<language::eq_op, TinyVector<2ul, double>, TinyVector<2ul, double> >) | +-(language::name:x:NameProcessor) - | `-(language::expression_list:ASTNodeExpressionListProcessor) + | `-(language::vector_expression:TinyVectorExpressionProcessor<2ul>) | +-(language::integer:1:ValueProcessor) | `-(language::integer:2:ValueProcessor) - +-(language::eq_op:AffectationToTinyVectorFromListProcessor<language::eq_op, TinyVector<2ul, double> >) + +-(language::eq_op:AffectationProcessor<language::eq_op, TinyVector<2ul, double>, TinyVector<2ul, double> >) | +-(language::name:y:NameProcessor) - | `-(language::expression_list:ASTNodeExpressionListProcessor) + | `-(language::vector_expression:TinyVectorExpressionProcessor<2ul>) | +-(language::real:0.3:ValueProcessor) | `-(language::real:0.7:ValueProcessor) `-(language::plus_op:BinaryExpressionProcessor<language::plus_op, TinyVector<2ul, double>, TinyVector<2ul, double>, TinyVector<2ul, double> >) @@ -433,25 +451,45 @@ x+y; CHECK_AST(data, result); } - SECTION("R^3") + SECTION("R^2 raw") + { + std::string_view data = R"( +[1,2]+[0.3,0.7]; +)"; + + std::string_view result = R"( +(root:ASTNodeListProcessor) + `-(language::plus_op:BinaryExpressionProcessor<language::plus_op, TinyVector<2ul, double>, TinyVector<2ul, double>, TinyVector<2ul, double> >) + +-(language::vector_expression:TinyVectorExpressionProcessor<2ul>) + | +-(language::integer:1:ValueProcessor) + | `-(language::integer:2:ValueProcessor) + `-(language::vector_expression:TinyVectorExpressionProcessor<2ul>) + +-(language::real:0.3:ValueProcessor) + `-(language::real:0.7:ValueProcessor) +)"; + + CHECK_AST(data, result); + } + + SECTION("R^3 with variables") { std::string_view data = R"( -let x : R^3, x = (1,2,3); -let y : R^3, y = (4,3,2); +let x : R^3, x = [1,2,3]; +let y : R^3, y = [4,3,2]; x+y; )"; std::string_view result = R"( (root:ASTNodeListProcessor) - +-(language::eq_op:AffectationToTinyVectorFromListProcessor<language::eq_op, TinyVector<3ul, double> >) + +-(language::eq_op:AffectationProcessor<language::eq_op, TinyVector<3ul, double>, TinyVector<3ul, double> >) | +-(language::name:x:NameProcessor) - | `-(language::expression_list:ASTNodeExpressionListProcessor) + | `-(language::vector_expression:TinyVectorExpressionProcessor<3ul>) | +-(language::integer:1:ValueProcessor) | +-(language::integer:2:ValueProcessor) | `-(language::integer:3:ValueProcessor) - +-(language::eq_op:AffectationToTinyVectorFromListProcessor<language::eq_op, TinyVector<3ul, double> >) + +-(language::eq_op:AffectationProcessor<language::eq_op, TinyVector<3ul, double>, TinyVector<3ul, double> >) | +-(language::name:y:NameProcessor) - | `-(language::expression_list:ASTNodeExpressionListProcessor) + | `-(language::vector_expression:TinyVectorExpressionProcessor<3ul>) | +-(language::integer:4:ValueProcessor) | +-(language::integer:3:ValueProcessor) | `-(language::integer:2:ValueProcessor) @@ -463,6 +501,28 @@ x+y; CHECK_AST(data, result); } + SECTION("R^3 raw") + { + std::string_view data = R"( +[1,2,3]+[4,3,2]; +)"; + + std::string_view result = R"( +(root:ASTNodeListProcessor) + `-(language::plus_op:BinaryExpressionProcessor<language::plus_op, TinyVector<3ul, double>, TinyVector<3ul, double>, TinyVector<3ul, double> >) + +-(language::vector_expression:TinyVectorExpressionProcessor<3ul>) + | +-(language::integer:1:ValueProcessor) + | +-(language::integer:2:ValueProcessor) + | `-(language::integer:3:ValueProcessor) + `-(language::vector_expression:TinyVectorExpressionProcessor<3ul>) + +-(language::integer:4:ValueProcessor) + +-(language::integer:3:ValueProcessor) + `-(language::integer:2:ValueProcessor) +)"; + + CHECK_AST(data, result); + } + SECTION("string concatenate bool") { std::string_view data = R"( @@ -659,24 +719,42 @@ x-y; CHECK_AST(data, result); } - SECTION("R^2") + SECTION("R^1 raw") { std::string_view data = R"( -let x : R^2, x = (1,2); -let y : R^2, y = (0.3,0.7); +[1]-[2]; +)"; + + std::string_view result = R"( +(root:ASTNodeListProcessor) + `-(language::minus_op:BinaryExpressionProcessor<language::minus_op, TinyVector<1ul, double>, TinyVector<1ul, double>, TinyVector<1ul, double> >) + +-(language::vector_expression:TinyVectorExpressionProcessor<1ul>) + | `-(language::integer:1:ValueProcessor) + `-(language::vector_expression:TinyVectorExpressionProcessor<1ul>) + `-(language::integer:2:ValueProcessor) +)"; + + CHECK_AST(data, result); + } + + SECTION("R^2 with variables") + { + std::string_view data = R"( +let x : R^2, x = [1,2]; +let y : R^2, y = [0.3,0.7]; x-y; )"; std::string_view result = R"( (root:ASTNodeListProcessor) - +-(language::eq_op:AffectationToTinyVectorFromListProcessor<language::eq_op, TinyVector<2ul, double> >) + +-(language::eq_op:AffectationProcessor<language::eq_op, TinyVector<2ul, double>, TinyVector<2ul, double> >) | +-(language::name:x:NameProcessor) - | `-(language::expression_list:ASTNodeExpressionListProcessor) + | `-(language::vector_expression:TinyVectorExpressionProcessor<2ul>) | +-(language::integer:1:ValueProcessor) | `-(language::integer:2:ValueProcessor) - +-(language::eq_op:AffectationToTinyVectorFromListProcessor<language::eq_op, TinyVector<2ul, double> >) + +-(language::eq_op:AffectationProcessor<language::eq_op, TinyVector<2ul, double>, TinyVector<2ul, double> >) | +-(language::name:y:NameProcessor) - | `-(language::expression_list:ASTNodeExpressionListProcessor) + | `-(language::vector_expression:TinyVectorExpressionProcessor<2ul>) | +-(language::real:0.3:ValueProcessor) | `-(language::real:0.7:ValueProcessor) `-(language::minus_op:BinaryExpressionProcessor<language::minus_op, TinyVector<2ul, double>, TinyVector<2ul, double>, TinyVector<2ul, double> >) @@ -687,25 +765,45 @@ x-y; CHECK_AST(data, result); } - SECTION("R^3") + SECTION("R^2 raw") { std::string_view data = R"( -let x : R^3, x = (1,2,3); -let y : R^3, y = (4,3,2); +[1,2]-[0.3,0.7]; +)"; + + std::string_view result = R"( +(root:ASTNodeListProcessor) + `-(language::minus_op:BinaryExpressionProcessor<language::minus_op, TinyVector<2ul, double>, TinyVector<2ul, double>, TinyVector<2ul, double> >) + +-(language::vector_expression:TinyVectorExpressionProcessor<2ul>) + | +-(language::integer:1:ValueProcessor) + | `-(language::integer:2:ValueProcessor) + `-(language::vector_expression:TinyVectorExpressionProcessor<2ul>) + +-(language::real:0.3:ValueProcessor) + `-(language::real:0.7:ValueProcessor) +)"; + + CHECK_AST(data, result); + } + + SECTION("R^3 with variables") + { + std::string_view data = R"( +let x : R^3, x = [1,2,3]; +let y : R^3, y = [4,3,2]; x-y; )"; std::string_view result = R"( (root:ASTNodeListProcessor) - +-(language::eq_op:AffectationToTinyVectorFromListProcessor<language::eq_op, TinyVector<3ul, double> >) + +-(language::eq_op:AffectationProcessor<language::eq_op, TinyVector<3ul, double>, TinyVector<3ul, double> >) | +-(language::name:x:NameProcessor) - | `-(language::expression_list:ASTNodeExpressionListProcessor) + | `-(language::vector_expression:TinyVectorExpressionProcessor<3ul>) | +-(language::integer:1:ValueProcessor) | +-(language::integer:2:ValueProcessor) | `-(language::integer:3:ValueProcessor) - +-(language::eq_op:AffectationToTinyVectorFromListProcessor<language::eq_op, TinyVector<3ul, double> >) + +-(language::eq_op:AffectationProcessor<language::eq_op, TinyVector<3ul, double>, TinyVector<3ul, double> >) | +-(language::name:y:NameProcessor) - | `-(language::expression_list:ASTNodeExpressionListProcessor) + | `-(language::vector_expression:TinyVectorExpressionProcessor<3ul>) | +-(language::integer:4:ValueProcessor) | +-(language::integer:3:ValueProcessor) | `-(language::integer:2:ValueProcessor) @@ -716,6 +814,28 @@ x-y; CHECK_AST(data, result); } + + SECTION("R^3 raw") + { + std::string_view data = R"( +[1,2,3]-[4,3,2]; +)"; + + std::string_view result = R"( +(root:ASTNodeListProcessor) + `-(language::minus_op:BinaryExpressionProcessor<language::minus_op, TinyVector<3ul, double>, TinyVector<3ul, double>, TinyVector<3ul, double> >) + +-(language::vector_expression:TinyVectorExpressionProcessor<3ul>) + | +-(language::integer:1:ValueProcessor) + | +-(language::integer:2:ValueProcessor) + | `-(language::integer:3:ValueProcessor) + `-(language::vector_expression:TinyVectorExpressionProcessor<3ul>) + +-(language::integer:4:ValueProcessor) + +-(language::integer:3:ValueProcessor) + `-(language::integer:2:ValueProcessor) +)"; + + CHECK_AST(data, result); + } } SECTION("or") @@ -1172,8 +1292,7 @@ a == 3; { std::string_view data = R"( let x : R^1, x = 1; -let y : R^1, y = 2; -x==y; +x==[2]; )"; std::string_view result = R"( @@ -1181,12 +1300,10 @@ x==y; +-(language::eq_op:AffectationProcessor<language::eq_op, TinyVector<1ul, double>, long>) | +-(language::name:x:NameProcessor) | `-(language::integer:1:ValueProcessor) - +-(language::eq_op:AffectationProcessor<language::eq_op, TinyVector<1ul, double>, long>) - | +-(language::name:y:NameProcessor) - | `-(language::integer:2:ValueProcessor) `-(language::eqeq_op:BinaryExpressionProcessor<language::eqeq_op, bool, TinyVector<1ul, double>, TinyVector<1ul, double> >) +-(language::name:x:NameProcessor) - `-(language::name:y:NameProcessor) + `-(language::vector_expression:TinyVectorExpressionProcessor<1ul>) + `-(language::integer:2:ValueProcessor) )"; CHECK_AST(data, result); @@ -1195,26 +1312,22 @@ x==y; SECTION("R^2") { std::string_view data = R"( -let x : R^2, x = (1,2); -let y : R^2, y = (0.3,0.7); -x==y; +let x : R^2, x = [1,2]; +x==[0.3,0.7]; )"; std::string_view result = R"( (root:ASTNodeListProcessor) - +-(language::eq_op:AffectationToTinyVectorFromListProcessor<language::eq_op, TinyVector<2ul, double> >) + +-(language::eq_op:AffectationProcessor<language::eq_op, TinyVector<2ul, double>, TinyVector<2ul, double> >) | +-(language::name:x:NameProcessor) - | `-(language::expression_list:ASTNodeExpressionListProcessor) + | `-(language::vector_expression:TinyVectorExpressionProcessor<2ul>) | +-(language::integer:1:ValueProcessor) | `-(language::integer:2:ValueProcessor) - +-(language::eq_op:AffectationToTinyVectorFromListProcessor<language::eq_op, TinyVector<2ul, double> >) - | +-(language::name:y:NameProcessor) - | `-(language::expression_list:ASTNodeExpressionListProcessor) - | +-(language::real:0.3:ValueProcessor) - | `-(language::real:0.7:ValueProcessor) `-(language::eqeq_op:BinaryExpressionProcessor<language::eqeq_op, bool, TinyVector<2ul, double>, TinyVector<2ul, double> >) +-(language::name:x:NameProcessor) - `-(language::name:y:NameProcessor) + `-(language::vector_expression:TinyVectorExpressionProcessor<2ul>) + +-(language::real:0.3:ValueProcessor) + `-(language::real:0.7:ValueProcessor) )"; CHECK_AST(data, result); @@ -1223,28 +1336,24 @@ x==y; SECTION("R^3") { std::string_view data = R"( -let x : R^3, x = (1,2,3); -let y : R^3, y = (4,3,2); -x==y; +let x : R^3, x = [1,2,3]; +x==[4,3,2]; )"; std::string_view result = R"( (root:ASTNodeListProcessor) - +-(language::eq_op:AffectationToTinyVectorFromListProcessor<language::eq_op, TinyVector<3ul, double> >) + +-(language::eq_op:AffectationProcessor<language::eq_op, TinyVector<3ul, double>, TinyVector<3ul, double> >) | +-(language::name:x:NameProcessor) - | `-(language::expression_list:ASTNodeExpressionListProcessor) + | `-(language::vector_expression:TinyVectorExpressionProcessor<3ul>) | +-(language::integer:1:ValueProcessor) | +-(language::integer:2:ValueProcessor) | `-(language::integer:3:ValueProcessor) - +-(language::eq_op:AffectationToTinyVectorFromListProcessor<language::eq_op, TinyVector<3ul, double> >) - | +-(language::name:y:NameProcessor) - | `-(language::expression_list:ASTNodeExpressionListProcessor) - | +-(language::integer:4:ValueProcessor) - | +-(language::integer:3:ValueProcessor) - | `-(language::integer:2:ValueProcessor) `-(language::eqeq_op:BinaryExpressionProcessor<language::eqeq_op, bool, TinyVector<3ul, double>, TinyVector<3ul, double> >) +-(language::name:x:NameProcessor) - `-(language::name:y:NameProcessor) + `-(language::vector_expression:TinyVectorExpressionProcessor<3ul>) + +-(language::integer:4:ValueProcessor) + +-(language::integer:3:ValueProcessor) + `-(language::integer:2:ValueProcessor) )"; CHECK_AST(data, result); @@ -1325,8 +1434,7 @@ a != 3; { std::string_view data = R"( let x : R^1, x = 1; -let y : R^1, y = 2; -x!=y; +x!=[2]; )"; std::string_view result = R"( @@ -1334,12 +1442,10 @@ x!=y; +-(language::eq_op:AffectationProcessor<language::eq_op, TinyVector<1ul, double>, long>) | +-(language::name:x:NameProcessor) | `-(language::integer:1:ValueProcessor) - +-(language::eq_op:AffectationProcessor<language::eq_op, TinyVector<1ul, double>, long>) - | +-(language::name:y:NameProcessor) - | `-(language::integer:2:ValueProcessor) `-(language::not_eq_op:BinaryExpressionProcessor<language::not_eq_op, bool, TinyVector<1ul, double>, TinyVector<1ul, double> >) +-(language::name:x:NameProcessor) - `-(language::name:y:NameProcessor) + `-(language::vector_expression:TinyVectorExpressionProcessor<1ul>) + `-(language::integer:2:ValueProcessor) )"; CHECK_AST(data, result); @@ -1348,26 +1454,22 @@ x!=y; SECTION("R^2") { std::string_view data = R"( -let x : R^2, x = (1,2); -let y : R^2, y = (0.3,0.7); -x!=y; +let x : R^2, x = [1,2]; +x!=[0.3,0.7]; )"; std::string_view result = R"( (root:ASTNodeListProcessor) - +-(language::eq_op:AffectationToTinyVectorFromListProcessor<language::eq_op, TinyVector<2ul, double> >) + +-(language::eq_op:AffectationProcessor<language::eq_op, TinyVector<2ul, double>, TinyVector<2ul, double> >) | +-(language::name:x:NameProcessor) - | `-(language::expression_list:ASTNodeExpressionListProcessor) + | `-(language::vector_expression:TinyVectorExpressionProcessor<2ul>) | +-(language::integer:1:ValueProcessor) | `-(language::integer:2:ValueProcessor) - +-(language::eq_op:AffectationToTinyVectorFromListProcessor<language::eq_op, TinyVector<2ul, double> >) - | +-(language::name:y:NameProcessor) - | `-(language::expression_list:ASTNodeExpressionListProcessor) - | +-(language::real:0.3:ValueProcessor) - | `-(language::real:0.7:ValueProcessor) `-(language::not_eq_op:BinaryExpressionProcessor<language::not_eq_op, bool, TinyVector<2ul, double>, TinyVector<2ul, double> >) +-(language::name:x:NameProcessor) - `-(language::name:y:NameProcessor) + `-(language::vector_expression:TinyVectorExpressionProcessor<2ul>) + +-(language::real:0.3:ValueProcessor) + `-(language::real:0.7:ValueProcessor) )"; CHECK_AST(data, result); @@ -1376,28 +1478,24 @@ x!=y; SECTION("R^3") { std::string_view data = R"( -let x : R^3, x = (1,2,3); -let y : R^3, y = (4,3,2); -x!=y; +let x : R^3, x = [1,2,3]; +x!=[4,3,2]; )"; std::string_view result = R"( (root:ASTNodeListProcessor) - +-(language::eq_op:AffectationToTinyVectorFromListProcessor<language::eq_op, TinyVector<3ul, double> >) + +-(language::eq_op:AffectationProcessor<language::eq_op, TinyVector<3ul, double>, TinyVector<3ul, double> >) | +-(language::name:x:NameProcessor) - | `-(language::expression_list:ASTNodeExpressionListProcessor) + | `-(language::vector_expression:TinyVectorExpressionProcessor<3ul>) | +-(language::integer:1:ValueProcessor) | +-(language::integer:2:ValueProcessor) | `-(language::integer:3:ValueProcessor) - +-(language::eq_op:AffectationToTinyVectorFromListProcessor<language::eq_op, TinyVector<3ul, double> >) - | +-(language::name:y:NameProcessor) - | `-(language::expression_list:ASTNodeExpressionListProcessor) - | +-(language::integer:4:ValueProcessor) - | +-(language::integer:3:ValueProcessor) - | `-(language::integer:2:ValueProcessor) `-(language::not_eq_op:BinaryExpressionProcessor<language::not_eq_op, bool, TinyVector<3ul, double>, TinyVector<3ul, double> >) +-(language::name:x:NameProcessor) - `-(language::name:y:NameProcessor) + `-(language::vector_expression:TinyVectorExpressionProcessor<3ul>) + +-(language::integer:4:ValueProcessor) + +-(language::integer:3:ValueProcessor) + `-(language::integer:2:ValueProcessor) )"; CHECK_AST(data, result); diff --git a/tests/test_ASTNodeBuiltinFunctionExpressionBuilder.cpp b/tests/test_ASTNodeBuiltinFunctionExpressionBuilder.cpp index 7fb68cd69c16331c07db8354a40dcb029fcb5c14..7c96baebb0ad6b9771bda10b7065dd72208b5b09 100644 --- a/tests/test_ASTNodeBuiltinFunctionExpressionBuilder.cpp +++ b/tests/test_ASTNodeBuiltinFunctionExpressionBuilder.cpp @@ -474,10 +474,10 @@ R2toR(0); CHECK_AST(data, result); } - SECTION("from R^2") + SECTION("from R^2 variable") { std::string_view data = R"( -let x:R^2, x = (1,2); +let x:R^2, x = [1,2]; R2toR(x); )"; @@ -491,17 +491,17 @@ R2toR(x); CHECK_AST(data, result); } - SECTION("from list") + SECTION("from R^2 value") { std::string_view data = R"( -R2toR((1,2)); +R2toR([1,2]); )"; std::string_view result = R"( (root:ASTNodeListProcessor) `-(language::function_evaluation:BuiltinFunctionProcessor) +-(language::name:R2toR:FakeProcessor) - `-(language::tuple_expression:TupleToVectorProcessor<ASTNodeExpressionListProcessor>) + `-(language::vector_expression:TinyVectorExpressionProcessor<2ul>) +-(language::integer:1:ValueProcessor) `-(language::integer:2:ValueProcessor) )"; @@ -528,10 +528,10 @@ R22toR(0); CHECK_AST(data, result); } - SECTION("from R^2x2") + SECTION("from R^2x2 variable") { std::string_view data = R"( -let x:R^2x2, x = (1,2,3,4); +let x:R^2x2, x = [[1,2],[3,4]]; R22toR(x); )"; @@ -545,21 +545,23 @@ R22toR(x); CHECK_AST(data, result); } - SECTION("from list") + SECTION("from R^2x2 value") { std::string_view data = R"( -R22toR((1,2,3,4)); +R22toR([[1,2],[3,4]]); )"; std::string_view result = R"( (root:ASTNodeListProcessor) `-(language::function_evaluation:BuiltinFunctionProcessor) +-(language::name:R22toR:FakeProcessor) - `-(language::tuple_expression:TupleToVectorProcessor<ASTNodeExpressionListProcessor>) - +-(language::integer:1:ValueProcessor) - +-(language::integer:2:ValueProcessor) - +-(language::integer:3:ValueProcessor) - `-(language::integer:4:ValueProcessor) + `-(language::matrix_expression:TinyMatrixExpressionProcessor<2ul, 2ul>) + +-(language::row_expression:FakeProcessor) + | +-(language::integer:1:ValueProcessor) + | `-(language::integer:2:ValueProcessor) + `-(language::row_expression:FakeProcessor) + +-(language::integer:3:ValueProcessor) + `-(language::integer:4:ValueProcessor) )"; CHECK_AST(data, result); @@ -584,10 +586,10 @@ R3toR(0); CHECK_AST(data, result); } - SECTION("from R^3") + SECTION("from R^3 variable") { std::string_view data = R"( -let x:R^3, x = (1,2,4); +let x:R^3, x = [1,2,4]; R3toR(x); )"; @@ -601,17 +603,17 @@ R3toR(x); CHECK_AST(data, result); } - SECTION("from list") + SECTION("from R^3 value") { std::string_view data = R"( -R3toR((1,2,3)); +R3toR([1,2,3]); )"; std::string_view result = R"( (root:ASTNodeListProcessor) `-(language::function_evaluation:BuiltinFunctionProcessor) +-(language::name:R3toR:FakeProcessor) - `-(language::tuple_expression:TupleToVectorProcessor<ASTNodeExpressionListProcessor>) + `-(language::vector_expression:TinyVectorExpressionProcessor<3ul>) +-(language::integer:1:ValueProcessor) +-(language::integer:2:ValueProcessor) `-(language::integer:3:ValueProcessor) @@ -639,10 +641,10 @@ R33toR(0); CHECK_AST(data, result); } - SECTION("from R^3x3") + SECTION("from R^3x3 variable") { std::string_view data = R"( -let x:R^3x3, x = (1,2,3,4,5,6,7,8,9); +let x:R^3x3, x = [[1,2,3],[4,5,6],[7,8,9]]; R33toR(x); )"; @@ -656,26 +658,29 @@ R33toR(x); CHECK_AST(data, result); } - SECTION("from list") + SECTION("from R^3x3 value") { std::string_view data = R"( -R33toR((1,2,3,4,5,6,7,8,9)); +R33toR([[1,2,3],[4,5,6],[7,8,9]]); )"; std::string_view result = R"( (root:ASTNodeListProcessor) `-(language::function_evaluation:BuiltinFunctionProcessor) +-(language::name:R33toR:FakeProcessor) - `-(language::tuple_expression:TupleToVectorProcessor<ASTNodeExpressionListProcessor>) - +-(language::integer:1:ValueProcessor) - +-(language::integer:2:ValueProcessor) - +-(language::integer:3:ValueProcessor) - +-(language::integer:4:ValueProcessor) - +-(language::integer:5:ValueProcessor) - +-(language::integer:6:ValueProcessor) - +-(language::integer:7:ValueProcessor) - +-(language::integer:8:ValueProcessor) - `-(language::integer:9:ValueProcessor) + `-(language::matrix_expression:TinyMatrixExpressionProcessor<3ul, 3ul>) + +-(language::row_expression:FakeProcessor) + | +-(language::integer:1:ValueProcessor) + | +-(language::integer:2:ValueProcessor) + | `-(language::integer:3:ValueProcessor) + +-(language::row_expression:FakeProcessor) + | +-(language::integer:4:ValueProcessor) + | +-(language::integer:5:ValueProcessor) + | `-(language::integer:6:ValueProcessor) + `-(language::row_expression:FakeProcessor) + +-(language::integer:7:ValueProcessor) + +-(language::integer:8:ValueProcessor) + `-(language::integer:9:ValueProcessor) )"; CHECK_AST(data, result); @@ -828,8 +833,8 @@ RRtoB(1., 0.); SECTION("from R^3*R^2") { std::string_view data = R"( -let x : R^3, x = (1,2,3); -let y : R^2, y = (2,3); +let x : R^3, x = [1,2,3]; +let y : R^2, y = [2,3]; R3R2toR(x,y); )"; @@ -845,10 +850,10 @@ R3R2toR(x,y); CHECK_AST(data, result); } - SECTION("from (R,R,R)*(R,R)") + SECTION("from R^3*R^2 value") { std::string_view data = R"( -R3R2toR((1,2,3),(3,4)); +R3R2toR([1,2,3],[3,4]); )"; std::string_view result = R"( @@ -856,11 +861,11 @@ R3R2toR((1,2,3),(3,4)); `-(language::function_evaluation:BuiltinFunctionProcessor) +-(language::name:R3R2toR:FakeProcessor) `-(language::function_argument_list:ASTNodeExpressionListProcessor) - +-(language::tuple_expression:TupleToVectorProcessor<ASTNodeExpressionListProcessor>) + +-(language::vector_expression:TinyVectorExpressionProcessor<3ul>) | +-(language::integer:1:ValueProcessor) | +-(language::integer:2:ValueProcessor) | `-(language::integer:3:ValueProcessor) - `-(language::tuple_expression:TupleToVectorProcessor<ASTNodeExpressionListProcessor>) + `-(language::vector_expression:TinyVectorExpressionProcessor<2ul>) +-(language::integer:3:ValueProcessor) `-(language::integer:4:ValueProcessor) )"; @@ -868,10 +873,10 @@ R3R2toR((1,2,3),(3,4)); CHECK_AST(data, result); } - SECTION("from (R,R,R)*(0)") + SECTION("from R^3*'0'") { std::string_view data = R"( -R3R2toR((1,2,3),0); +R3R2toR([1,2,3],0); )"; std::string_view result = R"( @@ -879,7 +884,7 @@ R3R2toR((1,2,3),0); `-(language::function_evaluation:BuiltinFunctionProcessor) +-(language::name:R3R2toR:FakeProcessor) `-(language::function_argument_list:ASTNodeExpressionListProcessor) - +-(language::tuple_expression:TupleToVectorProcessor<ASTNodeExpressionListProcessor>) + +-(language::vector_expression:TinyVectorExpressionProcessor<3ul>) | +-(language::integer:1:ValueProcessor) | +-(language::integer:2:ValueProcessor) | `-(language::integer:3:ValueProcessor) @@ -895,8 +900,8 @@ R3R2toR((1,2,3),0); SECTION("from R^3x3*R^2x2") { std::string_view data = R"( -let x : R^3x3, x = (1,2,3,4,5,6,7,8,9); -let y : R^2x2, y = (1,2,3,4); +let x : R^3x3, x = [[1,2,3],[4,5,6],[7,8,9]]; +let y : R^2x2, y = [[1,2],[3,4]]; R33R22toR(x,y); )"; @@ -912,10 +917,10 @@ R33R22toR(x,y); CHECK_AST(data, result); } - SECTION("from (R,R,R,R,R,R,R,R,R)*(R,R,R,R)") + SECTION("from R^3x3*R^2x2 value") { std::string_view data = R"( -R33R22toR((1,2,3,4,5,6,7,8,9),(1,2,3,4)); +R33R22toR([[1,2,3],[4,5,6],[7,8,9]],[[1,2],[3,4]]); )"; std::string_view result = R"( @@ -923,30 +928,35 @@ R33R22toR((1,2,3,4,5,6,7,8,9),(1,2,3,4)); `-(language::function_evaluation:BuiltinFunctionProcessor) +-(language::name:R33R22toR:FakeProcessor) `-(language::function_argument_list:ASTNodeExpressionListProcessor) - +-(language::tuple_expression:TupleToVectorProcessor<ASTNodeExpressionListProcessor>) - | +-(language::integer:1:ValueProcessor) - | +-(language::integer:2:ValueProcessor) - | +-(language::integer:3:ValueProcessor) - | +-(language::integer:4:ValueProcessor) - | +-(language::integer:5:ValueProcessor) - | +-(language::integer:6:ValueProcessor) - | +-(language::integer:7:ValueProcessor) - | +-(language::integer:8:ValueProcessor) - | `-(language::integer:9:ValueProcessor) - `-(language::tuple_expression:TupleToVectorProcessor<ASTNodeExpressionListProcessor>) - +-(language::integer:1:ValueProcessor) - +-(language::integer:2:ValueProcessor) - +-(language::integer:3:ValueProcessor) - `-(language::integer:4:ValueProcessor) + +-(language::matrix_expression:TinyMatrixExpressionProcessor<3ul, 3ul>) + | +-(language::row_expression:FakeProcessor) + | | +-(language::integer:1:ValueProcessor) + | | +-(language::integer:2:ValueProcessor) + | | `-(language::integer:3:ValueProcessor) + | +-(language::row_expression:FakeProcessor) + | | +-(language::integer:4:ValueProcessor) + | | +-(language::integer:5:ValueProcessor) + | | `-(language::integer:6:ValueProcessor) + | `-(language::row_expression:FakeProcessor) + | +-(language::integer:7:ValueProcessor) + | +-(language::integer:8:ValueProcessor) + | `-(language::integer:9:ValueProcessor) + `-(language::matrix_expression:TinyMatrixExpressionProcessor<2ul, 2ul>) + +-(language::row_expression:FakeProcessor) + | +-(language::integer:1:ValueProcessor) + | `-(language::integer:2:ValueProcessor) + `-(language::row_expression:FakeProcessor) + +-(language::integer:3:ValueProcessor) + `-(language::integer:4:ValueProcessor) )"; CHECK_AST(data, result); } - SECTION("from (R,R,R,R,R,R,R,R,R)*(0)") + SECTION("from R^3x3*'0'") { std::string_view data = R"( -R33R22toR((1,2,3,4,5,6,7,8,9),0); +R33R22toR([[1,2,3],[4,5,6],[7,8,9]],0); )"; std::string_view result = R"( @@ -954,16 +964,19 @@ R33R22toR((1,2,3,4,5,6,7,8,9),0); `-(language::function_evaluation:BuiltinFunctionProcessor) +-(language::name:R33R22toR:FakeProcessor) `-(language::function_argument_list:ASTNodeExpressionListProcessor) - +-(language::tuple_expression:TupleToVectorProcessor<ASTNodeExpressionListProcessor>) - | +-(language::integer:1:ValueProcessor) - | +-(language::integer:2:ValueProcessor) - | +-(language::integer:3:ValueProcessor) - | +-(language::integer:4:ValueProcessor) - | +-(language::integer:5:ValueProcessor) - | +-(language::integer:6:ValueProcessor) - | +-(language::integer:7:ValueProcessor) - | +-(language::integer:8:ValueProcessor) - | `-(language::integer:9:ValueProcessor) + +-(language::matrix_expression:TinyMatrixExpressionProcessor<3ul, 3ul>) + | +-(language::row_expression:FakeProcessor) + | | +-(language::integer:1:ValueProcessor) + | | +-(language::integer:2:ValueProcessor) + | | `-(language::integer:3:ValueProcessor) + | +-(language::row_expression:FakeProcessor) + | | +-(language::integer:4:ValueProcessor) + | | +-(language::integer:5:ValueProcessor) + | | `-(language::integer:6:ValueProcessor) + | `-(language::row_expression:FakeProcessor) + | +-(language::integer:7:ValueProcessor) + | +-(language::integer:8:ValueProcessor) + | `-(language::integer:9:ValueProcessor) `-(language::integer:0:ValueProcessor) )"; @@ -1514,7 +1527,7 @@ tuple_R2ToR(r); SECTION("compound_list -> tuple(R^2)") { std::string_view data = R"( -let r:R^2, r = (1,2); +let r:R^2, r = [1,2]; tuple_R2ToR((r,r)); )"; @@ -1549,7 +1562,7 @@ tuple_R22ToR(0); SECTION("R^2x2 -> tuple(R^2x2)") { std::string_view data = R"( -let r:R^2x2, r = (1,2,3,4); +let r:R^2x2, r = [[1,2],[3,4]]; tuple_R22ToR(r); )"; @@ -1566,7 +1579,7 @@ tuple_R22ToR(r); SECTION("compound_list -> tuple(R^2x2)") { std::string_view data = R"( -let r:R^2x2, r = (1,2,3,4); +let r:R^2x2, r = [[1,2],[3,4]]; tuple_R22ToR((r,r)); )"; @@ -1601,7 +1614,7 @@ tuple_R3ToR(0); SECTION("R^3 -> tuple(R^3)") { std::string_view data = R"( -let r:R^3, r = (1,2,3); +let r:R^3, r = [1,2,3]; tuple_R3ToR(r); )"; @@ -1634,7 +1647,7 @@ tuple_R33ToR(0); SECTION("R^3x3 -> tuple(R^3x3)") { std::string_view data = R"( -let r:R^3x3, r = (1,2,3,4,5,6,7,8,9); +let r:R^3x3, r = [[1,2,3],[4,5,6],[7,8,9]]; tuple_R33ToR(r); )"; diff --git a/tests/test_ASTNodeDataTypeBuilder.cpp b/tests/test_ASTNodeDataTypeBuilder.cpp index 5dcd6f57cb77dc3e91b8e2e084f98b9143a75f1c..d8921fe051231713af2c2e8e258348098a1db6bb 100644 --- a/tests/test_ASTNodeDataTypeBuilder.cpp +++ b/tests/test_ASTNodeDataTypeBuilder.cpp @@ -743,7 +743,7 @@ let double : R^2 -> R^2, x -> 2*x; SECTION("R-list -> R^d") { std::string_view data = R"( -let square : R -> R^2, x -> (x, x*x); +let square : R -> R^2, x -> [x, x*x]; )"; std::string_view result = R"( @@ -806,7 +806,7 @@ let det : R^2x2 -> R, x -> x[0,0]*x[1,1]-x[1,0]*x[0,1]; SECTION("R-list -> R^dxd") { std::string_view data = R"( -let f : R -> R^2x2, x -> (x, x*x, 2-x, 0); +let f : R -> R^2x2, x -> [[x, x*x], [2-x, 0]]; )"; std::string_view result = R"( @@ -821,7 +821,7 @@ let f : R -> R^2x2, x -> (x, x*x, 2-x, 0); SECTION("R^d*R^d -> R^dxd") { std::string_view data = R"( -let f : R^2*R^2 -> R^2x2, (x,y) -> (x[0], y[0], x[1], y[1]); +let f : R^2*R^2 -> R^2x2, (x,y) -> [[x[0], y[0]], [x[1], y[1]]]; )"; std::string_view result = R"( @@ -1153,8 +1153,8 @@ let f: R -> X, x -> x; SECTION("single argument") { std::string_view data = R"( -let f : R^2 -> R^2, x -> (x[0]+1, x[1]-2); -let x : R^2, x = (1,2); +let f : R^2 -> R^2, x -> [x[0]+1, x[1]-2]; +let x : R^2, x = [1,2]; x = f(x); )"; @@ -1168,7 +1168,7 @@ x = f(x); | | +-(language::R_set:R) | | `-(language::integer:2:Z) | +-(language::name:x:R^2) - | `-(language::expression_list:Z*Z) + | `-(language::vector_expression:R^2) | +-(language::integer:1:Z) | `-(language::integer:2:Z) `-(language::eq_op:void) diff --git a/tests/test_ASTNodeExpressionBuilder.cpp b/tests/test_ASTNodeExpressionBuilder.cpp index 56af1db48dce6019d5cb3fedf93c3e32cfc12e25..127b2e01624a07ba9579494692573106ced0bc9a 100644 --- a/tests/test_ASTNodeExpressionBuilder.cpp +++ b/tests/test_ASTNodeExpressionBuilder.cpp @@ -273,7 +273,7 @@ z -= 2; SECTION("tuple -> R^3") { std::string_view data = R"( -let (t,x): R*R^3, (t,x) = (0,(1,2,3)); +let (t,x): R*R^3, (t,x) = (0,[1,2,3]); )"; std::string result = R"( @@ -284,7 +284,7 @@ let (t,x): R*R^3, (t,x) = (0,(1,2,3)); | `-(language::name:x:NameProcessor) `-(language::expression_list:ASTNodeExpressionListProcessor) +-(language::integer:0:ValueProcessor) - `-(language::tuple_expression:TupleToVectorProcessor<ASTNodeExpressionListProcessor>) + `-(language::vector_expression:TinyVectorExpressionProcessor<3ul>) +-(language::integer:1:ValueProcessor) +-(language::integer:2:ValueProcessor) `-(language::integer:3:ValueProcessor) @@ -296,7 +296,7 @@ let (t,x): R*R^3, (t,x) = (0,(1,2,3)); SECTION("tuple -> R^2") { std::string_view data = R"( -let (t,x): R*R^2, (t,x) = (0,(1,2)); +let (t,x): R*R^2, (t,x) = (0,[1,2]); )"; std::string result = R"( @@ -307,7 +307,7 @@ let (t,x): R*R^2, (t,x) = (0,(1,2)); | `-(language::name:x:NameProcessor) `-(language::expression_list:ASTNodeExpressionListProcessor) +-(language::integer:0:ValueProcessor) - `-(language::tuple_expression:TupleToVectorProcessor<ASTNodeExpressionListProcessor>) + `-(language::vector_expression:TinyVectorExpressionProcessor<2ul>) +-(language::integer:1:ValueProcessor) `-(language::integer:2:ValueProcessor) )"; @@ -466,15 +466,15 @@ a--; SECTION("array subscript") { std::string_view data = R"( -let x: R^3, x = (1, 2, 3); +let x: R^3, x = [1, 2, 3]; let y: R, y = x[2]; )"; std::string result = R"( (root:ASTNodeListProcessor) - +-(language::eq_op:AffectationToTinyVectorFromListProcessor<language::eq_op, TinyVector<3ul, double> >) + +-(language::eq_op:AffectationProcessor<language::eq_op, TinyVector<3ul, double>, TinyVector<3ul, double> >) | +-(language::name:x:NameProcessor) - | `-(language::expression_list:ASTNodeExpressionListProcessor) + | `-(language::vector_expression:TinyVectorExpressionProcessor<3ul>) | +-(language::integer:1:ValueProcessor) | +-(language::integer:2:ValueProcessor) | `-(language::integer:3:ValueProcessor) diff --git a/tests/test_ASTNodeFunctionExpressionBuilder.cpp b/tests/test_ASTNodeFunctionExpressionBuilder.cpp index 4bf775a679490306efecc2617547cb424c6a256b..3429ed5bb152725ee667a96247623628284c1159 100644 --- a/tests/test_ASTNodeFunctionExpressionBuilder.cpp +++ b/tests/test_ASTNodeFunctionExpressionBuilder.cpp @@ -492,13 +492,13 @@ f(1); SECTION("Return tuple -> R^2") { std::string_view data = R"( -let f : R*R -> R^2, (x,y) -> (x,y); +let f : R*R -> R^2, (x,y) -> [x,y]; f(1,2); )"; std::string_view result = R"( (root:ASTNodeListProcessor) - `-(language::function_evaluation:TupleToTinyVectorProcessor<FunctionProcessor, 2ul>) + `-(language::function_evaluation:FunctionProcessor) +-(language::name:f:NameProcessor) `-(language::function_argument_list:ASTNodeExpressionListProcessor) +-(language::integer:1:ValueProcessor) @@ -511,13 +511,13 @@ f(1,2); SECTION("Return tuple -> R^3") { std::string_view data = R"( -let f : R*R*R -> R^3, (x,y,z) -> (x,y,z); +let f : R*R*R -> R^3, (x,y,z) -> [x,y,z]; f(1,2,3); )"; std::string_view result = R"( (root:ASTNodeListProcessor) - `-(language::function_evaluation:TupleToTinyVectorProcessor<FunctionProcessor, 3ul>) + `-(language::function_evaluation:FunctionProcessor) +-(language::name:f:NameProcessor) `-(language::function_argument_list:ASTNodeExpressionListProcessor) +-(language::integer:1:ValueProcessor) @@ -548,13 +548,13 @@ f(1); SECTION("Return tuple -> R^2x2") { std::string_view data = R"( -let f : R*R*R*R -> R^2x2, (x,y,z,t) -> (x,y,z,t); +let f : R*R*R*R -> R^2x2, (x,y,z,t) -> [[x,y],[z,t]]; f(1,2,3,4); )"; std::string_view result = R"( (root:ASTNodeListProcessor) - `-(language::function_evaluation:TupleToTinyMatrixProcessor<FunctionProcessor, 2ul>) + `-(language::function_evaluation:FunctionProcessor) +-(language::name:f:NameProcessor) `-(language::function_argument_list:ASTNodeExpressionListProcessor) +-(language::integer:1:ValueProcessor) @@ -569,24 +569,24 @@ f(1,2,3,4); SECTION("Return tuple -> R^3x3") { std::string_view data = R"( -let f : R^3*R^3*R^3 -> R^3x3, (x,y,z) -> (x[0],x[1],x[2],y[0],y[1],y[2],z[0],z[1],z[2]); -f((1,2,3),(4,5,6),(7,8,9)); +let f : R^3*R^3*R^3 -> R^3x3, (x,y,z) -> [[x[0],x[1],x[2]],[y[0],y[1],y[2]],[z[0],z[1],z[2]]]; +f([1,2,3],[4,5,6],[7,8,9]); )"; std::string_view result = R"( (root:ASTNodeListProcessor) - `-(language::function_evaluation:TupleToTinyMatrixProcessor<FunctionProcessor, 3ul>) + `-(language::function_evaluation:FunctionProcessor) +-(language::name:f:NameProcessor) `-(language::function_argument_list:ASTNodeExpressionListProcessor) - +-(language::tuple_expression:TupleToVectorProcessor<ASTNodeExpressionListProcessor>) + +-(language::vector_expression:TinyVectorExpressionProcessor<3ul>) | +-(language::integer:1:ValueProcessor) | +-(language::integer:2:ValueProcessor) | `-(language::integer:3:ValueProcessor) - +-(language::tuple_expression:TupleToVectorProcessor<ASTNodeExpressionListProcessor>) + +-(language::vector_expression:TinyVectorExpressionProcessor<3ul>) | +-(language::integer:4:ValueProcessor) | +-(language::integer:5:ValueProcessor) | `-(language::integer:6:ValueProcessor) - `-(language::tuple_expression:TupleToVectorProcessor<ASTNodeExpressionListProcessor>) + `-(language::vector_expression:TinyVectorExpressionProcessor<3ul>) +-(language::integer:7:ValueProcessor) +-(language::integer:8:ValueProcessor) `-(language::integer:9:ValueProcessor) @@ -700,7 +700,7 @@ f(1); SECTION("Return embedded R^d compound") { std::string_view data = R"( -let f : R*R*R*R -> R*R^1*R^2*R^3, (x,y,z,t) -> (t, (x), (x,y), (x,y,z)); +let f : R*R*R*R -> R*R^1*R^2*R^3, (x,y,z,t) -> (t, [x], [x,y], [x,y,z]); f(1,2,3,4); )"; @@ -721,7 +721,7 @@ f(1,2,3,4); SECTION("Return embedded R^dxd compound") { std::string_view data = R"( -let f : R*R*R*R -> R*R^1x1*R^2x2*R^3x3, (x,y,z,t) -> (t, (x), (x,y,z,t), (x,y,z, x,x,x, t,t,t)); +let f : R*R*R*R -> R*R^1x1*R^2x2*R^3x3, (x,y,z,t) -> (t, [[x]], [[x,y],[z,t]], [[x,y,z], [x,x,x], [t,t,t]]); f(1,2,3,4); )"; @@ -742,7 +742,7 @@ f(1,2,3,4); SECTION("Return embedded R^d compound with '0'") { std::string_view data = R"( -let f : R*R*R*R -> R*R^1*R^2*R^3, (x,y,z,t) -> (t, 0, 0, (x,y,z)); +let f : R*R*R*R -> R*R^1*R^2*R^3, (x,y,z,t) -> (t, 0, 0, [x,y,z]); f(1,2,3,4); )"; @@ -763,7 +763,7 @@ f(1,2,3,4); SECTION("Return embedded R^dxd compound with '0'") { std::string_view data = R"( -let f : R*R*R*R -> R*R^1x1*R^2x2*R^3x3, (x,y,z,t) -> (t, 0, 0, (x, y, z, t, x, y, z, t, x)); +let f : R*R*R*R -> R*R^1x1*R^2x2*R^3x3, (x,y,z,t) -> (t, 0, 0, [[x, y, z], [t, x, y], [z, t, x]]); f(1,2,3,4); )"; @@ -887,14 +887,14 @@ f(0); { std::string_view data = R"( let f: R^3 -> R, x -> x[0]+x[1]+x[2]; -f((1,2,3)); +f([1,2,3]); )"; std::string_view result = R"( (root:ASTNodeListProcessor) `-(language::function_evaluation:FunctionProcessor) +-(language::name:f:NameProcessor) - `-(language::tuple_expression:TupleToVectorProcessor<ASTNodeExpressionListProcessor>) + `-(language::vector_expression:TinyVectorExpressionProcessor<3ul>) +-(language::integer:1:ValueProcessor) +-(language::integer:2:ValueProcessor) `-(language::integer:3:ValueProcessor) @@ -907,23 +907,26 @@ f((1,2,3)); { std::string_view data = R"( let f: R^3x3 -> R, x -> x[0,0]+x[0,1]+x[0,2]; -f((1,2,3,4,5,6,7,8,9)); +f([[1,2,3],[4,5,6],[7,8,9]]); )"; std::string_view result = R"( (root:ASTNodeListProcessor) `-(language::function_evaluation:FunctionProcessor) +-(language::name:f:NameProcessor) - `-(language::tuple_expression:TupleToVectorProcessor<ASTNodeExpressionListProcessor>) - +-(language::integer:1:ValueProcessor) - +-(language::integer:2:ValueProcessor) - +-(language::integer:3:ValueProcessor) - +-(language::integer:4:ValueProcessor) - +-(language::integer:5:ValueProcessor) - +-(language::integer:6:ValueProcessor) - +-(language::integer:7:ValueProcessor) - +-(language::integer:8:ValueProcessor) - `-(language::integer:9:ValueProcessor) + `-(language::matrix_expression:TinyMatrixExpressionProcessor<3ul, 3ul>) + +-(language::row_expression:FakeProcessor) + | +-(language::integer:1:ValueProcessor) + | +-(language::integer:2:ValueProcessor) + | `-(language::integer:3:ValueProcessor) + +-(language::row_expression:FakeProcessor) + | +-(language::integer:4:ValueProcessor) + | +-(language::integer:5:ValueProcessor) + | `-(language::integer:6:ValueProcessor) + `-(language::row_expression:FakeProcessor) + +-(language::integer:7:ValueProcessor) + +-(language::integer:8:ValueProcessor) + `-(language::integer:9:ValueProcessor) )"; CHECK_AST(data, result); @@ -933,7 +936,7 @@ f((1,2,3,4,5,6,7,8,9)); { std::string_view data = R"( let f: R*R^3*R^2x2->R, (t,x,y) -> t*(x[0]+x[1]+x[2])*y[0,0]+y[1,1]; -f(2,(1,2,3),(2,3,-1,1.3)); +f(2,[1,2,3],[[2,3],[-1,1.3]]); )"; std::string_view result = R"( @@ -942,16 +945,18 @@ f(2,(1,2,3),(2,3,-1,1.3)); +-(language::name:f:NameProcessor) `-(language::function_argument_list:ASTNodeExpressionListProcessor) +-(language::integer:2:ValueProcessor) - +-(language::tuple_expression:TupleToVectorProcessor<ASTNodeExpressionListProcessor>) + +-(language::vector_expression:TinyVectorExpressionProcessor<3ul>) | +-(language::integer:1:ValueProcessor) | +-(language::integer:2:ValueProcessor) | `-(language::integer:3:ValueProcessor) - `-(language::tuple_expression:TupleToVectorProcessor<ASTNodeExpressionListProcessor>) - +-(language::integer:2:ValueProcessor) - +-(language::integer:3:ValueProcessor) - +-(language::unary_minus:UnaryExpressionProcessor<language::unary_minus, long, long>) - | `-(language::integer:1:ValueProcessor) - `-(language::real:1.3:ValueProcessor) + `-(language::matrix_expression:TinyMatrixExpressionProcessor<2ul, 2ul>) + +-(language::row_expression:FakeProcessor) + | +-(language::integer:2:ValueProcessor) + | `-(language::integer:3:ValueProcessor) + `-(language::row_expression:FakeProcessor) + +-(language::unary_minus:UnaryExpressionProcessor<language::unary_minus, long, long>) + | `-(language::integer:1:ValueProcessor) + `-(language::real:1.3:ValueProcessor) )"; CHECK_AST(data, result); @@ -1114,52 +1119,44 @@ prev(3 + .24); SECTION("arguments invalid tuple -> R^d conversion") { - SECTION("tuple[3] -> R^2") + SECTION("tuple[2] -> R^2") { std::string_view data = R"( let f : R^2 -> R, x->x[0]; -f((1,2,3)); +f((1,2)); )"; - CHECK_EXPRESSION_BUILDER_THROWS_WITH(data, - std::string{ - "incompatible dimensions in affectation: expecting 2, but provided 3"}); + CHECK_EXPRESSION_BUILDER_THROWS_WITH(data, std::string{"cannot convert list to R^2"}); } - SECTION("tuple[2] -> R^3") + SECTION("tuple[3] -> R^3") { std::string_view data = R"( let f : R^3 -> R, x->x[0]; -f((1,2)); +f((1,2,3)); )"; - CHECK_EXPRESSION_BUILDER_THROWS_WITH(data, - std::string{ - "incompatible dimensions in affectation: expecting 3, but provided 2"}); + CHECK_EXPRESSION_BUILDER_THROWS_WITH(data, std::string{"cannot convert list to R^3"}); } - SECTION("compound tuple[3] -> R^2") + SECTION("compound tuple[2] -> R^2") { std::string_view data = R"( let f : R*R^2 -> R, (t,x)->x[0]; -f(1,(1,2,3)); +f(1,(1,2)); )"; - CHECK_EXPRESSION_BUILDER_THROWS_WITH(data, - std::string{ - "incompatible dimensions in affectation: expecting 2, but provided 3"}); + CHECK_EXPRESSION_BUILDER_THROWS_WITH(data, std::string{"cannot convert list to R^2"}); } SECTION("compound tuple[2] -> R^3") { std::string_view data = R"( let f : R^3*R^2 -> R, (x,y)->x[0]*y[1]; -f((1,2),(3,4)); +f((1,2,3),[3,4]); )"; - CHECK_EXPRESSION_BUILDER_THROWS_WITH(data, - std::string{ - "incompatible dimensions in affectation: expecting 3, but provided 2"}); + CHECK_EXPRESSION_BUILDER_THROWS_WITH(data, std::string{"cannot convert list to R^3"}); } SECTION("list instead of tuple -> R^3") @@ -1176,7 +1173,7 @@ f(1,2,3); { std::string_view data = R"( let f : R^3*R^2 -> R, (x,y) -> x[0]*x[1]-y[0]; -f((1,2,3),2,3); +f([1,2,3],2,3); )"; CHECK_EXPRESSION_BUILDER_THROWS_WITH(data, std::string{"bad number of arguments: expecting 2, provided 3"}); diff --git a/tests/test_ASTNodeListAffectationExpressionBuilder.cpp b/tests/test_ASTNodeListAffectationExpressionBuilder.cpp index 8d495053e0d0e09b67c103a4f387ecf6afc018bf..44f3d6713e9256cbaf0e12814200aac4f8b333fa 100644 --- a/tests/test_ASTNodeListAffectationExpressionBuilder.cpp +++ b/tests/test_ASTNodeListAffectationExpressionBuilder.cpp @@ -189,8 +189,8 @@ let (r,b,z,m): R*R*R*R , (r,b,z,m) = (3.2, 1, 6, 2); { std::string_view data = R"( let a:R^1, a = 0; -let b:R^2, b = (1,2); -let c:R^3, c = (1,2,3); +let b:R^2, b = [1,2]; +let c:R^3, c = [1,2,3]; let (x1,x2,x3,x) : R^1*R^2*R^3*R, (x1,x2,x3,x) = (a, b, c, 2); )"; @@ -200,14 +200,14 @@ let (x1,x2,x3,x) : R^1*R^2*R^3*R, +-(language::eq_op:AffectationFromZeroProcessor<TinyVector<1ul, double> >) | +-(language::name:a:NameProcessor) | `-(language::integer:0:ValueProcessor) - +-(language::eq_op:AffectationToTinyVectorFromListProcessor<language::eq_op, TinyVector<2ul, double> >) + +-(language::eq_op:AffectationProcessor<language::eq_op, TinyVector<2ul, double>, TinyVector<2ul, double> >) | +-(language::name:b:NameProcessor) - | `-(language::expression_list:ASTNodeExpressionListProcessor) + | `-(language::vector_expression:TinyVectorExpressionProcessor<2ul>) | +-(language::integer:1:ValueProcessor) | `-(language::integer:2:ValueProcessor) - +-(language::eq_op:AffectationToTinyVectorFromListProcessor<language::eq_op, TinyVector<3ul, double> >) + +-(language::eq_op:AffectationProcessor<language::eq_op, TinyVector<3ul, double>, TinyVector<3ul, double> >) | +-(language::name:c:NameProcessor) - | `-(language::expression_list:ASTNodeExpressionListProcessor) + | `-(language::vector_expression:TinyVectorExpressionProcessor<3ul>) | +-(language::integer:1:ValueProcessor) | +-(language::integer:2:ValueProcessor) | `-(language::integer:3:ValueProcessor) @@ -231,8 +231,8 @@ let (x1,x2,x3,x) : R^1*R^2*R^3*R, { std::string_view data = R"( let a:R^1x1, a = 0; -let b:R^2x2, b = (1, 2, 3, 4); -let c:R^3x3, c = (9, 8, 7, 6, 5, 4, 3, 2, 1); +let b:R^2x2, b = [[1, 2], [3, 4]]; +let c:R^3x3, c = [[9, 8, 7], [6, 5, 4], [3, 2, 1]]; let (x1,x2,x3,x) : R^1x1*R^2x2*R^3x3*R, (x1,x2,x3,x) = (a, b, c, 2); )"; @@ -242,25 +242,30 @@ let (x1,x2,x3,x) : R^1x1*R^2x2*R^3x3*R, +-(language::eq_op:AffectationProcessor<language::eq_op, TinyMatrix<1ul, 1ul, double>, long>) | +-(language::name:a:NameProcessor) | `-(language::integer:0:ValueProcessor) - +-(language::eq_op:AffectationToTinyMatrixFromListProcessor<language::eq_op, TinyMatrix<2ul, 2ul, double> >) + +-(language::eq_op:AffectationProcessor<language::eq_op, TinyMatrix<2ul, 2ul, double>, TinyMatrix<2ul, 2ul, double> >) | +-(language::name:b:NameProcessor) - | `-(language::expression_list:ASTNodeExpressionListProcessor) - | +-(language::integer:1:ValueProcessor) - | +-(language::integer:2:ValueProcessor) - | +-(language::integer:3:ValueProcessor) - | `-(language::integer:4:ValueProcessor) - +-(language::eq_op:AffectationToTinyMatrixFromListProcessor<language::eq_op, TinyMatrix<3ul, 3ul, double> >) + | `-(language::matrix_expression:TinyMatrixExpressionProcessor<2ul, 2ul>) + | +-(language::row_expression:FakeProcessor) + | | +-(language::integer:1:ValueProcessor) + | | `-(language::integer:2:ValueProcessor) + | `-(language::row_expression:FakeProcessor) + | +-(language::integer:3:ValueProcessor) + | `-(language::integer:4:ValueProcessor) + +-(language::eq_op:AffectationProcessor<language::eq_op, TinyMatrix<3ul, 3ul, double>, TinyMatrix<3ul, 3ul, double> >) | +-(language::name:c:NameProcessor) - | `-(language::expression_list:ASTNodeExpressionListProcessor) - | +-(language::integer:9:ValueProcessor) - | +-(language::integer:8:ValueProcessor) - | +-(language::integer:7:ValueProcessor) - | +-(language::integer:6:ValueProcessor) - | +-(language::integer:5:ValueProcessor) - | +-(language::integer:4:ValueProcessor) - | +-(language::integer:3:ValueProcessor) - | +-(language::integer:2:ValueProcessor) - | `-(language::integer:1:ValueProcessor) + | `-(language::matrix_expression:TinyMatrixExpressionProcessor<3ul, 3ul>) + | +-(language::row_expression:FakeProcessor) + | | +-(language::integer:9:ValueProcessor) + | | +-(language::integer:8:ValueProcessor) + | | `-(language::integer:7:ValueProcessor) + | +-(language::row_expression:FakeProcessor) + | | +-(language::integer:6:ValueProcessor) + | | +-(language::integer:5:ValueProcessor) + | | `-(language::integer:4:ValueProcessor) + | `-(language::row_expression:FakeProcessor) + | +-(language::integer:3:ValueProcessor) + | +-(language::integer:2:ValueProcessor) + | `-(language::integer:1:ValueProcessor) `-(language::eq_op:ListAffectationProcessor<language::eq_op>) +-(language::name_list:FakeProcessor) | +-(language::name:x1:NameProcessor) @@ -503,7 +508,7 @@ let x:R; SECTION("invalid R^n -> R^m conversion") { std::string_view data = R"( -let x:R^2, x = (1,2); +let x:R^2, x = [1,2]; let y:R^3, y = x; )"; diff --git a/tests/test_ASTNodeNaturalConversionChecker.cpp b/tests/test_ASTNodeNaturalConversionChecker.cpp index 6852222ae307f2cdac86463ecc2b59fde4536618..7823664a1319f7699c3264805ac4c4fb68085e4a 100644 --- a/tests/test_ASTNodeNaturalConversionChecker.cpp +++ b/tests/test_ASTNodeNaturalConversionChecker.cpp @@ -94,19 +94,6 @@ TEST_CASE("ASTNodeNaturalConversionChecker", "[language]") ASTNodeNaturalConversionChecker{*data_node, ASTNodeDataType::build<ASTNodeDataType::matrix_t>(1, 1)}); } - SECTION("list -> R^1x1") - { - data_node->m_data_type = - ASTNodeDataType::build<ASTNodeDataType::list_t>({std::make_shared<const ASTNodeDataType>(double_dt)}); - { - std::unique_ptr list0_node = std::make_unique<ASTNode>(); - list0_node->m_data_type = double_dt; - data_node->emplace_back(std::move(list0_node)); - } - REQUIRE_NOTHROW( - ASTNodeNaturalConversionChecker{*data_node, ASTNodeDataType::build<ASTNodeDataType::matrix_t>(1, 1)}); - } - SECTION("'0' -> R^dxd") { data_node->m_data_type = int_dt; @@ -140,88 +127,12 @@ TEST_CASE("ASTNodeNaturalConversionChecker", "[language]") ASTNodeNaturalConversionChecker{*data_node, ASTNodeDataType::build<ASTNodeDataType::matrix_t>(2, 2)}); } - SECTION("list -> R^2x2") - { - data_node->m_data_type = ASTNodeDataType::build<ASTNodeDataType::list_t>( - {std::make_shared<const ASTNodeDataType>(double_dt), std::make_shared<const ASTNodeDataType>(unsigned_int_dt), - std::make_shared<const ASTNodeDataType>(unsigned_int_dt), - std::make_shared<const ASTNodeDataType>(unsigned_int_dt)}); - { - std::unique_ptr list0_node = std::make_unique<ASTNode>(); - list0_node->m_data_type = double_dt; - data_node->emplace_back(std::move(list0_node)); - - std::unique_ptr list1_node = std::make_unique<ASTNode>(); - list1_node->m_data_type = unsigned_int_dt; - data_node->emplace_back(std::move(list1_node)); - - std::unique_ptr list2_node = std::make_unique<ASTNode>(); - list2_node->m_data_type = unsigned_int_dt; - data_node->emplace_back(std::move(list2_node)); - - std::unique_ptr list3_node = std::make_unique<ASTNode>(); - list3_node->m_data_type = unsigned_int_dt; - data_node->emplace_back(std::move(list3_node)); - } - REQUIRE_NOTHROW( - ASTNodeNaturalConversionChecker{*data_node, ASTNodeDataType::build<ASTNodeDataType::matrix_t>(2, 2)}); - } - SECTION("R^3x3 -> R^3x3") { data_node->m_data_type = ASTNodeDataType::build<ASTNodeDataType::matrix_t>(3, 3); REQUIRE_NOTHROW( ASTNodeNaturalConversionChecker{*data_node, ASTNodeDataType::build<ASTNodeDataType::matrix_t>(3, 3)}); } - - SECTION("list -> R^3x3") - { - data_node->m_data_type = ASTNodeDataType::build<ASTNodeDataType::list_t>( - {std::make_shared<const ASTNodeDataType>(double_dt), std::make_shared<const ASTNodeDataType>(unsigned_int_dt), - std::make_shared<const ASTNodeDataType>(int_dt), std::make_shared<const ASTNodeDataType>(double_dt), - std::make_shared<const ASTNodeDataType>(unsigned_int_dt), std::make_shared<const ASTNodeDataType>(int_dt), - std::make_shared<const ASTNodeDataType>(double_dt), std::make_shared<const ASTNodeDataType>(unsigned_int_dt), - std::make_shared<const ASTNodeDataType>(int_dt)}); - { - std::unique_ptr list0_node = std::make_unique<ASTNode>(); - list0_node->m_data_type = double_dt; - data_node->emplace_back(std::move(list0_node)); - - std::unique_ptr list1_node = std::make_unique<ASTNode>(); - list1_node->m_data_type = unsigned_int_dt; - data_node->emplace_back(std::move(list1_node)); - - std::unique_ptr list2_node = std::make_unique<ASTNode>(); - list2_node->m_data_type = int_dt; - data_node->emplace_back(std::move(list2_node)); - - std::unique_ptr list3_node = std::make_unique<ASTNode>(); - list3_node->m_data_type = double_dt; - data_node->emplace_back(std::move(list3_node)); - - std::unique_ptr list4_node = std::make_unique<ASTNode>(); - list4_node->m_data_type = unsigned_int_dt; - data_node->emplace_back(std::move(list4_node)); - - std::unique_ptr list5_node = std::make_unique<ASTNode>(); - list5_node->m_data_type = int_dt; - data_node->emplace_back(std::move(list5_node)); - - std::unique_ptr list6_node = std::make_unique<ASTNode>(); - list6_node->m_data_type = double_dt; - data_node->emplace_back(std::move(list6_node)); - - std::unique_ptr list7_node = std::make_unique<ASTNode>(); - list7_node->m_data_type = unsigned_int_dt; - data_node->emplace_back(std::move(list7_node)); - - std::unique_ptr list8_node = std::make_unique<ASTNode>(); - list8_node->m_data_type = int_dt; - data_node->emplace_back(std::move(list8_node)); - } - REQUIRE_NOTHROW( - ASTNodeNaturalConversionChecker{*data_node, ASTNodeDataType::build<ASTNodeDataType::matrix_t>(3, 3)}); - } } SECTION("-> R^d") @@ -233,19 +144,6 @@ TEST_CASE("ASTNodeNaturalConversionChecker", "[language]") ASTNodeNaturalConversionChecker{*data_node, ASTNodeDataType::build<ASTNodeDataType::vector_t>(1)}); } - SECTION("list -> R^1") - { - data_node->m_data_type = - ASTNodeDataType::build<ASTNodeDataType::list_t>({std::make_shared<const ASTNodeDataType>(double_dt)}); - { - std::unique_ptr list0_node = std::make_unique<ASTNode>(); - list0_node->m_data_type = double_dt; - data_node->emplace_back(std::move(list0_node)); - } - REQUIRE_NOTHROW( - ASTNodeNaturalConversionChecker{*data_node, ASTNodeDataType::build<ASTNodeDataType::vector_t>(1)}); - } - SECTION("'0' -> R^d") { data_node->m_data_type = int_dt; @@ -279,52 +177,12 @@ TEST_CASE("ASTNodeNaturalConversionChecker", "[language]") ASTNodeNaturalConversionChecker{*data_node, ASTNodeDataType::build<ASTNodeDataType::vector_t>(2)}); } - SECTION("list -> R^2") - { - data_node->m_data_type = - ASTNodeDataType::build<ASTNodeDataType::list_t>({std::make_shared<const ASTNodeDataType>(double_dt), - std::make_shared<const ASTNodeDataType>(unsigned_int_dt)}); - { - std::unique_ptr list0_node = std::make_unique<ASTNode>(); - list0_node->m_data_type = double_dt; - data_node->emplace_back(std::move(list0_node)); - - std::unique_ptr list1_node = std::make_unique<ASTNode>(); - list1_node->m_data_type = unsigned_int_dt; - data_node->emplace_back(std::move(list1_node)); - } - REQUIRE_NOTHROW( - ASTNodeNaturalConversionChecker{*data_node, ASTNodeDataType::build<ASTNodeDataType::vector_t>(2)}); - } - SECTION("R^3 -> R^3") { data_node->m_data_type = ASTNodeDataType::build<ASTNodeDataType::vector_t>(3); REQUIRE_NOTHROW( ASTNodeNaturalConversionChecker{*data_node, ASTNodeDataType::build<ASTNodeDataType::vector_t>(3)}); } - - SECTION("list -> R^3") - { - data_node->m_data_type = ASTNodeDataType::build<ASTNodeDataType::list_t>( - {std::make_shared<const ASTNodeDataType>(double_dt), std::make_shared<const ASTNodeDataType>(unsigned_int_dt), - std::make_shared<const ASTNodeDataType>(int_dt)}); - { - std::unique_ptr list0_node = std::make_unique<ASTNode>(); - list0_node->m_data_type = double_dt; - data_node->emplace_back(std::move(list0_node)); - - std::unique_ptr list1_node = std::make_unique<ASTNode>(); - list1_node->m_data_type = unsigned_int_dt; - data_node->emplace_back(std::move(list1_node)); - - std::unique_ptr list2_node = std::make_unique<ASTNode>(); - list2_node->m_data_type = int_dt; - data_node->emplace_back(std::move(list2_node)); - } - REQUIRE_NOTHROW( - ASTNodeNaturalConversionChecker{*data_node, ASTNodeDataType::build<ASTNodeDataType::vector_t>(3)}); - } } SECTION("-> R") @@ -908,99 +766,6 @@ TEST_CASE("ASTNodeNaturalConversionChecker", "[language]") "invalid implicit conversion: R^2x2 -> R^3x3"); } - SECTION("list1 -> R^dxd") - { - data_node->m_data_type = - ASTNodeDataType::build<ASTNodeDataType::list_t>({std::make_shared<const ASTNodeDataType>(double_dt)}); - { - std::unique_ptr list0_node = std::make_unique<ASTNode>(); - list0_node->m_data_type = double_dt; - data_node->emplace_back(std::move(list0_node)); - } - - SECTION("d=2") - { - REQUIRE_THROWS_WITH((ASTNodeNaturalConversionChecker{*data_node, - ASTNodeDataType::build<ASTNodeDataType::matrix_t>(2, - 2)}), - "incompatible dimensions in affectation: expecting 4, but provided 1"); - } - - SECTION("d=3") - { - REQUIRE_THROWS_WITH((ASTNodeNaturalConversionChecker{*data_node, - ASTNodeDataType::build<ASTNodeDataType::matrix_t>(3, - 3)}), - "incompatible dimensions in affectation: expecting 9, but provided 1"); - } - } - - SECTION("list2 -> R^dxd") - { - data_node->m_data_type = list_dt; - { - std::unique_ptr list0_node = std::make_unique<ASTNode>(); - list0_node->m_data_type = double_dt; - data_node->emplace_back(std::move(list0_node)); - - std::unique_ptr list1_node = std::make_unique<ASTNode>(); - list1_node->m_data_type = unsigned_int_dt; - data_node->emplace_back(std::move(list1_node)); - } - - SECTION("d=1") - { - REQUIRE_THROWS_WITH((ASTNodeNaturalConversionChecker{*data_node, - ASTNodeDataType::build<ASTNodeDataType::matrix_t>(1, - 1)}), - "incompatible dimensions in affectation: expecting 1, but provided 2"); - } - - SECTION("d=3") - { - REQUIRE_THROWS_WITH((ASTNodeNaturalConversionChecker{*data_node, - ASTNodeDataType::build<ASTNodeDataType::matrix_t>(3, - 3)}), - "incompatible dimensions in affectation: expecting 9, but provided 2"); - } - } - - SECTION("list3 -> R^dxd") - { - data_node->m_data_type = ASTNodeDataType::build<ASTNodeDataType::list_t>( - {std::make_shared<const ASTNodeDataType>(double_dt), std::make_shared<const ASTNodeDataType>(unsigned_int_dt), - std::make_shared<const ASTNodeDataType>(int_dt)}); - { - std::unique_ptr list0_node = std::make_unique<ASTNode>(); - list0_node->m_data_type = double_dt; - data_node->emplace_back(std::move(list0_node)); - - std::unique_ptr list1_node = std::make_unique<ASTNode>(); - list1_node->m_data_type = unsigned_int_dt; - data_node->emplace_back(std::move(list1_node)); - - std::unique_ptr list2_node = std::make_unique<ASTNode>(); - list2_node->m_data_type = int_dt; - data_node->emplace_back(std::move(list2_node)); - } - - SECTION("d=1") - { - REQUIRE_THROWS_WITH((ASTNodeNaturalConversionChecker{*data_node, - ASTNodeDataType::build<ASTNodeDataType::matrix_t>(1, - 1)}), - "incompatible dimensions in affectation: expecting 1, but provided 3"); - } - - SECTION("d=2") - { - REQUIRE_THROWS_WITH((ASTNodeNaturalConversionChecker{*data_node, - ASTNodeDataType::build<ASTNodeDataType::matrix_t>(2, - 2)}), - "incompatible dimensions in affectation: expecting 4, but provided 3"); - } - } - SECTION("tuple -> R^dxd") { SECTION("tuple(N) -> R^1x1") @@ -1273,6 +1038,98 @@ TEST_CASE("ASTNodeNaturalConversionChecker", "[language]") "invalid implicit conversion: string -> R^3x3"); } } + + SECTION("invalid list -> R^1x1") + { + data_node->m_data_type = + ASTNodeDataType::build<ASTNodeDataType::list_t>({std::make_shared<const ASTNodeDataType>(double_dt)}); + { + std::unique_ptr list0_node = std::make_unique<ASTNode>(); + list0_node->m_data_type = double_dt; + data_node->emplace_back(std::move(list0_node)); + } + REQUIRE_THROWS_WITH((ASTNodeNaturalConversionChecker{*data_node, + ASTNodeDataType::build<ASTNodeDataType::matrix_t>(1, 1)}), + "cannot convert list to R^1x1"); + } + + SECTION("invalid list -> R^2x2") + { + data_node->m_data_type = ASTNodeDataType::build<ASTNodeDataType::list_t>( + {std::make_shared<const ASTNodeDataType>(double_dt), std::make_shared<const ASTNodeDataType>(unsigned_int_dt), + std::make_shared<const ASTNodeDataType>(unsigned_int_dt), + std::make_shared<const ASTNodeDataType>(unsigned_int_dt)}); + { + std::unique_ptr list0_node = std::make_unique<ASTNode>(); + list0_node->m_data_type = double_dt; + data_node->emplace_back(std::move(list0_node)); + + std::unique_ptr list1_node = std::make_unique<ASTNode>(); + list1_node->m_data_type = unsigned_int_dt; + data_node->emplace_back(std::move(list1_node)); + + std::unique_ptr list2_node = std::make_unique<ASTNode>(); + list2_node->m_data_type = unsigned_int_dt; + data_node->emplace_back(std::move(list2_node)); + + std::unique_ptr list3_node = std::make_unique<ASTNode>(); + list3_node->m_data_type = unsigned_int_dt; + data_node->emplace_back(std::move(list3_node)); + } + REQUIRE_THROWS_WITH((ASTNodeNaturalConversionChecker{*data_node, + ASTNodeDataType::build<ASTNodeDataType::matrix_t>(2, 2)}), + "cannot convert list to R^2x2"); + } + + SECTION("invalid list -> R^3x3") + { + data_node->m_data_type = ASTNodeDataType::build<ASTNodeDataType::list_t>( + {std::make_shared<const ASTNodeDataType>(double_dt), std::make_shared<const ASTNodeDataType>(unsigned_int_dt), + std::make_shared<const ASTNodeDataType>(int_dt), std::make_shared<const ASTNodeDataType>(double_dt), + std::make_shared<const ASTNodeDataType>(unsigned_int_dt), std::make_shared<const ASTNodeDataType>(int_dt), + std::make_shared<const ASTNodeDataType>(double_dt), std::make_shared<const ASTNodeDataType>(unsigned_int_dt), + std::make_shared<const ASTNodeDataType>(int_dt)}); + { + std::unique_ptr list0_node = std::make_unique<ASTNode>(); + list0_node->m_data_type = double_dt; + data_node->emplace_back(std::move(list0_node)); + + std::unique_ptr list1_node = std::make_unique<ASTNode>(); + list1_node->m_data_type = unsigned_int_dt; + data_node->emplace_back(std::move(list1_node)); + + std::unique_ptr list2_node = std::make_unique<ASTNode>(); + list2_node->m_data_type = int_dt; + data_node->emplace_back(std::move(list2_node)); + + std::unique_ptr list3_node = std::make_unique<ASTNode>(); + list3_node->m_data_type = double_dt; + data_node->emplace_back(std::move(list3_node)); + + std::unique_ptr list4_node = std::make_unique<ASTNode>(); + list4_node->m_data_type = unsigned_int_dt; + data_node->emplace_back(std::move(list4_node)); + + std::unique_ptr list5_node = std::make_unique<ASTNode>(); + list5_node->m_data_type = int_dt; + data_node->emplace_back(std::move(list5_node)); + + std::unique_ptr list6_node = std::make_unique<ASTNode>(); + list6_node->m_data_type = double_dt; + data_node->emplace_back(std::move(list6_node)); + + std::unique_ptr list7_node = std::make_unique<ASTNode>(); + list7_node->m_data_type = unsigned_int_dt; + data_node->emplace_back(std::move(list7_node)); + + std::unique_ptr list8_node = std::make_unique<ASTNode>(); + list8_node->m_data_type = int_dt; + data_node->emplace_back(std::move(list8_node)); + } + REQUIRE_THROWS_WITH((ASTNodeNaturalConversionChecker{*data_node, + ASTNodeDataType::build<ASTNodeDataType::matrix_t>(3, 3)}), + "cannot convert list to R^3x3"); + } } SECTION("-> R^d") @@ -1325,93 +1182,6 @@ TEST_CASE("ASTNodeNaturalConversionChecker", "[language]") "invalid implicit conversion: R^2 -> R^3"); } - SECTION("list1 -> R^d") - { - data_node->m_data_type = - ASTNodeDataType::build<ASTNodeDataType::list_t>({std::make_shared<const ASTNodeDataType>(double_dt)}); - { - std::unique_ptr list0_node = std::make_unique<ASTNode>(); - list0_node->m_data_type = double_dt; - data_node->emplace_back(std::move(list0_node)); - } - - SECTION("d=2") - { - REQUIRE_THROWS_WITH((ASTNodeNaturalConversionChecker{*data_node, - ASTNodeDataType::build<ASTNodeDataType::vector_t>(2)}), - "incompatible dimensions in affectation: expecting 2, but provided 1"); - } - - SECTION("d=3") - { - REQUIRE_THROWS_WITH((ASTNodeNaturalConversionChecker{*data_node, - ASTNodeDataType::build<ASTNodeDataType::vector_t>(3)}), - "incompatible dimensions in affectation: expecting 3, but provided 1"); - } - } - - SECTION("list2 -> R^d") - { - data_node->m_data_type = list_dt; - { - std::unique_ptr list0_node = std::make_unique<ASTNode>(); - list0_node->m_data_type = double_dt; - data_node->emplace_back(std::move(list0_node)); - - std::unique_ptr list1_node = std::make_unique<ASTNode>(); - list1_node->m_data_type = unsigned_int_dt; - data_node->emplace_back(std::move(list1_node)); - } - - SECTION("d=1") - { - REQUIRE_THROWS_WITH((ASTNodeNaturalConversionChecker{*data_node, - ASTNodeDataType::build<ASTNodeDataType::vector_t>(1)}), - "incompatible dimensions in affectation: expecting 1, but provided 2"); - } - - SECTION("d=3") - { - REQUIRE_THROWS_WITH((ASTNodeNaturalConversionChecker{*data_node, - ASTNodeDataType::build<ASTNodeDataType::vector_t>(3)}), - "incompatible dimensions in affectation: expecting 3, but provided 2"); - } - } - - SECTION("list3 -> R^d") - { - data_node->m_data_type = ASTNodeDataType::build<ASTNodeDataType::list_t>( - {std::make_shared<const ASTNodeDataType>(double_dt), std::make_shared<const ASTNodeDataType>(unsigned_int_dt), - std::make_shared<const ASTNodeDataType>(int_dt)}); - { - std::unique_ptr list0_node = std::make_unique<ASTNode>(); - list0_node->m_data_type = double_dt; - data_node->emplace_back(std::move(list0_node)); - - std::unique_ptr list1_node = std::make_unique<ASTNode>(); - list1_node->m_data_type = unsigned_int_dt; - data_node->emplace_back(std::move(list1_node)); - - std::unique_ptr list2_node = std::make_unique<ASTNode>(); - list2_node->m_data_type = int_dt; - data_node->emplace_back(std::move(list2_node)); - } - - SECTION("d=1") - { - REQUIRE_THROWS_WITH((ASTNodeNaturalConversionChecker{*data_node, - ASTNodeDataType::build<ASTNodeDataType::vector_t>(1)}), - "incompatible dimensions in affectation: expecting 1, but provided 3"); - } - - SECTION("d=2") - { - REQUIRE_THROWS_WITH((ASTNodeNaturalConversionChecker{*data_node, - ASTNodeDataType::build<ASTNodeDataType::vector_t>(2)}), - "incompatible dimensions in affectation: expecting 2, but provided 3"); - } - } - SECTION("tuple -> R^d") { SECTION("tuple(N) -> R^1") @@ -1714,6 +1484,62 @@ TEST_CASE("ASTNodeNaturalConversionChecker", "[language]") "invalid implicit conversion: string -> R^3"); } } + + SECTION("invalid list -> R^1") + { + data_node->m_data_type = + ASTNodeDataType::build<ASTNodeDataType::list_t>({std::make_shared<const ASTNodeDataType>(double_dt)}); + { + std::unique_ptr list0_node = std::make_unique<ASTNode>(); + list0_node->m_data_type = double_dt; + data_node->emplace_back(std::move(list0_node)); + } + REQUIRE_THROWS_WITH((ASTNodeNaturalConversionChecker{*data_node, + ASTNodeDataType::build<ASTNodeDataType::vector_t>(1)}), + "cannot convert list to R^1"); + } + + SECTION("invalid list -> R^2") + { + data_node->m_data_type = + ASTNodeDataType::build<ASTNodeDataType::list_t>({std::make_shared<const ASTNodeDataType>(double_dt), + std::make_shared<const ASTNodeDataType>(unsigned_int_dt)}); + { + std::unique_ptr list0_node = std::make_unique<ASTNode>(); + list0_node->m_data_type = double_dt; + data_node->emplace_back(std::move(list0_node)); + + std::unique_ptr list1_node = std::make_unique<ASTNode>(); + list1_node->m_data_type = unsigned_int_dt; + data_node->emplace_back(std::move(list1_node)); + } + REQUIRE_THROWS_WITH((ASTNodeNaturalConversionChecker{*data_node, + ASTNodeDataType::build<ASTNodeDataType::vector_t>(2)}), + "cannot convert list to R^2"); + } + + SECTION("invalid list -> R^3") + { + data_node->m_data_type = ASTNodeDataType::build<ASTNodeDataType::list_t>( + {std::make_shared<const ASTNodeDataType>(double_dt), std::make_shared<const ASTNodeDataType>(unsigned_int_dt), + std::make_shared<const ASTNodeDataType>(int_dt)}); + { + std::unique_ptr list0_node = std::make_unique<ASTNode>(); + list0_node->m_data_type = double_dt; + data_node->emplace_back(std::move(list0_node)); + + std::unique_ptr list1_node = std::make_unique<ASTNode>(); + list1_node->m_data_type = unsigned_int_dt; + data_node->emplace_back(std::move(list1_node)); + + std::unique_ptr list2_node = std::make_unique<ASTNode>(); + list2_node->m_data_type = int_dt; + data_node->emplace_back(std::move(list2_node)); + } + REQUIRE_THROWS_WITH((ASTNodeNaturalConversionChecker{*data_node, + ASTNodeDataType::build<ASTNodeDataType::vector_t>(3)}), + "cannot convert list to R^3"); + } } SECTION("-> R") diff --git a/tests/test_AffectationProcessor.cpp b/tests/test_AffectationProcessor.cpp index 42c0514f963d5c452558bf6a8676c8d69395658d..2f8c4bb92067614fe1eb62d527fc1656301c2d87 100644 --- a/tests/test_AffectationProcessor.cpp +++ b/tests/test_AffectationProcessor.cpp @@ -108,21 +108,25 @@ TEST_CASE("AffectationProcessor", "[language]") CHECK_AFFECTATION_RESULT("let x : R^1, x = true;", "x", (TinyVector<1>{true})); CHECK_AFFECTATION_RESULT("let x : R^1, x = false;", "x", (TinyVector<1>{false})); CHECK_AFFECTATION_RESULT("let x : R^1, x = -2.3;", "x", (TinyVector<1>{-2.3})); + CHECK_AFFECTATION_RESULT("let x : R^1, x = [-1];", "x", (TinyVector<1>{-1})); + CHECK_AFFECTATION_RESULT("let x : R^1, x = [true];", "x", (TinyVector<1>{true})); + CHECK_AFFECTATION_RESULT("let x : R^1, x = [false];", "x", (TinyVector<1>{false})); + CHECK_AFFECTATION_RESULT("let x : R^1, x = [-2.3];", "x", (TinyVector<1>{-2.3})); CHECK_AFFECTATION_RESULT("let x : R^1, x = 0;", "x", (TinyVector<1>{zero})); } SECTION("R^2") { - CHECK_AFFECTATION_RESULT("let x : R^2, x = (-1, true);", "x", (TinyVector<2>{-1, true})); - CHECK_AFFECTATION_RESULT("let x : R^2, x = (true, false);", "x", (TinyVector<2>{true, false})); - CHECK_AFFECTATION_RESULT("let x : R^2, x = (-0.3, 12);", "x", (TinyVector<2>{-0.3, 12})); + CHECK_AFFECTATION_RESULT("let x : R^2, x = [-1, true];", "x", (TinyVector<2>{-1, true})); + CHECK_AFFECTATION_RESULT("let x : R^2, x = [true, false];", "x", (TinyVector<2>{true, false})); + CHECK_AFFECTATION_RESULT("let x : R^2, x = [-0.3, 12];", "x", (TinyVector<2>{-0.3, 12})); CHECK_AFFECTATION_RESULT("let x : R^2, x = 0;", "x", (TinyVector<2>{zero})); } SECTION("R^3") { - CHECK_AFFECTATION_RESULT("let x : R^3, x = (-1, true, false);", "x", (TinyVector<3>{-1, true, false})); - CHECK_AFFECTATION_RESULT("let x : R^3, x = (-0.3, 12, 6.2);", "x", (TinyVector<3>{-0.3, 12, 6.2})); + CHECK_AFFECTATION_RESULT("let x : R^3, x = [-1, true, false];", "x", (TinyVector<3>{-1, true, false})); + CHECK_AFFECTATION_RESULT("let x : R^3, x = [-0.3, 12, 6.2];", "x", (TinyVector<3>{-0.3, 12, 6.2})); CHECK_AFFECTATION_RESULT("let x : R^3; x = 0;", "x", (TinyVector<3>{zero})); } @@ -132,23 +136,27 @@ TEST_CASE("AffectationProcessor", "[language]") CHECK_AFFECTATION_RESULT("let x : R^1x1, x = true;", "x", (TinyMatrix<1>{true})); CHECK_AFFECTATION_RESULT("let x : R^1x1, x = false;", "x", (TinyMatrix<1>{false})); CHECK_AFFECTATION_RESULT("let x : R^1x1, x = -2.3;", "x", (TinyMatrix<1>{-2.3})); + CHECK_AFFECTATION_RESULT("let x : R^1x1, x = [[-1]];", "x", (TinyMatrix<1>{-1})); + CHECK_AFFECTATION_RESULT("let x : R^1x1, x = [[true]];", "x", (TinyMatrix<1>{true})); + CHECK_AFFECTATION_RESULT("let x : R^1x1, x = [[false]];", "x", (TinyMatrix<1>{false})); + CHECK_AFFECTATION_RESULT("let x : R^1x1, x = [[-2.3]];", "x", (TinyMatrix<1>{-2.3})); CHECK_AFFECTATION_RESULT("let x : R^1x1; x = 0;", "x", (TinyMatrix<1>{zero})); } SECTION("R^2x2") { - CHECK_AFFECTATION_RESULT("let x : R^2x2, x = (-1, true, 3, 5);", "x", (TinyMatrix<2>{-1, true, 3, 5})); - CHECK_AFFECTATION_RESULT("let x : R^2x2, x = (true, false, 1==2, 2==2);", "x", + CHECK_AFFECTATION_RESULT("let x : R^2x2, x = [[-1, true], [3, 5]];", "x", (TinyMatrix<2>{-1, true, 3, 5})); + CHECK_AFFECTATION_RESULT("let x : R^2x2, x = [[true, false], [1==2, 2==2]];", "x", (TinyMatrix<2>{true, false, false, true})); - CHECK_AFFECTATION_RESULT("let x : R^2x2, x = (-0.3, 12, 2, -3);", "x", (TinyMatrix<2>{-0.3, 12, 2, -3})); + CHECK_AFFECTATION_RESULT("let x : R^2x2, x = [[-0.3, 12],[2, -3]];", "x", (TinyMatrix<2>{-0.3, 12, 2, -3})); CHECK_AFFECTATION_RESULT("let x : R^2x2, x = 0;", "x", (TinyMatrix<2>{zero})); } SECTION("R^3x3") { - CHECK_AFFECTATION_RESULT("let x : R^3x3, x = (-1, true, false, 2, 3.1, 4, -1, true, 2);", "x", + CHECK_AFFECTATION_RESULT("let x : R^3x3, x = [[-1, true, false], [2, 3.1, 4], [-1, true, 2]];", "x", (TinyMatrix<3>{-1, true, false, 2, 3.1, 4, -1, true, 2})); - CHECK_AFFECTATION_RESULT("let x : R^3x3, x = (-0.3, 12, 6.2, 7.1, 3.2, 2-3, 2, -1, 0);", "x", + CHECK_AFFECTATION_RESULT("let x : R^3x3, x = [[-0.3, 12, 6.2], [7.1, 3.2, 2-3], [2, -1, 0]];", "x", (TinyMatrix<3>{-0.3, 12, 6.2, 7.1, 3.2, 2 - 3, 2, -1, 0})); CHECK_AFFECTATION_RESULT("let x : R^3x3, x = 0;", "x", (TinyMatrix<3>{zero})); } @@ -189,13 +197,13 @@ TEST_CASE("AffectationProcessor", "[language]") SECTION("R^2") { - CHECK_AFFECTATION_RESULT("let x : R^2, x = (-1, true); let y : R^2, y = (1,3); x += y;", "x", + CHECK_AFFECTATION_RESULT("let x : R^2, x = [-1, true]; x += [1,3];", "x", (TinyVector<2>{-1, true} + TinyVector<2>{1, 3})); } SECTION("R^3") { - CHECK_AFFECTATION_RESULT("let x : R^3, x = (-1, true, false); let y : R^3, y = (1,2,3); x += y;", "x", + CHECK_AFFECTATION_RESULT("let x : R^3, x = [-1, true, false]; x += [1,2,3];", "x", (TinyVector<3>{-1, true, false} + TinyVector<3>{1, 2, 3})); } } @@ -229,19 +237,18 @@ TEST_CASE("AffectationProcessor", "[language]") SECTION("R^1") { - CHECK_AFFECTATION_RESULT("let x : R^1, x = -1; let y : R^1, y = 1; x -= y;", "x", - (TinyVector<1>{-1} - TinyVector<1>{1})); + CHECK_AFFECTATION_RESULT("let x : R^1, x = [-1]; x -= [1];", "x", (TinyVector<1>{-1} - TinyVector<1>{1})); } SECTION("R^2") { - CHECK_AFFECTATION_RESULT("let x : R^2, x = (-1, true); let y : R^2, y = (1,3); x -= y;", "x", + CHECK_AFFECTATION_RESULT("let x : R^2, x = [-1, true]; x -= [1,3];", "x", (TinyVector<2>{-1, true} - TinyVector<2>{1, 3})); } SECTION("R^3") { - CHECK_AFFECTATION_RESULT("let x : R^3, x = (-1, true, false); let y : R^3, y = (1,2,3); x-=y;", "x", + CHECK_AFFECTATION_RESULT("let x : R^3, x = [-1, true, false]; x-=[1,2,3];", "x", (TinyVector<3>{-1, true, false} - TinyVector<3>{1, 2, 3})); } } @@ -280,13 +287,13 @@ TEST_CASE("AffectationProcessor", "[language]") SECTION("R^2") { - CHECK_AFFECTATION_RESULT("let x : R^2, x = (-1, true); x *= 3;", "x", + CHECK_AFFECTATION_RESULT("let x : R^2, x = [-1, true]; x *= 3;", "x", (TinyVector<2>{TinyVector<2>{-1, true} *= 3})); } SECTION("R^3") { - CHECK_AFFECTATION_RESULT("let x : R^3, x = (-1, true, false); x*=5.2;", "x", + CHECK_AFFECTATION_RESULT("let x : R^3, x = [-1, true, false]; x*=5.2;", "x", (TinyVector<3>{TinyVector<3>{-1, true, false} *= 5.2})); } @@ -297,13 +304,13 @@ TEST_CASE("AffectationProcessor", "[language]") SECTION("R^2x2") { - CHECK_AFFECTATION_RESULT("let x : R^2x2, x = (-1, true, 3, 6); x *= 3;", "x", + CHECK_AFFECTATION_RESULT("let x : R^2x2, x = [[-1, true], [3, 6]]; x *= 3;", "x", (TinyMatrix<2>{TinyMatrix<2>{-1, true, 3, 6} *= 3})); } SECTION("R^3x3") { - CHECK_AFFECTATION_RESULT("let x : R^3x3, x = (-1, true, false, 2, -3, 11, 5, -4, 2); x*=5.2;", "x", + CHECK_AFFECTATION_RESULT("let x : R^3x3, x = [[-1, true, false], [2, -3, 11], [5, -4, 2]]; x*=5.2;", "x", (TinyMatrix<3>{TinyMatrix<3>{-1, true, false, 2, -3, 11, 5, -4, 2} *= 5.2})); } } @@ -401,9 +408,9 @@ TEST_CASE("AffectationProcessor", "[language]") CHECK_AFFECTATION_THROWS_WITH("let x : R^1; let y : R^1x1, y = 1; x = y;", "undefined affectation type: R^1 = R^1x1"); - CHECK_AFFECTATION_THROWS_WITH("let x : R^2; let y : R^2x2, y = (1,2,4,4); x = y;", + CHECK_AFFECTATION_THROWS_WITH("let x : R^2; let y : R^2x2, y = [[1,2],[4,4]]; x = y;", "undefined affectation type: R^2 = R^2x2"); - CHECK_AFFECTATION_THROWS_WITH("let x : R^3; let y : R^3x3, y = (1,2,3,4,5,6,7,8,9); x = y;", + CHECK_AFFECTATION_THROWS_WITH("let x : R^3; let y : R^3x3, y = [[1,2,3],[4,5,6],[7,8,9]]; x = y;", "undefined affectation type: R^3 = R^3x3"); CHECK_AFFECTATION_THROWS_WITH("let x : R^2, x = 4;", "invalid integral value (0 is the solely valid value)"); @@ -425,14 +432,8 @@ TEST_CASE("AffectationProcessor", "[language]") "undefined affectation type: R^2 = R^3"); CHECK_AFFECTATION_THROWS_WITH("let x : R^1, x = (1,2);", "undefined affectation type: R^1 = list"); - - CHECK_AFFECTATION_THROWS_WITH("let x : R^2, x = (1,2,3);", - "incompatible dimensions in affectation: expecting 2, but provided 3"); - - CHECK_AFFECTATION_THROWS_WITH("let x : R^3, x = (1,2);", - "incompatible dimensions in affectation: expecting 3, but provided 2"); - CHECK_AFFECTATION_THROWS_WITH("let x : R^3, x = (1,2,3,4);", - "incompatible dimensions in affectation: expecting 3, but provided 4"); + CHECK_AFFECTATION_THROWS_WITH("let x : R^2, x = (1,2);", "undefined affectation type: R^2 = list"); + CHECK_AFFECTATION_THROWS_WITH("let x : R^3, x = (1,2,3);", "undefined affectation type: R^3 = list"); } SECTION("-> R^n (affectation of components is forbidden)") @@ -478,11 +479,9 @@ TEST_CASE("AffectationProcessor", "[language]") CHECK_AFFECTATION_THROWS_WITH("let x : R^2, x = 3.2;", "undefined affectation type: R^2 = R"); CHECK_AFFECTATION_THROWS_WITH("let x : R^3, x = 2.3;", "undefined affectation type: R^3 = R"); - CHECK_AFFECTATION_THROWS_WITH("let x : R^1; let y : R^1x1, y = 1; x = y;", - "undefined affectation type: R^1 = R^1x1"); - CHECK_AFFECTATION_THROWS_WITH("let x : R^2; let y : R^2x2, y = (1,2,4,4); x = y;", - "undefined affectation type: R^2 = R^2x2"); - CHECK_AFFECTATION_THROWS_WITH("let x : R^3; let y : R^3x3, y = (1,2,3,4,5,6,7,8,9); x = y;", + CHECK_AFFECTATION_THROWS_WITH("let x : R^1; x = [[1]];", "undefined affectation type: R^1 = R^1x1"); + CHECK_AFFECTATION_THROWS_WITH("let x : R^2; x = [[1,2],[4,4]];", "undefined affectation type: R^2 = R^2x2"); + CHECK_AFFECTATION_THROWS_WITH("let x : R^3; x = [[1,2,3],[4,5,6],[7,8,9]];", "undefined affectation type: R^3 = R^3x3"); CHECK_AFFECTATION_THROWS_WITH("let x : R^2, x = 4;", "invalid integral value (0 is the solely valid value)"); @@ -504,14 +503,8 @@ TEST_CASE("AffectationProcessor", "[language]") "undefined affectation type: R^2 = R^3"); CHECK_AFFECTATION_THROWS_WITH("let x : R^1, x = (1,2);", "undefined affectation type: R^1 = list"); - - CHECK_AFFECTATION_THROWS_WITH("let x : R^2, x = (1,2,3);", - "incompatible dimensions in affectation: expecting 2, but provided 3"); - - CHECK_AFFECTATION_THROWS_WITH("let x : R^3, x = (1,2);", - "incompatible dimensions in affectation: expecting 3, but provided 2"); - CHECK_AFFECTATION_THROWS_WITH("let x : R^3, x = (1,2,3,4);", - "incompatible dimensions in affectation: expecting 3, but provided 4"); + CHECK_AFFECTATION_THROWS_WITH("let x : R^2, x = (1,2);", "undefined affectation type: R^2 = list"); + CHECK_AFFECTATION_THROWS_WITH("let x : R^3, x = (1,2,3);", "undefined affectation type: R^3 = list"); } SECTION("-> R^nxn") @@ -557,12 +550,9 @@ TEST_CASE("AffectationProcessor", "[language]") CHECK_AFFECTATION_THROWS_WITH("let x : R^2x2, x = 3.2;", "undefined affectation type: R^2x2 = R"); CHECK_AFFECTATION_THROWS_WITH("let x : R^3x3, x = 2.3;", "undefined affectation type: R^3x3 = R"); - CHECK_AFFECTATION_THROWS_WITH("let x : R^1x1; let y : R^1, y = 1; x = y;", - "undefined affectation type: R^1x1 = R^1"); - CHECK_AFFECTATION_THROWS_WITH("let x : R^2x2; let y : R^2, y = (1,2); x = y;", - "undefined affectation type: R^2x2 = R^2"); - CHECK_AFFECTATION_THROWS_WITH("let x : R^3x3; let y : R^3, y = (1,2,3); x = y;", - "undefined affectation type: R^3x3 = R^3"); + CHECK_AFFECTATION_THROWS_WITH("let x : R^1x1; x = [1];", "undefined affectation type: R^1x1 = R^1"); + CHECK_AFFECTATION_THROWS_WITH("let x : R^2x2; x = [1,2];", "undefined affectation type: R^2x2 = R^2"); + CHECK_AFFECTATION_THROWS_WITH("let x : R^3x3; x = [1,2,3];", "undefined affectation type: R^3x3 = R^3"); CHECK_AFFECTATION_THROWS_WITH("let x : R^2x2; x = 3.2;", "undefined affectation type: R^2x2 = R"); CHECK_AFFECTATION_THROWS_WITH("let x : R^3x3; x = 2.3;", "undefined affectation type: R^3x3 = R"); @@ -570,10 +560,8 @@ TEST_CASE("AffectationProcessor", "[language]") CHECK_AFFECTATION_THROWS_WITH("let x : R^2x2, x = 4;", "invalid integral value (0 is the solely valid value)"); CHECK_AFFECTATION_THROWS_WITH("let x : R^3x3, x = 3;", "invalid integral value (0 is the solely valid value)"); - CHECK_AFFECTATION_THROWS_WITH("let x : R^1x1, x = 0; let y : R^2x2, y = x;", - "undefined affectation type: R^2x2 = R^1x1"); - CHECK_AFFECTATION_THROWS_WITH("let x : R^1x1, x = 0; let y : R^3x3, y = x;", - "undefined affectation type: R^3x3 = R^1x1"); + CHECK_AFFECTATION_THROWS_WITH("let y : R^2x2, y = [[0]];", "undefined affectation type: R^2x2 = R^1x1"); + CHECK_AFFECTATION_THROWS_WITH("let y : R^3x3, y = [[0]];", "undefined affectation type: R^3x3 = R^1x1"); CHECK_AFFECTATION_THROWS_WITH("let x : R^2x2, x = 0; let y : R^1x1, y = x;", "undefined affectation type: R^1x1 = R^2x2"); @@ -586,16 +574,9 @@ TEST_CASE("AffectationProcessor", "[language]") "undefined affectation type: R^2x2 = R^3x3"); CHECK_AFFECTATION_THROWS_WITH("let x : R^1x1, x = (1,2);", "undefined affectation type: R^1x1 = list"); - - CHECK_AFFECTATION_THROWS_WITH("let x : R^2x2, x = (1,2,3);", - "incompatible dimensions in affectation: expecting 4, but provided 3"); - CHECK_AFFECTATION_THROWS_WITH("let x : R^2x2, x = (1,2,3,4,5);", - "incompatible dimensions in affectation: expecting 4, but provided 5"); - - CHECK_AFFECTATION_THROWS_WITH("let x : R^3x3, x = (1,2,3,4,5,6,7,8);", - "incompatible dimensions in affectation: expecting 9, but provided 8"); - CHECK_AFFECTATION_THROWS_WITH("let x : R^3x3, x = (1,2,3,4,5,6,7,8,9,10);", - "incompatible dimensions in affectation: expecting 9, but provided 10"); + CHECK_AFFECTATION_THROWS_WITH("let x : R^2x2, x = (1,2,3,4);", "undefined affectation type: R^2x2 = list"); + CHECK_AFFECTATION_THROWS_WITH("let x : R^3x3, x = (1,2,3,4,5,6,7,8,9);", + "undefined affectation type: R^3x3 = list"); } } } diff --git a/tests/test_AffectationToStringProcessor.cpp b/tests/test_AffectationToStringProcessor.cpp index 01c7ba7b938945dc9f929f602a3fe071b052379c..d65a18a2e106f9afbbee3ca580255182ecf880e3 100644 --- a/tests/test_AffectationToStringProcessor.cpp +++ b/tests/test_AffectationToStringProcessor.cpp @@ -66,12 +66,12 @@ TEST_CASE("ASTAffectationToStringProcessor", "[language]") { std::ostringstream os; os << TinyVector<2>{2, 3}; - CHECK_AFFECTATION_RESULT(R"(let x : R^2, x = (2,3); let s : string; s = x;)", "s", os.str()); + CHECK_AFFECTATION_RESULT(R"(let x : R^2, x = [2,3]; let s : string; s = x;)", "s", os.str()); } { std::ostringstream os; os << TinyVector<3>{1, 2, 3}; - CHECK_AFFECTATION_RESULT(R"(let x : R^3, x = (1,2,3); let s : string; s = x;)", "s", os.str()); + CHECK_AFFECTATION_RESULT(R"(let x : R^3, x = [1,2,3]; let s : string; s = x;)", "s", os.str()); } } @@ -93,12 +93,12 @@ TEST_CASE("ASTAffectationToStringProcessor", "[language]") { std::ostringstream os; os << "foo" << TinyVector<2>{2, 3}; - CHECK_AFFECTATION_RESULT(R"(let x : R^2, x = (2,3); let s : string, s="foo"; s += x;)", "s", os.str()); + CHECK_AFFECTATION_RESULT(R"(let x : R^2, x = [2,3]; let s : string, s="foo"; s += x;)", "s", os.str()); } { std::ostringstream os; os << "foo" << TinyVector<3>{1, 2, 3}; - CHECK_AFFECTATION_RESULT(R"(let x : R^3, x = (1,2,3); let s : string, s="foo"; s += x;)", "s", os.str()); + CHECK_AFFECTATION_RESULT(R"(let x : R^3, x = [1,2,3]; let s : string, s="foo"; s += x;)", "s", os.str()); } } } diff --git a/tests/test_AffectationToTupleProcessor.cpp b/tests/test_AffectationToTupleProcessor.cpp index d832ac2739cb6b8417e6dfd3818e11252639b7b4..9871cf1d085f007652b4c6f2d9ea0ab750d2420f 100644 --- a/tests/test_AffectationToTupleProcessor.cpp +++ b/tests/test_AffectationToTupleProcessor.cpp @@ -75,7 +75,7 @@ let s :(string); s = 2.; }(); CHECK_AFFECTATION_RESULT(R"( -let x :R^3, x = (1,2,3); +let x :R^3, x = [1,2,3]; let s :(string); s = x; )", "s", (std::vector<std::string>{x_string})); @@ -92,7 +92,7 @@ let s :(R^1); s = 1.3; }(); CHECK_AFFECTATION_RESULT(R"( -let A :R^2x2, A = (1,2,3,4); +let A :R^2x2, A = [[1,2],[3,4]]; let s :(string); s = A; )", "s", (std::vector<std::string>{A_string})); @@ -128,19 +128,19 @@ let s :(string); s = (2.,3,"foo"); }(); CHECK_AFFECTATION_RESULT(R"( -let x : R^2, x = (1,2); +let x : R^2, x = [1,2]; let s : (string); s = (2.,3, x); )", "s", (std::vector<std::string>{std::to_string(2.), std::to_string(3), x_string})); CHECK_AFFECTATION_RESULT(R"( -let x : R^2, x = (1,2); +let x : R^2, x = [1,2]; let t :(R^2); t = (x,0); )", "t", (std::vector<TinyVector<2>>{TinyVector<2>{1, 2}, TinyVector<2>{0, 0}})); CHECK_AFFECTATION_RESULT(R"( -let t :(R^2); t = ((1,2),0); +let t :(R^2); t = ([1,2],0); )", "t", (std::vector<TinyVector<2>>{TinyVector<2>{1, 2}, TinyVector<2>{0, 0}})); @@ -167,19 +167,19 @@ let t :(R^1); t = (x,2); }(); CHECK_AFFECTATION_RESULT(R"( -let A : R^2x2, A = (1,2,3,4); +let A : R^2x2, A = [[1,2],[3,4]]; let s : (string); s = (2.,3, A); )", "s", (std::vector<std::string>{std::to_string(2.), std::to_string(3), A_string})); CHECK_AFFECTATION_RESULT(R"( -let A : R^2x2, A = (1,2,3,4); +let A : R^2x2, A = [[1,2],[3,4]]; let t :(R^2x2); t = (A,0); )", "t", (std::vector<TinyMatrix<2>>{TinyMatrix<2>{1, 2, 3, 4}, TinyMatrix<2>{0, 0, 0, 0}})); CHECK_AFFECTATION_RESULT(R"( -let t :(R^2x2); t = ((1,2,3,4),0); +let t :(R^2x2); t = ([[1,2],[3,4]],0); )", "t", (std::vector<TinyMatrix<2>>{TinyMatrix<2>{1, 2, 3, 4}, TinyMatrix<2>{0, 0, 0, 0}})); @@ -209,7 +209,7 @@ let t :(R^1x1); t = (x,2); }(); CHECK_AFFECTATION_RESULT(R"( -let x :(R^3), x = ((1,2,3)); +let x :(R^3), x = [1,2,3]; let s :(string); s = x; )", "s", (std::vector<std::string>{x_string})); @@ -221,7 +221,7 @@ let s :(string); s = x; }(); CHECK_AFFECTATION_RESULT(R"( -let A :(R^3x3), A = ((1,2,3,4,5,6,7,8,9)); +let A :(R^3x3), A = ([[1,2,3],[4,5,6],[7,8,9]]); let s :(string); s = A; )", "s", (std::vector<std::string>{A_string})); diff --git a/tests/test_ArraySubscriptProcessor.cpp b/tests/test_ArraySubscriptProcessor.cpp index cac519c63447a307864a1a8940dfbf3427388317..5b1ac6c1cf0a00f56a4da806b86bb4124c42b317 100644 --- a/tests/test_ArraySubscriptProcessor.cpp +++ b/tests/test_ArraySubscriptProcessor.cpp @@ -88,7 +88,7 @@ let x0: R, x0 = x[0]; SECTION("R^2 component access") { std::string_view data = R"( -let x : R^2, x = (1,2); +let x : R^2, x = [1,2]; let x0: R, x0 = x[0]; let x1: R, x1 = x[1]; )"; @@ -99,7 +99,7 @@ let x1: R, x1 = x[1]; SECTION("R^3 component access") { std::string_view data = R"( -let x : R^3, x = (1,2,3); +let x : R^3, x = [1,2,3]; let x0 : R, x0 = x[0]; let x1 : R, x1 = x[1]; let x2 : R, x2 = x[2]; @@ -121,7 +121,7 @@ let x00: R, x00 = x[0,0]; SECTION("R^2x2 component access") { std::string_view data = R"( -let x : R^2x2, x = (1,2,3,4); +let x : R^2x2, x = [[1,2],[3,4]]; let x00: R, x00 = x[0,0]; let x01: R, x01 = x[0,1]; let x10: R, x10 = x[1,0]; @@ -136,7 +136,7 @@ let x11: R, x11 = x[1,1]; SECTION("R^3x3 component access") { std::string_view data = R"( -let x : R^3x3, x = (1,2,3,4,5,6,7,8,9); +let x : R^3x3, x = [[1,2,3],[4,5,6],[7,8,9]]; let x00 : R, x00 = x[0,0]; let x01 : R, x01 = x[0,1]; let x02 : R, x02 = x[0,2]; @@ -161,10 +161,10 @@ let x22 : R, x22 = x[2,2]; SECTION("R^d component access from integer expression") { std::string_view data = R"( -let x : R^3, x = (1,2,3); +let x : R^3, x = [1,2,3]; let x0: R, x0 = x[3-2-1]; -let y : R^2, y = (2,7); +let y : R^2, y = [2,7]; let y1: R, y1 = y[2/2]; let z : R^1, z = 8; @@ -178,10 +178,10 @@ let z0: R, z0 = z[(2-2)*1]; SECTION("R^dxd component access from integer expression") { std::string_view data = R"( -let x : R^3x3, x = (1,2,3,4,5,6,7,8,9); +let x : R^3x3, x = [[1,2,3],[4,5,6],[7,8,9]]; let x01: R, x01 = x[3-2-1,2+3-4]; -let y : R^2x2, y = (2,7,6,-2); +let y : R^2x2, y = [[2,7],[6,-2]]; let y11: R, y11 = y[2/2, 3/1-2]; let z : R^1x1, z = 8; @@ -197,7 +197,7 @@ let z00: R, z00 = z[(2-2)*1, (3-1)*2-4]; SECTION("R index type") { std::string_view data = R"( -let x : R^3, x = (1,2,3); +let x : R^3, x = [1,2,3]; let x0: R, x0 = x[2.3]; )"; @@ -207,7 +207,7 @@ let x0: R, x0 = x[2.3]; SECTION("string index type") { std::string_view data = R"( -let x : R^3, x = (1,2,3); +let x : R^3, x = [1,2,3]; let x0: R, x0 = x["foo"]; )"; @@ -217,7 +217,7 @@ let x0: R, x0 = x["foo"]; SECTION("R^d index type") { std::string_view data = R"( -let x : R^3, x = (1,2,3); +let x : R^3, x = [1,2,3]; let x0: R, x0 = x[x]; )"; diff --git a/tests/test_BinaryExpressionProcessor_shift.cpp b/tests/test_BinaryExpressionProcessor_shift.cpp index 834e86cfe483d3745c483defc14d810809ffcd0b..010201d122ea543b828a1de7060700aa78313593 100644 --- a/tests/test_BinaryExpressionProcessor_shift.cpp +++ b/tests/test_BinaryExpressionProcessor_shift.cpp @@ -30,12 +30,12 @@ fout << createSocketServer(0) << "\n";)"; data << "let n:(N), n = (1,3);\n"; data << "let z:(Z), z = (-1,3);\n"; data << "let r:(R), r = (2.3,4);\n"; - data << "let u1:(R^1), u1 = (2.3,4);\n"; - data << "let u2:(R^2), u2 = ((2.3,4), (3,2));\n"; - data << "let u3:(R^3), u3 = ((2.3,4,-1), (3,2,1));\n"; - data << "let A1:(R^1x1), A1 = (2.3, 4);\n"; - data << "let A2:(R^2x2), A2 = ((2.3,4,2,0.3), (3,2.3,1,-4));\n"; - data << "let A3:(R^3x3), A3 = ((2.3,4,-1,2,7,2.3,6,2,8), (3,2,1,1,2,5,2.1,3,-2.6));\n"; + data << "let u1:(R^1), u1 = (2.3,[4]);\n"; + data << "let u2:(R^2), u2 = ([2.3,4], [3,2]);\n"; + data << "let u3:(R^3), u3 = ([2.3,4,-1], [3,2,1]);\n"; + data << "let A1:(R^1x1), A1 = (2.3, [[4]]);\n"; + data << "let A2:(R^2x2), A2 = ([[2.3,4],[2,0.3]], [[3,2.3],[1,-4]]);\n"; + data << "let A3:(R^3x3), A3 = ([[2.3,4,-1],[2,7,2.3],[6,2,8]], [[3,2,1],[1,2,5],[2.1,3,-2.6]]);\n"; data << R"(let s:(string), s = ("foo", "bar");)"; data << R"(fout << b << "\n";)"; data << R"(fout << n << "\n";)"; diff --git a/tests/test_BuiltinFunctionProcessor.cpp b/tests/test_BuiltinFunctionProcessor.cpp index bbc5ac52e1a6e8034b68b591adff83c1d8701ff5..95d743f1a79ea55ea482b14d63fdb1f7fa49e664 100644 --- a/tests/test_BuiltinFunctionProcessor.cpp +++ b/tests/test_BuiltinFunctionProcessor.cpp @@ -17,6 +17,8 @@ TAO_PEGTL_NAMESPACE::string_input input{data, "test.pgs"}; \ auto ast = ASTBuilder::build(input); \ \ + test_only::test_BuiltinFunctionRegister{*ast}; \ + \ ASTModulesImporter{*ast}; \ ASTNodeTypeCleaner<language::import_instruction>{*ast}; \ \ @@ -329,8 +331,8 @@ let s:R, s = dot(x,y); tested_function_set.insert("dot:R^2*R^2"); std::string_view data = R"( import math; -let x:R^2, x = (-2, 3); -let y:R^2, y = (4, 3); +let x:R^2, x = [-2, 3]; +let y:R^2, y = [4, 3]; let s:R, s = dot(x,y); )"; CHECK_BUILTIN_FUNCTION_EVALUATION_RESULT(data, "s", dot(TinyVector<2>{-2, 3}, TinyVector<2>{4, 3})); @@ -340,8 +342,8 @@ let s:R, s = dot(x,y); tested_function_set.insert("dot:R^3*R^3"); std::string_view data = R"( import math; -let x:R^3, x = (-2, 3, 4); -let y:R^3, y = (4, 3, 5); +let x:R^3, x = [-2, 3, 4]; +let y:R^3, y = [4, 3, 5]; let s:R, s = dot(x,y); )"; CHECK_BUILTIN_FUNCTION_EVALUATION_RESULT(data, "s", dot(TinyVector<3>{-2, 3, 4}, TinyVector<3>{4, 3, 5})); @@ -369,4 +371,24 @@ runtimeError(); CHECK_AST_THROWS_WITH(data, error); } } + + SECTION("int list -> tuple args evalation") + { + { + std::string_view data = R"( +let x:R, x = tuple_ZtoR((1,2,3-4)); +)"; + CHECK_BUILTIN_FUNCTION_EVALUATION_RESULT(data, "x", 0.5 * (1 + 2 + 3 - 4)); + } + } + + SECTION("simple N to tuple args evalation") + { + { + std::string_view data = R"( +let x:R, x = tuple_ZtoR(3); +)"; + CHECK_BUILTIN_FUNCTION_EVALUATION_RESULT(data, "x", 0.5 * 3); + } + } } diff --git a/tests/test_BuiltinFunctionRegister.hpp b/tests/test_BuiltinFunctionRegister.hpp index 49bceabb565ec13b04350f083009c85702886fc2..fc4e6c0d40db70eeb6e9774d2147e121e6b0a89d 100644 --- a/tests/test_BuiltinFunctionRegister.hpp +++ b/tests/test_BuiltinFunctionRegister.hpp @@ -121,7 +121,13 @@ class test_BuiltinFunctionRegister m_name_builtin_function_map.insert( std::make_pair("tuple_ZtoR:(Z...)", std::make_shared<BuiltinFunctionEmbedder<double(std::vector<int64_t>)>>( - [](const std::vector<int64_t>&) -> double { return 0.5; }))); + [](const std::vector<int64_t>& v) -> double { + int64_t sum = 0; + for (auto vi : v) { + sum += vi; + } + return 0.5 * sum; + }))); m_name_builtin_function_map.insert( std::make_pair("tuple_RtoB:(R...)", std::make_shared<BuiltinFunctionEmbedder<bool(std::vector<double>)>>( diff --git a/tests/test_ConcatExpressionProcessor.cpp b/tests/test_ConcatExpressionProcessor.cpp index 4c5e202b71a1b9630683145aa4ffb30863ce9a27..ce6c23ddcbc3719907d43ea2b14cff52337dc655 100644 --- a/tests/test_ConcatExpressionProcessor.cpp +++ b/tests/test_ConcatExpressionProcessor.cpp @@ -90,7 +90,7 @@ TEST_CASE("ConcatExpressionProcessor", "[language]") std::ostringstream os; os << "foo_" << TinyVector<2>{1, 2}; - CHECK_CONCAT_EXPRESSION_RESULT(R"(let x:R^2, x = (1,2); let s:string, s = "foo_"; s = s+x;)", "s", os.str()); + CHECK_CONCAT_EXPRESSION_RESULT(R"(let x:R^2, x = [1,2]; let s:string, s = "foo_"; s = s+x;)", "s", os.str()); } SECTION("string + R^3") @@ -98,6 +98,6 @@ TEST_CASE("ConcatExpressionProcessor", "[language]") std::ostringstream os; os << "foo_" << TinyVector<3>{1, 2, 3}; - CHECK_CONCAT_EXPRESSION_RESULT(R"(let x:R^3, x = (1,2,3); let s:string, s = "foo_"; s = s+x;)", "s", os.str()); + CHECK_CONCAT_EXPRESSION_RESULT(R"(let s:string, s = "foo_"; s = s+[1,2,3];)", "s", os.str()); } } diff --git a/tests/test_DiscreteFunctionIntegrator.cpp b/tests/test_DiscreteFunctionIntegrator.cpp index 465288f67d4efcd9a7a78eff53ab9649d381e572..031f6c62bd4f123e0a001eacdea0721716325978 100644 --- a/tests/test_DiscreteFunctionIntegrator.cpp +++ b/tests/test_DiscreteFunctionIntegrator.cpp @@ -61,11 +61,11 @@ let N_scalar_non_linear_1d: R^1 -> N, x -> floor(3 * x[0] * x[0] + 2); let Z_scalar_non_linear_1d: R^1 -> Z, x -> floor(exp(2 * x[0]) - 1); let R_scalar_non_linear_1d: R^1 -> R, x -> 2 * exp(x[0]) + 3; let R1_non_linear_1d: R^1 -> R^1, x -> 2 * exp(x[0]); -let R2_non_linear_1d: R^1 -> R^2, x -> (2 * exp(x[0]), -3*x[0]); -let R3_non_linear_1d: R^1 -> R^3, x -> (2 * exp(x[0]) + 3, x[0] - 2, 3); +let R2_non_linear_1d: R^1 -> R^2, x -> [2 * exp(x[0]), -3*x[0]]; +let R3_non_linear_1d: R^1 -> R^3, x -> [2 * exp(x[0]) + 3, x[0] - 2, 3]; let R1x1_non_linear_1d: R^1 -> R^1x1, x -> (2 * exp(x[0]) * sin(x[0]) + 3); -let R2x2_non_linear_1d: R^1 -> R^2x2, x -> (2 * exp(x[0]) * sin(x[0]) + 3, sin(x[0] - 2 * x[0]), 3, x[0] * x[0]); -let R3x3_non_linear_1d: R^1 -> R^3x3, x -> (2 * exp(x[0]) * sin(x[0]) + 3, sin(x[0] - 2 * x[0]), 3, x[0] * x[0], -4*x[0], 2*x[0]+1, 3, -6*x[0], exp(x[0])); +let R2x2_non_linear_1d: R^1 -> R^2x2, x -> [[2 * exp(x[0]) * sin(x[0]) + 3, sin(x[0] - 2 * x[0])], [3, x[0] * x[0]]]; +let R3x3_non_linear_1d: R^1 -> R^3x3, x -> [[2 * exp(x[0]) * sin(x[0]) + 3, sin(x[0] - 2 * x[0]), 3], [x[0] * x[0], -4*x[0], 2*x[0]+1], [3, -6*x[0], exp(x[0])]]; )"; TAO_PEGTL_NAMESPACE::string_input input{data, "test.pgs"}; @@ -307,11 +307,11 @@ let N_scalar_non_linear_2d: R^2 -> N, x -> floor(3 * (x[0] + x[1]) * (x[0] + x[1 let Z_scalar_non_linear_2d: R^2 -> Z, x -> floor(exp(2 * x[0]) - 3 * x[1]); let R_scalar_non_linear_2d: R^2 -> R, x -> 2 * exp(x[0]) + 3 * x[1]; let R1_non_linear_2d: R^2 -> R^1, x -> 2 * exp(x[0]); -let R2_non_linear_2d: R^2 -> R^2, x -> (2 * exp(x[0]), -3*x[1]); -let R3_non_linear_2d: R^2 -> R^3, x -> (2 * exp(x[0]) + 3, x[1] - 2, 3); -let R1x1_non_linear_2d: R^2 -> R^1x1, x -> (2 * exp(x[0]) * sin(x[1]) + 3); -let R2x2_non_linear_2d: R^2 -> R^2x2, x -> (2 * exp(x[0]) * sin(x[1]) + 3, sin(x[1] - 2 * x[0]), 3, x[1] * x[0]); -let R3x3_non_linear_2d: R^2 -> R^3x3, x -> (2 * exp(x[0]) * sin(x[1]) + 3, sin(x[1] - 2 * x[0]), 3, x[1] * x[0], -4*x[1], 2*x[0]+1, 3, -6*x[0], exp(x[1])); +let R2_non_linear_2d: R^2 -> R^2, x -> [2 * exp(x[0]), -3*x[1]]; +let R3_non_linear_2d: R^2 -> R^3, x -> [2 * exp(x[0]) + 3, x[1] - 2, 3]; +let R1x1_non_linear_2d: R^2 -> R^1x1, x -> 2 * exp(x[0]) * sin(x[1]) + 3; +let R2x2_non_linear_2d: R^2 -> R^2x2, x -> [[2 * exp(x[0]) * sin(x[1]) + 3, sin(x[1] - 2 * x[0])], [3, x[1] * x[0]]]; +let R3x3_non_linear_2d: R^2 -> R^3x3, x -> [[2 * exp(x[0]) * sin(x[1]) + 3, sin(x[1] - 2 * x[0]), 3], [x[1] * x[0], -4*x[1], 2*x[0]+1], [3, -6*x[0], exp(x[1])]]; )"; TAO_PEGTL_NAMESPACE::string_input input{data, "test.pgs"}; @@ -553,11 +553,11 @@ let N_scalar_non_linear_3d: R^3 -> N, x -> floor(3 * (x[0] + x[1]) * (x[0] + x[1 let Z_scalar_non_linear_3d: R^3 -> Z, x -> floor(exp(2 * x[0]) - 3 * x[1] + x[2]); let R_scalar_non_linear_3d: R^3 -> R, x -> 2 * exp(x[0]+x[2]) + 3 * x[1]; let R1_non_linear_3d: R^3 -> R^1, x -> 2 * exp(x[0])+sin(x[1] + x[2]); -let R2_non_linear_3d: R^3 -> R^2, x -> (2 * exp(x[0]), -3*x[1] * x[2]); -let R3_non_linear_3d: R^3 -> R^3, x -> (2 * exp(x[0]) + 3, x[1] - 2, 3 * x[2]); +let R2_non_linear_3d: R^3 -> R^2, x -> [2 * exp(x[0]), -3*x[1] * x[2]]; +let R3_non_linear_3d: R^3 -> R^3, x -> [2 * exp(x[0]) + 3, x[1] - 2, 3 * x[2]]; let R1x1_non_linear_3d: R^3 -> R^1x1, x -> (2 * exp(x[0]) * sin(x[1]) + 3 * x[2]); -let R2x2_non_linear_3d: R^3 -> R^2x2, x -> (2 * exp(x[0]) * sin(x[1]) + 3, sin(x[2] - 2 * x[0]), 3, x[1] * x[0] - x[2]); -let R3x3_non_linear_3d: R^3 -> R^3x3, x -> (2 * exp(x[0]) * sin(x[1]) + 3, sin(x[1] - 2 * x[2]), 3, x[1] * x[2], -4*x[1], 2*x[2]+1, 3, -6*x[2], exp(x[1] + x[2])); +let R2x2_non_linear_3d: R^3 -> R^2x2, x -> [[2 * exp(x[0]) * sin(x[1]) + 3, sin(x[2] - 2 * x[0])], [3, x[1] * x[0] - x[2]]]; +let R3x3_non_linear_3d: R^3 -> R^3x3, x -> [[2 * exp(x[0]) * sin(x[1]) + 3, sin(x[1] - 2 * x[2]), 3], [x[1] * x[2], -4*x[1], 2*x[2]+1], [3, -6*x[2], exp(x[1] + x[2])]]; )"; TAO_PEGTL_NAMESPACE::string_input input{data, "test.pgs"}; diff --git a/tests/test_DiscreteFunctionIntegratorByZone.cpp b/tests/test_DiscreteFunctionIntegratorByZone.cpp index 071f8cddb7e9f71e0b102bf361afb8715a7afe87..19c0ac87c1d941e4c5f0026e154087be305c55f2 100644 --- a/tests/test_DiscreteFunctionIntegratorByZone.cpp +++ b/tests/test_DiscreteFunctionIntegratorByZone.cpp @@ -64,11 +64,11 @@ let N_scalar_non_linear_1d: R^1 -> N, x -> floor(3 * x[0] * x[0] + 2); let Z_scalar_non_linear_1d: R^1 -> Z, x -> floor(exp(2 * x[0]) - 1); let R_scalar_non_linear_1d: R^1 -> R, x -> 2 * exp(x[0]) + 3; let R1_non_linear_1d: R^1 -> R^1, x -> 2 * exp(x[0]); -let R2_non_linear_1d: R^1 -> R^2, x -> (2 * exp(x[0]), -3*x[0]); -let R3_non_linear_1d: R^1 -> R^3, x -> (2 * exp(x[0]) + 3, x[0] - 2, 3); +let R2_non_linear_1d: R^1 -> R^2, x -> [2 * exp(x[0]), -3*x[0]]; +let R3_non_linear_1d: R^1 -> R^3, x -> [2 * exp(x[0]) + 3, x[0] - 2, 3]; let R1x1_non_linear_1d: R^1 -> R^1x1, x -> (2 * exp(x[0]) * sin(x[0]) + 3); -let R2x2_non_linear_1d: R^1 -> R^2x2, x -> (2 * exp(x[0]) * sin(x[0]) + 3, sin(x[0] - 2 * x[0]), 3, x[0] * x[0]); -let R3x3_non_linear_1d: R^1 -> R^3x3, x -> (2 * exp(x[0]) * sin(x[0]) + 3, sin(x[0] - 2 * x[0]), 3, x[0] * x[0], -4*x[0], 2*x[0]+1, 3, -6*x[0], exp(x[0])); +let R2x2_non_linear_1d: R^1 -> R^2x2, x -> [[2 * exp(x[0]) * sin(x[0]) + 3, sin(x[0] - 2 * x[0])], [3, x[0] * x[0]]]; +let R3x3_non_linear_1d: R^1 -> R^3x3, x -> [[2 * exp(x[0]) * sin(x[0]) + 3, sin(x[0] - 2 * x[0]), 3], [x[0] * x[0], -4*x[0], 2*x[0]+1], [3, -6*x[0], exp(x[0])]]; )"; TAO_PEGTL_NAMESPACE::string_input input{data, "test.pgs"}; @@ -403,11 +403,11 @@ let N_scalar_non_linear_2d: R^2 -> N, x -> floor(3 * (x[0] + x[1]) * (x[0] + x[1 let Z_scalar_non_linear_2d: R^2 -> Z, x -> floor(exp(2 * x[0]) - 3 * x[1]); let R_scalar_non_linear_2d: R^2 -> R, x -> 2 * exp(x[0]) + 3 * x[1]; let R1_non_linear_2d: R^2 -> R^1, x -> 2 * exp(x[0]); -let R2_non_linear_2d: R^2 -> R^2, x -> (2 * exp(x[0]), -3*x[1]); -let R3_non_linear_2d: R^2 -> R^3, x -> (2 * exp(x[0]) + 3, x[1] - 2, 3); +let R2_non_linear_2d: R^2 -> R^2, x -> [2 * exp(x[0]), -3*x[1]]; +let R3_non_linear_2d: R^2 -> R^3, x -> [2 * exp(x[0]) + 3, x[1] - 2, 3]; let R1x1_non_linear_2d: R^2 -> R^1x1, x -> (2 * exp(x[0]) * sin(x[1]) + 3); -let R2x2_non_linear_2d: R^2 -> R^2x2, x -> (2 * exp(x[0]) * sin(x[1]) + 3, sin(x[1] - 2 * x[0]), 3, x[1] * x[0]); -let R3x3_non_linear_2d: R^2 -> R^3x3, x -> (2 * exp(x[0]) * sin(x[1]) + 3, sin(x[1] - 2 * x[0]), 3, x[1] * x[0], -4*x[1], 2*x[0]+1, 3, -6*x[0], exp(x[1])); +let R2x2_non_linear_2d: R^2 -> R^2x2, x -> [[2 * exp(x[0]) * sin(x[1]) + 3, sin(x[1] - 2 * x[0])], [3, x[1] * x[0]]]; +let R3x3_non_linear_2d: R^2 -> R^3x3, x -> [[2 * exp(x[0]) * sin(x[1]) + 3, sin(x[1] - 2 * x[0]), 3], [x[1] * x[0], -4*x[1], 2*x[0]+1], [3, -6*x[0], exp(x[1])]]; )"; TAO_PEGTL_NAMESPACE::string_input input{data, "test.pgs"}; @@ -742,11 +742,11 @@ let N_scalar_non_linear_3d: R^3 -> N, x -> floor(3 * (x[0] + x[1]) * (x[0] + x[1 let Z_scalar_non_linear_3d: R^3 -> Z, x -> floor(exp(2 * x[0]) - 3 * x[1] + x[2]); let R_scalar_non_linear_3d: R^3 -> R, x -> 2 * exp(x[0]+x[2]) + 3 * x[1]; let R1_non_linear_3d: R^3 -> R^1, x -> 2 * exp(x[0])+sin(x[1] + x[2]); -let R2_non_linear_3d: R^3 -> R^2, x -> (2 * exp(x[0]), -3*x[1] * x[2]); -let R3_non_linear_3d: R^3 -> R^3, x -> (2 * exp(x[0]) + 3, x[1] - 2, 3 * x[2]); +let R2_non_linear_3d: R^3 -> R^2, x -> [2 * exp(x[0]), -3*x[1] * x[2]]; +let R3_non_linear_3d: R^3 -> R^3, x -> [2 * exp(x[0]) + 3, x[1] - 2, 3 * x[2]]; let R1x1_non_linear_3d: R^3 -> R^1x1, x -> (2 * exp(x[0]) * sin(x[1]) + 3 * x[2]); -let R2x2_non_linear_3d: R^3 -> R^2x2, x -> (2 * exp(x[0]) * sin(x[1]) + 3, sin(x[2] - 2 * x[0]), 3, x[1] * x[0] - x[2]); -let R3x3_non_linear_3d: R^3 -> R^3x3, x -> (2 * exp(x[0]) * sin(x[1]) + 3, sin(x[1] - 2 * x[2]), 3, x[1] * x[2], -4*x[1], 2*x[2]+1, 3, -6*x[2], exp(x[1] + x[2])); +let R2x2_non_linear_3d: R^3 -> R^2x2, x -> [[2 * exp(x[0]) * sin(x[1]) + 3, sin(x[2] - 2 * x[0])], [3, x[1] * x[0] - x[2]]]; +let R3x3_non_linear_3d: R^3 -> R^3x3, x -> [[2 * exp(x[0]) * sin(x[1]) + 3, sin(x[1] - 2 * x[2]), 3], [x[1] * x[2], -4*x[1], 2*x[2]+1], [3, -6*x[2], exp(x[1] + x[2])]]; )"; TAO_PEGTL_NAMESPACE::string_input input{data, "test.pgs"}; diff --git a/tests/test_DiscreteFunctionInterpoler.cpp b/tests/test_DiscreteFunctionInterpoler.cpp index 809ca559ca254cbbb5d90c63f8dcd943a5df23c8..f9d870d29dbd53f6eef9f49bf114be2566475d0d 100644 --- a/tests/test_DiscreteFunctionInterpoler.cpp +++ b/tests/test_DiscreteFunctionInterpoler.cpp @@ -59,11 +59,11 @@ let N_scalar_non_linear_1d: R^1 -> N, x -> floor(3 * x[0] * x[0] + 2); let Z_scalar_non_linear_1d: R^1 -> Z, x -> floor(exp(2 * x[0]) - 1); let R_scalar_non_linear_1d: R^1 -> R, x -> 2 * exp(x[0]) + 3; let R1_non_linear_1d: R^1 -> R^1, x -> 2 * exp(x[0]); -let R2_non_linear_1d: R^1 -> R^2, x -> (2 * exp(x[0]), -3*x[0]); -let R3_non_linear_1d: R^1 -> R^3, x -> (2 * exp(x[0]) + 3, x[0] - 2, 3); +let R2_non_linear_1d: R^1 -> R^2, x -> [2 * exp(x[0]), -3*x[0]]; +let R3_non_linear_1d: R^1 -> R^3, x -> [2 * exp(x[0]) + 3, x[0] - 2, 3]; let R1x1_non_linear_1d: R^1 -> R^1x1, x -> (2 * exp(x[0]) * sin(x[0]) + 3); -let R2x2_non_linear_1d: R^1 -> R^2x2, x -> (2 * exp(x[0]) * sin(x[0]) + 3, sin(x[0] - 2 * x[0]), 3, x[0] * x[0]); -let R3x3_non_linear_1d: R^1 -> R^3x3, x -> (2 * exp(x[0]) * sin(x[0]) + 3, sin(x[0] - 2 * x[0]), 3, x[0] * x[0], -4*x[0], 2*x[0]+1, 3, -6*x[0], exp(x[0])); +let R2x2_non_linear_1d: R^1 -> R^2x2, x -> [[2 * exp(x[0]) * sin(x[0]) + 3, sin(x[0] - 2 * x[0])], [3, x[0] * x[0]]]; +let R3x3_non_linear_1d: R^1 -> R^3x3, x -> [[2 * exp(x[0]) * sin(x[0]) + 3, sin(x[0] - 2 * x[0]), 3], [x[0] * x[0], -4*x[0], 2*x[0]+1], [3, -6*x[0], exp(x[0])]]; )"; TAO_PEGTL_NAMESPACE::string_input input{data, "test.pgs"}; @@ -358,11 +358,11 @@ let N_scalar_non_linear_2d: R^2 -> N, x -> floor(3 * (x[0] + x[1]) * (x[0] + x[1 let Z_scalar_non_linear_2d: R^2 -> Z, x -> floor(exp(2 * x[0]) - 3 * x[1]); let R_scalar_non_linear_2d: R^2 -> R, x -> 2 * exp(x[0]) + 3 * x[1]; let R1_non_linear_2d: R^2 -> R^1, x -> 2 * exp(x[0]); -let R2_non_linear_2d: R^2 -> R^2, x -> (2 * exp(x[0]), -3*x[1]); -let R3_non_linear_2d: R^2 -> R^3, x -> (2 * exp(x[0]) + 3, x[1] - 2, 3); -let R1x1_non_linear_2d: R^2 -> R^1x1, x -> (2 * exp(x[0]) * sin(x[1]) + 3); -let R2x2_non_linear_2d: R^2 -> R^2x2, x -> (2 * exp(x[0]) * sin(x[1]) + 3, sin(x[1] - 2 * x[0]), 3, x[1] * x[0]); -let R3x3_non_linear_2d: R^2 -> R^3x3, x -> (2 * exp(x[0]) * sin(x[1]) + 3, sin(x[1] - 2 * x[0]), 3, x[1] * x[0], -4*x[1], 2*x[0]+1, 3, -6*x[0], exp(x[1])); +let R2_non_linear_2d: R^2 -> R^2, x -> [2 * exp(x[0]), -3*x[1]]; +let R3_non_linear_2d: R^2 -> R^3, x -> [2 * exp(x[0]) + 3, x[1] - 2, 3]; +let R1x1_non_linear_2d: R^2 -> R^1x1, x -> [[2 * exp(x[0]) * sin(x[1]) + 3]]; +let R2x2_non_linear_2d: R^2 -> R^2x2, x -> [[2 * exp(x[0]) * sin(x[1]) + 3, sin(x[1] - 2 * x[0])], [3, x[1] * x[0]]]; +let R3x3_non_linear_2d: R^2 -> R^3x3, x -> [[2 * exp(x[0]) * sin(x[1]) + 3, sin(x[1] - 2 * x[0]), 3], [x[1] * x[0], -4*x[1], 2*x[0]+1], [3, -6*x[0], exp(x[1])]]; )"; TAO_PEGTL_NAMESPACE::string_input input{data, "test.pgs"}; @@ -658,11 +658,11 @@ let N_scalar_non_linear_3d: R^3 -> N, x -> floor(3 * (x[0] + x[1]) * (x[0] + x[1 let Z_scalar_non_linear_3d: R^3 -> Z, x -> floor(exp(2 * x[0]) - 3 * x[1] + x[2]); let R_scalar_non_linear_3d: R^3 -> R, x -> 2 * exp(x[0]+x[2]) + 3 * x[1]; let R1_non_linear_3d: R^3 -> R^1, x -> 2 * exp(x[0])+sin(x[1] + x[2]); -let R2_non_linear_3d: R^3 -> R^2, x -> (2 * exp(x[0]), -3*x[1] * x[2]); -let R3_non_linear_3d: R^3 -> R^3, x -> (2 * exp(x[0]) + 3, x[1] - 2, 3 * x[2]); -let R1x1_non_linear_3d: R^3 -> R^1x1, x -> (2 * exp(x[0]) * sin(x[1]) + 3 * x[2]); -let R2x2_non_linear_3d: R^3 -> R^2x2, x -> (2 * exp(x[0]) * sin(x[1]) + 3, sin(x[2] - 2 * x[0]), 3, x[1] * x[0] - x[2]); -let R3x3_non_linear_3d: R^3 -> R^3x3, x -> (2 * exp(x[0]) * sin(x[1]) + 3, sin(x[1] - 2 * x[2]), 3, x[1] * x[2], -4*x[1], 2*x[2]+1, 3, -6*x[2], exp(x[1] + x[2])); +let R2_non_linear_3d: R^3 -> R^2, x -> [2 * exp(x[0]), -3*x[1] * x[2]]; +let R3_non_linear_3d: R^3 -> R^3, x -> [2 * exp(x[0]) + 3, x[1] - 2, 3 * x[2]]; +let R1x1_non_linear_3d: R^3 -> R^1x1, x -> 2 * exp(x[0]) * sin(x[1]) + 3 * x[2]; +let R2x2_non_linear_3d: R^3 -> R^2x2, x -> [[2 * exp(x[0]) * sin(x[1]) + 3, sin(x[2] - 2 * x[0])], [3, x[1] * x[0] - x[2]]]; +let R3x3_non_linear_3d: R^3 -> R^3x3, x -> [[2 * exp(x[0]) * sin(x[1]) + 3, sin(x[1] - 2 * x[2]), 3], [x[1] * x[2], -4*x[1], 2*x[2]+1], [3, -6*x[2], exp(x[1] + x[2])]]; )"; TAO_PEGTL_NAMESPACE::string_input input{data, "test.pgs"}; diff --git a/tests/test_DiscreteFunctionInterpolerByZone.cpp b/tests/test_DiscreteFunctionInterpolerByZone.cpp index 4ad5f464f5fe276bf489df459cd2cfc90e42a519..dce3b645a7e98ee91b41f8cd5f158edb019d94ed 100644 --- a/tests/test_DiscreteFunctionInterpolerByZone.cpp +++ b/tests/test_DiscreteFunctionInterpolerByZone.cpp @@ -67,11 +67,11 @@ let N_scalar_non_linear_1d: R^1 -> N, x -> floor(3 * x[0] * x[0] + 2); let Z_scalar_non_linear_1d: R^1 -> Z, x -> floor(exp(2 * x[0]) - 1); let R_scalar_non_linear_1d: R^1 -> R, x -> 2 * exp(x[0]) + 3; let R1_non_linear_1d: R^1 -> R^1, x -> 2 * exp(x[0]); -let R2_non_linear_1d: R^1 -> R^2, x -> (2 * exp(x[0]), -3*x[0]); -let R3_non_linear_1d: R^1 -> R^3, x -> (2 * exp(x[0]) + 3, x[0] - 2, 3); -let R1x1_non_linear_1d: R^1 -> R^1x1, x -> (2 * exp(x[0]) * sin(x[0]) + 3); -let R2x2_non_linear_1d: R^1 -> R^2x2, x -> (2 * exp(x[0]) * sin(x[0]) + 3, sin(x[0] - 2 * x[0]), 3, x[0] * x[0]); -let R3x3_non_linear_1d: R^1 -> R^3x3, x -> (2 * exp(x[0]) * sin(x[0]) + 3, sin(x[0] - 2 * x[0]), 3, x[0] * x[0], -4*x[0], 2*x[0]+1, 3, -6*x[0], exp(x[0])); +let R2_non_linear_1d: R^1 -> R^2, x -> [2 * exp(x[0]), -3*x[0]]; +let R3_non_linear_1d: R^1 -> R^3, x -> [2 * exp(x[0]) + 3, x[0] - 2, 3]; +let R1x1_non_linear_1d: R^1 -> R^1x1, x -> 2 * exp(x[0]) * sin(x[0]) + 3; +let R2x2_non_linear_1d: R^1 -> R^2x2, x -> [[2 * exp(x[0]) * sin(x[0]) + 3, sin(x[0] - 2 * x[0])], [3, x[0] * x[0]]]; +let R3x3_non_linear_1d: R^1 -> R^3x3, x -> [[2 * exp(x[0]) * sin(x[0]) + 3, sin(x[0] - 2 * x[0]), 3], [x[0] * x[0], -4*x[0], 2*x[0]+1], [3, -6*x[0], exp(x[0])]]; )"; TAO_PEGTL_NAMESPACE::string_input input{data, "test.pgs"}; @@ -410,11 +410,11 @@ let N_scalar_non_linear_2d: R^2 -> N, x -> floor(3 * (x[0] + x[1]) * (x[0] + x[1 let Z_scalar_non_linear_2d: R^2 -> Z, x -> floor(exp(2 * x[0]) - 3 * x[1]); let R_scalar_non_linear_2d: R^2 -> R, x -> 2 * exp(x[0]) + 3 * x[1]; let R1_non_linear_2d: R^2 -> R^1, x -> 2 * exp(x[0]); -let R2_non_linear_2d: R^2 -> R^2, x -> (2 * exp(x[0]), -3*x[1]); -let R3_non_linear_2d: R^2 -> R^3, x -> (2 * exp(x[0]) + 3, x[1] - 2, 3); +let R2_non_linear_2d: R^2 -> R^2, x -> [2 * exp(x[0]), -3*x[1]]; +let R3_non_linear_2d: R^2 -> R^3, x -> [2 * exp(x[0]) + 3, x[1] - 2, 3]; let R1x1_non_linear_2d: R^2 -> R^1x1, x -> (2 * exp(x[0]) * sin(x[1]) + 3); -let R2x2_non_linear_2d: R^2 -> R^2x2, x -> (2 * exp(x[0]) * sin(x[1]) + 3, sin(x[1] - 2 * x[0]), 3, x[1] * x[0]); -let R3x3_non_linear_2d: R^2 -> R^3x3, x -> (2 * exp(x[0]) * sin(x[1]) + 3, sin(x[1] - 2 * x[0]), 3, x[1] * x[0], -4*x[1], 2*x[0]+1, 3, -6*x[0], exp(x[1])); +let R2x2_non_linear_2d: R^2 -> R^2x2, x -> [[2 * exp(x[0]) * sin(x[1]) + 3, sin(x[1] - 2 * x[0])], [3, x[1] * x[0]]]; +let R3x3_non_linear_2d: R^2 -> R^3x3, x -> [[2 * exp(x[0]) * sin(x[1]) + 3, sin(x[1] - 2 * x[0]), 3], [x[1] * x[0], -4*x[1], 2*x[0]+1], [3, -6*x[0], exp(x[1])]]; )"; TAO_PEGTL_NAMESPACE::string_input input{data, "test.pgs"}; @@ -754,11 +754,11 @@ let N_scalar_non_linear_3d: R^3 -> N, x -> floor(3 * (x[0] + x[1]) * (x[0] + x[1 let Z_scalar_non_linear_3d: R^3 -> Z, x -> floor(exp(2 * x[0]) - 3 * x[1] + x[2]); let R_scalar_non_linear_3d: R^3 -> R, x -> 2 * exp(x[0]+x[2]) + 3 * x[1]; let R1_non_linear_3d: R^3 -> R^1, x -> 2 * exp(x[0])+sin(x[1] + x[2]); -let R2_non_linear_3d: R^3 -> R^2, x -> (2 * exp(x[0]), -3*x[1] * x[2]); -let R3_non_linear_3d: R^3 -> R^3, x -> (2 * exp(x[0]) + 3, x[1] - 2, 3 * x[2]); +let R2_non_linear_3d: R^3 -> R^2, x -> [2 * exp(x[0]), -3*x[1] * x[2]]; +let R3_non_linear_3d: R^3 -> R^3, x -> [2 * exp(x[0]) + 3, x[1] - 2, 3 * x[2]]; let R1x1_non_linear_3d: R^3 -> R^1x1, x -> (2 * exp(x[0]) * sin(x[1]) + 3 * x[2]); -let R2x2_non_linear_3d: R^3 -> R^2x2, x -> (2 * exp(x[0]) * sin(x[1]) + 3, sin(x[2] - 2 * x[0]), 3, x[1] * x[0] - x[2]); -let R3x3_non_linear_3d: R^3 -> R^3x3, x -> (2 * exp(x[0]) * sin(x[1]) + 3, sin(x[1] - 2 * x[2]), 3, x[1] * x[2], -4*x[1], 2*x[2]+1, 3, -6*x[2], exp(x[1] + x[2])); +let R2x2_non_linear_3d: R^3 -> R^2x2, x -> [[2 * exp(x[0]) * sin(x[1]) + 3, sin(x[2] - 2 * x[0])], [3, x[1] * x[0] - x[2]]]; +let R3x3_non_linear_3d: R^3 -> R^3x3, x -> [[2 * exp(x[0]) * sin(x[1]) + 3, sin(x[1] - 2 * x[2]), 3], [x[1] * x[2], -4*x[1], 2*x[2]+1], [3, -6*x[2], exp(x[1] + x[2])]]; )"; TAO_PEGTL_NAMESPACE::string_input input{data, "test.pgs"}; diff --git a/tests/test_DiscreteFunctionVectorIntegrator.cpp b/tests/test_DiscreteFunctionVectorIntegrator.cpp index d0a9d6a78fd260c0b259aa630d9e79f85271ae89..31fd447f525f2b002ead1246219319454c792588 100644 --- a/tests/test_DiscreteFunctionVectorIntegrator.cpp +++ b/tests/test_DiscreteFunctionVectorIntegrator.cpp @@ -348,7 +348,7 @@ let B_scalar_non_linear_2d: R^2 -> B, x -> (exp(2 * x[0] + x[1]) + 3 > 4); let N_scalar_non_linear_1d: R^1 -> N, x -> floor(3 * x[0] * x[0] + 2); let Z_scalar_non_linear_3d: R^3 -> Z, x -> floor(exp(2 * x[1]) - x[2]); let R_scalar_non_linear_3d: R^3 -> R, x -> 2 * exp(x[0] + x[1]) + 3 * x[2]; -let R2_scalar_non_linear_3d: R^3 -> R^2, x -> (2 * exp(x[0] + x[1]) + 3 * x[2], x[0] - x[1]); +let R2_scalar_non_linear_3d: R^3 -> R^2, x -> [2 * exp(x[0] + x[1]) + 3 * x[2], x[0] - x[1]]; )"; TAO_PEGTL_NAMESPACE::string_input input{data, "test.pgs"}; diff --git a/tests/test_DiscreteFunctionVectorInterpoler.cpp b/tests/test_DiscreteFunctionVectorInterpoler.cpp index 692dd8c6c18ad85f87f5c85dcc41a6bcb0838312..3c3fefc38aba5b7377a86eb28ce4c6439ed82164 100644 --- a/tests/test_DiscreteFunctionVectorInterpoler.cpp +++ b/tests/test_DiscreteFunctionVectorInterpoler.cpp @@ -390,7 +390,7 @@ let B_scalar_non_linear_2d: R^2 -> B, x -> (exp(2 * x[0] + x[1]) + 3 > 4); let N_scalar_non_linear_1d: R^1 -> N, x -> floor(3 * x[0] * x[0] + 2); let Z_scalar_non_linear_3d: R^3 -> Z, x -> floor(exp(2 * x[1]) - x[2]); let R_scalar_non_linear_3d: R^3 -> R, x -> 2 * exp(x[0] + x[1]) + 3 * x[2]; -let R2_scalar_non_linear_3d: R^3 -> R^2, x -> (2 * exp(x[0] + x[1]) + 3 * x[2], x[0] - x[1]); +let R2_scalar_non_linear_3d: R^3 -> R^2, x -> [2 * exp(x[0] + x[1]) + 3 * x[2], x[0] - x[1]]; )"; TAO_PEGTL_NAMESPACE::string_input input{data, "test.pgs"}; diff --git a/tests/test_DiscreteFunctionVectorInterpolerByZone.cpp b/tests/test_DiscreteFunctionVectorInterpolerByZone.cpp index 172c68d4f59f318d0f36c315aaf4962e71195dbe..c3605a232c7b032ad4215db72cdf711695818c6e 100644 --- a/tests/test_DiscreteFunctionVectorInterpolerByZone.cpp +++ b/tests/test_DiscreteFunctionVectorInterpolerByZone.cpp @@ -443,7 +443,7 @@ let B_scalar_non_linear_2d: R^2 -> B, x -> (exp(2 * x[0] + x[1]) + 3 > 4); let N_scalar_non_linear_1d: R^1 -> N, x -> floor(3 * x[0] * x[0] + 2); let Z_scalar_non_linear_3d: R^3 -> Z, x -> floor(exp(2 * x[1]) - x[2]); let R_scalar_non_linear_3d: R^3 -> R, x -> 2 * exp(x[0] + x[1]) + 3 * x[2]; -let R2_scalar_non_linear_3d: R^3 -> R^2, x -> (2 * exp(x[0] + x[1]) + 3 * x[2], x[0] - x[1]); +let R2_scalar_non_linear_3d: R^3 -> R^2, x -> [2 * exp(x[0] + x[1]) + 3 * x[2], x[0] - x[1]]; )"; TAO_PEGTL_NAMESPACE::string_input input{data, "test.pgs"}; diff --git a/tests/test_FunctionProcessor.cpp b/tests/test_FunctionProcessor.cpp index 5c72fd0d7b96a4919490b6707bde1bef03aa0b28..7a1780e900efb31addcab6112ebc6424c5547d52 100644 --- a/tests/test_FunctionProcessor.cpp +++ b/tests/test_FunctionProcessor.cpp @@ -358,7 +358,7 @@ let fx:R^1, fx = f(x); { std::string_view data = R"( let f : R^2 -> R^2, x -> 2*x; -let x:R^2, x = (3, 7); +let x:R^2, x = [3, 7]; let fx:R^2, fx = f(x); )"; @@ -369,9 +369,8 @@ let fx:R^2, fx = f(x); { std::string_view data = R"( let f : R^3 -> R^3, x -> 2*x; -let x:R^3, x = (2, 4, 7); -let fx:R^3, fx = f(x); +let fx:R^3, fx = f([2, 4, 7]); )"; CHECK_FUNCTION_EVALUATION_RESULT(data, "fx", (2 * TinyVector<3>{2, 4, 7})); } @@ -390,7 +389,7 @@ let fx:R^1, fx = f(x); SECTION(" R*R -> R^2") { std::string_view data = R"( -let f : R*R -> R^2, (x,y) -> (2*x, 3*y); +let f : R*R -> R^2, (x,y) -> [2*x, 3*y]; let fx:R^2, fx = f(2, 3); )"; CHECK_FUNCTION_EVALUATION_RESULT(data, "fx", (TinyVector<2>{2 * 2, 3 * 3})); @@ -399,7 +398,7 @@ let fx:R^2, fx = f(2, 3); SECTION(" R -> R^3") { std::string_view data = R"( -let f : R -> R^3, x -> (x, 2*x, x*x); +let f : R -> R^3, x -> [x, 2*x, x*x]; let fx:R^3, fx = f(3); )"; @@ -424,9 +423,8 @@ let fx:R^1x1, fx = f(x); { std::string_view data = R"( let f : R^2x2 -> R^2x2, x -> 2*x; -let x:R^2x2, x = (3, 7, 6, -2); -let fx:R^2x2, fx = f(x); +let fx:R^2x2, fx = f([[3, 7], [6, -2]]); )"; CHECK_FUNCTION_EVALUATION_RESULT(data, "fx", (2 * TinyMatrix<2>{3, 7, 6, -2})); } @@ -435,7 +433,7 @@ let fx:R^2x2, fx = f(x); { std::string_view data = R"( let f : R^3x3 -> R^3x3, x -> 2*x; -let x:R^3x3, x = (2, 4, 7, 1, 3, 5, -6, 2, -3); +let x:R^3x3, x = [[2, 4, 7],[1, 3, 5],[-6, 2, -3]]; let fx:R^3x3, fx = f(x); )"; @@ -456,7 +454,7 @@ let fx:R^1x1, fx = f(x); SECTION(" R*R -> R^2x2") { std::string_view data = R"( -let f : R*R -> R^2x2, (x,y) -> (2*x, 3*y, 5*(x-y), 2*x-y); +let f : R*R -> R^2x2, (x,y) -> [[2*x, 3*y], [5*(x-y), 2*x-y]]; let fx:R^2x2, fx = f(2, 3); )"; @@ -468,7 +466,7 @@ let fx:R^2x2, fx = f(2, 3); SECTION(" R -> R^3x3") { std::string_view data = R"( -let f : R -> R^3x3, x -> (x, 2*x, x*x, 3*x, 2+x, x-1, x+0.5, 2*x-1, 1/x); +let f : R -> R^3x3, x -> [[x, 2*x, x*x], [3*x, 2+x, x-1], [x+0.5, 2*x-1, 1/x]]; let fx:R^3x3, fx = f(3); )"; @@ -485,7 +483,7 @@ let fx:R^3x3, fx = f(3); SECTION(" R -> R*R^1*R^2*R^3") { std::string_view data = R"( -let f : R -> R*R^1*R^2*R^3, x -> (x+1, 2*x, (x-2, x+2), (1, 0.5*x, x*x)); +let f : R -> R*R^1*R^2*R^3, x -> (x+1, 2*x, [x-2, x+2], [1, 0.5*x, x*x]); let (x, x1, x2, x3):R*R^1*R^2*R^3, (x, x1, x2, x3) = f(3); )"; @@ -501,10 +499,10 @@ let (x, x1, x2, x3):R*R^1*R^2*R^3, (x, x1, x2, x3) = f(3); { std::string_view data = R"( let f : R^2*R^3 -> R*R^1*R^2*R^3, - (x2, x3) -> (x2[0]+x3[2], x3[1], (x3[0], x2[1]), (x3[0], x3[0]+x2[1], x3[2])); + (x2, x3) -> (x2[0]+x3[2], [x3[1]], [x3[0], x2[1]], [x3[0], x3[0]+x2[1], x3[2]]); -let y2:R^2, y2 = (2.3, 4.1); -let y3:R^3, y3 = (1.2, 1.3, 2.1); +let y2:R^2, y2 = [2.3, 4.1]; +let y3:R^3, y3 = [1.2, 1.3, 2.1]; let(x, x1, x2, x3) : R*R^1*R^2*R^3, (x, x1, x2, x3) = f(y2, y3); )"; @@ -520,9 +518,9 @@ let(x, x1, x2, x3) : R*R^1*R^2*R^3, (x, x1, x2, x3) = f(y2, y3); { std::string_view data = R"( let f : R^2*R^3 -> R*R^1*R^2*R^3, - (x2, x3) -> (x2[0]+x3[2], x3[1], (x3[0], x2[1]), (x3[0], x3[0]+x2[1], x3[2])); + (x2, x3) -> (x2[0]+x3[2], [x3[1]], [x3[0], x2[1]], [x3[0], x3[0]+x2[1], x3[2]]); -let y2:R^2, y2 = (2.3, 4.1); +let y2:R^2, y2 = [2.3, 4.1]; let (x, x1, x2, x3) : R*R^1*R^2*R^3, (x, x1, x2, x3) = f(y2, 0); )"; @@ -540,7 +538,7 @@ let (x, x1, x2, x3) : R*R^1*R^2*R^3, (x, x1, x2, x3) = f(y2, 0); let f : R^2*R^3 -> R*R^1*R^2*R^3, (x2, x3) -> (x2[0]+x3[2], x3[1], 0, 0); -let y2:R^2, y2 = (2.3, 4.1); +let y2:R^2, y2 = [2.3, 4.1]; let (x, x1, x2, x3):R*R^1*R^2*R^3, (x, x1, x2, x3) = f(y2, 0); )"; @@ -558,7 +556,7 @@ let (x, x1, x2, x3):R*R^1*R^2*R^3, (x, x1, x2, x3) = f(y2, 0); SECTION(" R -> R*R^1x1*R^2x2*R^3x3") { std::string_view data = R"( -let f : R -> R*R^1x1*R^2x2*R^3x3, x -> (x+1, 2*x, (x-2, x+2, 3, 2), (1, 0.5*x, x*x, x+1, 1/x, 2, x*x, 2*x-1, 3*x)); +let f : R -> R*R^1x1*R^2x2*R^3x3, x -> (x+1, 2*x, [[x-2, x+2], [3, 2]], [[1, 0.5*x, x*x], [x+1, 1/x, 2], [x*x, 2*x-1, 3*x]]); let (x, x11, x22, x33):R*R^1x1*R^2x2*R^3x3, (x, x11, x22, x33) = f(3); )"; @@ -575,10 +573,10 @@ let (x, x11, x22, x33):R*R^1x1*R^2x2*R^3x3, (x, x11, x22, x33) = f(3); { std::string_view data = R"( let f : R^2x2*R^3x3 -> R*R^1x1*R^2x2*R^3x3, - (x22, x33) -> (x22[0,0]+x33[2,0], x33[1,2], (x33[0,1], x22[1,1], x22[0,0], x33[2,2]), x22[0,0]*x33); + (x22, x33) -> (x22[0,0]+x33[2,0], x33[1,2], [[x33[0,1], x22[1,1]], [x22[0,0], x33[2,2]]], x22[0,0]*x33); -let y22:R^2x2, y22 = (2.3, 4.1, 6, -3); -let y33:R^3x3, y33 = (1.2, 1.3, 2.1, 3.2, -1.5, 2.3, -0.2, 3.1, -2.6); +let y22:R^2x2, y22 = [[2.3, 4.1], [6, -3]]; +let y33:R^3x3, y33 = [[1.2, 1.3, 2.1], [3.2,-1.5, 2.3],[-0.2, 3.1, -2.6]]; let(x, x11, x22, x33) : R*R^1x1*R^2x2*R^3x3, (x, x11, x22, x33) = f(y22, y33); )"; @@ -594,15 +592,15 @@ let(x, x11, x22, x33) : R*R^1x1*R^2x2*R^3x3, (x, x11, x22, x33) = f(y22, y33); { std::string_view data = R"( let f : R^2x2*R^3x3 -> R*R^1x1*R^2x2*R^3x3, - (x22, x33) -> (x22[0,0]+x33[2,1], x33[1,2], (x33[0,1], x22[1,0], x22[0,1], x33[2,2]), - (x22[1,0], x33[0,2]+x22[1,1], x33[2,2], - x33[2,0], x33[2,0]+x22[0,0], x33[1,1], - x33[2,1], x33[1,2]+x22[1,1], x33[0,0])); - -let y22:R^2x2, y22 = (2.3, 4.1, 3.1, 1.7); -let y33:R^3x3, y33 = (2.7, 3.1, 2.1, - 0.3, 1.2, 1.6, - 1.7, 2.2, 1.4); + (x22, x33) -> (x22[0,0]+x33[2,1], x33[1,2], [[x33[0,1], x22[1,0]], [x22[0,1], x33[2,2]]], + [[x22[1,0], x33[0,2]+x22[1,1], x33[2,2]], + [x33[2,0], x33[2,0]+x22[0,0], x33[1,1]], + [x33[2,1], x33[1,2]+x22[1,1], x33[0,0]]]); + +let y22:R^2x2, y22 = [[2.3, 4.1], [3.1, 1.7]]; +let y33:R^3x3, y33 = [[2.7, 3.1, 2.1], + [0.3, 1.2, 1.6], + [1.7, 2.2, 1.4]]; let (x, x11, x22, x33) : R*R^1x1*R^2x2*R^3x3, (x, x11, x22, x33) = f(y22, y33); )"; @@ -623,7 +621,7 @@ let (x, x11, x22, x33) : R*R^1x1*R^2x2*R^3x3, (x, x11, x22, x33) = f(y22, y33); let f : R^2x2*R^3x3 -> R*R^1x1*R^2x2*R^3x3, (x22, x33) -> (x22[0,0]+x33[2,0], x33[1,1], 0, 0); -let y22:R^2x2, y22 = (2.3, 4.1, 3.1, 1.7); +let y22:R^2x2, y22 = [[2.3, 4.1],[3.1, 1.7]]; let (x, x11, x22, x33):R*R^1x1*R^2x2*R^3x3, (x, x11, x22, x33) = f(y22, 0); )"; @@ -675,7 +673,7 @@ let x:R, x = pow(f(2)); SECTION("R -> R^2 -> R") { std::string_view data = R"( -let f : R -> R^2, x -> (x+1, x*2); +let f : R -> R^2, x -> [x+1, x*2]; let g : R^2 -> R, x -> x[0] + x[1]; let x:R, x = g(f(3)); @@ -688,7 +686,7 @@ let x:R, x = g(f(3)); SECTION("R -> R^2*R^3 -> R") { std::string_view data = R"( -let f : R -> R^2*R^3, x -> ((x+1, x*2), (6*x, 7-x, x/2.3)); +let f : R -> R^2*R^3, x -> ([x+1, x*2], [6*x, 7-x, x/2.3]); let g : R^2*R^3 -> R, (x, y) -> x[0]*x[1] + y[0]*y[1]-y[2]; let x:R, x = g(f(3)); @@ -701,7 +699,7 @@ let x:R, x = g(f(3)); SECTION("R -> R^2x2 -> R") { std::string_view data = R"( -let f : R -> R^2x2, x -> (x+1, x*2, x-1, x); +let f : R -> R^2x2, x -> [[x+1, x*2], [x-1, x]]; let g : R^2x2 -> R, A -> A[0,0] + 2*A[1,1] + 3*A[0,1]+ A[1, 0]; let x:R, x = g(f(3)); @@ -715,7 +713,7 @@ let x:R, x = g(f(3)); SECTION("R -> R^2x2*R^3x3 -> R") { std::string_view data = R"( -let f : R -> R^2x2*R^3x3, x -> ((x+1, x*2, x-1, x), (6*x, 7-x, x/2.3, -x, 2*x, x/2.5, x*x, 2*x, x)); +let f : R -> R^2x2*R^3x3, x -> ([[x+1, x*2], [x-1, x]], [[6*x, 7-x, x/2.3], [-x, 2*x, x/2.5], [x*x, 2*x, x]]); let g : R^2x2*R^3x3 -> R, (A22, A33) -> A22[0,0]*A22[1,1] + (A33[0,0]*A33[1,0]-A33[2,2])*A22[0,1]-A33[2,0]*A33[0,2]-A22[1,1]; let x:R, x = g(f(3)); diff --git a/tests/test_IntegrateCellValue.cpp b/tests/test_IntegrateCellValue.cpp index df35a215bea28b236cd2bcd7b243e2f759c4f40b..5df4d0c447c50751db43c0ce2db5345612fc514f 100644 --- a/tests/test_IntegrateCellValue.cpp +++ b/tests/test_IntegrateCellValue.cpp @@ -56,7 +56,7 @@ TEST_CASE("IntegrateCellValue", "[language]") std::string_view data = R"( import math; -let R2x2_1d: R^1 -> R^2x2, x -> (2 * exp(x[0]) * sin(x[0]) + 3, sin(x[0] - 2 * x[0]), 3, x[0] * x[0]); +let R2x2_1d: R^1 -> R^2x2, x -> [[2 * exp(x[0]) * sin(x[0]) + 3, sin(x[0] - 2 * x[0])], [3, x[0] * x[0]]]; )"; TAO_PEGTL_NAMESPACE::string_input input{data, "test.pgs"}; @@ -113,7 +113,7 @@ let R2x2_1d: R^1 -> R^2x2, x -> (2 * exp(x[0]) * sin(x[0]) + 3, sin(x[0] - 2 * x std::string_view data = R"( import math; -let R3_2d: R^2 -> R^3, x -> (2*exp(x[0])*sin(x[1])+3, x[0]-2*x[1], 3); +let R3_2d: R^2 -> R^3, x -> [2*exp(x[0])*sin(x[1])+3, x[0]-2*x[1], 3]; )"; TAO_PEGTL_NAMESPACE::string_input input{data, "test.pgs"}; @@ -325,7 +325,7 @@ let scalar_1d: R^1 -> R, x -> 2 * exp(x[0]) + 3; std::string_view data = R"( import math; -let R3_2d: R^2 -> R^3, x -> (2*exp(x[0])*sin(x[1])+3, x[0]-2*x[1], 3); +let R3_2d: R^2 -> R^3, x -> [2*exp(x[0])*sin(x[1])+3, x[0]-2*x[1], 3]; )"; TAO_PEGTL_NAMESPACE::string_input input{data, "test.pgs"}; @@ -404,7 +404,7 @@ let R3_2d: R^2 -> R^3, x -> (2*exp(x[0])*sin(x[1])+3, x[0]-2*x[1], 3); std::string_view data = R"( import math; -let R2x2_3d: R^3 -> R^2x2, x -> (2 * exp(x[0]) * sin(x[1]) + 3 * cos(x[2]), sin(x[0] - 2 * x[1] * x[2]), 3, x[0] * x[1] * x[2]); +let R2x2_3d: R^3 -> R^2x2, x -> [[2 * exp(x[0]) * sin(x[1]) + 3 * cos(x[2]), sin(x[0] - 2 * x[1] * x[2])], [3, x[0] * x[1] * x[2]]]; )"; TAO_PEGTL_NAMESPACE::string_input input{data, "test.pgs"}; diff --git a/tests/test_IntegrateOnCells.cpp b/tests/test_IntegrateOnCells.cpp index cf2d770265fd3dbf1812b14606aa7fadda972d05..80463f0831bc21c3c172bb62b0564c261629b7f0 100644 --- a/tests/test_IntegrateOnCells.cpp +++ b/tests/test_IntegrateOnCells.cpp @@ -59,8 +59,8 @@ TEST_CASE("IntegrateOnCells", "[language]") std::string_view data = R"( import math; let scalar_1d: R^1 -> R, x -> 2 * exp(x[0]) + 3; -let R3_1d: R^1 -> R^3, x -> (2 * exp(x[0]) + 3, x[0] - 2, 3); -let R2x2_1d: R^1 -> R^2x2, x -> (2 * exp(x[0]) * sin(x[0]) + 3, sin(x[0] - 2 * x[0]), 3, x[0] * x[0]); +let R3_1d: R^1 -> R^3, x -> [2 * exp(x[0]) + 3, x[0] - 2, 3]; +let R2x2_1d: R^1 -> R^2x2, x -> [[2 * exp(x[0]) * sin(x[0]) + 3, sin(x[0] - 2 * x[0])], [3, x[0] * x[0]]]; )"; TAO_PEGTL_NAMESPACE::string_input input{data, "test.pgs"}; @@ -159,8 +159,8 @@ let R2x2_1d: R^1 -> R^2x2, x -> (2 * exp(x[0]) * sin(x[0]) + 3, sin(x[0] - 2 * x std::string_view data = R"( import math; let scalar_2d: R^2 -> R, x -> 2*exp(x[0])*sin(x[1])+3; -let R3_2d: R^2 -> R^3, x -> (2*exp(x[0])*sin(x[1])+3, x[0]-2*x[1], 3); -let R2x2_2d: R^2 -> R^2x2, x -> (2*exp(x[0])*sin(x[1])+3, sin(x[0]-2*x[1]), 3, x[0]*x[1]); +let R3_2d: R^2 -> R^3, x -> [2*exp(x[0])*sin(x[1])+3, x[0]-2*x[1], 3]; +let R2x2_2d: R^2 -> R^2x2, x -> [[2*exp(x[0])*sin(x[1])+3, sin(x[0]-2*x[1])], [3, x[0]*x[1]]]; )"; TAO_PEGTL_NAMESPACE::string_input input{data, "test.pgs"}; @@ -272,8 +272,8 @@ let R2x2_2d: R^2 -> R^2x2, x -> (2*exp(x[0])*sin(x[1])+3, sin(x[0]-2*x[1]), 3, x std::string_view data = R"( import math; let scalar_3d: R^3 -> R, x -> 2 * exp(x[0]) * sin(x[1]) * x[2] + 3; -let R3_3d: R^3 -> R^3, x -> (2 * exp(x[0]) * sin(x[1]) + x[2] + 3, x[0] * x[2] - 2 * x[1], 3); -let R2x2_3d: R^3 -> R^2x2, x -> (2 * exp(x[0]) * sin(x[1]) + 3 * cos(x[2]), sin(x[0] - 2 * x[1] * x[2]), 3, x[0] * x[1] * x[2]); +let R3_3d: R^3 -> R^3, x -> [2 * exp(x[0]) * sin(x[1]) + x[2] + 3, x[0] * x[2] - 2 * x[1], 3]; +let R2x2_3d: R^3 -> R^2x2, x -> [[2 * exp(x[0]) * sin(x[1]) + 3 * cos(x[2]), sin(x[0] - 2 * x[1] * x[2])], [3, x[0] * x[1] * x[2]]]; )"; TAO_PEGTL_NAMESPACE::string_input input{data, "test.pgs"}; @@ -400,8 +400,8 @@ let R2x2_3d: R^3 -> R^2x2, x -> (2 * exp(x[0]) * sin(x[1]) + 3 * cos(x[2]), sin( std::string_view data = R"( import math; let scalar_1d: R^1 -> R, x -> 2 * exp(x[0]) + 3; -let R3_1d: R^1 -> R^3, x -> (2 * exp(x[0]) + 3, x[0] - 2, 3); -let R2x2_1d: R^1 -> R^2x2, x -> (2 * exp(x[0]) * sin(x[0]) + 3, sin(x[0] - 2 * x[0]), 3, x[0] * x[0]); +let R3_1d: R^1 -> R^3, x -> [2 * exp(x[0]) + 3, x[0] - 2, 3]; +let R2x2_1d: R^1 -> R^2x2, x -> [[2 * exp(x[0]) * sin(x[0]) + 3, sin(x[0] - 2 * x[0])], [3, x[0] * x[0]]]; )"; TAO_PEGTL_NAMESPACE::string_input input{data, "test.pgs"}; @@ -510,8 +510,8 @@ let R2x2_1d: R^1 -> R^2x2, x -> (2 * exp(x[0]) * sin(x[0]) + 3, sin(x[0] - 2 * x std::string_view data = R"( import math; let scalar_2d: R^2 -> R, x -> 2*exp(x[0])*sin(x[1])+3; -let R3_2d: R^2 -> R^3, x -> (2*exp(x[0])*sin(x[1])+3, x[0]-2*x[1], 3); -let R2x2_2d: R^2 -> R^2x2, x -> (2*exp(x[0])*sin(x[1])+3, sin(x[0]-2*x[1]), 3, x[0]*x[1]); +let R3_2d: R^2 -> R^3, x -> [2*exp(x[0])*sin(x[1])+3, x[0]-2*x[1], 3]; +let R2x2_2d: R^2 -> R^2x2, x -> [[2*exp(x[0])*sin(x[1])+3, sin(x[0]-2*x[1])], [3, x[0]*x[1]]]; )"; TAO_PEGTL_NAMESPACE::string_input input{data, "test.pgs"}; @@ -633,8 +633,8 @@ let R2x2_2d: R^2 -> R^2x2, x -> (2*exp(x[0])*sin(x[1])+3, sin(x[0]-2*x[1]), 3, x std::string_view data = R"( import math; let scalar_3d: R^3 -> R, x -> 2 * exp(x[0]) * sin(x[1]) * x[2] + 3; -let R3_3d: R^3 -> R^3, x -> (2 * exp(x[0]) * sin(x[1]) + x[2] + 3, x[0] * x[2] - 2 * x[1], 3); -let R2x2_3d: R^3 -> R^2x2, x -> (2 * exp(x[0]) * sin(x[1]) + 3 * cos(x[2]), sin(x[0] - 2 * x[1] * x[2]), 3, x[0] * x[1] * x[2]); +let R3_3d: R^3 -> R^3, x -> [2 * exp(x[0]) * sin(x[1]) + x[2] + 3, x[0] * x[2] - 2 * x[1], 3]; +let R2x2_3d: R^3 -> R^2x2, x -> [[2 * exp(x[0]) * sin(x[1]) + 3 * cos(x[2]), sin(x[0] - 2 * x[1] * x[2])], [3, x[0] * x[1] * x[2]]]; )"; TAO_PEGTL_NAMESPACE::string_input input{data, "test.pgs"}; @@ -755,8 +755,8 @@ let R2x2_3d: R^3 -> R^2x2, x -> (2 * exp(x[0]) * sin(x[1]) + 3 * cos(x[2]), sin( std::string_view data = R"( import math; let scalar_1d: R^1 -> R, x -> 2 * exp(x[0]) + 3; -let R3_1d: R^1 -> R^3, x -> (2 * exp(x[0]) + 3, x[0] - 2, 3); -let R2x2_1d: R^1 -> R^2x2, x -> (2 * exp(x[0]) * sin(x[0]) + 3, sin(x[0] - 2 * x[0]), 3, x[0] * x[0]); +let R3_1d: R^1 -> R^3, x -> [2 * exp(x[0]) + 3, x[0] - 2, 3]; +let R2x2_1d: R^1 -> R^2x2, x -> [[2 * exp(x[0]) * sin(x[0]) + 3, sin(x[0] - 2 * x[0])], [3, x[0] * x[0]]]; )"; TAO_PEGTL_NAMESPACE::string_input input{data, "test.pgs"}; @@ -855,8 +855,8 @@ let R2x2_1d: R^1 -> R^2x2, x -> (2 * exp(x[0]) * sin(x[0]) + 3, sin(x[0] - 2 * x std::string_view data = R"( import math; let scalar_2d: R^2 -> R, x -> 2*exp(x[0])*sin(x[1])+3; -let R3_2d: R^2 -> R^3, x -> (2*exp(x[0])*sin(x[1])+3, x[0]-2*x[1], 3); -let R2x2_2d: R^2 -> R^2x2, x -> (2*exp(x[0])*sin(x[1])+3, sin(x[0]-2*x[1]), 3, x[0]*x[1]); +let R3_2d: R^2 -> R^3, x -> [2*exp(x[0])*sin(x[1])+3, x[0]-2*x[1], 3]; +let R2x2_2d: R^2 -> R^2x2, x -> [[2*exp(x[0])*sin(x[1])+3, sin(x[0]-2*x[1])], [3, x[0]*x[1]]]; )"; TAO_PEGTL_NAMESPACE::string_input input{data, "test.pgs"}; @@ -968,8 +968,8 @@ let R2x2_2d: R^2 -> R^2x2, x -> (2*exp(x[0])*sin(x[1])+3, sin(x[0]-2*x[1]), 3, x std::string_view data = R"( import math; let scalar_3d: R^3 -> R, x -> 2 * exp(x[0]) * sin(x[1]) * x[2] + 3; -let R3_3d: R^3 -> R^3, x -> (2 * exp(x[0]) * sin(x[1]) + x[2] + 3, x[0] * x[2] - 2 * x[1], 3); -let R2x2_3d: R^3 -> R^2x2, x -> (2 * exp(x[0]) * sin(x[1]) + 3 * cos(x[2]), sin(x[0] - 2 * x[1] * x[2]), 3, x[0] * x[1] * x[2]); +let R3_3d: R^3 -> R^3, x -> [2 * exp(x[0]) * sin(x[1]) + x[2] + 3, x[0] * x[2] - 2 * x[1], 3]; +let R2x2_3d: R^3 -> R^2x2, x -> [[2 * exp(x[0]) * sin(x[1]) + 3 * cos(x[2]), sin(x[0] - 2 * x[1] * x[2])], [3, x[0] * x[1] * x[2]]]; )"; TAO_PEGTL_NAMESPACE::string_input input{data, "test.pgs"}; @@ -1096,8 +1096,8 @@ let R2x2_3d: R^3 -> R^2x2, x -> (2 * exp(x[0]) * sin(x[1]) + 3 * cos(x[2]), sin( std::string_view data = R"( import math; let scalar_1d: R^1 -> R, x -> 2 * exp(x[0]) + 3; -let R3_1d: R^1 -> R^3, x -> (2 * exp(x[0]) + 3, x[0] - 2, 3); -let R2x2_1d: R^1 -> R^2x2, x -> (2 * exp(x[0]) * sin(x[0]) + 3, sin(x[0] - 2 * x[0]), 3, x[0] * x[0]); +let R3_1d: R^1 -> R^3, x -> [2 * exp(x[0]) + 3, x[0] - 2, 3]; +let R2x2_1d: R^1 -> R^2x2, x -> [[2 * exp(x[0]) * sin(x[0]) + 3, sin(x[0] - 2 * x[0])], [3, x[0] * x[0]]]; )"; TAO_PEGTL_NAMESPACE::string_input input{data, "test.pgs"}; @@ -1206,8 +1206,8 @@ let R2x2_1d: R^1 -> R^2x2, x -> (2 * exp(x[0]) * sin(x[0]) + 3, sin(x[0] - 2 * x std::string_view data = R"( import math; let scalar_2d: R^2 -> R, x -> 2*exp(x[0])*sin(x[1])+3; -let R3_2d: R^2 -> R^3, x -> (2*exp(x[0])*sin(x[1])+3, x[0]-2*x[1], 3); -let R2x2_2d: R^2 -> R^2x2, x -> (2*exp(x[0])*sin(x[1])+3, sin(x[0]-2*x[1]), 3, x[0]*x[1]); +let R3_2d: R^2 -> R^3, x -> [2*exp(x[0])*sin(x[1])+3, x[0]-2*x[1], 3]; +let R2x2_2d: R^2 -> R^2x2, x -> [[2*exp(x[0])*sin(x[1])+3, sin(x[0]-2*x[1])], [3, x[0]*x[1]]]; )"; TAO_PEGTL_NAMESPACE::string_input input{data, "test.pgs"}; @@ -1329,8 +1329,8 @@ let R2x2_2d: R^2 -> R^2x2, x -> (2*exp(x[0])*sin(x[1])+3, sin(x[0]-2*x[1]), 3, x std::string_view data = R"( import math; let scalar_3d: R^3 -> R, x -> 2 * exp(x[0]) * sin(x[1]) * x[2] + 3; -let R3_3d: R^3 -> R^3, x -> (2 * exp(x[0]) * sin(x[1]) + x[2] + 3, x[0] * x[2] - 2 * x[1], 3); -let R2x2_3d: R^3 -> R^2x2, x -> (2 * exp(x[0]) * sin(x[1]) + 3 * cos(x[2]), sin(x[0] - 2 * x[1] * x[2]), 3, x[0] * x[1] * x[2]); +let R3_3d: R^3 -> R^3, x -> [2 * exp(x[0]) * sin(x[1]) + x[2] + 3, x[0] * x[2] - 2 * x[1], 3]; +let R2x2_3d: R^3 -> R^2x2, x -> [[2 * exp(x[0]) * sin(x[1]) + 3 * cos(x[2]), sin(x[0] - 2 * x[1] * x[2])], [3, x[0] * x[1] * x[2]]]; )"; TAO_PEGTL_NAMESPACE::string_input input{data, "test.pgs"}; @@ -1451,8 +1451,8 @@ let R2x2_3d: R^3 -> R^2x2, x -> (2 * exp(x[0]) * sin(x[1]) + 3 * cos(x[2]), sin( std::string_view data = R"( import math; let scalar_1d: R^1 -> R, x -> 2 * exp(x[0]) + 3; -let R3_1d: R^1 -> R^3, x -> (2 * exp(x[0]) + 3, x[0] - 2, 3); -let R2x2_1d: R^1 -> R^2x2, x -> (2 * exp(x[0]) * sin(x[0]) + 3, sin(x[0] - 2 * x[0]), 3, x[0] * x[0]); +let R3_1d: R^1 -> R^3, x -> [2 * exp(x[0]) + 3, x[0] - 2, 3]; +let R2x2_1d: R^1 -> R^2x2, x -> [[2 * exp(x[0]) * sin(x[0]) + 3, sin(x[0] - 2 * x[0])], [3, x[0] * x[0]]]; )"; TAO_PEGTL_NAMESPACE::string_input input{data, "test.pgs"}; @@ -1551,8 +1551,8 @@ let R2x2_1d: R^1 -> R^2x2, x -> (2 * exp(x[0]) * sin(x[0]) + 3, sin(x[0] - 2 * x std::string_view data = R"( import math; let scalar_2d: R^2 -> R, x -> 2*exp(x[0])*sin(x[1])+3; -let R3_2d: R^2 -> R^3, x -> (2*exp(x[0])*sin(x[1])+3, x[0]-2*x[1], 3); -let R2x2_2d: R^2 -> R^2x2, x -> (2*exp(x[0])*sin(x[1])+3, sin(x[0]-2*x[1]), 3, x[0]*x[1]); +let R3_2d: R^2 -> R^3, x -> [2*exp(x[0])*sin(x[1])+3, x[0]-2*x[1], 3]; +let R2x2_2d: R^2 -> R^2x2, x -> [[2*exp(x[0])*sin(x[1])+3, sin(x[0]-2*x[1])], [3, x[0]*x[1]]]; )"; TAO_PEGTL_NAMESPACE::string_input input{data, "test.pgs"}; @@ -1664,8 +1664,8 @@ let R2x2_2d: R^2 -> R^2x2, x -> (2*exp(x[0])*sin(x[1])+3, sin(x[0]-2*x[1]), 3, x std::string_view data = R"( import math; let scalar_3d: R^3 -> R, x -> 2 * exp(x[0]) * sin(x[1]) * x[2] + 3; -let R3_3d: R^3 -> R^3, x -> (2 * exp(x[0]) * sin(x[1]) + x[2] + 3, x[0] * x[2] - 2 * x[1], 3); -let R2x2_3d: R^3 -> R^2x2, x -> (2 * exp(x[0]) * sin(x[1]) + 3 * cos(x[2]), sin(x[0] - 2 * x[1] * x[2]), 3, x[0] * x[1] * x[2]); +let R3_3d: R^3 -> R^3, x -> [2 * exp(x[0]) * sin(x[1]) + x[2] + 3, x[0] * x[2] - 2 * x[1], 3]; +let R2x2_3d: R^3 -> R^2x2, x -> [[2 * exp(x[0]) * sin(x[1]) + 3 * cos(x[2]), sin(x[0] - 2 * x[1] * x[2])], [3, x[0] * x[1] * x[2]]]; )"; TAO_PEGTL_NAMESPACE::string_input input{data, "test.pgs"}; @@ -1792,8 +1792,8 @@ let R2x2_3d: R^3 -> R^2x2, x -> (2 * exp(x[0]) * sin(x[1]) + 3 * cos(x[2]), sin( std::string_view data = R"( import math; let scalar_1d: R^1 -> R, x -> 2 * exp(x[0]) + 3; -let R3_1d: R^1 -> R^3, x -> (2 * exp(x[0]) + 3, x[0] - 2, 3); -let R2x2_1d: R^1 -> R^2x2, x -> (2 * exp(x[0]) * sin(x[0]) + 3, sin(x[0] - 2 * x[0]), 3, x[0] * x[0]); +let R3_1d: R^1 -> R^3, x -> [2 * exp(x[0]) + 3, x[0] - 2, 3]; +let R2x2_1d: R^1 -> R^2x2, x -> [[2 * exp(x[0]) * sin(x[0]) + 3, sin(x[0] - 2 * x[0])], [3, x[0] * x[0]]]; )"; TAO_PEGTL_NAMESPACE::string_input input{data, "test.pgs"}; @@ -1902,8 +1902,8 @@ let R2x2_1d: R^1 -> R^2x2, x -> (2 * exp(x[0]) * sin(x[0]) + 3, sin(x[0] - 2 * x std::string_view data = R"( import math; let scalar_2d: R^2 -> R, x -> 2*exp(x[0])*sin(x[1])+3; -let R3_2d: R^2 -> R^3, x -> (2*exp(x[0])*sin(x[1])+3, x[0]-2*x[1], 3); -let R2x2_2d: R^2 -> R^2x2, x -> (2*exp(x[0])*sin(x[1])+3, sin(x[0]-2*x[1]), 3, x[0]*x[1]); +let R3_2d: R^2 -> R^3, x -> [2*exp(x[0])*sin(x[1])+3, x[0]-2*x[1], 3]; +let R2x2_2d: R^2 -> R^2x2, x -> [[2*exp(x[0])*sin(x[1])+3, sin(x[0]-2*x[1])], [3, x[0]*x[1]]]; )"; TAO_PEGTL_NAMESPACE::string_input input{data, "test.pgs"}; @@ -2025,8 +2025,8 @@ let R2x2_2d: R^2 -> R^2x2, x -> (2*exp(x[0])*sin(x[1])+3, sin(x[0]-2*x[1]), 3, x std::string_view data = R"( import math; let scalar_3d: R^3 -> R, x -> 2 * exp(x[0]) * sin(x[1]) * x[2] + 3; -let R3_3d: R^3 -> R^3, x -> (2 * exp(x[0]) * sin(x[1]) + x[2] + 3, x[0] * x[2] - 2 * x[1], 3); -let R2x2_3d: R^3 -> R^2x2, x -> (2 * exp(x[0]) * sin(x[1]) + 3 * cos(x[2]), sin(x[0] - 2 * x[1] * x[2]), 3, x[0] * x[1] * x[2]); +let R3_3d: R^3 -> R^3, x -> [2 * exp(x[0]) * sin(x[1]) + x[2] + 3, x[0] * x[2] - 2 * x[1], 3]; +let R2x2_3d: R^3 -> R^2x2, x -> [[2 * exp(x[0]) * sin(x[1]) + 3 * cos(x[2]), sin(x[0] - 2 * x[1] * x[2])], [3, x[0] * x[1] * x[2]]]; )"; TAO_PEGTL_NAMESPACE::string_input input{data, "test.pgs"}; diff --git a/tests/test_InterpolateItemValue.cpp b/tests/test_InterpolateItemValue.cpp index 1d7032c660ee001d652339abc0d2daee8a825fff..45832349fd50410aa70cadfb6df74ad59156c045 100644 --- a/tests/test_InterpolateItemValue.cpp +++ b/tests/test_InterpolateItemValue.cpp @@ -56,10 +56,10 @@ TEST_CASE("InterpolateItemValue", "[language]") import math; let scalar_affine_1d: R^1 -> R, x -> 2*x[0] + 2; let scalar_non_linear_1d: R^1 -> R, x -> 2 * exp(x[0]) + 3; -let R3_affine_1d: R^1 -> R^3, x -> (2 * x[0] + 2, 3 * x[0], 2); -let R3_non_linear_1d: R^1 -> R^3, x -> (2 * exp(x[0]) + 3, x[0] - 2, 3); -let R2x2_affine_1d: R^1 -> R^2x2, x -> (2 * x[0] + 3 + 2, 3 * x[0], 2 * x[0], 2); -let R2x2_non_linear_1d: R^1 -> R^2x2, x -> (2 * exp(x[0]) * sin(x[0]) + 3, sin(x[0] - 2 * x[0]), 3, x[0] * x[0]); +let R3_affine_1d: R^1 -> R^3, x -> [2 * x[0] + 2, 3 * x[0], 2]; +let R3_non_linear_1d: R^1 -> R^3, x -> [2 * exp(x[0]) + 3, x[0] - 2, 3]; +let R2x2_affine_1d: R^1 -> R^2x2, x -> [[2 * x[0] + 3 + 2, 3 * x[0]], [2 * x[0], 2]]; +let R2x2_non_linear_1d: R^1 -> R^2x2, x -> [[2 * exp(x[0]) * sin(x[0]) + 3, sin(x[0] - 2 * x[0])], [3, x[0] * x[0]]]; )"; TAO_PEGTL_NAMESPACE::string_input input{data, "test.pgs"}; @@ -227,10 +227,10 @@ let R2x2_non_linear_1d: R^1 -> R^2x2, x -> (2 * exp(x[0]) * sin(x[0]) + 3, sin(x import math; let scalar_affine_2d: R^2 -> R, x -> 2*x[0] + 3*x[1] + 2; let scalar_non_linear_2d: R^2 -> R, x -> 2*exp(x[0])*sin(x[1])+3; -let R3_affine_2d: R^2 -> R^3, x -> (2 * x[0] + 3 * x[1] + 2, 3 * x[0] + x[1], 2 * x[1]); -let R3_non_linear_2d: R^2 -> R^3, x -> (2*exp(x[0])*sin(x[1])+3, x[0]-2*x[1], 3); -let R2x2_affine_2d: R^2 -> R^2x2, x -> (2 * x[0] + 3 * x[1] + 2, 3 * x[0] + x[1], 2 * x[0] + x[1], 2); -let R2x2_non_linear_2d: R^2 -> R^2x2, x -> (2*exp(x[0])*sin(x[1])+3, sin(x[0]-2*x[1]), 3, x[0]*x[1]); +let R3_affine_2d: R^2 -> R^3, x -> [2 * x[0] + 3 * x[1] + 2, 3 * x[0] + x[1], 2 * x[1]]; +let R3_non_linear_2d: R^2 -> R^3, x -> [2*exp(x[0])*sin(x[1])+3, x[0]-2*x[1], 3]; +let R2x2_affine_2d: R^2 -> R^2x2, x -> [[2 * x[0] + 3 * x[1] + 2, 3 * x[0] + x[1]], [2 * x[0] + x[1], 2]]; +let R2x2_non_linear_2d: R^2 -> R^2x2, x -> [[2*exp(x[0])*sin(x[1])+3, sin(x[0]-2*x[1])], [3, x[0]*x[1]]]; )"; TAO_PEGTL_NAMESPACE::string_input input{data, "test.pgs"}; @@ -392,10 +392,10 @@ let R2x2_non_linear_2d: R^2 -> R^2x2, x -> (2*exp(x[0])*sin(x[1])+3, sin(x[0]-2* import math; let scalar_affine_3d: R^3 -> R, x -> 2 * x[0] + 3 * x[1] + 2 * x[2] - 1; let scalar_non_linear_3d: R^3 -> R, x -> 2 * exp(x[0]) * sin(x[1]) * x[2] + 3; -let R3_affine_3d: R^3 -> R^3, x -> (2 * x[0] + 3 * x[1] + 2, 3 * x[0] + x[1] + 2 * x[2], 2 * x[2]); -let R3_non_linear_3d: R^3 -> R^3, x -> (2 * exp(x[0]) * sin(x[1]) + x[2] + 3, x[0] * x[2] - 2 * x[1], 3); -let R2x2_affine_3d: R^3 -> R^2x2, x -> (2 * x[0] + 3 * x[1] + 2 * x[2] + 1, 3 * x[0] + x[1] + 2 * x[2], 2 * x[0] + x[1] + x[2], 2); -let R2x2_non_linear_3d: R^3 -> R^2x2, x -> (2 * exp(x[0]) * sin(x[1]) + 3 * cos(x[2]), sin(x[0] - 2 * x[1] * x[2]), 3, x[0] * x[1] * x[2]); +let R3_affine_3d: R^3 -> R^3, x -> [2 * x[0] + 3 * x[1] + 2, 3 * x[0] + x[1] + 2 * x[2], 2 * x[2]]; +let R3_non_linear_3d: R^3 -> R^3, x -> [2 * exp(x[0]) * sin(x[1]) + x[2] + 3, x[0] * x[2] - 2 * x[1], 3]; +let R2x2_affine_3d: R^3 -> R^2x2, x -> [[2 * x[0] + 3 * x[1] + 2 * x[2] + 1, 3 * x[0] + x[1] + 2 * x[2]], [2 * x[0] + x[1] + x[2], 2]]; +let R2x2_non_linear_3d: R^3 -> R^2x2, x -> [[2 * exp(x[0]) * sin(x[1]) + 3 * cos(x[2]), sin(x[0] - 2 * x[1] * x[2])], [3, x[0] * x[1] * x[2]]]; )"; TAO_PEGTL_NAMESPACE::string_input input{data, "test.pgs"}; @@ -579,10 +579,10 @@ let R2x2_non_linear_3d: R^3 -> R^2x2, x -> (2 * exp(x[0]) * sin(x[1]) + 3 * cos( import math; let scalar_affine_1d: R^1 -> R, x -> 2*x[0] + 2; let scalar_non_linear_1d: R^1 -> R, x -> 2 * exp(x[0]) + 3; -let R3_affine_1d: R^1 -> R^3, x -> (2 * x[0] + 2, 3 * x[0], 2); -let R3_non_linear_1d: R^1 -> R^3, x -> (2 * exp(x[0]) + 3, x[0] - 2, 3); -let R2x2_affine_1d: R^1 -> R^2x2, x -> (2 * x[0] + 3 + 2, 3 * x[0], 2 * x[0], 2); -let R2x2_non_linear_1d: R^1 -> R^2x2, x -> (2 * exp(x[0]) * sin(x[0]) + 3, sin(x[0] - 2 * x[0]), 3, x[0] * x[0]); +let R3_affine_1d: R^1 -> R^3, x -> [2 * x[0] + 2, 3 * x[0], 2]; +let R3_non_linear_1d: R^1 -> R^3, x -> [2 * exp(x[0]) + 3, x[0] - 2, 3]; +let R2x2_affine_1d: R^1 -> R^2x2, x -> [[2 * x[0] + 3 + 2, 3 * x[0]], [2 * x[0], 2]]; +let R2x2_non_linear_1d: R^1 -> R^2x2, x -> [[2 * exp(x[0]) * sin(x[0]) + 3, sin(x[0] - 2 * x[0])], [3, x[0] * x[0]]]; )"; TAO_PEGTL_NAMESPACE::string_input input{data, "test.pgs"}; @@ -758,10 +758,10 @@ let R2x2_non_linear_1d: R^1 -> R^2x2, x -> (2 * exp(x[0]) * sin(x[0]) + 3, sin(x import math; let scalar_affine_2d: R^2 -> R, x -> 2*x[0] + 3*x[1] + 2; let scalar_non_linear_2d: R^2 -> R, x -> 2*exp(x[0])*sin(x[1])+3; -let R3_affine_2d: R^2 -> R^3, x -> (2 * x[0] + 3 * x[1] + 2, 3 * x[0] + x[1], 2 * x[1]); -let R3_non_linear_2d: R^2 -> R^3, x -> (2*exp(x[0])*sin(x[1])+3, x[0]-2*x[1], 3); -let R2x2_affine_2d: R^2 -> R^2x2, x -> (2 * x[0] + 3 * x[1] + 2, 3 * x[0] + x[1], 2 * x[0] + x[1], 2); -let R2x2_non_linear_2d: R^2 -> R^2x2, x -> (2*exp(x[0])*sin(x[1])+3, sin(x[0]-2*x[1]), 3, x[0]*x[1]); +let R3_affine_2d: R^2 -> R^3, x -> [2 * x[0] + 3 * x[1] + 2, 3 * x[0] + x[1], 2 * x[1]]; +let R3_non_linear_2d: R^2 -> R^3, x -> [2*exp(x[0])*sin(x[1])+3, x[0]-2*x[1], 3]; +let R2x2_affine_2d: R^2 -> R^2x2, x -> [[2 * x[0] + 3 * x[1] + 2, 3 * x[0] + x[1]], [2 * x[0] + x[1], 2]]; +let R2x2_non_linear_2d: R^2 -> R^2x2, x -> [[2*exp(x[0])*sin(x[1])+3, sin(x[0]-2*x[1])], [3, x[0]*x[1]]]; )"; TAO_PEGTL_NAMESPACE::string_input input{data, "test.pgs"}; @@ -932,10 +932,10 @@ let R2x2_non_linear_2d: R^2 -> R^2x2, x -> (2*exp(x[0])*sin(x[1])+3, sin(x[0]-2* import math; let scalar_affine_3d: R^3 -> R, x -> 2 * x[0] + 3 * x[1] + 2 * x[2] - 1; let scalar_non_linear_3d: R^3 -> R, x -> 2 * exp(x[0]) * sin(x[1]) * x[2] + 3; -let R3_affine_3d: R^3 -> R^3, x -> (2 * x[0] + 3 * x[1] + 2, 3 * x[0] + x[1] + 2 * x[2], 2 * x[2]); -let R3_non_linear_3d: R^3 -> R^3, x -> (2 * exp(x[0]) * sin(x[1]) + x[2] + 3, x[0] * x[2] - 2 * x[1], 3); -let R2x2_affine_3d: R^3 -> R^2x2, x -> (2 * x[0] + 3 * x[1] + 2 * x[2] + 1, 3 * x[0] + x[1] + 2 * x[2], 2 * x[0] + x[1] + x[2], 2); -let R2x2_non_linear_3d: R^3 -> R^2x2, x -> (2 * exp(x[0]) * sin(x[1]) + 3 * cos(x[2]), sin(x[0] - 2 * x[1] * x[2]), 3, x[0] * x[1] * x[2]); +let R3_affine_3d: R^3 -> R^3, x -> [2 * x[0] + 3 * x[1] + 2, 3 * x[0] + x[1] + 2 * x[2], 2 * x[2]]; +let R3_non_linear_3d: R^3 -> R^3, x -> [2 * exp(x[0]) * sin(x[1]) + x[2] + 3, x[0] * x[2] - 2 * x[1], 3]; +let R2x2_affine_3d: R^3 -> R^2x2, x -> [[2 * x[0] + 3 * x[1] + 2 * x[2] + 1, 3 * x[0] + x[1] + 2 * x[2]], [2 * x[0] + x[1] + x[2], 2]]; +let R2x2_non_linear_3d: R^3 -> R^2x2, x -> [[2 * exp(x[0]) * sin(x[1]) + 3 * cos(x[2]), sin(x[0] - 2 * x[1] * x[2])], [3, x[0] * x[1] * x[2]]]; )"; TAO_PEGTL_NAMESPACE::string_input input{data, "test.pgs"}; diff --git a/tests/test_ListAffectationProcessor.cpp b/tests/test_ListAffectationProcessor.cpp index f84ee471a7b2b4621ca4ef45d7c9a07610484a38..d02ee365f788ba72e5dfbdf0ed143805ffb4e16c 100644 --- a/tests/test_ListAffectationProcessor.cpp +++ b/tests/test_ListAffectationProcessor.cpp @@ -53,36 +53,36 @@ TEST_CASE("ListAffectationProcessor", "[language]") { SECTION("R*R^2*R^2x2*string") { - CHECK_AFFECTATION_RESULT(R"(let (x,u,A,s): R*R^2*R^2x2*string, (x,u,A,s) = (1.2, (2,3), (4,3,2,1), "foo");)", "x", - double{1.2}); - CHECK_AFFECTATION_RESULT(R"(let (x,u,A,s): R*R^2*R^2x2*string, (x,u,A,s) = (1.2, (2,3), (4,3,2,1), "foo");)", "u", - (TinyVector<2>{2, 3})); - CHECK_AFFECTATION_RESULT(R"(let (x,u,A,s): R*R^2*R^2x2*string, (x,u,A,s) = (1.2, (2,3), (4,3,2,1), "foo");)", "A", - (TinyMatrix<2>{4, 3, 2, 1})); - CHECK_AFFECTATION_RESULT(R"(let (x,u,A,s): R*R^2*R^2x2*string, (x,u,A,s) = (1.2, (2,3), (4,3,2,1), "foo");)", "s", - std::string{"foo"}); + CHECK_AFFECTATION_RESULT(R"(let (x,u,A,s): R*R^2*R^2x2*string, (x,u,A,s) = (1.2, [2,3], [[4,3],[2,1]], "foo");)", + "x", double{1.2}); + CHECK_AFFECTATION_RESULT(R"(let (x,u,A,s): R*R^2*R^2x2*string, (x,u,A,s) = (1.2, [2,3], [[4,3],[2,1]], "foo");)", + "u", (TinyVector<2>{2, 3})); + CHECK_AFFECTATION_RESULT(R"(let (x,u,A,s): R*R^2*R^2x2*string, (x,u,A,s) = (1.2, [2,3], [[4,3],[2,1]], "foo");)", + "A", (TinyMatrix<2>{4, 3, 2, 1})); + CHECK_AFFECTATION_RESULT(R"(let (x,u,A,s): R*R^2*R^2x2*string, (x,u,A,s) = (1.2, [2,3], [[4,3],[2,1]], "foo");)", + "s", std::string{"foo"}); } SECTION("compound with string conversion") { - CHECK_AFFECTATION_RESULT(R"(let z:R, z = 3; let (x,u,s):R*R^2*string, (x,u,s) = (1.2, (2,3), z);)", "s", + CHECK_AFFECTATION_RESULT(R"(let z:R, z = 3; let (x,u,s):R*R^2*string, (x,u,s) = (1.2, [2,3], z);)", "s", std::to_string(double{3})); { std::ostringstream os; os << TinyVector<1>{7}; - CHECK_AFFECTATION_RESULT(R"(let v:R^1, v = 7; let (x,u,s):R*R^2*string, (x,u,s) = (1.2, (2,3), v);)", "s", + CHECK_AFFECTATION_RESULT(R"(let v:R^1, v = 7; let (x,u,s):R*R^2*string, (x,u,s) = (1.2, [2,3], v);)", "s", os.str()); } { std::ostringstream os; os << TinyVector<2>{6, 3}; - CHECK_AFFECTATION_RESULT(R"(let v: R^2, v = (6,3); let (x,u,s):R*R^2*string, (x,u,s) = (1.2, (2,3), v);)", "s", + CHECK_AFFECTATION_RESULT(R"(let v: R^2, v = [6,3]; let (x,u,s):R*R^2*string, (x,u,s) = (1.2, [2,3], v);)", "s", os.str()); } { std::ostringstream os; os << TinyVector<3>{1, 2, 3}; - CHECK_AFFECTATION_RESULT(R"(let v:R^3, v = (1,2,3); let (x,u,s):R*R^2*string, (x,u,s) = (1.2, (2,3), v);)", "s", + CHECK_AFFECTATION_RESULT(R"(let v:R^3, v = [1,2,3]; let (x,u,s):R*R^2*string, (x,u,s) = (1.2, [2,3], v);)", "s", os.str()); } } diff --git a/tests/test_PugsFunctionAdapter.cpp b/tests/test_PugsFunctionAdapter.cpp index d8708c49a9601d38602251a5179cad939382f291..9e645802fde6e286abfeb57e7c4c35dd584583c4 100644 --- a/tests/test_PugsFunctionAdapter.cpp +++ b/tests/test_PugsFunctionAdapter.cpp @@ -72,7 +72,7 @@ let BandB: B*B -> B, (a,b) -> a and b; let NplusN: N*N -> N, (x,y) -> x+y; let ZplusZ: Z*Z -> Z, (x,y) -> x+y; let RplusR: R*R -> R, (x,y) -> x+y; -let RRtoR2: R*R -> R^2, (x,y) -> (x+y, x-y); +let RRtoR2: R*R -> R^2, (x,y) -> [x+y, x-y]; let R3times2: R^3 -> R^3, x -> 2*x; let R33times2: R^3x3 -> R^3x3, x -> 2*x; let BtoR1: B -> R^1, b -> not b; @@ -368,11 +368,11 @@ let R33toR33zero: R^3x3 -> R^3x3, x -> 0; std::string_view data = R"( let R1toR1: R^1 -> R^1, x -> x; let R3toR3: R^3 -> R^3, x -> 0; -let RRRtoR3: R*R*R -> R^3, (x,y,z) -> (x,y,z); -let R3toR2: R^3 -> R^2, x -> (x[0],x[1]+x[2]); +let RRRtoR3: R*R*R -> R^3, (x,y,z) -> [x,y,z]; +let R3toR2: R^3 -> R^2, x -> [x[0],x[1]+x[2]]; let RtoNS: R -> N*string, x -> (1, "foo"); let RtoR: R -> R, x -> 2*x; -let R33toR22: R^3x3 -> R^2x2, x -> (x[0,0], x[0,1]+x[0,2], x[2,0]*x[1,1], x[2,1]+x[2,2]); +let R33toR22: R^3x3 -> R^2x2, x -> [[x[0,0], x[0,1]+x[0,2]], [x[2,0]*x[1,1], x[2,1]+x[2,2]]]; )"; TAO_PEGTL_NAMESPACE::string_input input{data, "test.pgs"}; diff --git a/tests/test_TupleToVectorProcessor.cpp b/tests/test_TupleToVectorProcessor.cpp index 817e5c9ba54af0664a34045d5de528f80c59db4a..74865d2ce1019e19e2474f059fde4708a2e5e735 100644 --- a/tests/test_TupleToVectorProcessor.cpp +++ b/tests/test_TupleToVectorProcessor.cpp @@ -77,17 +77,17 @@ TEST_CASE("TupleToVectorProcessor", "[language]") SECTION("Return tuple -> R^3") { std::string_view data = R"( -let f: R*R*R->R^3, (x,y,z) -> (x,y,z); +let f: R*R*R->R^3, (x,y,z) -> [y,z,x]; let x:R^3, x = f(1,2,3); )"; - CHECK_EVALUATION_RESULT(data, "x", (TinyVector<3>{1, 2, 3})); + CHECK_EVALUATION_RESULT(data, "x", (TinyVector<3>{2, 3, 1})); } SECTION("Return tuple -> R^2") { std::string_view data = R"( -let f: R^3->R^2, x -> (x[2],x[1]); -let x:R^3, x = (1,2,3); +let f: R^3->R^2, x -> [x[2],x[1]]; +let x:R^3, x = [1,2,3]; let y:R^2, y = f(x); )"; CHECK_EVALUATION_RESULT(data, "y", (TinyVector<2>{3, 2}));