diff --git a/src/language/node_processor/AffectationProcessor.hpp b/src/language/node_processor/AffectationProcessor.hpp index b06a96ac54f055f12b5afb626d7740a89d07b485..e28c8044b2ec1543fb8dddaf38884aea26734e24 100644 --- a/src/language/node_processor/AffectationProcessor.hpp +++ b/src/language/node_processor/AffectationProcessor.hpp @@ -562,37 +562,50 @@ class AffectationFromTupleProcessor final : public AffectationToDataVariantProce { DataVariant value = m_rhs_node.execute(exec_policy); - std::visit( - [&](auto&& v) { - using T = std::decay_t<decltype(v)>; - if constexpr (is_std_vector_v<T>) { - using TupleContentType = std::decay_t<typename T::value_type>; - if (v.size() == 1) { - std::cout << "TUPLE [" << demangle<TupleContentType>() << "] -> " << demangle<ValueT>() << '\n'; - if constexpr (std::is_same_v<TupleContentType, ValueT>) { - *m_lhs = v[0]; - } else if constexpr (std::is_arithmetic_v<ValueT> and std::is_convertible_v<TupleContentType, ValueT>) { -#warning treat the case (Z) -> N (check sign) - *m_lhs = static_cast<ValueT>(v[0]); + try { + std::visit( + [&](auto&& v) { + using T = std::decay_t<decltype(v)>; + if constexpr (is_std_vector_v<T>) { + using TupleContentType = std::decay_t<typename T::value_type>; + if (v.size() == 1) { + if constexpr (std::is_same_v<TupleContentType, ValueT>) { + *m_lhs = std::move(static_cast<ValueT>(v[0])); + } else if constexpr (std::is_arithmetic_v<ValueT> and std::is_convertible_v<TupleContentType, ValueT>) { + if constexpr (std::is_same_v<uint64_t, ValueT> and std::is_same_v<int64_t, TupleContentType>) { + if (v[0] < 0) { + throw std::domain_error("trying to affect negative value (" + stringify(v[0]) + ")"); + } + } + *m_lhs = std::move(static_cast<ValueT>(v[0])); + } else if constexpr ((std::is_same_v<ValueT, TinyVector<1>> or + std::is_same_v<ValueT, TinyMatrix<1>>)and(std::is_arithmetic_v<TupleContentType>)) { + *m_lhs = std::move(ValueT(v[0])); + } else if constexpr (std::is_same_v<std::string, ValueT>) { + *m_lhs = std::move(stringify(v[0])); + } else { + // LCOV_EXCL_START + throw UnexpectedError("unexpected rhs tuple content"); + // LCOV_EXCL_STOP + } } else { -#warning missing cases - throw NotImplementedError("remaining cases?"); + std::ostringstream error_msg; + error_msg << "cannot affect a " << rang::fgB::yellow << dataTypeName(m_rhs_node.m_data_type) + << rang::fg::reset << " of size " << v.size() << " to a " << rang::fgB::yellow + << dataTypeName(m_lhs_node.m_data_type) << rang::fg::reset; + throw ParseError(error_msg.str(), m_rhs_node.begin()); } } else { - std::ostringstream error_msg; - error_msg << "cannot affect a " << rang::fgB::yellow << dataTypeName(m_rhs_node.m_data_type) - << rang::fg::reset << " of size " << v.size() << " to a " << rang::fgB::yellow - << dataTypeName(m_lhs_node.m_data_type) << rang::fg::reset; - throw ParseError(error_msg.str(), m_rhs_node.begin()); + // LCOV_EXCL_START + throw UnexpectedError("right hand side must be a tuple"); + // LCOV_EXCL_STOP } - } else { - // LCOV_EXCL_START - throw UnexpectedError("right hand side must be a tuple"); - // LCOV_EXCL_STOP - } - }, - value); - + }, + value); + } + catch (std::domain_error& e) { + throw ParseError(e.what(), m_rhs_node.begin()); + } return {}; } @@ -698,7 +711,7 @@ class AffectationToTupleFromListProcessor final : public AffectationToDataVarian m_rhs_node.execute(exec_policy)); } catch (std::domain_error& e) { - throw ParseError(e.what(), m_rhs_node.begin()); + throw ParseError(e.what(), m_rhs_node.begin()); // LCOV_EXCL_LINE } return {}; } diff --git a/src/language/utils/AffectationRegisterForN.cpp b/src/language/utils/AffectationRegisterForN.cpp index ecb982c23359c716aaf7e799cfa13288e03bdd9a..9340545ea3320cca700b61076a5fce2ed8d9e166 100644 --- a/src/language/utils/AffectationRegisterForN.cpp +++ b/src/language/utils/AffectationRegisterForN.cpp @@ -33,6 +33,12 @@ AffectationRegisterForN::_register_eq_op() repository.addAffectation<language::eq_op>(ASTNodeDataType::build<ASTNodeDataType::tuple_t>(N), ASTNodeDataType::build<ASTNodeDataType::tuple_t>(Z), std::make_shared<AffectationToTupleFromTupleProcessorBuilder<uint64_t>>()); + + repository.addAffectation<language::eq_op>(N, ASTNodeDataType::build<ASTNodeDataType::tuple_t>(B), + std::make_shared<AffectationFromTupleProcessorBuilder<uint64_t>>()); + + repository.addAffectation<language::eq_op>(N, ASTNodeDataType::build<ASTNodeDataType::tuple_t>(Z), + std::make_shared<AffectationFromTupleProcessorBuilder<uint64_t>>()); } void diff --git a/src/language/utils/AffectationRegisterForR.cpp b/src/language/utils/AffectationRegisterForR.cpp index f7c5d3efa7867f18bbdad15552317b086ba695d9..409e66815396bb9c539874ef114e6ef8e0e6688e 100644 --- a/src/language/utils/AffectationRegisterForR.cpp +++ b/src/language/utils/AffectationRegisterForR.cpp @@ -45,6 +45,15 @@ AffectationRegisterForR::_register_eq_op() repository.addAffectation<language::eq_op>(ASTNodeDataType::build<ASTNodeDataType::tuple_t>(R), ASTNodeDataType::build<ASTNodeDataType::tuple_t>(Z), std::make_shared<AffectationToTupleFromTupleProcessorBuilder<double>>()); + + repository.addAffectation<language::eq_op>(R, ASTNodeDataType::build<ASTNodeDataType::tuple_t>(B), + std::make_shared<AffectationFromTupleProcessorBuilder<double>>()); + + repository.addAffectation<language::eq_op>(R, ASTNodeDataType::build<ASTNodeDataType::tuple_t>(N), + std::make_shared<AffectationFromTupleProcessorBuilder<double>>()); + + repository.addAffectation<language::eq_op>(R, ASTNodeDataType::build<ASTNodeDataType::tuple_t>(Z), + std::make_shared<AffectationFromTupleProcessorBuilder<double>>()); } void diff --git a/src/language/utils/AffectationRegisterForRn.cpp b/src/language/utils/AffectationRegisterForRn.cpp index 5ab23dba39b1c6192c67d8fa705692fb2d0e2f87..9850970f3556a91ace84bb603fe54c55a9329ee2 100644 --- a/src/language/utils/AffectationRegisterForRn.cpp +++ b/src/language/utils/AffectationRegisterForRn.cpp @@ -88,6 +88,22 @@ AffectationRegisterForRn<1>::_register_eq_op() .addAffectation<language::eq_op>(ASTNodeDataType::build<ASTNodeDataType::tuple_t>(R1), ASTNodeDataType::build<ASTNodeDataType::tuple_t>(R), std::make_shared<AffectationToTupleFromTupleProcessorBuilder<TinyVector<1>>>()); + + repository + .addAffectation<language::eq_op>(R1, ASTNodeDataType::build<ASTNodeDataType::tuple_t>(B), + std::make_shared<AffectationFromTupleProcessorBuilder<TinyVector<Dimension>>>()); + + repository + .addAffectation<language::eq_op>(R1, ASTNodeDataType::build<ASTNodeDataType::tuple_t>(N), + std::make_shared<AffectationFromTupleProcessorBuilder<TinyVector<Dimension>>>()); + + repository + .addAffectation<language::eq_op>(R1, ASTNodeDataType::build<ASTNodeDataType::tuple_t>(Z), + std::make_shared<AffectationFromTupleProcessorBuilder<TinyVector<Dimension>>>()); + + repository + .addAffectation<language::eq_op>(R1, ASTNodeDataType::build<ASTNodeDataType::tuple_t>(R), + std::make_shared<AffectationFromTupleProcessorBuilder<TinyVector<Dimension>>>()); } template <size_t Dimension> diff --git a/src/language/utils/AffectationRegisterForRnxn.cpp b/src/language/utils/AffectationRegisterForRnxn.cpp index 2ca3f7f6eee10147c5211164aae2d91fb36872d8..04cb101667497c55002bae68d4c7727d49f4b3d6 100644 --- a/src/language/utils/AffectationRegisterForRnxn.cpp +++ b/src/language/utils/AffectationRegisterForRnxn.cpp @@ -89,6 +89,22 @@ AffectationRegisterForRnxn<1>::_register_eq_op() .addAffectation<language::eq_op>(ASTNodeDataType::build<ASTNodeDataType::tuple_t>(R1x1), ASTNodeDataType::build<ASTNodeDataType::tuple_t>(R), std::make_shared<AffectationToTupleFromTupleProcessorBuilder<TinyMatrix<1>>>()); + + repository + .addAffectation<language::eq_op>(R1x1, ASTNodeDataType::build<ASTNodeDataType::tuple_t>(B), + std::make_shared<AffectationFromTupleProcessorBuilder<TinyMatrix<Dimension>>>()); + + repository + .addAffectation<language::eq_op>(R1x1, ASTNodeDataType::build<ASTNodeDataType::tuple_t>(N), + std::make_shared<AffectationFromTupleProcessorBuilder<TinyMatrix<Dimension>>>()); + + repository + .addAffectation<language::eq_op>(R1x1, ASTNodeDataType::build<ASTNodeDataType::tuple_t>(Z), + std::make_shared<AffectationFromTupleProcessorBuilder<TinyMatrix<Dimension>>>()); + + repository + .addAffectation<language::eq_op>(R1x1, ASTNodeDataType::build<ASTNodeDataType::tuple_t>(R), + std::make_shared<AffectationFromTupleProcessorBuilder<TinyMatrix<Dimension>>>()); } template <size_t Dimension> diff --git a/src/language/utils/AffectationRegisterForString.cpp b/src/language/utils/AffectationRegisterForString.cpp index 44f8a561ef3fdbec225adc59acc126908e4628ec..d9177dc7fc72c65f058a9537e4c1ee12c71d29cb 100644 --- a/src/language/utils/AffectationRegisterForString.cpp +++ b/src/language/utils/AffectationRegisterForString.cpp @@ -139,6 +139,36 @@ AffectationRegisterForString::_register_eq_op() .addAffectation<language::eq_op>(ASTNodeDataType::build<ASTNodeDataType::tuple_t>(string_t), ASTNodeDataType::build<ASTNodeDataType::tuple_t>(R3x3), std::make_shared<AffectationToTupleFromTupleProcessorBuilder<std::string>>()); + + repository.addAffectation<language::eq_op>(string_t, ASTNodeDataType::build<ASTNodeDataType::tuple_t>(B), + std::make_shared<AffectationFromTupleProcessorBuilder<std::string>>()); + + repository.addAffectation<language::eq_op>(string_t, ASTNodeDataType::build<ASTNodeDataType::tuple_t>(N), + std::make_shared<AffectationFromTupleProcessorBuilder<std::string>>()); + + repository.addAffectation<language::eq_op>(string_t, ASTNodeDataType::build<ASTNodeDataType::tuple_t>(Z), + std::make_shared<AffectationFromTupleProcessorBuilder<std::string>>()); + + repository.addAffectation<language::eq_op>(string_t, ASTNodeDataType::build<ASTNodeDataType::tuple_t>(R), + std::make_shared<AffectationFromTupleProcessorBuilder<std::string>>()); + + repository.addAffectation<language::eq_op>(string_t, ASTNodeDataType::build<ASTNodeDataType::tuple_t>(R1), + std::make_shared<AffectationFromTupleProcessorBuilder<std::string>>()); + + repository.addAffectation<language::eq_op>(string_t, ASTNodeDataType::build<ASTNodeDataType::tuple_t>(R2), + std::make_shared<AffectationFromTupleProcessorBuilder<std::string>>()); + + repository.addAffectation<language::eq_op>(string_t, ASTNodeDataType::build<ASTNodeDataType::tuple_t>(R3), + std::make_shared<AffectationFromTupleProcessorBuilder<std::string>>()); + + repository.addAffectation<language::eq_op>(string_t, ASTNodeDataType::build<ASTNodeDataType::tuple_t>(R1x1), + std::make_shared<AffectationFromTupleProcessorBuilder<std::string>>()); + + repository.addAffectation<language::eq_op>(string_t, ASTNodeDataType::build<ASTNodeDataType::tuple_t>(R2x2), + std::make_shared<AffectationFromTupleProcessorBuilder<std::string>>()); + + repository.addAffectation<language::eq_op>(string_t, ASTNodeDataType::build<ASTNodeDataType::tuple_t>(R3x3), + std::make_shared<AffectationFromTupleProcessorBuilder<std::string>>()); } void diff --git a/src/language/utils/AffectationRegisterForZ.cpp b/src/language/utils/AffectationRegisterForZ.cpp index 553a0e83cb72ec1b29c733746c8d5048b117e5fb..648c680c23eb7a0c51d61d44aca2c75ee170c4ab 100644 --- a/src/language/utils/AffectationRegisterForZ.cpp +++ b/src/language/utils/AffectationRegisterForZ.cpp @@ -33,6 +33,12 @@ AffectationRegisterForZ::_register_eq_op() repository.addAffectation<language::eq_op>(ASTNodeDataType::build<ASTNodeDataType::tuple_t>(Z), ASTNodeDataType::build<ASTNodeDataType::tuple_t>(N), std::make_shared<AffectationToTupleFromTupleProcessorBuilder<int64_t>>()); + + repository.addAffectation<language::eq_op>(Z, ASTNodeDataType::build<ASTNodeDataType::tuple_t>(B), + std::make_shared<AffectationFromTupleProcessorBuilder<int64_t>>()); + + repository.addAffectation<language::eq_op>(Z, ASTNodeDataType::build<ASTNodeDataType::tuple_t>(N), + std::make_shared<AffectationFromTupleProcessorBuilder<int64_t>>()); } void diff --git a/src/language/utils/BasicAffectationRegistrerFor.hpp b/src/language/utils/BasicAffectationRegistrerFor.hpp index 06f905ca239750964cea9945206484d52a2da05f..72569803014412bc9e7e556fb5ea8fb6e024ff54 100644 --- a/src/language/utils/BasicAffectationRegistrerFor.hpp +++ b/src/language/utils/BasicAffectationRegistrerFor.hpp @@ -30,6 +30,10 @@ class BasicAffectationRegisterFor repository.addAffectation<language::eq_op>(ASTNodeDataType::build<ASTNodeDataType::tuple_t>(ast_node_data_type), ASTNodeDataType::build<ASTNodeDataType::tuple_t>(ast_node_data_type), std::make_shared<AffectationToTupleFromTupleProcessorBuilder<T>>()); + + repository.addAffectation<language::eq_op>(ast_node_data_type, + ASTNodeDataType::build<ASTNodeDataType::tuple_t>(ast_node_data_type), + std::make_shared<AffectationFromTupleProcessorBuilder<T>>()); } }; diff --git a/src/language/utils/ItemValueVariantFunctionInterpoler.cpp b/src/language/utils/ItemValueVariantFunctionInterpoler.cpp index 018dd7a9837997e4faf595898773f7c847f47f20..e10e834e55a126823414316ce5d527716befd761 100644 --- a/src/language/utils/ItemValueVariantFunctionInterpoler.cpp +++ b/src/language/utils/ItemValueVariantFunctionInterpoler.cpp @@ -41,9 +41,11 @@ ItemValueVariantFunctionInterpoler::_interpolate() const InterpolateItemValue<DataType(TinyVector<Dimension>)>::template interpolate<ItemType::node>(m_function_id, p_mesh->xr())); } + // LCOV_EXCL_START default: { throw UnexpectedError("invalid item type"); } + // LCOV_EXCL_STOP } } diff --git a/tests/test_ASTNodeAffectationExpressionBuilder.cpp b/tests/test_ASTNodeAffectationExpressionBuilder.cpp index 57b8290ec489223498b67ab40dad50f86bb32a0a..64c15221949915d15c8559d7c017e2c172a2c670 100644 --- a/tests/test_ASTNodeAffectationExpressionBuilder.cpp +++ b/tests/test_ASTNodeAffectationExpressionBuilder.cpp @@ -949,7 +949,7 @@ let t : (builtin_t), t= (a,b,a); } } - SECTION("singleton -> tuple") + SECTION("value -> tuple") { SECTION(" -> (B)") { @@ -1083,7 +1083,7 @@ let t : (Z), t = -2; SECTION("-> (R)") { - SECTION("Z -> (B)") + SECTION("B -> (R)") { std::string_view data = R"( let t : (R), t = true; @@ -1099,7 +1099,7 @@ let t : (R), t = true; CHECK_AST(data, result); } - SECTION("N -> (B)") + SECTION("N -> (R)") { std::string_view data = R"( let n : N, n = 2; @@ -1253,6 +1253,111 @@ let t3 : (R^1), t3 = 2.3; } } + SECTION("-> R^dxd") + { + SECTION("B -> (R^1x1)") + { + std::string_view data = R"( +let t : (R^1x1), t = false; +)"; + + std::string_view result = R"( +(root:ASTNodeListProcessor) + `-(language::eq_op:AffectationToTupleProcessor<TinyMatrix<1ul, 1ul, double> >) + +-(language::name:t:NameProcessor) + `-(language::false_kw:ValueProcessor) +)"; + + CHECK_AST(data, result); + } + + SECTION("N -> (R^1x1)") + { + std::string_view data = R"( +let n : N, n = 3; +let t : (R^1x1), t = n; +)"; + + std::string_view result = R"( +(root:ASTNodeListProcessor) + +-(language::eq_op:AffectationProcessor<language::eq_op, unsigned long, long>) + | +-(language::name:n:NameProcessor) + | `-(language::integer:3:ValueProcessor) + `-(language::eq_op:AffectationToTupleProcessor<TinyMatrix<1ul, 1ul, double> >) + +-(language::name:t:NameProcessor) + `-(language::name:n:NameProcessor) +)"; + + CHECK_AST(data, result); + } + + SECTION("Z -> (R^1x1)") + { + std::string_view data = R"( +let t : (R^1x1), t = 3; +)"; + + std::string_view result = R"( +(root:ASTNodeListProcessor) + `-(language::eq_op:AffectationToTupleProcessor<TinyMatrix<1ul, 1ul, double> >) + +-(language::name:t:NameProcessor) + `-(language::integer:3:ValueProcessor) +)"; + + CHECK_AST(data, result); + } + + SECTION("R -> (R^1x1)") + { + std::string_view data = R"( +let t : (R^1x1), t = 3.3; +)"; + + std::string_view result = R"( +(root:ASTNodeListProcessor) + `-(language::eq_op:AffectationToTupleProcessor<TinyMatrix<1ul, 1ul, double> >) + +-(language::name:t:NameProcessor) + `-(language::real:3.3:ValueProcessor) +)"; + + CHECK_AST(data, result); + } + + SECTION("R^dxd -> (R^dxd)") + { + std::string_view data = R"( +let a : R^2x2, a = [[2,3.1],[2,3.2]]; +let t1 : (R^2x2), t1 = a; +let t2 : (R^3x3), t2 = 0; +let t3 : (R^1x1), t3 = 2.3; +)"; + + std::string_view result = R"( +(root:ASTNodeListProcessor) + +-(language::eq_op:AffectationProcessor<language::eq_op, TinyMatrix<2ul, 2ul, double>, TinyMatrix<2ul, 2ul, double> >) + | +-(language::name:a:NameProcessor) + | `-(language::matrix_expression:TinyMatrixExpressionProcessor<2ul, 2ul>) + | +-(language::row_expression:FakeProcessor) + | | +-(language::integer:2:ValueProcessor) + | | `-(language::real:3.1:ValueProcessor) + | `-(language::row_expression:FakeProcessor) + | +-(language::integer:2:ValueProcessor) + | `-(language::real:3.2:ValueProcessor) + +-(language::eq_op:AffectationToTupleProcessor<TinyMatrix<2ul, 2ul, double> >) + | +-(language::name:t1:NameProcessor) + | `-(language::name:a:NameProcessor) + +-(language::eq_op:AffectationToTupleProcessor<TinyMatrix<3ul, 3ul, double> >) + | +-(language::name:t2:NameProcessor) + | `-(language::integer:0:ValueProcessor) + `-(language::eq_op:AffectationToTupleProcessor<TinyMatrix<1ul, 1ul, double> >) + +-(language::name:t3:NameProcessor) + `-(language::real:2.3:ValueProcessor) +)"; + + CHECK_AST(data, result); + } + } + SECTION("-> (string)") { SECTION("B -> (string)") @@ -1494,883 +1599,5887 @@ let t : (builtin_t), t = a; CHECK_AST_WITH_BUILTIN(data, result); } } - } - SECTION("+=") - { - SECTION("N += N") + SECTION("tuple -> value") { - std::string_view data = R"( -let n : N, n=1; n+=n; + SECTION(" -> B") + { + SECTION("(B) -> B") + { + std::string_view data = R"( +let t : (B), t = true; +let b : B, b = t; )"; - std::string_view result = R"( + std::string_view result = R"( (root:ASTNodeListProcessor) - +-(language::eq_op:AffectationProcessor<language::eq_op, unsigned long, long>) - | +-(language::name:n:NameProcessor) - | `-(language::integer:1:ValueProcessor) - `-(language::pluseq_op:AffectationProcessor<language::pluseq_op, unsigned long, unsigned long>) - +-(language::name:n:NameProcessor) - `-(language::name:n:NameProcessor) + +-(language::eq_op:AffectationToTupleProcessor<bool>) + | +-(language::name:t:NameProcessor) + | `-(language::true_kw:ValueProcessor) + `-(language::eq_op:AffectationFromTupleProcessor<bool>) + +-(language::name:b:NameProcessor) + `-(language::name:t:NameProcessor) )"; - CHECK_AST(data, result); - } + CHECK_AST(data, result); + } + } - SECTION("R += N") - { - std::string_view data = R"( -let x : R, x=1; x+=2; + SECTION("-> N") + { + SECTION("(B) -> N") + { + std::string_view data = R"( +let t : (B), t = true; +let n : N, n = t; )"; - std::string_view result = R"( + std::string_view result = R"( (root:ASTNodeListProcessor) - +-(language::eq_op:AffectationProcessor<language::eq_op, double, long>) - | +-(language::name:x:NameProcessor) - | `-(language::integer:1:ValueProcessor) - `-(language::pluseq_op:AffectationProcessor<language::pluseq_op, double, long>) - +-(language::name:x:NameProcessor) - `-(language::integer:2:ValueProcessor) + +-(language::eq_op:AffectationToTupleProcessor<bool>) + | +-(language::name:t:NameProcessor) + | `-(language::true_kw:ValueProcessor) + `-(language::eq_op:AffectationFromTupleProcessor<unsigned long>) + +-(language::name:n:NameProcessor) + `-(language::name:t:NameProcessor) )"; - CHECK_AST(data, result); - } + CHECK_AST(data, result); + } - SECTION("string += N") - { - std::string_view data = R"( -let s : string, s="foo"; s+=2; + SECTION("(N) -> N") + { + std::string_view data = R"( +let t : (N), t = 1; +let n : N, n = t; )"; - std::string result = R"( + std::string_view result = R"( (root:ASTNodeListProcessor) - +-(language::eq_op:AffectationProcessor<language::eq_op, )" + - demangled_stdstring + ", " + demangled_stdstring + R"( >) - | +-(language::name:s:NameProcessor) - | `-(language::literal:"foo":ValueProcessor) - `-(language::pluseq_op:AffectationProcessor<language::pluseq_op, )" + - demangled_stdstring + - R"(, long>) - +-(language::name:s:NameProcessor) - `-(language::integer:2:ValueProcessor) + +-(language::eq_op:AffectationToTupleProcessor<unsigned long>) + | +-(language::name:t:NameProcessor) + | `-(language::integer:1:ValueProcessor) + `-(language::eq_op:AffectationFromTupleProcessor<unsigned long>) + +-(language::name:n:NameProcessor) + `-(language::name:t:NameProcessor) )"; - CHECK_AST(data, result); - } + CHECK_AST(data, result); + } - SECTION("R^1 += R^1") - { - std::string_view data = R"( -let x : R^1; -let y : R^1; -x += y; + SECTION("(Z) -> N") + { + std::string_view data = R"( +let t : (Z), t = 1; +let n : N, n = t; )"; - std::string result = R"( + std::string_view result = R"( (root:ASTNodeListProcessor) - `-(language::pluseq_op:AffectationProcessor<language::pluseq_op, TinyVector<1ul, double>, TinyVector<1ul, double> >) - +-(language::name:x:NameProcessor) - `-(language::name:y:NameProcessor) + +-(language::eq_op:AffectationToTupleProcessor<long>) + | +-(language::name:t:NameProcessor) + | `-(language::integer:1:ValueProcessor) + `-(language::eq_op:AffectationFromTupleProcessor<unsigned long>) + +-(language::name:n:NameProcessor) + `-(language::name:t:NameProcessor) )"; - CHECK_AST(data, result); - } + CHECK_AST(data, result); + } + } - SECTION("R^2 += R^2") - { - std::string_view data = R"( -let x : R^2; -let y : R^2; -x += y; + SECTION("-> Z") + { + SECTION("(B) -> Z") + { + std::string_view data = R"( +let t : (B), t = true; +let z : Z, z = t; )"; - std::string result = R"( + std::string_view result = R"( (root:ASTNodeListProcessor) - `-(language::pluseq_op:AffectationProcessor<language::pluseq_op, TinyVector<2ul, double>, TinyVector<2ul, double> >) - +-(language::name:x:NameProcessor) - `-(language::name:y:NameProcessor) + +-(language::eq_op:AffectationToTupleProcessor<bool>) + | +-(language::name:t:NameProcessor) + | `-(language::true_kw:ValueProcessor) + `-(language::eq_op:AffectationFromTupleProcessor<long>) + +-(language::name:z:NameProcessor) + `-(language::name:t:NameProcessor) )"; - CHECK_AST(data, result); - } + CHECK_AST(data, result); + } - SECTION("R^3 += R^3") - { - std::string_view data = R"( -let x : R^3; -let y : R^3; -x += y; + SECTION("(N) -> Z") + { + std::string_view data = R"( +let t : (N), t = 2; +let z : Z, z = t; )"; - std::string result = R"( + std::string_view result = R"( (root:ASTNodeListProcessor) - `-(language::pluseq_op:AffectationProcessor<language::pluseq_op, TinyVector<3ul, double>, TinyVector<3ul, double> >) - +-(language::name:x:NameProcessor) - `-(language::name:y:NameProcessor) + +-(language::eq_op:AffectationToTupleProcessor<unsigned long>) + | +-(language::name:t:NameProcessor) + | `-(language::integer:2:ValueProcessor) + `-(language::eq_op:AffectationFromTupleProcessor<long>) + +-(language::name:z:NameProcessor) + `-(language::name:t:NameProcessor) )"; - CHECK_AST(data, result); - } - } + CHECK_AST(data, result); + } - SECTION("-=") - { - SECTION("Z -= Z") - { - std::string_view data = R"( -let z : Z, z=1; z-=2; + SECTION("(Z) -> Z") + { + std::string_view data = R"( +let t : (Z), t = -2; +let z : Z, z = t; )"; - std::string_view result = R"( + std::string_view result = R"( (root:ASTNodeListProcessor) - +-(language::eq_op:AffectationProcessor<language::eq_op, long, long>) - | +-(language::name:z:NameProcessor) - | `-(language::integer:1:ValueProcessor) - `-(language::minuseq_op:AffectationProcessor<language::minuseq_op, long, long>) + +-(language::eq_op:AffectationToTupleProcessor<long>) + | +-(language::name:t:NameProcessor) + | `-(language::unary_minus:UnaryExpressionProcessor<language::unary_minus, long, long>) + | `-(language::integer:2:ValueProcessor) + `-(language::eq_op:AffectationFromTupleProcessor<long>) +-(language::name:z:NameProcessor) - `-(language::integer:2:ValueProcessor) + `-(language::name:t:NameProcessor) )"; - CHECK_AST(data, result); - } + CHECK_AST(data, result); + } + } - SECTION("R -= R") - { - std::string_view data = R"( -let x : R, x=1; x-=2.3; + SECTION("-> R") + { + SECTION("(B) -> R") + { + std::string_view data = R"( +let t : (B), t = true; +let x: R, x = t; )"; - std::string_view result = R"( + std::string_view result = R"( (root:ASTNodeListProcessor) - +-(language::eq_op:AffectationProcessor<language::eq_op, double, long>) - | +-(language::name:x:NameProcessor) - | `-(language::integer:1:ValueProcessor) - `-(language::minuseq_op:AffectationProcessor<language::minuseq_op, double, double>) + +-(language::eq_op:AffectationToTupleProcessor<bool>) + | +-(language::name:t:NameProcessor) + | `-(language::true_kw:ValueProcessor) + `-(language::eq_op:AffectationFromTupleProcessor<double>) +-(language::name:x:NameProcessor) - `-(language::real:2.3:ValueProcessor) + `-(language::name:t:NameProcessor) )"; - CHECK_AST(data, result); - } + CHECK_AST(data, result); + } - SECTION("R^1 -= R^1") - { - std::string_view data = R"( -let x : R^1; -let y : R^1; -x -= y; + SECTION("(N) -> R") + { + std::string_view data = R"( +let t : (N), t = 2; +let x : R, x = 2; )"; - std::string result = R"( + std::string_view result = R"( (root:ASTNodeListProcessor) - `-(language::minuseq_op:AffectationProcessor<language::minuseq_op, TinyVector<1ul, double>, TinyVector<1ul, double> >) + +-(language::eq_op:AffectationToTupleProcessor<unsigned long>) + | +-(language::name:t:NameProcessor) + | `-(language::integer:2:ValueProcessor) + `-(language::eq_op:AffectationProcessor<language::eq_op, double, long>) +-(language::name:x:NameProcessor) - `-(language::name:y:NameProcessor) + `-(language::integer:2:ValueProcessor) )"; - CHECK_AST(data, result); - } + CHECK_AST(data, result); + } - SECTION("R^2 -= R^2") - { - std::string_view data = R"( -let x : R^2; -let y : R^2; -x -= y; + SECTION("(Z) -> R") + { + std::string_view data = R"( +let t : (Z), t = 3; +let x : R, x = t; )"; - std::string result = R"( + std::string_view result = R"( (root:ASTNodeListProcessor) - `-(language::minuseq_op:AffectationProcessor<language::minuseq_op, TinyVector<2ul, double>, TinyVector<2ul, double> >) + +-(language::eq_op:AffectationToTupleProcessor<long>) + | +-(language::name:t:NameProcessor) + | `-(language::integer:3:ValueProcessor) + `-(language::eq_op:AffectationFromTupleProcessor<double>) +-(language::name:x:NameProcessor) - `-(language::name:y:NameProcessor) + `-(language::name:t:NameProcessor) )"; - CHECK_AST(data, result); - } + CHECK_AST(data, result); + } - SECTION("R^3 -= R^3") - { - std::string_view data = R"( -let x : R^3; -let y : R^3; -x -= y; + SECTION("R -> (R)") + { + std::string_view data = R"( +let t : (R), t = 3.1; +let x : R, x = t; )"; - std::string result = R"( + std::string_view result = R"( (root:ASTNodeListProcessor) - `-(language::minuseq_op:AffectationProcessor<language::minuseq_op, TinyVector<3ul, double>, TinyVector<3ul, double> >) + +-(language::eq_op:AffectationToTupleProcessor<double>) + | +-(language::name:t:NameProcessor) + | `-(language::real:3.1:ValueProcessor) + `-(language::eq_op:AffectationFromTupleProcessor<double>) +-(language::name:x:NameProcessor) - `-(language::name:y:NameProcessor) + `-(language::name:t:NameProcessor) )"; - CHECK_AST(data, result); - } - } + CHECK_AST(data, result); + } + } - SECTION("*=") - { - SECTION("Z *= Z") - { - std::string_view data = R"( -let z : Z, z=1; z*=2; + SECTION("-> R^d") + { + SECTION("(B) -> R^1") + { + std::string_view data = R"( +let t : (B), t = false; +let x : R^1, x = t; )"; - std::string_view result = R"( + std::string_view result = R"( (root:ASTNodeListProcessor) - +-(language::eq_op:AffectationProcessor<language::eq_op, long, long>) - | +-(language::name:z:NameProcessor) - | `-(language::integer:1:ValueProcessor) - `-(language::multiplyeq_op:AffectationProcessor<language::multiplyeq_op, long, long>) - +-(language::name:z:NameProcessor) - `-(language::integer:2:ValueProcessor) + +-(language::eq_op:AffectationToTupleProcessor<bool>) + | +-(language::name:t:NameProcessor) + | `-(language::false_kw:ValueProcessor) + `-(language::eq_op:AffectationFromTupleProcessor<TinyVector<1ul, double> >) + +-(language::name:x:NameProcessor) + `-(language::name:t:NameProcessor) )"; - CHECK_AST(data, result); - } + CHECK_AST(data, result); + } - SECTION("R *= R") - { - std::string_view data = R"( -let x : R, x=1; x*=2.3; + SECTION("(N) -> R^1") + { + std::string_view data = R"( +let t : (N), t = 3; +let x : R^1, x = t; )"; - std::string_view result = R"( + std::string_view result = R"( (root:ASTNodeListProcessor) - +-(language::eq_op:AffectationProcessor<language::eq_op, double, long>) - | +-(language::name:x:NameProcessor) - | `-(language::integer:1:ValueProcessor) - `-(language::multiplyeq_op:AffectationProcessor<language::multiplyeq_op, double, double>) + +-(language::eq_op:AffectationToTupleProcessor<unsigned long>) + | +-(language::name:t:NameProcessor) + | `-(language::integer:3:ValueProcessor) + `-(language::eq_op:AffectationFromTupleProcessor<TinyVector<1ul, double> >) +-(language::name:x:NameProcessor) - `-(language::real:2.3:ValueProcessor) + `-(language::name:t:NameProcessor) )"; - CHECK_AST(data, result); - } + CHECK_AST(data, result); + } - SECTION("R^1 *= R") - { - std::string_view data = R"( -let x : R^1; x*=2.3; + SECTION("(Z) -> R^1") + { + std::string_view data = R"( +let t : (Z), t = 3; +let x : R^1, x = t; )"; - std::string_view result = R"( + std::string_view result = R"( (root:ASTNodeListProcessor) - `-(language::multiplyeq_op:AffectationProcessor<language::multiplyeq_op, TinyVector<1ul, double>, double>) + +-(language::eq_op:AffectationToTupleProcessor<long>) + | +-(language::name:t:NameProcessor) + | `-(language::integer:3:ValueProcessor) + `-(language::eq_op:AffectationFromTupleProcessor<TinyVector<1ul, double> >) +-(language::name:x:NameProcessor) - `-(language::real:2.3:ValueProcessor) + `-(language::name:t:NameProcessor) )"; - CHECK_AST(data, result); - } + CHECK_AST(data, result); + } - SECTION("R^2 *= R") - { - std::string_view data = R"( -let x : R^2; x*= 6.2; + SECTION("(R) -> R^1") + { + std::string_view data = R"( +let t : (R), t = 3.3; +let x : R^1, x = t; )"; - std::string_view result = R"( + std::string_view result = R"( (root:ASTNodeListProcessor) - `-(language::multiplyeq_op:AffectationProcessor<language::multiplyeq_op, TinyVector<2ul, double>, double>) + +-(language::eq_op:AffectationToTupleProcessor<double>) + | +-(language::name:t:NameProcessor) + | `-(language::real:3.3:ValueProcessor) + `-(language::eq_op:AffectationFromTupleProcessor<TinyVector<1ul, double> >) +-(language::name:x:NameProcessor) - `-(language::real:6.2:ValueProcessor) + `-(language::name:t:NameProcessor) )"; - CHECK_AST(data, result); - } + CHECK_AST(data, result); + } - SECTION("R^3 *= R") - { - std::string_view data = R"( -let x : R^3; x*= 3.1; + SECTION("(R^1) -> R^1") + { + std::string_view data = R"( +let t : (R^1), t = 2.3; +let x : R^1, x = t; )"; - std::string_view result = R"( + std::string_view result = R"( (root:ASTNodeListProcessor) - `-(language::multiplyeq_op:AffectationProcessor<language::multiplyeq_op, TinyVector<3ul, double>, double>) + +-(language::eq_op:AffectationToTupleProcessor<TinyVector<1ul, double> >) + | +-(language::name:t:NameProcessor) + | `-(language::real:2.3:ValueProcessor) + `-(language::eq_op:AffectationFromTupleProcessor<TinyVector<1ul, double> >) +-(language::name:x:NameProcessor) - `-(language::real:3.1:ValueProcessor) + `-(language::name:t:NameProcessor) )"; - CHECK_AST(data, result); - } + CHECK_AST(data, result); + } - SECTION("R *= Z") - { - std::string_view data = R"( -let x : R, x=1; x*=2; + SECTION("(R^2) -> R^2") + { + std::string_view data = R"( +let t : (R^2), t = [2.3, 1]; +let x : R^2, x = t; )"; - std::string_view result = R"( + std::string_view result = R"( (root:ASTNodeListProcessor) - +-(language::eq_op:AffectationProcessor<language::eq_op, double, long>) - | +-(language::name:x:NameProcessor) - | `-(language::integer:1:ValueProcessor) - `-(language::multiplyeq_op:AffectationProcessor<language::multiplyeq_op, double, long>) + +-(language::eq_op:AffectationToTupleProcessor<TinyVector<2ul, double> >) + | +-(language::name:t:NameProcessor) + | `-(language::vector_expression:TinyVectorExpressionProcessor<2ul>) + | +-(language::real:2.3:ValueProcessor) + | `-(language::integer:1:ValueProcessor) + `-(language::eq_op:AffectationFromTupleProcessor<TinyVector<2ul, double> >) +-(language::name:x:NameProcessor) - `-(language::integer:2:ValueProcessor) + `-(language::name:t:NameProcessor) )"; - CHECK_AST(data, result); - } + CHECK_AST(data, result); + } - SECTION("R^1 *= Z") - { - std::string_view data = R"( -let x : R^1; x *= 3; + SECTION("(R^3) -> R^3") + { + std::string_view data = R"( +let t : (R^3), t = [2.3, 1, 1]; +let x : R^3, x = t; )"; - std::string_view result = R"( + std::string_view result = R"( (root:ASTNodeListProcessor) - `-(language::multiplyeq_op:AffectationProcessor<language::multiplyeq_op, TinyVector<1ul, double>, long>) + +-(language::eq_op:AffectationToTupleProcessor<TinyVector<3ul, double> >) + | +-(language::name:t:NameProcessor) + | `-(language::vector_expression:TinyVectorExpressionProcessor<3ul>) + | +-(language::real:2.3:ValueProcessor) + | +-(language::integer:1:ValueProcessor) + | `-(language::integer:1:ValueProcessor) + `-(language::eq_op:AffectationFromTupleProcessor<TinyVector<3ul, double> >) +-(language::name:x:NameProcessor) - `-(language::integer:3:ValueProcessor) + `-(language::name:t:NameProcessor) )"; - CHECK_AST(data, result); - } + CHECK_AST(data, result); + } + } - SECTION("R^2 *= Z") - { - std::string_view data = R"( -let x : R^2; x *= 6; + SECTION("-> R^dxd") + { + SECTION("(B) -> R^1x1") + { + std::string_view data = R"( +let t : (B), t = false; +let x : R^1x1, x = t; )"; - std::string_view result = R"( + std::string_view result = R"( (root:ASTNodeListProcessor) - `-(language::multiplyeq_op:AffectationProcessor<language::multiplyeq_op, TinyVector<2ul, double>, long>) + +-(language::eq_op:AffectationToTupleProcessor<bool>) + | +-(language::name:t:NameProcessor) + | `-(language::false_kw:ValueProcessor) + `-(language::eq_op:AffectationFromTupleProcessor<TinyMatrix<1ul, 1ul, double> >) +-(language::name:x:NameProcessor) - `-(language::integer:6:ValueProcessor) + `-(language::name:t:NameProcessor) )"; - CHECK_AST(data, result); - } + CHECK_AST(data, result); + } - SECTION("R^3 *= Z") - { - std::string_view data = R"( -let x : R^3; x *= 4; + SECTION("(N) -> R^1x1") + { + std::string_view data = R"( +let t : (N), t = 3; +let x : R^1x1, x = t; )"; - std::string_view result = R"( + std::string_view result = R"( (root:ASTNodeListProcessor) - `-(language::multiplyeq_op:AffectationProcessor<language::multiplyeq_op, TinyVector<3ul, double>, long>) + +-(language::eq_op:AffectationToTupleProcessor<unsigned long>) + | +-(language::name:t:NameProcessor) + | `-(language::integer:3:ValueProcessor) + `-(language::eq_op:AffectationFromTupleProcessor<TinyMatrix<1ul, 1ul, double> >) +-(language::name:x:NameProcessor) - `-(language::integer:4:ValueProcessor) + `-(language::name:t:NameProcessor) )"; - CHECK_AST(data, result); - } + CHECK_AST(data, result); + } - SECTION("R *= N") - { - std::string_view data = R"( -let n : N, n=2; let x : R, x=1; x *= n; + SECTION("(Z) -> R^1x1") + { + std::string_view data = R"( +let t : (Z), t = 3; +let x : R^1x1, x = t; )"; - std::string_view result = R"( + std::string_view result = R"( (root:ASTNodeListProcessor) - +-(language::eq_op:AffectationProcessor<language::eq_op, unsigned long, long>) - | +-(language::name:n:NameProcessor) - | `-(language::integer:2:ValueProcessor) - +-(language::eq_op:AffectationProcessor<language::eq_op, double, long>) - | +-(language::name:x:NameProcessor) - | `-(language::integer:1:ValueProcessor) - `-(language::multiplyeq_op:AffectationProcessor<language::multiplyeq_op, double, unsigned long>) + +-(language::eq_op:AffectationToTupleProcessor<long>) + | +-(language::name:t:NameProcessor) + | `-(language::integer:3:ValueProcessor) + `-(language::eq_op:AffectationFromTupleProcessor<TinyMatrix<1ul, 1ul, double> >) +-(language::name:x:NameProcessor) - `-(language::name:n:NameProcessor) + `-(language::name:t:NameProcessor) )"; - CHECK_AST(data, result); - } + CHECK_AST(data, result); + } - SECTION("R^1 *= N") - { - std::string_view data = R"( -let n : N; -let x : R^1; x *= n; + SECTION("(R) -> R^1x1") + { + std::string_view data = R"( +let t : (R), t = 3.3; +let x : R^1x1, x = t; )"; - std::string_view result = R"( + std::string_view result = R"( (root:ASTNodeListProcessor) - `-(language::multiplyeq_op:AffectationProcessor<language::multiplyeq_op, TinyVector<1ul, double>, unsigned long>) + +-(language::eq_op:AffectationToTupleProcessor<double>) + | +-(language::name:t:NameProcessor) + | `-(language::real:3.3:ValueProcessor) + `-(language::eq_op:AffectationFromTupleProcessor<TinyMatrix<1ul, 1ul, double> >) +-(language::name:x:NameProcessor) - `-(language::name:n:NameProcessor) + `-(language::name:t:NameProcessor) )"; - CHECK_AST(data, result); - } + CHECK_AST(data, result); + } - SECTION("R^2 *= N") - { - std::string_view data = R"( -let n : N; -let x : R^2; x *= n; + SECTION("(R^1x1) -> R^1x1") + { + std::string_view data = R"( +let t : (R^1x1), t = 2.3; +let x : R^1x1, x = t; )"; - std::string_view result = R"( + std::string_view result = R"( (root:ASTNodeListProcessor) - `-(language::multiplyeq_op:AffectationProcessor<language::multiplyeq_op, TinyVector<2ul, double>, unsigned long>) + +-(language::eq_op:AffectationToTupleProcessor<TinyMatrix<1ul, 1ul, double> >) + | +-(language::name:t:NameProcessor) + | `-(language::real:2.3:ValueProcessor) + `-(language::eq_op:AffectationFromTupleProcessor<TinyMatrix<1ul, 1ul, double> >) +-(language::name:x:NameProcessor) - `-(language::name:n:NameProcessor) + `-(language::name:t:NameProcessor) )"; - CHECK_AST(data, result); - } + CHECK_AST(data, result); + } - SECTION("R^3 *= N") - { - std::string_view data = R"( -let n : N; -let x : R^3; x *= n; + SECTION("(R^2x2) -> R^2x2") + { + std::string_view data = R"( +let t : (R^2x2), t = [[2.3, 1], [6,5]]; +let x : R^2x2, x = t; )"; - std::string_view result = R"( + std::string_view result = R"( (root:ASTNodeListProcessor) - `-(language::multiplyeq_op:AffectationProcessor<language::multiplyeq_op, TinyVector<3ul, double>, unsigned long>) + +-(language::eq_op:AffectationToTupleProcessor<TinyMatrix<2ul, 2ul, double> >) + | +-(language::name:t:NameProcessor) + | `-(language::matrix_expression:TinyMatrixExpressionProcessor<2ul, 2ul>) + | +-(language::row_expression:FakeProcessor) + | | +-(language::real:2.3:ValueProcessor) + | | `-(language::integer:1:ValueProcessor) + | `-(language::row_expression:FakeProcessor) + | +-(language::integer:6:ValueProcessor) + | `-(language::integer:5:ValueProcessor) + `-(language::eq_op:AffectationFromTupleProcessor<TinyMatrix<2ul, 2ul, double> >) +-(language::name:x:NameProcessor) - `-(language::name:n:NameProcessor) + `-(language::name:t:NameProcessor) )"; - CHECK_AST(data, result); - } + CHECK_AST(data, result); + } - SECTION("R *= B") - { - std::string_view data = R"( -let x : R, x=1; x *= true; + SECTION("(R^3x3) -> R^3x3") + { + std::string_view data = R"( +let t : (R^3x3), t = [[2.3, 1, 1],[1, 2, 3], [2,1,2]]; +let x : R^3x3, x = t; )"; - std::string_view result = R"( + std::string_view result = R"( (root:ASTNodeListProcessor) - +-(language::eq_op:AffectationProcessor<language::eq_op, double, long>) - | +-(language::name:x:NameProcessor) - | `-(language::integer:1:ValueProcessor) - `-(language::multiplyeq_op:AffectationProcessor<language::multiplyeq_op, double, bool>) + +-(language::eq_op:AffectationToTupleProcessor<TinyMatrix<3ul, 3ul, double> >) + | +-(language::name:t:NameProcessor) + | `-(language::matrix_expression:TinyMatrixExpressionProcessor<3ul, 3ul>) + | +-(language::row_expression:FakeProcessor) + | | +-(language::real:2.3:ValueProcessor) + | | +-(language::integer:1:ValueProcessor) + | | `-(language::integer:1:ValueProcessor) + | +-(language::row_expression:FakeProcessor) + | | +-(language::integer:1:ValueProcessor) + | | +-(language::integer:2:ValueProcessor) + | | `-(language::integer:3:ValueProcessor) + | `-(language::row_expression:FakeProcessor) + | +-(language::integer:2:ValueProcessor) + | +-(language::integer:1:ValueProcessor) + | `-(language::integer:2:ValueProcessor) + `-(language::eq_op:AffectationFromTupleProcessor<TinyMatrix<3ul, 3ul, double> >) +-(language::name:x:NameProcessor) - `-(language::true_kw:ValueProcessor) + `-(language::name:t:NameProcessor) )"; - CHECK_AST(data, result); - } + CHECK_AST(data, result); + } + } - SECTION("R^1 *= B") - { - std::string_view data = R"( -let x : R^1; x *= true; + SECTION("-> string") + { + SECTION("(B) -> string") + { + std::string_view data = R"( +let t : (B), t = true; +let s : string, s = t; )"; - std::string_view result = R"( + std::string result = R"( (root:ASTNodeListProcessor) - `-(language::multiplyeq_op:AffectationProcessor<language::multiplyeq_op, TinyVector<1ul, double>, bool>) - +-(language::name:x:NameProcessor) - `-(language::true_kw:ValueProcessor) + +-(language::eq_op:AffectationToTupleProcessor<bool>) + | +-(language::name:t:NameProcessor) + | `-(language::true_kw:ValueProcessor) + `-(language::eq_op:AffectationFromTupleProcessor<)" + + demangled_stdstring + R"( >) + +-(language::name:s:NameProcessor) + `-(language::name:t:NameProcessor) )"; - CHECK_AST(data, result); + CHECK_AST(data, result); + } + + SECTION("(N) -> string") + { + std::string_view data = R"( +let t : (N), t = true; +let s : string, s = t; +)"; + + std::string result = R"( +(root:ASTNodeListProcessor) + +-(language::eq_op:AffectationToTupleProcessor<unsigned long>) + | +-(language::name:t:NameProcessor) + | `-(language::true_kw:ValueProcessor) + `-(language::eq_op:AffectationFromTupleProcessor<)" + + demangled_stdstring + R"( >) + +-(language::name:s:NameProcessor) + `-(language::name:t:NameProcessor) +)"; + + CHECK_AST(data, result); + } + + SECTION("(Z) -> string") + { + std::string_view data = R"( +let t : (Z), t = -2; +let s : string, s = t; +)"; + + std::string result = R"( +(root:ASTNodeListProcessor) + +-(language::eq_op:AffectationToTupleProcessor<long>) + | +-(language::name:t:NameProcessor) + | `-(language::unary_minus:UnaryExpressionProcessor<language::unary_minus, long, long>) + | `-(language::integer:2:ValueProcessor) + `-(language::eq_op:AffectationFromTupleProcessor<)" + + demangled_stdstring + R"( >) + +-(language::name:s:NameProcessor) + `-(language::name:t:NameProcessor) +)"; + + CHECK_AST(data, result); + } + + SECTION("(R) -> string") + { + std::string_view data = R"( +let t : (R), t = 3.2; +let s : string, s = t; +)"; + + std::string result = R"( +(root:ASTNodeListProcessor) + +-(language::eq_op:AffectationToTupleProcessor<double>) + | +-(language::name:t:NameProcessor) + | `-(language::real:3.2:ValueProcessor) + `-(language::eq_op:AffectationFromTupleProcessor<)" + + demangled_stdstring + R"( >) + +-(language::name:s:NameProcessor) + `-(language::name:t:NameProcessor) +)"; + + CHECK_AST(data, result); + } + + SECTION("(R^1) -> string") + { + std::string_view data = R"( +let t : (R^1), t = [1.5]; +let s : string, s = t; +)"; + + std::string result = R"( +(root:ASTNodeListProcessor) + +-(language::eq_op:AffectationToTupleProcessor<TinyVector<1ul, double> >) + | +-(language::name:t:NameProcessor) + | `-(language::vector_expression:TinyVectorExpressionProcessor<1ul>) + | `-(language::real:1.5:ValueProcessor) + `-(language::eq_op:AffectationFromTupleProcessor<)" + + demangled_stdstring + R"( >) + +-(language::name:s:NameProcessor) + `-(language::name:t:NameProcessor) +)"; + + CHECK_AST(data, result); + } + + SECTION("(R^2) -> string") + { + std::string_view data = R"( +let t : (R^2), t = [1.5, 2]; +let s : string, s = t; +)"; + + std::string result = R"( +(root:ASTNodeListProcessor) + +-(language::eq_op:AffectationToTupleProcessor<TinyVector<2ul, double> >) + | +-(language::name:t:NameProcessor) + | `-(language::vector_expression:TinyVectorExpressionProcessor<2ul>) + | +-(language::real:1.5:ValueProcessor) + | `-(language::integer:2:ValueProcessor) + `-(language::eq_op:AffectationFromTupleProcessor<)" + + demangled_stdstring + R"( >) + +-(language::name:s:NameProcessor) + `-(language::name:t:NameProcessor) +)"; + + CHECK_AST(data, result); + } + + SECTION("(R^3) -> string") + { + std::string_view data = R"( +let t : (R^3), t = [1.5, 2, 1]; +let s : string, s = t; +)"; + + std::string result = R"( +(root:ASTNodeListProcessor) + +-(language::eq_op:AffectationToTupleProcessor<TinyVector<3ul, double> >) + | +-(language::name:t:NameProcessor) + | `-(language::vector_expression:TinyVectorExpressionProcessor<3ul>) + | +-(language::real:1.5:ValueProcessor) + | +-(language::integer:2:ValueProcessor) + | `-(language::integer:1:ValueProcessor) + `-(language::eq_op:AffectationFromTupleProcessor<)" + + demangled_stdstring + R"( >) + +-(language::name:s:NameProcessor) + `-(language::name:t:NameProcessor) +)"; + + CHECK_AST(data, result); + } + + SECTION("(R^1x1) -> string") + { + std::string_view data = R"( +let t : (R^1x1), t = [[1.5]]; +let s : string, s = t; +)"; + + std::string result = R"( +(root:ASTNodeListProcessor) + +-(language::eq_op:AffectationToTupleProcessor<TinyMatrix<1ul, 1ul, double> >) + | +-(language::name:t:NameProcessor) + | `-(language::matrix_expression:TinyMatrixExpressionProcessor<1ul, 1ul>) + | `-(language::row_expression:FakeProcessor) + | `-(language::real:1.5:ValueProcessor) + `-(language::eq_op:AffectationFromTupleProcessor<)" + + demangled_stdstring + R"( >) + +-(language::name:s:NameProcessor) + `-(language::name:t:NameProcessor) +)"; + + CHECK_AST(data, result); + } + + SECTION("(R^2x2) -> string") + { + std::string_view data = R"( +let t : (R^2x2), t = [[1.5, 1],[-2, 3]]; +let s : string, s = t; +)"; + + std::string result = R"( +(root:ASTNodeListProcessor) + +-(language::eq_op:AffectationToTupleProcessor<TinyMatrix<2ul, 2ul, double> >) + | +-(language::name:t:NameProcessor) + | `-(language::matrix_expression:TinyMatrixExpressionProcessor<2ul, 2ul>) + | +-(language::row_expression:FakeProcessor) + | | +-(language::real:1.5:ValueProcessor) + | | `-(language::integer:1:ValueProcessor) + | `-(language::row_expression:FakeProcessor) + | +-(language::unary_minus:UnaryExpressionProcessor<language::unary_minus, long, long>) + | | `-(language::integer:2:ValueProcessor) + | `-(language::integer:3:ValueProcessor) + `-(language::eq_op:AffectationFromTupleProcessor<)" + + demangled_stdstring + R"( >) + +-(language::name:s:NameProcessor) + `-(language::name:t:NameProcessor) +)"; + + CHECK_AST(data, result); + } + + SECTION("(R^3x3) -> string") + { + std::string_view data = R"( +let t : (R^3x3), t = [[1.5, 1, -1],[-2, 3, 1],[-5, 1, 6]]; +let s : string, s = t; +)"; + + std::string result = R"( +(root:ASTNodeListProcessor) + +-(language::eq_op:AffectationToTupleProcessor<TinyMatrix<3ul, 3ul, double> >) + | +-(language::name:t:NameProcessor) + | `-(language::matrix_expression:TinyMatrixExpressionProcessor<3ul, 3ul>) + | +-(language::row_expression:FakeProcessor) + | | +-(language::real:1.5:ValueProcessor) + | | +-(language::integer:1:ValueProcessor) + | | `-(language::unary_minus:UnaryExpressionProcessor<language::unary_minus, long, long>) + | | `-(language::integer:1:ValueProcessor) + | +-(language::row_expression:FakeProcessor) + | | +-(language::unary_minus:UnaryExpressionProcessor<language::unary_minus, long, long>) + | | | `-(language::integer:2:ValueProcessor) + | | +-(language::integer:3:ValueProcessor) + | | `-(language::integer:1:ValueProcessor) + | `-(language::row_expression:FakeProcessor) + | +-(language::unary_minus:UnaryExpressionProcessor<language::unary_minus, long, long>) + | | `-(language::integer:5:ValueProcessor) + | +-(language::integer:1:ValueProcessor) + | `-(language::integer:6:ValueProcessor) + `-(language::eq_op:AffectationFromTupleProcessor<)" + + demangled_stdstring + R"( >) + +-(language::name:s:NameProcessor) + `-(language::name:t:NameProcessor) +)"; + + CHECK_AST(data, result); + } + + SECTION("string -> (string)") + { + std::string_view data = R"( +let t : (string), t = "foo"; +let s : string, s = t; +)"; + + std::string result = R"( +(root:ASTNodeListProcessor) + +-(language::eq_op:AffectationToTupleProcessor<)" + + demangled_stdstring + R"( >) + | +-(language::name:t:NameProcessor) + | `-(language::literal:"foo":ValueProcessor) + `-(language::eq_op:AffectationFromTupleProcessor<)" + + demangled_stdstring + R"( >) + +-(language::name:s:NameProcessor) + `-(language::name:t:NameProcessor) +)"; + + CHECK_AST(data, result); + } + } + + SECTION("-> type_id") + { + std::string_view data = R"( +let t : (builtin_t), t = a; +let bt: builtin_t, bt = t; +)"; + + std::string_view result = R"( +(root:ASTNodeListProcessor) + +-(language::eq_op:AffectationToTupleProcessor<EmbeddedData>) + | +-(language::name:t:NameProcessor) + | `-(language::name:a:NameProcessor) + `-(language::eq_op:AffectationFromTupleProcessor<EmbeddedData>) + +-(language::name:bt:NameProcessor) + `-(language::name:t:NameProcessor) +)"; + + CHECK_AST_WITH_BUILTIN(data, result); + } } + } - SECTION("R^2 *= B") + SECTION("+=") + { + SECTION("N += N") { std::string_view data = R"( -let x : R^2; x *= false; +let n : N, n=1; n+=n; )"; std::string_view result = R"( (root:ASTNodeListProcessor) - `-(language::multiplyeq_op:AffectationProcessor<language::multiplyeq_op, TinyVector<2ul, double>, bool>) - +-(language::name:x:NameProcessor) - `-(language::false_kw:ValueProcessor) + +-(language::eq_op:AffectationProcessor<language::eq_op, unsigned long, long>) + | +-(language::name:n:NameProcessor) + | `-(language::integer:1:ValueProcessor) + `-(language::pluseq_op:AffectationProcessor<language::pluseq_op, unsigned long, unsigned long>) + +-(language::name:n:NameProcessor) + `-(language::name:n:NameProcessor) )"; CHECK_AST(data, result); } - SECTION("R^3 *= B") + SECTION("R += N") { std::string_view data = R"( -let b : B; let x : R^3; x *= b; +let x : R, x=1; x+=2; )"; std::string_view result = R"( (root:ASTNodeListProcessor) - `-(language::multiplyeq_op:AffectationProcessor<language::multiplyeq_op, TinyVector<3ul, double>, bool>) + +-(language::eq_op:AffectationProcessor<language::eq_op, double, long>) + | +-(language::name:x:NameProcessor) + | `-(language::integer:1:ValueProcessor) + `-(language::pluseq_op:AffectationProcessor<language::pluseq_op, double, long>) +-(language::name:x:NameProcessor) - `-(language::name:b:NameProcessor) + `-(language::integer:2:ValueProcessor) )"; CHECK_AST(data, result); } - } - SECTION("/=") - { - SECTION("Z /= Z") + SECTION("string += N") { std::string_view data = R"( -let z : Z, z=6; z/=2; +let s : string, s="foo"; s+=2; )"; - std::string_view result = R"( + std::string result = R"( (root:ASTNodeListProcessor) - +-(language::eq_op:AffectationProcessor<language::eq_op, long, long>) + +-(language::eq_op:AffectationProcessor<language::eq_op, )" + + demangled_stdstring + ", " + demangled_stdstring + R"( >) + | +-(language::name:s:NameProcessor) + | `-(language::literal:"foo":ValueProcessor) + `-(language::pluseq_op:AffectationProcessor<language::pluseq_op, )" + + demangled_stdstring + + R"(, long>) + +-(language::name:s:NameProcessor) + `-(language::integer:2:ValueProcessor) +)"; + + CHECK_AST(data, result); + } + + SECTION("R^1 += R^1") + { + std::string_view data = R"( +let x : R^1; +let y : R^1; +x += y; +)"; + + std::string result = R"( +(root:ASTNodeListProcessor) + `-(language::pluseq_op:AffectationProcessor<language::pluseq_op, TinyVector<1ul, double>, TinyVector<1ul, double> >) + +-(language::name:x:NameProcessor) + `-(language::name:y:NameProcessor) +)"; + + CHECK_AST(data, result); + } + + SECTION("R^2 += R^2") + { + std::string_view data = R"( +let x : R^2; +let y : R^2; +x += y; +)"; + + std::string result = R"( +(root:ASTNodeListProcessor) + `-(language::pluseq_op:AffectationProcessor<language::pluseq_op, TinyVector<2ul, double>, TinyVector<2ul, double> >) + +-(language::name:x:NameProcessor) + `-(language::name:y:NameProcessor) +)"; + + CHECK_AST(data, result); + } + + SECTION("R^3 += R^3") + { + std::string_view data = R"( +let x : R^3; +let y : R^3; +x += y; +)"; + + std::string result = R"( +(root:ASTNodeListProcessor) + `-(language::pluseq_op:AffectationProcessor<language::pluseq_op, TinyVector<3ul, double>, TinyVector<3ul, double> >) + +-(language::name:x:NameProcessor) + `-(language::name:y:NameProcessor) +)"; + + CHECK_AST(data, result); + } + } + + SECTION("-=") + { + SECTION("Z -= Z") + { + std::string_view data = R"( +let z : Z, z=1; z-=2; +)"; + + std::string_view result = R"( +(root:ASTNodeListProcessor) + +-(language::eq_op:AffectationProcessor<language::eq_op, long, long>) | +-(language::name:z:NameProcessor) - | `-(language::integer:6:ValueProcessor) - `-(language::divideeq_op:AffectationProcessor<language::divideeq_op, long, long>) + | `-(language::integer:1:ValueProcessor) + `-(language::minuseq_op:AffectationProcessor<language::minuseq_op, long, long>) + +-(language::name:z:NameProcessor) + `-(language::integer:2:ValueProcessor) +)"; + + CHECK_AST(data, result); + } + + SECTION("R -= R") + { + std::string_view data = R"( +let x : R, x=1; x-=2.3; +)"; + + std::string_view result = R"( +(root:ASTNodeListProcessor) + +-(language::eq_op:AffectationProcessor<language::eq_op, double, long>) + | +-(language::name:x:NameProcessor) + | `-(language::integer:1:ValueProcessor) + `-(language::minuseq_op:AffectationProcessor<language::minuseq_op, double, double>) + +-(language::name:x:NameProcessor) + `-(language::real:2.3:ValueProcessor) +)"; + + CHECK_AST(data, result); + } + + SECTION("R^1 -= R^1") + { + std::string_view data = R"( +let x : R^1; +let y : R^1; +x -= y; +)"; + + std::string result = R"( +(root:ASTNodeListProcessor) + `-(language::minuseq_op:AffectationProcessor<language::minuseq_op, TinyVector<1ul, double>, TinyVector<1ul, double> >) + +-(language::name:x:NameProcessor) + `-(language::name:y:NameProcessor) +)"; + + CHECK_AST(data, result); + } + + SECTION("R^2 -= R^2") + { + std::string_view data = R"( +let x : R^2; +let y : R^2; +x -= y; +)"; + + std::string result = R"( +(root:ASTNodeListProcessor) + `-(language::minuseq_op:AffectationProcessor<language::minuseq_op, TinyVector<2ul, double>, TinyVector<2ul, double> >) + +-(language::name:x:NameProcessor) + `-(language::name:y:NameProcessor) +)"; + + CHECK_AST(data, result); + } + + SECTION("R^3 -= R^3") + { + std::string_view data = R"( +let x : R^3; +let y : R^3; +x -= y; +)"; + + std::string result = R"( +(root:ASTNodeListProcessor) + `-(language::minuseq_op:AffectationProcessor<language::minuseq_op, TinyVector<3ul, double>, TinyVector<3ul, double> >) + +-(language::name:x:NameProcessor) + `-(language::name:y:NameProcessor) +)"; + + CHECK_AST(data, result); + } + } + + SECTION("*=") + { + SECTION("Z *= Z") + { + std::string_view data = R"( +let z : Z, z=1; z*=2; +)"; + + std::string_view result = R"( +(root:ASTNodeListProcessor) + +-(language::eq_op:AffectationProcessor<language::eq_op, long, long>) + | +-(language::name:z:NameProcessor) + | `-(language::integer:1:ValueProcessor) + `-(language::multiplyeq_op:AffectationProcessor<language::multiplyeq_op, long, long>) +-(language::name:z:NameProcessor) `-(language::integer:2:ValueProcessor) )"; - CHECK_AST(data, result); - } + CHECK_AST(data, result); + } + + SECTION("R *= R") + { + std::string_view data = R"( +let x : R, x=1; x*=2.3; +)"; + + std::string_view result = R"( +(root:ASTNodeListProcessor) + +-(language::eq_op:AffectationProcessor<language::eq_op, double, long>) + | +-(language::name:x:NameProcessor) + | `-(language::integer:1:ValueProcessor) + `-(language::multiplyeq_op:AffectationProcessor<language::multiplyeq_op, double, double>) + +-(language::name:x:NameProcessor) + `-(language::real:2.3:ValueProcessor) +)"; + + CHECK_AST(data, result); + } + + SECTION("R^1 *= R") + { + std::string_view data = R"( +let x : R^1; x*=2.3; +)"; + + std::string_view result = R"( +(root:ASTNodeListProcessor) + `-(language::multiplyeq_op:AffectationProcessor<language::multiplyeq_op, TinyVector<1ul, double>, double>) + +-(language::name:x:NameProcessor) + `-(language::real:2.3:ValueProcessor) +)"; + + CHECK_AST(data, result); + } + + SECTION("R^2 *= R") + { + std::string_view data = R"( +let x : R^2; x*= 6.2; +)"; + + std::string_view result = R"( +(root:ASTNodeListProcessor) + `-(language::multiplyeq_op:AffectationProcessor<language::multiplyeq_op, TinyVector<2ul, double>, double>) + +-(language::name:x:NameProcessor) + `-(language::real:6.2:ValueProcessor) +)"; + + CHECK_AST(data, result); + } + + SECTION("R^3 *= R") + { + std::string_view data = R"( +let x : R^3; x*= 3.1; +)"; + + std::string_view result = R"( +(root:ASTNodeListProcessor) + `-(language::multiplyeq_op:AffectationProcessor<language::multiplyeq_op, TinyVector<3ul, double>, double>) + +-(language::name:x:NameProcessor) + `-(language::real:3.1:ValueProcessor) +)"; + + CHECK_AST(data, result); + } + + SECTION("R *= Z") + { + std::string_view data = R"( +let x : R, x=1; x*=2; +)"; + + std::string_view result = R"( +(root:ASTNodeListProcessor) + +-(language::eq_op:AffectationProcessor<language::eq_op, double, long>) + | +-(language::name:x:NameProcessor) + | `-(language::integer:1:ValueProcessor) + `-(language::multiplyeq_op:AffectationProcessor<language::multiplyeq_op, double, long>) + +-(language::name:x:NameProcessor) + `-(language::integer:2:ValueProcessor) +)"; + + CHECK_AST(data, result); + } + + SECTION("R^1 *= Z") + { + std::string_view data = R"( +let x : R^1; x *= 3; +)"; + + std::string_view result = R"( +(root:ASTNodeListProcessor) + `-(language::multiplyeq_op:AffectationProcessor<language::multiplyeq_op, TinyVector<1ul, double>, long>) + +-(language::name:x:NameProcessor) + `-(language::integer:3:ValueProcessor) +)"; + + CHECK_AST(data, result); + } + + SECTION("R^2 *= Z") + { + std::string_view data = R"( +let x : R^2; x *= 6; +)"; + + std::string_view result = R"( +(root:ASTNodeListProcessor) + `-(language::multiplyeq_op:AffectationProcessor<language::multiplyeq_op, TinyVector<2ul, double>, long>) + +-(language::name:x:NameProcessor) + `-(language::integer:6:ValueProcessor) +)"; + + CHECK_AST(data, result); + } + + SECTION("R^3 *= Z") + { + std::string_view data = R"( +let x : R^3; x *= 4; +)"; + + std::string_view result = R"( +(root:ASTNodeListProcessor) + `-(language::multiplyeq_op:AffectationProcessor<language::multiplyeq_op, TinyVector<3ul, double>, long>) + +-(language::name:x:NameProcessor) + `-(language::integer:4:ValueProcessor) +)"; + + CHECK_AST(data, result); + } + + SECTION("R *= N") + { + std::string_view data = R"( +let n : N, n=2; let x : R, x=1; x *= n; +)"; + + std::string_view result = R"( +(root:ASTNodeListProcessor) + +-(language::eq_op:AffectationProcessor<language::eq_op, unsigned long, long>) + | +-(language::name:n:NameProcessor) + | `-(language::integer:2:ValueProcessor) + +-(language::eq_op:AffectationProcessor<language::eq_op, double, long>) + | +-(language::name:x:NameProcessor) + | `-(language::integer:1:ValueProcessor) + `-(language::multiplyeq_op:AffectationProcessor<language::multiplyeq_op, double, unsigned long>) + +-(language::name:x:NameProcessor) + `-(language::name:n:NameProcessor) +)"; + + CHECK_AST(data, result); + } + + SECTION("R^1 *= N") + { + std::string_view data = R"( +let n : N; +let x : R^1; x *= n; +)"; + + std::string_view result = R"( +(root:ASTNodeListProcessor) + `-(language::multiplyeq_op:AffectationProcessor<language::multiplyeq_op, TinyVector<1ul, double>, unsigned long>) + +-(language::name:x:NameProcessor) + `-(language::name:n:NameProcessor) +)"; + + CHECK_AST(data, result); + } + + SECTION("R^2 *= N") + { + std::string_view data = R"( +let n : N; +let x : R^2; x *= n; +)"; + + std::string_view result = R"( +(root:ASTNodeListProcessor) + `-(language::multiplyeq_op:AffectationProcessor<language::multiplyeq_op, TinyVector<2ul, double>, unsigned long>) + +-(language::name:x:NameProcessor) + `-(language::name:n:NameProcessor) +)"; + + CHECK_AST(data, result); + } + + SECTION("R^3 *= N") + { + std::string_view data = R"( +let n : N; +let x : R^3; x *= n; +)"; + + std::string_view result = R"( +(root:ASTNodeListProcessor) + `-(language::multiplyeq_op:AffectationProcessor<language::multiplyeq_op, TinyVector<3ul, double>, unsigned long>) + +-(language::name:x:NameProcessor) + `-(language::name:n:NameProcessor) +)"; + + CHECK_AST(data, result); + } + + SECTION("R *= B") + { + std::string_view data = R"( +let x : R, x=1; x *= true; +)"; + + std::string_view result = R"( +(root:ASTNodeListProcessor) + +-(language::eq_op:AffectationProcessor<language::eq_op, double, long>) + | +-(language::name:x:NameProcessor) + | `-(language::integer:1:ValueProcessor) + `-(language::multiplyeq_op:AffectationProcessor<language::multiplyeq_op, double, bool>) + +-(language::name:x:NameProcessor) + `-(language::true_kw:ValueProcessor) +)"; + + CHECK_AST(data, result); + } + + SECTION("R^1 *= B") + { + std::string_view data = R"( +let x : R^1; x *= true; +)"; + + std::string_view result = R"( +(root:ASTNodeListProcessor) + `-(language::multiplyeq_op:AffectationProcessor<language::multiplyeq_op, TinyVector<1ul, double>, bool>) + +-(language::name:x:NameProcessor) + `-(language::true_kw:ValueProcessor) +)"; + + CHECK_AST(data, result); + } + + SECTION("R^2 *= B") + { + std::string_view data = R"( +let x : R^2; x *= false; +)"; + + std::string_view result = R"( +(root:ASTNodeListProcessor) + `-(language::multiplyeq_op:AffectationProcessor<language::multiplyeq_op, TinyVector<2ul, double>, bool>) + +-(language::name:x:NameProcessor) + `-(language::false_kw:ValueProcessor) +)"; + + CHECK_AST(data, result); + } + + SECTION("R^3 *= B") + { + std::string_view data = R"( +let b : B; let x : R^3; x *= b; +)"; + + std::string_view result = R"( +(root:ASTNodeListProcessor) + `-(language::multiplyeq_op:AffectationProcessor<language::multiplyeq_op, TinyVector<3ul, double>, bool>) + +-(language::name:x:NameProcessor) + `-(language::name:b:NameProcessor) +)"; + + CHECK_AST(data, result); + } + } + + SECTION("/=") + { + SECTION("Z /= Z") + { + std::string_view data = R"( +let z : Z, z=6; z/=2; +)"; + + std::string_view result = R"( +(root:ASTNodeListProcessor) + +-(language::eq_op:AffectationProcessor<language::eq_op, long, long>) + | +-(language::name:z:NameProcessor) + | `-(language::integer:6:ValueProcessor) + `-(language::divideeq_op:AffectationProcessor<language::divideeq_op, long, long>) + +-(language::name:z:NameProcessor) + `-(language::integer:2:ValueProcessor) +)"; + + CHECK_AST(data, result); + } + + SECTION("R /= R") + { + std::string_view data = R"( +let x : R, x=1; x/=2.3; +)"; + + std::string_view result = R"( +(root:ASTNodeListProcessor) + +-(language::eq_op:AffectationProcessor<language::eq_op, double, long>) + | +-(language::name:x:NameProcessor) + | `-(language::integer:1:ValueProcessor) + `-(language::divideeq_op:AffectationProcessor<language::divideeq_op, double, double>) + +-(language::name:x:NameProcessor) + `-(language::real:2.3:ValueProcessor) +)"; + + CHECK_AST(data, result); + } + } + + SECTION("Errors") + { + SECTION("Invalid affectation operator") + { + auto ast = std::make_unique<ASTNode>(); + ast->m_data_type = ASTNodeDataType::build<ASTNodeDataType::void_t>(); + { + auto child_0 = std::make_unique<ASTNode>(); + child_0->m_data_type = ASTNodeDataType::build<ASTNodeDataType::bool_t>(); + auto child_1 = std::make_unique<ASTNode>(); + child_1->m_data_type = ASTNodeDataType::build<ASTNodeDataType::bool_t>(); + ast->children.emplace_back(std::move(child_0)); + ast->children.emplace_back(std::move(child_1)); + } + REQUIRE_THROWS_WITH(ASTNodeAffectationExpressionBuilder{*ast}, + "unexpected error: undefined affectation operator"); + } + + SECTION("Invalid string rhs") + { + auto ast = std::make_unique<ASTNode>(); + ast->set_type<language::eq_op>(); + + ast->children.emplace_back(std::make_unique<ASTNode>()); + ast->children[0]->m_data_type = ASTNodeDataType::build<ASTNodeDataType::string_t>(); + ast->children.emplace_back(std::make_unique<ASTNode>()); + REQUIRE_THROWS_WITH(ASTNodeAffectationExpressionBuilder{*ast}, "undefined affectation type: string = undefined"); + } + + SECTION("Invalid string affectation operator") + { + SECTION("string -= string") + { + std::string_view data = R"( +let s : string, s="foo"; s-="bar"; +)"; + + std::string error_message = "undefined affectation type: string -= string"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("string *= Z") + { + std::string_view data = R"( +let s : string, s="foo"; s*=2; +)"; + + std::string error_message = "undefined affectation type: string *= Z"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("string /= string") + { + std::string_view data = R"( + let s : string, s="foo"; s/="bar"; +)"; + + std::string error_message = "undefined affectation type: string /= string"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + } + + SECTION("type_id operator") + { + std::string_view data = R"( + let s :builtin_t, s = a; s *= b; +)"; + + std::string error_message = "undefined affectation type: builtin_t *= builtin_t"; + + CHECK_AST_WITH_BUILTIN_THROWS_WITH(data, error_message); + } + + SECTION("Invalid tuple operator") + { + std::string_view data = R"( + let s :(R), s=(1,2,3); s *= 4; +)"; + + std::string error_message = "undefined affectation type: (R) *= Z"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("Invalid tuple operator 2") + { + std::string_view data = R"( + let s : (builtin_t), s =(a,b); s *= b; +)"; + + std::string error_message = "undefined affectation type: (builtin_t) *= builtin_t"; + + CHECK_AST_WITH_BUILTIN_THROWS_WITH(data, error_message); + } + + SECTION("Invalid R^n -> R^m affectation") + { + SECTION("R^3 <- R^1") + { + std::string_view data = R"( +let x : R^3; let y : R^1; x = y; +)"; + + std::string error_message = "undefined affectation type: R^3 = R^1"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R^3 <- R^2") + { + std::string_view data = R"( +let x : R^3; let y : R^2; x = y; +)"; + + std::string error_message = "undefined affectation type: R^3 = R^2"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R^2 <- R^1") + { + std::string_view data = R"( +let x : R^2; let y : R^1; x = y; +)"; + + std::string error_message = "undefined affectation type: R^2 = R^1"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R^2 <- R^3") + { + std::string_view data = R"( +let x : R^2; let y : R^3; x = y; +)"; + + std::string error_message = "undefined affectation type: R^2 = R^3"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R^1 <- R^2") + { + std::string_view data = R"( +let x : R^1; let y : R^2; x = y; +)"; + + std::string error_message = "undefined affectation type: R^1 = R^2"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R^1 <- R^3") + { + std::string_view data = R"( +let x : R^1; let y : R^3; x = y; +)"; + + std::string error_message = "undefined affectation type: R^1 = R^3"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + } + + SECTION("Invalid Z -> R^m affectation [non-zero]") + { + SECTION("R^3 <- Z") + { + std::string_view data = R"( +let x : R^3, x = 3; +)"; + + std::string error_message = "invalid integral value (0 is the solely valid value)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R^2 <- Z") + { + std::string_view data = R"( +let x : R^2, x = 2; +)"; + + std::string error_message = "invalid integral value (0 is the solely valid value)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + } + + SECTION("Invalid R^d -> R^d affectation operator") + { + SECTION("R^3 <- R^3") + { + std::string_view data = R"( +let x : R^3; let y : R^3; x /= y; +)"; + + std::string error_message = "undefined affectation type: R^3 /= R^3"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R^2 <- R^2") + { + std::string_view data = R"( +let x : R^2; let y : R^2; x /= y; +)"; + + std::string error_message = "undefined affectation type: R^2 /= R^2"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R^1 <- R^1") + { + std::string_view data = R"( +let x : R^1; let y : R^1; x /= y; +)"; + + std::string error_message = "undefined affectation type: R^1 /= R^1"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + } + + SECTION("Invalid R^d -> R^d *= operand") + { + SECTION("R^3 <- R^3") + { + std::string_view data = R"( +let x : R^3; let y : R^3; x *= y; +)"; + + std::string error_message = "undefined affectation type: R^3 *= R^3"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R^2 <- R^2") + { + std::string_view data = R"( +let x : R^2; let y : R^2; x *= y; +)"; + + std::string error_message = "undefined affectation type: R^2 *= R^2"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R^1 <- R^1") + { + std::string_view data = R"( +let x : R^1; let y : R^1; x *= y; +)"; + + std::string error_message = "undefined affectation type: R^1 *= R^1"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + } + + SECTION("incorrect declarative/definition number of symbols") + { + std::string_view data = R"( +let (x,y,z):R*R*R, (x,y) = (2,3); +)"; + + TAO_PEGTL_NAMESPACE::string_input input{data, "test.pgs"}; + auto ast = ASTBuilder::build(input); + OperatorRepository::instance().reset(); + ASTModulesImporter{*ast}; + + ASTSymbolTableBuilder{*ast}; + REQUIRE_THROWS_WITH(ASTSymbolInitializationChecker{*ast}, + std::string{"invalid number of definition identifiers, expecting 3 found 2"}); + } + + SECTION("incorrect identifier/expression number of symbols") + { + std::string_view data = R"( +let y:R; +let x:R, (x,y) = (2,3); +)"; + + TAO_PEGTL_NAMESPACE::string_input input{data, "test.pgs"}; + auto ast = ASTBuilder::build(input); + OperatorRepository::instance().reset(); + ASTModulesImporter{*ast}; + + ASTSymbolTableBuilder{*ast}; + REQUIRE_THROWS_WITH(ASTSymbolInitializationChecker{*ast}, + std::string{"unexpected variable list, expecting one identifier"}); + } + + SECTION("incorrect definition variable identifier") + { + std::string_view data = R"( +let y:R; +let x:R, y = 3; +)"; + + TAO_PEGTL_NAMESPACE::string_input input{data, "test.pgs"}; + auto ast = ASTBuilder::build(input); + OperatorRepository::instance().reset(); + ASTModulesImporter{*ast}; + + ASTSymbolTableBuilder{*ast}; + REQUIRE_THROWS_WITH(ASTSymbolInitializationChecker{*ast}, std::string{"invalid identifier, expecting 'x'"}); + } + + SECTION("invalid definition variable identifier order") + { + std::string_view data = R"( +let (x,y):R, (y,x) = (3,2); +)"; + + TAO_PEGTL_NAMESPACE::string_input input{data, "test.pgs"}; + auto ast = ASTBuilder::build(input); + OperatorRepository::instance().reset(); + ASTModulesImporter{*ast}; + + ASTSymbolTableBuilder{*ast}; + REQUIRE_THROWS_WITH(ASTSymbolInitializationChecker{*ast}, std::string{"invalid identifier, expecting 'x'"}); + } + + SECTION("undefined affectations =") + { + SECTION("-> value") + { + SECTION("value -> value") + { + SECTION("-> B") + { + SECTION("N -> B") + { + std::string_view data = R"( +let n:N, n = 1; +let b:B, b = n; +)"; + + std::string error_message = "undefined affectation type: B = N"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("Z -> B") + { + std::string_view data = R"( +let b:B, b = 1; +)"; + + std::string error_message = "undefined affectation type: B = Z"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R -> B") + { + std::string_view data = R"( +let b:B, b = 1.2; +)"; + + std::string error_message = "undefined affectation type: B = R"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R^1 -> B") + { + std::string_view data = R"( +let b:B, b = [1.2]; +)"; + + std::string error_message = "undefined affectation type: B = R^1"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R^2 -> B") + { + std::string_view data = R"( +let b:B, b = [1.2, 3]; +)"; + + std::string error_message = "undefined affectation type: B = R^2"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R^3 -> B") + { + std::string_view data = R"( +let b:B, b = [1.2, 3, 1]; +)"; + + std::string error_message = "undefined affectation type: B = R^3"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R^1x1 -> B") + { + std::string_view data = R"( +let b:B, b = [[1.2]]; +)"; + + std::string error_message = "undefined affectation type: B = R^1x1"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R^2x2 -> B") + { + std::string_view data = R"( +let b:B, b = [[1.2, 3],[3,4]]; +)"; + + std::string error_message = "undefined affectation type: B = R^2x2"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R^3x3 -> B") + { + std::string_view data = R"( +let b:B, b = [[1.2, 3, 1],[1,2,3],[4,2,1]]; +)"; + + std::string error_message = "undefined affectation type: B = R^3x3"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("string -> B") + { + std::string_view data = R"( +let b:B, b = "foo"; +)"; + + std::string error_message = "undefined affectation type: B = string"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("builtin_t -> B") + { + std::string_view data = R"( +let bt:builtin_t, bt = a; +let v : B, v = bt; +)"; + + std::string error_message = "undefined affectation type: B = builtin_t"; + + CHECK_AST_WITH_BUILTIN_THROWS_WITH(data, error_message); + } + } + + SECTION("-> N") + { + SECTION("R -> N") + { + std::string_view data = R"( +let b:N, b = 1.2; +)"; + + std::string error_message = "undefined affectation type: N = R"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R^1 -> N") + { + std::string_view data = R"( +let b:N, b = [1.2]; +)"; + + std::string error_message = "undefined affectation type: N = R^1"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R^2 -> N") + { + std::string_view data = R"( +let b:N, b = [1.2, 3]; +)"; + + std::string error_message = "undefined affectation type: N = R^2"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R^3 -> N") + { + std::string_view data = R"( +let b:N, b = [1.2, 3, 1]; +)"; + + std::string error_message = "undefined affectation type: N = R^3"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R^1x1 -> N") + { + std::string_view data = R"( +let b:N, b = [[1.2]]; +)"; + + std::string error_message = "undefined affectation type: N = R^1x1"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R^2x2 -> N") + { + std::string_view data = R"( +let b:N, b = [[1.2, 3],[3,4]]; +)"; + + std::string error_message = "undefined affectation type: N = R^2x2"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R^3x3 -> N") + { + std::string_view data = R"( +let b:N, b = [[1.2, 3, 1],[1,2,3],[4,2,1]]; +)"; + + std::string error_message = "undefined affectation type: N = R^3x3"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("string -> N") + { + std::string_view data = R"( +let b:N, b = "foo"; +)"; + + std::string error_message = "undefined affectation type: N = string"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("builtin_t -> N") + { + std::string_view data = R"( +let bt:builtin_t, bt = a; +let v : N, v = bt; +)"; + + std::string error_message = "undefined affectation type: N = builtin_t"; + + CHECK_AST_WITH_BUILTIN_THROWS_WITH(data, error_message); + } + } + + SECTION("-> Z") + { + SECTION("R -> Z") + { + std::string_view data = R"( +let b:Z, b = 1.2; +)"; + + std::string error_message = "undefined affectation type: Z = R"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R^1 -> Z") + { + std::string_view data = R"( +let b:Z, b = [1.2]; +)"; + + std::string error_message = "undefined affectation type: Z = R^1"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R^2 -> Z") + { + std::string_view data = R"( +let b:Z, b = [1.2, 3]; +)"; + + std::string error_message = "undefined affectation type: Z = R^2"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R^3 -> Z") + { + std::string_view data = R"( +let b:Z, b = [1.2, 3, 1]; +)"; + + std::string error_message = "undefined affectation type: Z = R^3"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R^1x1 -> Z") + { + std::string_view data = R"( +let b:Z, b = [[1.2]]; +)"; + + std::string error_message = "undefined affectation type: Z = R^1x1"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R^2x2 -> Z") + { + std::string_view data = R"( +let b:Z, b = [[1.2, 3],[3,4]]; +)"; + + std::string error_message = "undefined affectation type: Z = R^2x2"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R^3x3 -> Z") + { + std::string_view data = R"( +let b:Z, b = [[1.2, 3, 1],[1,2,3],[4,2,1]]; +)"; + + std::string error_message = "undefined affectation type: Z = R^3x3"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("string -> Z") + { + std::string_view data = R"( +let b:Z, b = "foo"; +)"; + + std::string error_message = "undefined affectation type: Z = string"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("builtin_t -> Z") + { + std::string_view data = R"( +let bt:builtin_t, bt = a; +let v : Z, v = bt; +)"; + + std::string error_message = "undefined affectation type: Z = builtin_t"; + + CHECK_AST_WITH_BUILTIN_THROWS_WITH(data, error_message); + } + } + + SECTION("-> R") + { + SECTION("R^1 -> R") + { + std::string_view data = R"( +let b:R, b = [1.2]; +)"; + + std::string error_message = "undefined affectation type: R = R^1"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R^2 -> R") + { + std::string_view data = R"( +let b:R, b = [1.2, 3]; +)"; + + std::string error_message = "undefined affectation type: R = R^2"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R^3 -> R") + { + std::string_view data = R"( +let b:R, b = [1.2, 3, 1]; +)"; + + std::string error_message = "undefined affectation type: R = R^3"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R^1x1 -> R") + { + std::string_view data = R"( +let b:R, b = [[1.2]]; +)"; + + std::string error_message = "undefined affectation type: R = R^1x1"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R^2x2 -> R") + { + std::string_view data = R"( +let b:R, b = [[1.2, 3],[3,4]]; +)"; + + std::string error_message = "undefined affectation type: R = R^2x2"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R^3x3 -> R") + { + std::string_view data = R"( +let b:R, b = [[1.2, 3, 1],[1,2,3],[4,2,1]]; +)"; + + std::string error_message = "undefined affectation type: R = R^3x3"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("string -> R") + { + std::string_view data = R"( +let b:R, b = "foo"; +)"; + + std::string error_message = "undefined affectation type: R = string"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("builtin_t -> R") + { + std::string_view data = R"( +let bt:builtin_t, bt = a; +let v : R, v = bt; +)"; + + std::string error_message = "undefined affectation type: R = builtin_t"; + + CHECK_AST_WITH_BUILTIN_THROWS_WITH(data, error_message); + } + } + + SECTION("-> R^1") + { + SECTION("R^2 -> R^1") + { + std::string_view data = R"( +let b:R^1, b = [1.2, 3]; +)"; + + std::string error_message = "undefined affectation type: R^1 = R^2"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R^3 -> R^1") + { + std::string_view data = R"( +let b:R^1, b = [1.2, 3, 1]; +)"; + + std::string error_message = "undefined affectation type: R^1 = R^3"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R^1x1 -> R^1") + { + std::string_view data = R"( +let b:R^1, b = [[1.2]]; +)"; + + std::string error_message = "undefined affectation type: R^1 = R^1x1"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R^2x2 -> R^1") + { + std::string_view data = R"( +let b:R^1, b = [[1.2, 3],[3,4]]; +)"; + + std::string error_message = "undefined affectation type: R^1 = R^2x2"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R^3x3 -> R^1") + { + std::string_view data = R"( +let b:R^1, b = [[1.2, 3, 1],[1,2,3],[4,2,1]]; +)"; + + std::string error_message = "undefined affectation type: R^1 = R^3x3"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("string -> R^1") + { + std::string_view data = R"( +let b:R^1, b = "foo"; +)"; + + std::string error_message = "undefined affectation type: R^1 = string"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("builtin_t -> R^1") + { + std::string_view data = R"( +let bt:builtin_t, bt = a; +let v : R^1, v = bt; +)"; + + std::string error_message = "undefined affectation type: R^1 = builtin_t"; + + CHECK_AST_WITH_BUILTIN_THROWS_WITH(data, error_message); + } + } + + SECTION("-> R^2") + { + SECTION("N -> R^2") + { + std::string_view data = R"( +let n:N, n = 1; +let b:R^2, b = n; +)"; + + std::string error_message = "undefined affectation type: R^2 = N"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R -> R^2") + { + std::string_view data = R"( +let b:R^2, b = 1.2; +)"; + + std::string error_message = "undefined affectation type: R^2 = R"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R^1 -> R^2") + { + std::string_view data = R"( +let b:R^2, b = [1.2]; +)"; + + std::string error_message = "undefined affectation type: R^2 = R^1"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R^3 -> R^2") + { + std::string_view data = R"( +let b:R^2, b = [1.2, 3, 1]; +)"; + + std::string error_message = "undefined affectation type: R^2 = R^3"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R^1x1 -> R^2") + { + std::string_view data = R"( +let b:R^2, b = [[1.2]]; +)"; + + std::string error_message = "undefined affectation type: R^2 = R^1x1"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R^2x2 -> R^2") + { + std::string_view data = R"( +let b:R^2, b = [[1.2, 3],[3,4]]; +)"; + + std::string error_message = "undefined affectation type: R^2 = R^2x2"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R^3x3 -> R^2") + { + std::string_view data = R"( +let b:R^2, b = [[1.2, 3, 1],[1,2,3],[4,2,1]]; +)"; + + std::string error_message = "undefined affectation type: R^2 = R^3x3"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("string -> R^2") + { + std::string_view data = R"( +let b:R^2, b = "foo"; +)"; + + std::string error_message = "undefined affectation type: R^2 = string"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("builtin_t -> R^2") + { + std::string_view data = R"( +let bt:builtin_t, bt = a; +let v : R^2, v = bt; +)"; + + std::string error_message = "undefined affectation type: R^2 = builtin_t"; + + CHECK_AST_WITH_BUILTIN_THROWS_WITH(data, error_message); + } + } + + SECTION("-> R^3") + { + SECTION("N -> R^3") + { + std::string_view data = R"( +let n:N, n = 1; +let b:R^3, b = n; +)"; + + std::string error_message = "undefined affectation type: R^3 = N"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R -> R^3") + { + std::string_view data = R"( +let b:R^3, b = 1.2; +)"; + + std::string error_message = "undefined affectation type: R^3 = R"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R^1 -> R^3") + { + std::string_view data = R"( +let b:R^3, b = [1.2]; +)"; + + std::string error_message = "undefined affectation type: R^3 = R^1"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R^2 -> R^3") + { + std::string_view data = R"( +let b:R^3, b = [1.2, 3]; +)"; + + std::string error_message = "undefined affectation type: R^3 = R^2"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R^1x1 -> R^3") + { + std::string_view data = R"( +let b:R^3, b = [[1.2]]; +)"; + + std::string error_message = "undefined affectation type: R^3 = R^1x1"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R^2x2 -> R^3") + { + std::string_view data = R"( +let b:R^3, b = [[1.2, 3],[3,4]]; +)"; + + std::string error_message = "undefined affectation type: R^3 = R^2x2"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R^3x3 -> R^3") + { + std::string_view data = R"( +let b:R^3, b = [[1.2, 3, 1],[1,2,3],[4,2,1]]; +)"; + + std::string error_message = "undefined affectation type: R^3 = R^3x3"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("string -> R^3") + { + std::string_view data = R"( +let b:R^3, b = "foo"; +)"; + + std::string error_message = "undefined affectation type: R^3 = string"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("builtin_t -> R^3") + { + std::string_view data = R"( +let bt:builtin_t, bt = a; +let v : R^3, v = bt; +)"; + + std::string error_message = "undefined affectation type: R^3 = builtin_t"; + + CHECK_AST_WITH_BUILTIN_THROWS_WITH(data, error_message); + } + } + + SECTION("-> R^1x1") + { + SECTION("R^1 -> R^1x1") + { + std::string_view data = R"( +let b:R^1x1, b = [1.2]; +)"; + + std::string error_message = "undefined affectation type: R^1x1 = R^1"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R^2 -> R^1x1") + { + std::string_view data = R"( +let b:R^1x1, b = [1.2, 3]; +)"; + + std::string error_message = "undefined affectation type: R^1x1 = R^2"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R^3 -> R^1x1") + { + std::string_view data = R"( +let b:R^1x1, b = [1.2, 3, 1]; +)"; + + std::string error_message = "undefined affectation type: R^1x1 = R^3"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R^2x2 -> R^1x1") + { + std::string_view data = R"( +let b:R^1x1, b = [[1.2, 3],[3,4]]; +)"; + + std::string error_message = "undefined affectation type: R^1x1 = R^2x2"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R^3x3 -> R^1x1") + { + std::string_view data = R"( +let b:R^1x1, b = [[1.2, 3, 1],[1,2,3],[4,2,1]]; +)"; + + std::string error_message = "undefined affectation type: R^1x1 = R^3x3"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("string -> R^1x1") + { + std::string_view data = R"( +let b:R^1x1, b = "foo"; +)"; + + std::string error_message = "undefined affectation type: R^1x1 = string"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("builtin_t -> R^1x1") + { + std::string_view data = R"( +let bt:builtin_t, bt = a; +let v : R^1x1, v = bt; +)"; + + std::string error_message = "undefined affectation type: R^1x1 = builtin_t"; + + CHECK_AST_WITH_BUILTIN_THROWS_WITH(data, error_message); + } + } + + SECTION("-> R^2x2") + { + SECTION("N -> R^2x2") + { + std::string_view data = R"( +let n:N, n = 1; +let b:R^2x2, b = n; +)"; + + std::string error_message = "undefined affectation type: R^2x2 = N"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R -> R^2x2") + { + std::string_view data = R"( +let b:R^2x2, b = 1.2; +)"; + + std::string error_message = "undefined affectation type: R^2x2 = R"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R^1 -> R^2x2") + { + std::string_view data = R"( +let b:R^2x2, b = [1.2]; +)"; + + std::string error_message = "undefined affectation type: R^2x2 = R^1"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R^2 -> R^2x2") + { + std::string_view data = R"( +let b:R^2x2, b = [1.2, 3]; +)"; + + std::string error_message = "undefined affectation type: R^2x2 = R^2"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R^3 -> R^2x2") + { + std::string_view data = R"( +let b:R^2x2, b = [1.2, 3, 1]; +)"; + + std::string error_message = "undefined affectation type: R^2x2 = R^3"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R^1x1 -> R^2x2") + { + std::string_view data = R"( +let b:R^2x2, b = [[1.2]]; +)"; + + std::string error_message = "undefined affectation type: R^2x2 = R^1x1"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R^3x3 -> R^2x2") + { + std::string_view data = R"( +let b:R^2x2, b = [[1.2, 3, 1],[1,2,3],[4,2,1]]; +)"; + + std::string error_message = "undefined affectation type: R^2x2 = R^3x3"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("string -> R^2x2") + { + std::string_view data = R"( +let b:R^2x2, b = "foo"; +)"; + + std::string error_message = "undefined affectation type: R^2x2 = string"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("builtin_t -> R^2x2") + { + std::string_view data = R"( +let bt:builtin_t, bt = a; +let v : R^2x2, v = bt; +)"; + + std::string error_message = "undefined affectation type: R^2x2 = builtin_t"; + + CHECK_AST_WITH_BUILTIN_THROWS_WITH(data, error_message); + } + } + + SECTION("-> R^3x3") + { + SECTION("N -> R^3x3") + { + std::string_view data = R"( +let n:N, n = 1; +let b:R^3x3, b = n; +)"; + + std::string error_message = "undefined affectation type: R^3x3 = N"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R -> R^3x3") + { + std::string_view data = R"( +let b:R^3x3, b = 1.2; +)"; + + std::string error_message = "undefined affectation type: R^3x3 = R"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R^1 -> R^3x3") + { + std::string_view data = R"( +let b:R^3x3, b = [1.2]; +)"; + + std::string error_message = "undefined affectation type: R^3x3 = R^1"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R^2 -> R^3x3") + { + std::string_view data = R"( +let b:R^3x3, b = [1.2, 3]; +)"; + + std::string error_message = "undefined affectation type: R^3x3 = R^2"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R^3 -> R^3x3") + { + std::string_view data = R"( +let b:R^3x3, b = [1.2, 3, 1]; +)"; + + std::string error_message = "undefined affectation type: R^3x3 = R^3"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R^1x1 -> R^3x3") + { + std::string_view data = R"( +let b:R^3x3, b = [[1.2]]; +)"; + + std::string error_message = "undefined affectation type: R^3x3 = R^1x1"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R^2x2 -> R^3x3") + { + std::string_view data = R"( +let b:R^3x3, b = [[1.2, 3],[3,4]]; +)"; + + std::string error_message = "undefined affectation type: R^3x3 = R^2x2"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("string -> R^3x3") + { + std::string_view data = R"( +let b:R^3x3, b = "foo"; +)"; + + std::string error_message = "undefined affectation type: R^3x3 = string"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("builtin_t -> R^3") + { + std::string_view data = R"( +let bt:builtin_t, bt = a; +let v : R^3x3, v = bt; +)"; + + std::string error_message = "undefined affectation type: R^3x3 = builtin_t"; + + CHECK_AST_WITH_BUILTIN_THROWS_WITH(data, error_message); + } + } + } + + SECTION("tuple -> value") + { + SECTION("-> B") + { + SECTION("(N) -> B") + { + std::string_view data = R"( +let t:(N), t = 1; +let b:B, b = t; +)"; + + std::string error_message = "undefined affectation type: B = (N)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(Z) -> B") + { + std::string_view data = R"( +let t:(Z), t = 1; +let b:B, b = t; +)"; + + std::string error_message = "undefined affectation type: B = (Z)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(R) -> B") + { + std::string_view data = R"( +let t:(R), t = 1; +let b:B, b = t; +)"; + + std::string error_message = "undefined affectation type: B = (R)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(R^1) -> B") + { + std::string_view data = R"( +let t:(R^1), t = 1; +let b:B, b = t; +)"; + + std::string error_message = "undefined affectation type: B = (R^1)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(R^2) -> B") + { + std::string_view data = R"( +let t:(R^2), t = [1.2, 3]; +let b:B, b = t; +)"; + + std::string error_message = "undefined affectation type: B = (R^2)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(R^3) -> B") + { + std::string_view data = R"( +let t:(R^3), t = [1, 2, 3]; +let b:B, b = t; +)"; + + std::string error_message = "undefined affectation type: B = (R^3)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(R^1x1) -> B") + { + std::string_view data = R"( +let t:(R^1x1), t = [[1.2]]; +let b:B, b = t; +)"; + + std::string error_message = "undefined affectation type: B = (R^1x1)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(R^2x2) -> B") + { + std::string_view data = R"( +let t:(R^2x2), t = [[1.2, 3],[3,4]]; +let b:B, b = t; +)"; + + std::string error_message = "undefined affectation type: B = (R^2x2)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(R^3x3) -> B") + { + std::string_view data = R"( +let t:(R^3x3), t = [[1.2, 3, 1],[1,2,3],[4,2,1]]; +let b:B, b = t; +)"; + + std::string error_message = "undefined affectation type: B = (R^3x3)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(string) -> B") + { + std::string_view data = R"( +let t:(string), t = "foo"; +let b:B, b = t; +)"; + + std::string error_message = "undefined affectation type: B = (string)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(builtin_t) -> B") + { + std::string_view data = R"( +let bt:(builtin_t), bt = a; +let v : B, v = bt; +)"; + + std::string error_message = "undefined affectation type: B = (builtin_t)"; + + CHECK_AST_WITH_BUILTIN_THROWS_WITH(data, error_message); + } + } + + SECTION("-> N") + { + SECTION("(R) -> N") + { + std::string_view data = R"( +let t:(R), t = 1.2; +let b:N, b = t; +)"; + + std::string error_message = "undefined affectation type: N = (R)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(R^1) -> N") + { + std::string_view data = R"( +let t:(R^1), t = [1.2]; +let b:N, b = t; +)"; + + std::string error_message = "undefined affectation type: N = (R^1)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(R^2) -> N") + { + std::string_view data = R"( +let t:(R^2), t = [1.2, 3]; +let b:N, b = t; +)"; + + std::string error_message = "undefined affectation type: N = (R^2)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(R^3) -> N") + { + std::string_view data = R"( +let t:(R^3), t = [1.2, 3, 1]; +let b:N, b = t; +)"; + + std::string error_message = "undefined affectation type: N = (R^3)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(R^1x1) -> N") + { + std::string_view data = R"( +let t:(R^1x1), t = [[1.2]]; +let b:N, b = t; +)"; + + std::string error_message = "undefined affectation type: N = (R^1x1)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(R^2x2) -> N") + { + std::string_view data = R"( +let t:(R^2x2), t = [[1.2, 3],[3,4]]; +let b:N, b = t; +)"; + + std::string error_message = "undefined affectation type: N = (R^2x2)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(R^3x3) -> N") + { + std::string_view data = R"( +let t:(R^3x3), t = [[1.2, 3, 1],[1,2,3],[4,2,1]]; +let b:N, b = t; +)"; + + std::string error_message = "undefined affectation type: N = (R^3x3)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(string) -> N") + { + std::string_view data = R"( +let t:(string), t = "foo"; +let b:N, b = t; +)"; + + std::string error_message = "undefined affectation type: N = (string)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(builtin_t) -> N") + { + std::string_view data = R"( +let bt:(builtin_t), bt = a; +let v : N, v = bt; +)"; + + std::string error_message = "undefined affectation type: N = (builtin_t)"; + + CHECK_AST_WITH_BUILTIN_THROWS_WITH(data, error_message); + } + } + + SECTION("-> Z") + { + SECTION("(R) -> Z") + { + std::string_view data = R"( +let t:(R), t = 1.2; +let b:Z, b = t; +)"; + + std::string error_message = "undefined affectation type: Z = (R)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(R^1) -> Z") + { + std::string_view data = R"( +let t:(R^1), t = [1.2]; +let b:Z, b = t; +)"; + + std::string error_message = "undefined affectation type: Z = (R^1)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(R^2) -> Z") + { + std::string_view data = R"( +let t:(R^2), t = [1.2, 3]; +let b:Z, b = t; +)"; + + std::string error_message = "undefined affectation type: Z = (R^2)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(R^3) -> Z") + { + std::string_view data = R"( +let t:(R^3), t = [1.2, 3, 1]; +let b:Z, b = t; +)"; + + std::string error_message = "undefined affectation type: Z = (R^3)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(R^1x1) -> Z") + { + std::string_view data = R"( +let t:(R^1x1), t = [[1.2]]; +let b:Z, b = t; +)"; + + std::string error_message = "undefined affectation type: Z = (R^1x1)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(R^2x2) -> Z") + { + std::string_view data = R"( +let t:(R^2x2), t = [[1.2, 3],[3,4]]; +let b:Z, b = t; +)"; + + std::string error_message = "undefined affectation type: Z = (R^2x2)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(R^3x3) -> Z") + { + std::string_view data = R"( +let t:(R^3x3), t = [[1.2, 3, 1],[1,2,3],[4,2,1]]; +let b:Z, b = t; +)"; + + std::string error_message = "undefined affectation type: Z = (R^3x3)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(string) -> Z") + { + std::string_view data = R"( +let t:(string), t = "foo"; +let b:Z, b = t; +)"; + + std::string error_message = "undefined affectation type: Z = (string)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(builtin_t) -> Z") + { + std::string_view data = R"( +let bt:(builtin_t), bt = a; +let v : Z, v = bt; +)"; + + std::string error_message = "undefined affectation type: Z = (builtin_t)"; + + CHECK_AST_WITH_BUILTIN_THROWS_WITH(data, error_message); + } + } + + SECTION("-> R") + { + SECTION("(R^1) -> R") + { + std::string_view data = R"( +let t:(R^1), t = [1.2]; +let b:R, b = t; +)"; + + std::string error_message = "undefined affectation type: R = (R^1)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(R^2) -> R") + { + std::string_view data = R"( +let t:(R^2), t = [1.2, 3]; +let b:R, b = t; +)"; + + std::string error_message = "undefined affectation type: R = (R^2)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(R^3) -> R") + { + std::string_view data = R"( +let t:(R^3), t = [1.2, 3, 1]; +let b:R, b = t; +)"; + + std::string error_message = "undefined affectation type: R = (R^3)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(R^1x1) -> R") + { + std::string_view data = R"( +let t:(R^1x1), t = [[1.2]]; +let b:R, b = t; +)"; + + std::string error_message = "undefined affectation type: R = (R^1x1)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(R^2x2) -> R") + { + std::string_view data = R"( +let t:(R^2x2), t = [[1.2, 3],[3,4]]; +let b:R, b = t; +)"; + + std::string error_message = "undefined affectation type: R = (R^2x2)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(R^3x3) -> R") + { + std::string_view data = R"( +let t:(R^3x3), t = [[1.2, 3, 1],[1,2,3],[4,2,1]]; +let b:R, b = t; +)"; + + std::string error_message = "undefined affectation type: R = (R^3x3)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(string) -> R") + { + std::string_view data = R"( +let t:(string), t = "foo"; +let b:R, b = t; +)"; + + std::string error_message = "undefined affectation type: R = (string)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(builtin_t) -> R") + { + std::string_view data = R"( +let bt:(builtin_t), bt = a; +let v : R, v = bt; +)"; + + std::string error_message = "undefined affectation type: R = (builtin_t)"; + + CHECK_AST_WITH_BUILTIN_THROWS_WITH(data, error_message); + } + } + + SECTION("-> R^1") + { + SECTION("(R^2) -> R^1") + { + std::string_view data = R"( +let t:(R^2), t = [1.2, 3]; +let b:R^1, b = t; +)"; + + std::string error_message = "undefined affectation type: R^1 = (R^2)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(R^3) -> R^1") + { + std::string_view data = R"( +let t:(R^3), t = [1.2, 3, 1]; +let b:R^1, b = t; +)"; + + std::string error_message = "undefined affectation type: R^1 = (R^3)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(R^1x1) -> R^1") + { + std::string_view data = R"( +let t:(R^1x1), t = [[1.2]]; +let b:R^1, b = t; +)"; + + std::string error_message = "undefined affectation type: R^1 = (R^1x1)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(R^2x2) -> R^1") + { + std::string_view data = R"( +let t:(R^2x2), t = [[1.2, 3],[3,4]]; +let b:R^1, b = t; +)"; + + std::string error_message = "undefined affectation type: R^1 = (R^2x2)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(R^3x3) -> R^1") + { + std::string_view data = R"( +let t:(R^3x3), t = [[1.2, 3, 1],[1,2,3],[4,2,1]]; +let b:R^1, b = t; +)"; + + std::string error_message = "undefined affectation type: R^1 = (R^3x3)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(string) -> R^1") + { + std::string_view data = R"( +let t:(string), t = "foo"; +let b:R^1, b = t; +)"; + + std::string error_message = "undefined affectation type: R^1 = (string)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(builtin_t) -> R^1") + { + std::string_view data = R"( +let bt:(builtin_t), bt = a; +let v : R^1, v = bt; +)"; + + std::string error_message = "undefined affectation type: R^1 = (builtin_t)"; + + CHECK_AST_WITH_BUILTIN_THROWS_WITH(data, error_message); + } + } + + SECTION("-> R^2") + { + SECTION("(N) -> R^2") + { + std::string_view data = R"( +let n:(N), n = 1; +let b:R^2, b = n; +)"; + + std::string error_message = "undefined affectation type: R^2 = (N)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(R) -> R^2") + { + std::string_view data = R"( +let t:(R), t = 1.2; +let b:R^2, b = t; +)"; + + std::string error_message = "undefined affectation type: R^2 = (R)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(R^1) -> R^2") + { + std::string_view data = R"( +let t:(R^1), t = [1.2]; +let b:R^2, b = t; +)"; + + std::string error_message = "undefined affectation type: R^2 = (R^1)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(R^3) -> R^2") + { + std::string_view data = R"( +let t:(R^3), t = [1.2, 3, 1]; +let b:R^2, b = t; +)"; + + std::string error_message = "undefined affectation type: R^2 = (R^3)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(R^1x1) -> R^2") + { + std::string_view data = R"( +let t:(R^1x1), t = [[1.2]]; +let b:R^2, b = t; +)"; + + std::string error_message = "undefined affectation type: R^2 = (R^1x1)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(R^2x2) -> R^2") + { + std::string_view data = R"( +let t:(R^2x2), t = [[1.2, 3],[3,4]]; +let b:R^2, b = t; +)"; + + std::string error_message = "undefined affectation type: R^2 = (R^2x2)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(R^3x3) -> R^2") + { + std::string_view data = R"( +let t:(R^3x3), t = [[1.2, 3, 1],[1,2,3],[4,2,1]]; +let b:R^2, b = t; +)"; + + std::string error_message = "undefined affectation type: R^2 = (R^3x3)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(string) -> R^2") + { + std::string_view data = R"( +let t:(string), t = "foo"; +let b:R^2, b = t; +)"; + + std::string error_message = "undefined affectation type: R^2 = (string)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(builtin_t) -> R^2") + { + std::string_view data = R"( +let bt:(builtin_t), bt = a; +let v : R^2, v = bt; +)"; + + std::string error_message = "undefined affectation type: R^2 = (builtin_t)"; + + CHECK_AST_WITH_BUILTIN_THROWS_WITH(data, error_message); + } + } + + SECTION("-> R^3") + { + SECTION("(N) -> R^3") + { + std::string_view data = R"( +let n:(N), n = 1; +let b:R^3, b = n; +)"; + + std::string error_message = "undefined affectation type: R^3 = (N)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(R) -> R^3") + { + std::string_view data = R"( +let t:(R), t = 1.2; +let b:R^3, b = t; +)"; + + std::string error_message = "undefined affectation type: R^3 = (R)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(R^1) -> R^3") + { + std::string_view data = R"( +let t:(R^1), t = [1.2]; +let b:R^3, b = t; +)"; + + std::string error_message = "undefined affectation type: R^3 = (R^1)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(R^2) -> R^3") + { + std::string_view data = R"( +let t:(R^2), t = [1.2, 3]; +let b:R^3, b = t; +)"; + + std::string error_message = "undefined affectation type: R^3 = (R^2)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(R^1x1) -> R^3") + { + std::string_view data = R"( +let t:(R^1x1), t = [[1.2]]; +let b:R^3, b = t; +)"; + + std::string error_message = "undefined affectation type: R^3 = (R^1x1)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(R^2x2) -> R^3") + { + std::string_view data = R"( +let t:(R^2x2), t = [[1.2, 3],[3,4]]; +let b:R^3, b = t; +)"; + + std::string error_message = "undefined affectation type: R^3 = (R^2x2)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(R^3x3) -> R^3") + { + std::string_view data = R"( +let t:(R^3x3), t = [[1.2, 3, 1],[1,2,3],[4,2,1]]; +let b:R^3, b = t; +)"; + + std::string error_message = "undefined affectation type: R^3 = (R^3x3)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(string) -> R^3") + { + std::string_view data = R"( +let t:(string), t = "foo"; +let b:R^3, b = t; +)"; + + std::string error_message = "undefined affectation type: R^3 = (string)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(builtin_t) -> R^3") + { + std::string_view data = R"( +let bt:(builtin_t), bt = a; +let v : R^3, v = bt; +)"; + + std::string error_message = "undefined affectation type: R^3 = (builtin_t)"; + + CHECK_AST_WITH_BUILTIN_THROWS_WITH(data, error_message); + } + } + + SECTION("-> R^1x1") + { + SECTION("(R^1) -> R^1x1") + { + std::string_view data = R"( +let t:(R^1), t = [1.2]; +let b:R^1x1, b = t; +)"; + + std::string error_message = "undefined affectation type: R^1x1 = (R^1)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(R^2) -> R^1x1") + { + std::string_view data = R"( +let t:(R^2), t = [1.2, 3]; +let b:R^1x1, b = t; +)"; + + std::string error_message = "undefined affectation type: R^1x1 = (R^2)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(R^3) -> R^1x1") + { + std::string_view data = R"( +let t:(R^3), t = [1.2, 3, 1]; +let b:R^1x1, b = t; +)"; + + std::string error_message = "undefined affectation type: R^1x1 = (R^3)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(R^2x2) -> R^1x1") + { + std::string_view data = R"( +let t:(R^2x2), t = [[1.2, 3],[3,4]]; +let b:R^1x1, b = t; +)"; + + std::string error_message = "undefined affectation type: R^1x1 = (R^2x2)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(R^3x3) -> R^1x1") + { + std::string_view data = R"( +let t:(R^3x3), t = [[1.2, 3, 1],[1,2,3],[4,2,1]]; +let b:R^1x1, b = t; +)"; + + std::string error_message = "undefined affectation type: R^1x1 = (R^3x3)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(string) -> R^1x1") + { + std::string_view data = R"( +let t:(string), t = "foo"; +let b:R^1x1, b = t; +)"; + + std::string error_message = "undefined affectation type: R^1x1 = (string)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(builtin_t) -> R^1x1") + { + std::string_view data = R"( +let bt:(builtin_t), bt = a; +let v : R^1x1, v = bt; +)"; + + std::string error_message = "undefined affectation type: R^1x1 = (builtin_t)"; + + CHECK_AST_WITH_BUILTIN_THROWS_WITH(data, error_message); + } + } + + SECTION("-> R^2x2") + { + SECTION("(N) -> R^2x2") + { + std::string_view data = R"( +let n:(N), n = 1; +let b:R^2x2, b = n; +)"; + + std::string error_message = "undefined affectation type: R^2x2 = (N)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(R) -> R^2x2") + { + std::string_view data = R"( +let t:(R), t = 1.2; +let b:R^2x2, b = t; +)"; + + std::string error_message = "undefined affectation type: R^2x2 = (R)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(R^1) -> R^2x2") + { + std::string_view data = R"( +let t:(R^1), t = [1.2]; +let b:R^2x2, b = t; +)"; + + std::string error_message = "undefined affectation type: R^2x2 = (R^1)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(R^2) -> R^2x2") + { + std::string_view data = R"( +let t:(R^2), t = [1.2, 3]; +let b:R^2x2, b = t; +)"; + + std::string error_message = "undefined affectation type: R^2x2 = (R^2)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(R^3) -> R^2x2") + { + std::string_view data = R"( +let t:(R^3), t = [1.2, 3, 1]; +let b:R^2x2, b = t; +)"; + + std::string error_message = "undefined affectation type: R^2x2 = (R^3)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(R^1x1) -> R^2x2") + { + std::string_view data = R"( +let t:(R^1x1), t = [[1.2]]; +let b:R^2x2, b = t; +)"; + + std::string error_message = "undefined affectation type: R^2x2 = (R^1x1)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(R^3x3) -> R^2x2") + { + std::string_view data = R"( +let t:(R^3x3), t = [[1.2, 3, 1],[1,2,3],[4,2,1]]; +let b:R^2x2, b = t; +)"; + + std::string error_message = "undefined affectation type: R^2x2 = (R^3x3)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(string) -> R^2x2") + { + std::string_view data = R"( +let t:(string), t = "foo"; +let b:R^2x2, b = t; +)"; + + std::string error_message = "undefined affectation type: R^2x2 = (string)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(builtin_t) -> R^2x2") + { + std::string_view data = R"( +let bt:(builtin_t), bt = a; +let v : R^2x2, v = bt; +)"; + + std::string error_message = "undefined affectation type: R^2x2 = (builtin_t)"; + + CHECK_AST_WITH_BUILTIN_THROWS_WITH(data, error_message); + } + } + + SECTION("-> R^3x3") + { + SECTION("(N) -> R^3x3") + { + std::string_view data = R"( +let n:(N), n = 1; +let b:R^3x3, b = n; +)"; + + std::string error_message = "undefined affectation type: R^3x3 = (N)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(R) -> R^3x3") + { + std::string_view data = R"( +let t:(R), t = 1.2; +let b:R^3x3, b = t; +)"; + + std::string error_message = "undefined affectation type: R^3x3 = (R)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(R^1) -> R^3x3") + { + std::string_view data = R"( +let t:(R^1), t = [1.2]; +let b:R^3x3, b = t; +)"; + + std::string error_message = "undefined affectation type: R^3x3 = (R^1)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(R^2) -> R^3x3") + { + std::string_view data = R"( +let t:(R^2), t = [1.2, 3]; +let b:R^3x3, b = t; +)"; + + std::string error_message = "undefined affectation type: R^3x3 = (R^2)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(R^3) -> R^3x3") + { + std::string_view data = R"( +let t:(R^3), t = [1.2, 3, 1]; +let b:R^3x3, b = t; +)"; + + std::string error_message = "undefined affectation type: R^3x3 = (R^3)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(R^1x1) -> R^3x3") + { + std::string_view data = R"( +let t:(R^1x1), t = [[1.2]]; +let b:R^3x3, b = t; +)"; + + std::string error_message = "undefined affectation type: R^3x3 = (R^1x1)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(R^2x2) -> R^3x3") + { + std::string_view data = R"( +let t:(R^2x2), t = [[1.2, 3],[3,4]]; +let b:R^3x3, b = t; +)"; + + std::string error_message = "undefined affectation type: R^3x3 = (R^2x2)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(string) -> R^3x3") + { + std::string_view data = R"( +let t:(string), t = "foo"; +let b:R^3x3, b = t; +)"; + + std::string error_message = "undefined affectation type: R^3x3 = (string)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(builtin_t) -> R^3x3") + { + std::string_view data = R"( +let bt:(builtin_t), bt = a; +let v : R^3x3, v = bt; +)"; + + std::string error_message = "undefined affectation type: R^3x3 = (builtin_t)"; + + CHECK_AST_WITH_BUILTIN_THROWS_WITH(data, error_message); + } + } + } + } + + SECTION("-> tuple") + { + SECTION("value -> tuple") + { + SECTION("-> (B)") + { + SECTION("N -> (B)") + { + std::string_view data = R"( +let n:N, n = 1; +let b:(B), b = n; +)"; + + std::string error_message = "undefined affectation type: (B) = N"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("Z -> (B)") + { + std::string_view data = R"( +let b:(B), b = 1; +)"; + + std::string error_message = "undefined affectation type: (B) = Z"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R -> (B)") + { + std::string_view data = R"( +let b:(B), b = 1.2; +)"; + + std::string error_message = "undefined affectation type: (B) = R"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R^1 -> (B)") + { + std::string_view data = R"( +let b:(B), b = [1.2]; +)"; + + std::string error_message = "undefined affectation type: (B) = R^1"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R^2 -> (B)") + { + std::string_view data = R"( +let b:(B), b = [1.2, 3]; +)"; + + std::string error_message = "undefined affectation type: (B) = R^2"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R^3 -> (B)") + { + std::string_view data = R"( +let b:(B), b = [1.2, 3, 1]; +)"; + + std::string error_message = "undefined affectation type: (B) = R^3"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R^1x1 -> (B)") + { + std::string_view data = R"( +let b:(B), b = [[1.2]]; +)"; + + std::string error_message = "undefined affectation type: (B) = R^1x1"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R^2x2 -> (B)") + { + std::string_view data = R"( +let b:(B), b = [[1.2, 3],[3,4]]; +)"; + + std::string error_message = "undefined affectation type: (B) = R^2x2"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R^3x3 -> (B)") + { + std::string_view data = R"( +let b:(B), b = [[1.2, 3, 1],[1,2,3],[4,2,1]]; +)"; + + std::string error_message = "undefined affectation type: (B) = R^3x3"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("string -> (B)") + { + std::string_view data = R"( +let b:(B), b = "foo"; +)"; + + std::string error_message = "undefined affectation type: (B) = string"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("builtin_t -> (B)") + { + std::string_view data = R"( +let bt:builtin_t, bt = a; +let v:(B), v = bt; +)"; + + std::string error_message = "undefined affectation type: (B) = builtin_t"; + + CHECK_AST_WITH_BUILTIN_THROWS_WITH(data, error_message); + } + } + + SECTION("-> (N)") + { + SECTION("R -> (N)") + { + std::string_view data = R"( +let b:(N), b = 1.2; +)"; + + std::string error_message = "undefined affectation type: (N) = R"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R^1 -> (N)") + { + std::string_view data = R"( +let b:(N), b = [1.2]; +)"; + + std::string error_message = "undefined affectation type: (N) = R^1"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R^2 -> (N)") + { + std::string_view data = R"( +let b:(N), b = [1.2, 3]; +)"; + + std::string error_message = "undefined affectation type: (N) = R^2"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R^3 -> (N)") + { + std::string_view data = R"( +let b:(N), b = [1.2, 3, 1]; +)"; + + std::string error_message = "undefined affectation type: (N) = R^3"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R^1x1 -> (N)") + { + std::string_view data = R"( +let b:(N), b = [[1.2]]; +)"; + + std::string error_message = "undefined affectation type: (N) = R^1x1"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R^2x2 -> (N)") + { + std::string_view data = R"( +let b:(N), b = [[1.2, 3],[3,4]]; +)"; + + std::string error_message = "undefined affectation type: (N) = R^2x2"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R^3x3 -> (N)") + { + std::string_view data = R"( +let b:(N), b = [[1.2, 3, 1],[1,2,3],[4,2,1]]; +)"; + + std::string error_message = "undefined affectation type: (N) = R^3x3"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("string -> (N)") + { + std::string_view data = R"( +let b:(N), b = "foo"; +)"; + + std::string error_message = "undefined affectation type: (N) = string"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("builtin_t -> (N)") + { + std::string_view data = R"( +let bt:builtin_t, bt = a; +let v : (N), v = bt; +)"; + + std::string error_message = "undefined affectation type: (N) = builtin_t"; + + CHECK_AST_WITH_BUILTIN_THROWS_WITH(data, error_message); + } + } + + SECTION("-> (Z)") + { + SECTION("R -> (Z)") + { + std::string_view data = R"( +let b:(Z), b = 1.2; +)"; + + std::string error_message = "undefined affectation type: (Z) = R"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R^1 -> (Z)") + { + std::string_view data = R"( +let b:(Z), b = [1.2]; +)"; + + std::string error_message = "undefined affectation type: (Z) = R^1"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R^2 -> (Z)") + { + std::string_view data = R"( +let b:(Z), b = [1.2, 3]; +)"; + + std::string error_message = "undefined affectation type: (Z) = R^2"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R^3 -> (Z)") + { + std::string_view data = R"( +let b:(Z), b = [1.2, 3, 1]; +)"; + + std::string error_message = "undefined affectation type: (Z) = R^3"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R^1x1 -> (Z)") + { + std::string_view data = R"( +let b:(Z), b = [[1.2]]; +)"; + + std::string error_message = "undefined affectation type: (Z) = R^1x1"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R^2x2 -> (Z)") + { + std::string_view data = R"( +let b:(Z), b = [[1.2, 3],[3,4]]; +)"; + + std::string error_message = "undefined affectation type: (Z) = R^2x2"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R^3x3 -> (Z)") + { + std::string_view data = R"( +let b:(Z), b = [[1.2, 3, 1],[1,2,3],[4,2,1]]; +)"; + + std::string error_message = "undefined affectation type: (Z) = R^3x3"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("string -> (Z)") + { + std::string_view data = R"( +let b:(Z), b = "foo"; +)"; + + std::string error_message = "undefined affectation type: (Z) = string"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("builtin_t -> (Z)") + { + std::string_view data = R"( +let bt:builtin_t, bt = a; +let v : (Z), v = bt; +)"; + + std::string error_message = "undefined affectation type: (Z) = builtin_t"; + + CHECK_AST_WITH_BUILTIN_THROWS_WITH(data, error_message); + } + } + + SECTION("-> (R)") + { + SECTION("R^1 -> (R)") + { + std::string_view data = R"( +let b:(R), b = [1.2]; +)"; + + std::string error_message = "undefined affectation type: (R) = R^1"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R^2 -> (R)") + { + std::string_view data = R"( +let b:(R), b = [1.2, 3]; +)"; + + std::string error_message = "undefined affectation type: (R) = R^2"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R^3 -> (R)") + { + std::string_view data = R"( +let b:(R), b = [1.2, 3, 1]; +)"; + + std::string error_message = "undefined affectation type: (R) = R^3"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R^1x1 -> (R)") + { + std::string_view data = R"( +let b:(R), b = [[1.2]]; +)"; + + std::string error_message = "undefined affectation type: (R) = R^1x1"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R^2x2 -> (R)") + { + std::string_view data = R"( +let b:(R), b = [[1.2, 3],[3,4]]; +)"; + + std::string error_message = "undefined affectation type: (R) = R^2x2"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R^3x3 -> (R)") + { + std::string_view data = R"( +let b:(R), b = [[1.2, 3, 1],[1,2,3],[4,2,1]]; +)"; + + std::string error_message = "undefined affectation type: (R) = R^3x3"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("string -> (R)") + { + std::string_view data = R"( +let b:(R), b = "foo"; +)"; + + std::string error_message = "undefined affectation type: (R) = string"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("builtin_t -> (R)") + { + std::string_view data = R"( +let bt:builtin_t, bt = a; +let v :(R), v = bt; +)"; + + std::string error_message = "undefined affectation type: (R) = builtin_t"; + + CHECK_AST_WITH_BUILTIN_THROWS_WITH(data, error_message); + } + } + + SECTION("-> (R^1)") + { + SECTION("R^2 -> (R^1)") + { + std::string_view data = R"( +let b:(R^1), b = [1.2, 3]; +)"; + + std::string error_message = "undefined affectation type: (R^1) = R^2"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R^3 -> (R^1)") + { + std::string_view data = R"( +let b:(R^1), b = [1.2, 3, 1]; +)"; + + std::string error_message = "undefined affectation type: (R^1) = R^3"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R^1x1 -> (R^1)") + { + std::string_view data = R"( +let b:(R^1), b = [[1.2]]; +)"; + + std::string error_message = "undefined affectation type: (R^1) = R^1x1"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R^2x2 -> (R^1)") + { + std::string_view data = R"( +let b:(R^1), b = [[1.2, 3],[3,4]]; +)"; + + std::string error_message = "undefined affectation type: (R^1) = R^2x2"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R^3x3 -> (R^1)") + { + std::string_view data = R"( +let b:(R^1), b = [[1.2, 3, 1],[1,2,3],[4,2,1]]; +)"; + + std::string error_message = "undefined affectation type: (R^1) = R^3x3"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("string -> (R^1)") + { + std::string_view data = R"( +let b:(R^1), b = "foo"; +)"; + + std::string error_message = "undefined affectation type: (R^1) = string"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("builtin_t -> (R^1)") + { + std::string_view data = R"( +let bt:builtin_t, bt = a; +let v : (R^1), v = bt; +)"; + + std::string error_message = "undefined affectation type: (R^1) = builtin_t"; + + CHECK_AST_WITH_BUILTIN_THROWS_WITH(data, error_message); + } + } + + SECTION("-> (R^2)") + { + SECTION("N -> (R^2)") + { + std::string_view data = R"( +let n:N, n = 1; +let b:(R^2), b = n; +)"; + + std::string error_message = "undefined affectation type: (R^2) = N"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R -> (R^2)") + { + std::string_view data = R"( +let b:(R^2), b = 1.2; +)"; + + std::string error_message = "undefined affectation type: (R^2) = R"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R^1 -> (R^2)") + { + std::string_view data = R"( +let b:(R^2), b = [1.2]; +)"; + + std::string error_message = "undefined affectation type: (R^2) = R^1"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R^3 -> (R^2)") + { + std::string_view data = R"( +let b:(R^2), b = [1.2, 3, 1]; +)"; + + std::string error_message = "undefined affectation type: (R^2) = R^3"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R^1x1 -> (R^2)") + { + std::string_view data = R"( +let b:(R^2), b = [[1.2]]; +)"; + + std::string error_message = "undefined affectation type: (R^2) = R^1x1"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R^2x2 -> (R^2)") + { + std::string_view data = R"( +let b:(R^2), b = [[1.2, 3],[3,4]]; +)"; + + std::string error_message = "undefined affectation type: (R^2) = R^2x2"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R^3x3 -> (R^2)") + { + std::string_view data = R"( +let b:(R^2), b = [[1.2, 3, 1],[1,2,3],[4,2,1]]; +)"; + + std::string error_message = "undefined affectation type: (R^2) = R^3x3"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("string -> (R^2)") + { + std::string_view data = R"( +let b:(R^2), b = "foo"; +)"; + + std::string error_message = "undefined affectation type: (R^2) = string"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("builtin_t -> (R^2)") + { + std::string_view data = R"( +let bt:builtin_t, bt = a; +let v : (R^2), v = bt; +)"; + + std::string error_message = "undefined affectation type: (R^2) = builtin_t"; + + CHECK_AST_WITH_BUILTIN_THROWS_WITH(data, error_message); + } + } + + SECTION("-> (R^3)") + { + SECTION("N -> (R^3)") + { + std::string_view data = R"( +let n:N, n = 1; +let b:(R^3), b = n; +)"; + + std::string error_message = "undefined affectation type: (R^3) = N"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R -> (R^3)") + { + std::string_view data = R"( +let b:(R^3), b = 1.2; +)"; + + std::string error_message = "undefined affectation type: (R^3) = R"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R^1 -> (R^3)") + { + std::string_view data = R"( +let b:(R^3), b = [1.2]; +)"; + + std::string error_message = "undefined affectation type: (R^3) = R^1"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R^2 -> (R^3)") + { + std::string_view data = R"( +let b:(R^3), b = [1.2, 3]; +)"; + + std::string error_message = "undefined affectation type: (R^3) = R^2"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R^1x1 -> (R^3)") + { + std::string_view data = R"( +let b:(R^3), b = [[1.2]]; +)"; + + std::string error_message = "undefined affectation type: (R^3) = R^1x1"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R^2x2 -> (R^3)") + { + std::string_view data = R"( +let b:(R^3), b = [[1.2, 3],[3,4]]; +)"; + + std::string error_message = "undefined affectation type: (R^3) = R^2x2"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R^3x3 -> (R^3)") + { + std::string_view data = R"( +let b:(R^3), b = [[1.2, 3, 1],[1,2,3],[4,2,1]]; +)"; + + std::string error_message = "undefined affectation type: (R^3) = R^3x3"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("string -> (R^3)") + { + std::string_view data = R"( +let b:(R^3), b = "foo"; +)"; + + std::string error_message = "undefined affectation type: (R^3) = string"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("builtin_t -> (R^3)") + { + std::string_view data = R"( +let bt:builtin_t, bt = a; +let v : (R^3), v = bt; +)"; + + std::string error_message = "undefined affectation type: (R^3) = builtin_t"; + + CHECK_AST_WITH_BUILTIN_THROWS_WITH(data, error_message); + } + } + + SECTION("-> (R^1x1)") + { + SECTION("R^1 -> (R^1x1)") + { + std::string_view data = R"( +let b:(R^1x1), b = [1.2]; +)"; + + std::string error_message = "undefined affectation type: (R^1x1) = R^1"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R^2 -> (R^1x1)") + { + std::string_view data = R"( +let b:(R^1x1), b = [1.2, 3]; +)"; + + std::string error_message = "undefined affectation type: (R^1x1) = R^2"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R^3 -> (R^1x1)") + { + std::string_view data = R"( +let b:(R^1x1), b = [1.2, 3, 1]; +)"; + + std::string error_message = "undefined affectation type: (R^1x1) = R^3"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R^2x2 -> (R^1x1)") + { + std::string_view data = R"( +let b:(R^1x1), b = [[1.2, 3],[3,4]]; +)"; + + std::string error_message = "undefined affectation type: (R^1x1) = R^2x2"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R^3x3 -> (R^1x1)") + { + std::string_view data = R"( +let b:(R^1x1), b = [[1.2, 3, 1],[1,2,3],[4,2,1]]; +)"; + + std::string error_message = "undefined affectation type: (R^1x1) = R^3x3"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("string -> (R^1x1)") + { + std::string_view data = R"( +let b:(R^1x1), b = "foo"; +)"; + + std::string error_message = "undefined affectation type: (R^1x1) = string"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("builtin_t -> (R^1x1)") + { + std::string_view data = R"( +let bt:builtin_t, bt = a; +let v : (R^1x1), v = bt; +)"; + + std::string error_message = "undefined affectation type: (R^1x1) = builtin_t"; + + CHECK_AST_WITH_BUILTIN_THROWS_WITH(data, error_message); + } + } + + SECTION("-> (R^2x2)") + { + SECTION("N -> (R^2x2)") + { + std::string_view data = R"( +let n:N, n = 1; +let b:(R^2x2), b = n; +)"; + + std::string error_message = "undefined affectation type: (R^2x2) = N"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R -> (R^2x2)") + { + std::string_view data = R"( +let b:(R^2x2), b = 1.2; +)"; + + std::string error_message = "undefined affectation type: (R^2x2) = R"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R^1 -> (R^2x2)") + { + std::string_view data = R"( +let b:(R^2x2), b = [1.2]; +)"; + + std::string error_message = "undefined affectation type: (R^2x2) = R^1"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R^2 -> (R^2x2)") + { + std::string_view data = R"( +let b:(R^2x2), b = [1.2, 3]; +)"; + + std::string error_message = "undefined affectation type: (R^2x2) = R^2"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R^3 -> (R^2x2)") + { + std::string_view data = R"( +let b:(R^2x2), b = [1.2, 3, 1]; +)"; + + std::string error_message = "undefined affectation type: (R^2x2) = R^3"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R^1x1 -> (R^2x2)") + { + std::string_view data = R"( +let b:(R^2x2), b = [[1.2]]; +)"; + + std::string error_message = "undefined affectation type: (R^2x2) = R^1x1"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R^3x3 -> (R^2x2)") + { + std::string_view data = R"( +let b:(R^2x2), b = [[1.2, 3, 1],[1,2,3],[4,2,1]]; +)"; + + std::string error_message = "undefined affectation type: (R^2x2) = R^3x3"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("string -> (R^2x2)") + { + std::string_view data = R"( +let b:(R^2x2), b = "foo"; +)"; + + std::string error_message = "undefined affectation type: (R^2x2) = string"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("builtin_t -> (R^2x2)") + { + std::string_view data = R"( +let bt:builtin_t, bt = a; +let v : (R^2x2), v = bt; +)"; + + std::string error_message = "undefined affectation type: (R^2x2) = builtin_t"; + + CHECK_AST_WITH_BUILTIN_THROWS_WITH(data, error_message); + } + } + + SECTION("-> (R^3x3)") + { + SECTION("N -> (R^3x3)") + { + std::string_view data = R"( +let n:N, n = 1; +let b:(R^3x3), b = n; +)"; + + std::string error_message = "undefined affectation type: (R^3x3) = N"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R -> (R^3x3)") + { + std::string_view data = R"( +let b:(R^3x3), b = 1.2; +)"; + + std::string error_message = "undefined affectation type: (R^3x3) = R"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R^1 -> (R^3x3)") + { + std::string_view data = R"( +let b:(R^3x3), b = [1.2]; +)"; + + std::string error_message = "undefined affectation type: (R^3x3) = R^1"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R^2 -> (R^3x3)") + { + std::string_view data = R"( +let b:(R^3x3), b = [1.2, 3]; +)"; + + std::string error_message = "undefined affectation type: (R^3x3) = R^2"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R^3 -> (R^3x3)") + { + std::string_view data = R"( +let b:(R^3x3), b = [1.2, 3, 1]; +)"; + + std::string error_message = "undefined affectation type: (R^3x3) = R^3"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R^1x1 -> (R^3x3)") + { + std::string_view data = R"( +let b:(R^3x3), b = [[1.2]]; +)"; + + std::string error_message = "undefined affectation type: (R^3x3) = R^1x1"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("R^2x2 -> (R^3x3)") + { + std::string_view data = R"( +let b:(R^3x3), b = [[1.2, 3],[3,4]]; +)"; + + std::string error_message = "undefined affectation type: (R^3x3) = R^2x2"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("string -> (R^3x3)") + { + std::string_view data = R"( +let b:(R^3x3), b = "foo"; +)"; + + std::string error_message = "undefined affectation type: (R^3x3) = string"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("builtin_t -> (R^3x3)") + { + std::string_view data = R"( +let bt:builtin_t, bt = a; +let v : (R^3x3), v = bt; +)"; + + std::string error_message = "undefined affectation type: (R^3x3) = builtin_t"; + + CHECK_AST_WITH_BUILTIN_THROWS_WITH(data, error_message); + } + } + } + + SECTION("tuple -> tuple") + { + SECTION("-> (B)") + { + SECTION("(N) -> (B)") + { + std::string_view data = R"( +let t:(N), t = 1; +let b:(B), b = t; +)"; + + std::string error_message = "undefined affectation type: (B) = (N)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(Z) -> (B)") + { + std::string_view data = R"( +let t:(Z), t = 1; +let b:(B), b = t; +)"; + + std::string error_message = "undefined affectation type: (B) = (Z)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(R) -> (B)") + { + std::string_view data = R"( +let t:(R), t = 1; +let b:(B), b = t; +)"; + + std::string error_message = "undefined affectation type: (B) = (R)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(R^1) -> (B)") + { + std::string_view data = R"( +let t:(R^1), t = 1; +let b:(B), b = t; +)"; + + std::string error_message = "undefined affectation type: (B) = (R^1)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(R^2) -> (B)") + { + std::string_view data = R"( +let t:(R^2), t = [1.2, 3]; +let b:(B), b = t; +)"; + + std::string error_message = "undefined affectation type: (B) = (R^2)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(R^3) -> (B)") + { + std::string_view data = R"( +let t:(R^3), t = [1, 2, 3]; +let b:(B), b = t; +)"; + + std::string error_message = "undefined affectation type: (B) = (R^3)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(R^1x1) -> (B)") + { + std::string_view data = R"( +let t:(R^1x1), t = [[1.2]]; +let b:(B), b = t; +)"; + + std::string error_message = "undefined affectation type: (B) = (R^1x1)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(R^2x2) -> (B)") + { + std::string_view data = R"( +let t:(R^2x2), t = [[1.2, 3],[3,4]]; +let b:(B), b = t; +)"; + + std::string error_message = "undefined affectation type: (B) = (R^2x2)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(R^3x3) -> (B)") + { + std::string_view data = R"( +let t:(R^3x3), t = [[1.2, 3, 1],[1,2,3],[4,2,1]]; +let b:(B), b = t; +)"; + + std::string error_message = "undefined affectation type: (B) = (R^3x3)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(string) -> (B)") + { + std::string_view data = R"( +let t:(string), t = "foo"; +let b:(B), b = t; +)"; + + std::string error_message = "undefined affectation type: (B) = (string)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(builtin_t) -> (B)") + { + std::string_view data = R"( +let bt:(builtin_t), bt = a; +let v :(B), v = bt; +)"; + + std::string error_message = "undefined affectation type: (B) = (builtin_t)"; + + CHECK_AST_WITH_BUILTIN_THROWS_WITH(data, error_message); + } + } + + SECTION("-> (N)") + { + SECTION("(R) -> (N)") + { + std::string_view data = R"( +let t:(R), t = 1.2; +let b:(N), b = t; +)"; + + std::string error_message = "undefined affectation type: (N) = (R)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(R^1) -> (N)") + { + std::string_view data = R"( +let t:(R^1), t = [1.2]; +let b:(N), b = t; +)"; + + std::string error_message = "undefined affectation type: (N) = (R^1)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(R^2) -> (N)") + { + std::string_view data = R"( +let t:(R^2), t = [1.2, 3]; +let b:(N), b = t; +)"; + + std::string error_message = "undefined affectation type: (N) = (R^2)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(R^3) -> (N)") + { + std::string_view data = R"( +let t:(R^3), t = [1.2, 3, 1]; +let b:(N), b = t; +)"; + + std::string error_message = "undefined affectation type: (N) = (R^3)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(R^1x1) -> (N)") + { + std::string_view data = R"( +let t:(R^1x1), t = [[1.2]]; +let b:(N), b = t; +)"; + + std::string error_message = "undefined affectation type: (N) = (R^1x1)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(R^2x2) -> (N)") + { + std::string_view data = R"( +let t:(R^2x2), t = [[1.2, 3],[3,4]]; +let b:(N), b = t; +)"; + + std::string error_message = "undefined affectation type: (N) = (R^2x2)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(R^3x3) -> (N)") + { + std::string_view data = R"( +let t:(R^3x3), t = [[1.2, 3, 1],[1,2,3],[4,2,1]]; +let b:(N), b = t; +)"; + + std::string error_message = "undefined affectation type: (N) = (R^3x3)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(string) -> (N)") + { + std::string_view data = R"( +let t:(string), t = "foo"; +let b:(N), b = t; +)"; + + std::string error_message = "undefined affectation type: (N) = (string)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(builtin_t) -> (N)") + { + std::string_view data = R"( +let bt:(builtin_t), bt = a; +let v :(N), v = bt; +)"; + + std::string error_message = "undefined affectation type: (N) = (builtin_t)"; + + CHECK_AST_WITH_BUILTIN_THROWS_WITH(data, error_message); + } + } + + SECTION("-> (Z)") + { + SECTION("(R) -> (Z)") + { + std::string_view data = R"( +let t:(R), t = 1.2; +let b:(Z), b = t; +)"; + + std::string error_message = "undefined affectation type: (Z) = (R)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(R^1) -> (Z)") + { + std::string_view data = R"( +let t:(R^1), t = [1.2]; +let b:(Z), b = t; +)"; + + std::string error_message = "undefined affectation type: (Z) = (R^1)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(R^2) -> (Z)") + { + std::string_view data = R"( +let t:(R^2), t = [1.2, 3]; +let b:(Z), b = t; +)"; + + std::string error_message = "undefined affectation type: (Z) = (R^2)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(R^3) -> (Z)") + { + std::string_view data = R"( +let t:(R^3), t = [1.2, 3, 1]; +let b:(Z), b = t; +)"; + + std::string error_message = "undefined affectation type: (Z) = (R^3)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(R^1x1) -> (Z)") + { + std::string_view data = R"( +let t:(R^1x1), t = [[1.2]]; +let b:(Z), b = t; +)"; + + std::string error_message = "undefined affectation type: (Z) = (R^1x1)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(R^2x2) -> (Z)") + { + std::string_view data = R"( +let t:(R^2x2), t = [[1.2, 3],[3,4]]; +let b:(Z), b = t; +)"; + + std::string error_message = "undefined affectation type: (Z) = (R^2x2)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(R^3x3) -> (Z)") + { + std::string_view data = R"( +let t:(R^3x3), t = [[1.2, 3, 1],[1,2,3],[4,2,1]]; +let b:(Z), b = t; +)"; + + std::string error_message = "undefined affectation type: (Z) = (R^3x3)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(string) -> (Z)") + { + std::string_view data = R"( +let t:(string), t = "foo"; +let b:(Z), b = t; +)"; + + std::string error_message = "undefined affectation type: (Z) = (string)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(builtin_t) -> (Z)") + { + std::string_view data = R"( +let bt:(builtin_t), bt = a; +let v :(Z), v = bt; +)"; + + std::string error_message = "undefined affectation type: (Z) = (builtin_t)"; + + CHECK_AST_WITH_BUILTIN_THROWS_WITH(data, error_message); + } + } + + SECTION("-> (R)") + { + SECTION("(R^1) -> (R)") + { + std::string_view data = R"( +let t:(R^1), t = [1.2]; +let b:(R), b = t; +)"; + + std::string error_message = "undefined affectation type: (R) = (R^1)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(R^2) -> (R)") + { + std::string_view data = R"( +let t:(R^2), t = [1.2, 3]; +let b:(R), b = t; +)"; + + std::string error_message = "undefined affectation type: (R) = (R^2)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(R^3) -> (R)") + { + std::string_view data = R"( +let t:(R^3), t = [1.2, 3, 1]; +let b:(R), b = t; +)"; + + std::string error_message = "undefined affectation type: (R) = (R^3)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(R^1x1) -> (R)") + { + std::string_view data = R"( +let t:(R^1x1), t = [[1.2]]; +let b:(R), b = t; +)"; + + std::string error_message = "undefined affectation type: (R) = (R^1x1)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(R^2x2) -> (R)") + { + std::string_view data = R"( +let t:(R^2x2), t = [[1.2, 3],[3,4]]; +let b:(R), b = t; +)"; + + std::string error_message = "undefined affectation type: (R) = (R^2x2)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(R^3x3) -> (R)") + { + std::string_view data = R"( +let t:(R^3x3), t = [[1.2, 3, 1],[1,2,3],[4,2,1]]; +let b:(R), b = t; +)"; + + std::string error_message = "undefined affectation type: (R) = (R^3x3)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(string) -> (R)") + { + std::string_view data = R"( +let t:(string), t = "foo"; +let b:(R), b = t; +)"; + + std::string error_message = "undefined affectation type: (R) = (string)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(builtin_t) -> (R)") + { + std::string_view data = R"( +let bt:(builtin_t), bt = a; +let v :(R), v = bt; +)"; + + std::string error_message = "undefined affectation type: (R) = (builtin_t)"; + + CHECK_AST_WITH_BUILTIN_THROWS_WITH(data, error_message); + } + } + + SECTION("-> (R^1)") + { + SECTION("(R^2) -> (R^1)") + { + std::string_view data = R"( +let t:(R^2), t = [1.2, 3]; +let b:(R^1), b = t; +)"; + + std::string error_message = "undefined affectation type: (R^1) = (R^2)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(R^3) -> (R^1)") + { + std::string_view data = R"( +let t:(R^3), t = [1.2, 3, 1]; +let b:(R^1), b = t; +)"; + + std::string error_message = "undefined affectation type: (R^1) = (R^3)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(R^1x1) -> (R^1)") + { + std::string_view data = R"( +let t:(R^1x1), t = [[1.2]]; +let b:(R^1), b = t; +)"; + + std::string error_message = "undefined affectation type: (R^1) = (R^1x1)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(R^2x2) -> (R^1)") + { + std::string_view data = R"( +let t:(R^2x2), t = [[1.2, 3],[3,4]]; +let b:(R^1), b = t; +)"; + + std::string error_message = "undefined affectation type: (R^1) = (R^2x2)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(R^3x3) -> (R^1)") + { + std::string_view data = R"( +let t:(R^3x3), t = [[1.2, 3, 1],[1,2,3],[4,2,1]]; +let b:(R^1), b = t; +)"; + + std::string error_message = "undefined affectation type: (R^1) = (R^3x3)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(string) -> (R^1)") + { + std::string_view data = R"( +let t:(string), t = "foo"; +let b:(R^1), b = t; +)"; + + std::string error_message = "undefined affectation type: (R^1) = (string)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(builtin_t) -> (R^1)") + { + std::string_view data = R"( +let bt:(builtin_t), bt = a; +let v :(R^1), v = bt; +)"; + + std::string error_message = "undefined affectation type: (R^1) = (builtin_t)"; + + CHECK_AST_WITH_BUILTIN_THROWS_WITH(data, error_message); + } + } + + SECTION("-> (R^2)") + { + SECTION("(N) -> (R^2)") + { + std::string_view data = R"( +let n:(N), n = 1; +let b:(R^2), b = n; +)"; + + std::string error_message = "undefined affectation type: (R^2) = (N)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(R) -> (R^2)") + { + std::string_view data = R"( +let t:(R), t = 1.2; +let b:(R^2), b = t; +)"; + + std::string error_message = "undefined affectation type: (R^2) = (R)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(R^1) -> (R^2)") + { + std::string_view data = R"( +let t:(R^1), t = [1.2]; +let b:(R^2), b = t; +)"; + + std::string error_message = "undefined affectation type: (R^2) = (R^1)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(R^3) -> (R^2)") + { + std::string_view data = R"( +let t:(R^3), t = [1.2, 3, 1]; +let b:(R^2), b = t; +)"; + + std::string error_message = "undefined affectation type: (R^2) = (R^3)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(R^1x1) -> (R^2)") + { + std::string_view data = R"( +let t:(R^1x1), t = [[1.2]]; +let b:(R^2), b = t; +)"; + + std::string error_message = "undefined affectation type: (R^2) = (R^1x1)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(R^2x2) -> (R^2)") + { + std::string_view data = R"( +let t:(R^2x2), t = [[1.2, 3],[3,4]]; +let b:(R^2), b = t; +)"; + + std::string error_message = "undefined affectation type: (R^2) = (R^2x2)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(R^3x3) -> (R^2)") + { + std::string_view data = R"( +let t:(R^3x3), t = [[1.2, 3, 1],[1,2,3],[4,2,1]]; +let b:(R^2), b = t; +)"; + + std::string error_message = "undefined affectation type: (R^2) = (R^3x3)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(string) -> (R^2)") + { + std::string_view data = R"( +let t:(string), t = "foo"; +let b:(R^2), b = t; +)"; + + std::string error_message = "undefined affectation type: (R^2) = (string)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(builtin_t) -> (R^2)") + { + std::string_view data = R"( +let bt:(builtin_t), bt = a; +let v : (R^2), v = bt; +)"; + + std::string error_message = "undefined affectation type: (R^2) = (builtin_t)"; + + CHECK_AST_WITH_BUILTIN_THROWS_WITH(data, error_message); + } + } + + SECTION("-> (R^3)") + { + SECTION("(N) -> (R^3)") + { + std::string_view data = R"( +let n:(N), n = 1; +let b:(R^3), b = n; +)"; + + std::string error_message = "undefined affectation type: (R^3) = (N)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(R) -> (R^3)") + { + std::string_view data = R"( +let t:(R), t = 1.2; +let b:(R^3), b = t; +)"; + + std::string error_message = "undefined affectation type: (R^3) = (R)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(R^1) -> (R^3)") + { + std::string_view data = R"( +let t:(R^1), t = [1.2]; +let b:(R^3), b = t; +)"; + + std::string error_message = "undefined affectation type: (R^3) = (R^1)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(R^2) -> (R^3)") + { + std::string_view data = R"( +let t:(R^2), t = [1.2, 3]; +let b:(R^3), b = t; +)"; + + std::string error_message = "undefined affectation type: (R^3) = (R^2)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(R^1x1) -> (R^3)") + { + std::string_view data = R"( +let t:(R^1x1), t = [[1.2]]; +let b:(R^3), b = t; +)"; + + std::string error_message = "undefined affectation type: (R^3) = (R^1x1)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(R^2x2) -> (R^3)") + { + std::string_view data = R"( +let t:(R^2x2), t = [[1.2, 3],[3,4]]; +let b:(R^3), b = t; +)"; + + std::string error_message = "undefined affectation type: (R^3) = (R^2x2)"; - SECTION("R /= R") - { - std::string_view data = R"( -let x : R, x=1; x/=2.3; + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(R^3x3) -> (R^3)") + { + std::string_view data = R"( +let t:(R^3x3), t = [[1.2, 3, 1],[1,2,3],[4,2,1]]; +let b:(R^3), b = t; )"; - std::string_view result = R"( -(root:ASTNodeListProcessor) - +-(language::eq_op:AffectationProcessor<language::eq_op, double, long>) - | +-(language::name:x:NameProcessor) - | `-(language::integer:1:ValueProcessor) - `-(language::divideeq_op:AffectationProcessor<language::divideeq_op, double, double>) - +-(language::name:x:NameProcessor) - `-(language::real:2.3:ValueProcessor) + std::string error_message = "undefined affectation type: (R^3) = (R^3x3)"; + + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(string) -> (R^3)") + { + std::string_view data = R"( +let t:(string), t = "foo"; +let b:(R^3), b = t; )"; - CHECK_AST(data, result); - } - } + std::string error_message = "undefined affectation type: (R^3) = (string)"; - SECTION("Errors") - { - SECTION("Invalid affectation operator") - { - auto ast = std::make_unique<ASTNode>(); - ast->m_data_type = ASTNodeDataType::build<ASTNodeDataType::void_t>(); - { - auto child_0 = std::make_unique<ASTNode>(); - child_0->m_data_type = ASTNodeDataType::build<ASTNodeDataType::bool_t>(); - auto child_1 = std::make_unique<ASTNode>(); - child_1->m_data_type = ASTNodeDataType::build<ASTNodeDataType::bool_t>(); - ast->children.emplace_back(std::move(child_0)); - ast->children.emplace_back(std::move(child_1)); - } - REQUIRE_THROWS_WITH(ASTNodeAffectationExpressionBuilder{*ast}, - "unexpected error: undefined affectation operator"); - } + CHECK_AST_THROWS_WITH(data, error_message); + } - SECTION("Invalid string rhs") - { - auto ast = std::make_unique<ASTNode>(); - ast->set_type<language::eq_op>(); + SECTION("(builtin_t) -> (R^3)") + { + std::string_view data = R"( +let bt:(builtin_t), bt = a; +let v :(R^3), v = bt; +)"; - ast->children.emplace_back(std::make_unique<ASTNode>()); - ast->children[0]->m_data_type = ASTNodeDataType::build<ASTNodeDataType::string_t>(); - ast->children.emplace_back(std::make_unique<ASTNode>()); - REQUIRE_THROWS_WITH(ASTNodeAffectationExpressionBuilder{*ast}, "undefined affectation type: string = undefined"); - } + std::string error_message = "undefined affectation type: (R^3) = (builtin_t)"; - SECTION("Invalid string affectation operator") - { - SECTION("string -= string") - { - std::string_view data = R"( -let s : string, s="foo"; s-="bar"; + CHECK_AST_WITH_BUILTIN_THROWS_WITH(data, error_message); + } + } + + SECTION("-> (R^1x1)") + { + SECTION("(R^1) -> (R^1x1)") + { + std::string_view data = R"( +let t:(R^1), t = [1.2]; +let b:(R^1x1), b = t; )"; - std::string error_message = "undefined affectation type: string -= string"; + std::string error_message = "undefined affectation type: (R^1x1) = (R^1)"; - CHECK_AST_THROWS_WITH(data, error_message); - } + CHECK_AST_THROWS_WITH(data, error_message); + } - SECTION("string *= Z") - { - std::string_view data = R"( -let s : string, s="foo"; s*=2; + SECTION("(R^2) -> (R^1x1)") + { + std::string_view data = R"( +let t:(R^2), t = [1.2, 3]; +let b:(R^1x1), b = t; )"; - std::string error_message = "undefined affectation type: string *= Z"; + std::string error_message = "undefined affectation type: (R^1x1) = (R^2)"; - CHECK_AST_THROWS_WITH(data, error_message); - } + CHECK_AST_THROWS_WITH(data, error_message); + } - SECTION("string /= string") - { - std::string_view data = R"( - let s : string, s="foo"; s/="bar"; + SECTION("(R^3) -> (R^1x1)") + { + std::string_view data = R"( +let t:(R^3), t = [1.2, 3, 1]; +let b:(R^1x1), b = t; )"; - std::string error_message = "undefined affectation type: string /= string"; + std::string error_message = "undefined affectation type: (R^1x1) = (R^3)"; - CHECK_AST_THROWS_WITH(data, error_message); - } - } + CHECK_AST_THROWS_WITH(data, error_message); + } - SECTION("type_id operator") - { - std::string_view data = R"( - let s :builtin_t, s = a; s *= b; + SECTION("(R^2x2) -> (R^1x1)") + { + std::string_view data = R"( +let t:(R^2x2), t = [[1.2, 3],[3,4]]; +let b:(R^1x1), b = t; )"; - std::string error_message = "undefined affectation type: builtin_t *= builtin_t"; + std::string error_message = "undefined affectation type: (R^1x1) = (R^2x2)"; - CHECK_AST_WITH_BUILTIN_THROWS_WITH(data, error_message); - } + CHECK_AST_THROWS_WITH(data, error_message); + } - SECTION("Invalid tuple operator") - { - std::string_view data = R"( - let s :(R), s=(1,2,3); s *= 4; + SECTION("(R^3x3) -> (R^1x1)") + { + std::string_view data = R"( +let t:(R^3x3), t = [[1.2, 3, 1],[1,2,3],[4,2,1]]; +let b:(R^1x1), b = t; )"; - std::string error_message = "undefined affectation type: (R) *= Z"; + std::string error_message = "undefined affectation type: (R^1x1) = (R^3x3)"; - CHECK_AST_THROWS_WITH(data, error_message); - } + CHECK_AST_THROWS_WITH(data, error_message); + } - SECTION("Invalid tuple operator 2") - { - std::string_view data = R"( - let s : (builtin_t), s =(a,b); s *= b; + SECTION("(string) -> (R^1x1)") + { + std::string_view data = R"( +let t:(string), t = "foo"; +let b:(R^1x1), b = t; )"; - std::string error_message = "undefined affectation type: (builtin_t) *= builtin_t"; + std::string error_message = "undefined affectation type: (R^1x1) = (string)"; - CHECK_AST_WITH_BUILTIN_THROWS_WITH(data, error_message); - } + CHECK_AST_THROWS_WITH(data, error_message); + } - SECTION("Invalid R^n -> R^m affectation") - { - SECTION("R^3 <- R^1") - { - std::string_view data = R"( -let x : R^3; let y : R^1; x = y; + SECTION("(builtin_t) -> (R^1x1)") + { + std::string_view data = R"( +let bt:(builtin_t), bt = a; +let v :(R^1x1), v = bt; )"; - std::string error_message = "undefined affectation type: R^3 = R^1"; + std::string error_message = "undefined affectation type: (R^1x1) = (builtin_t)"; - CHECK_AST_THROWS_WITH(data, error_message); - } + CHECK_AST_WITH_BUILTIN_THROWS_WITH(data, error_message); + } + } - SECTION("R^3 <- R^2") - { - std::string_view data = R"( -let x : R^3; let y : R^2; x = y; + SECTION("-> (R^2x2)") + { + SECTION("(N) -> (R^2x2)") + { + std::string_view data = R"( +let n:(N), n = 1; +let b:(R^2x2), b = n; )"; - std::string error_message = "undefined affectation type: R^3 = R^2"; + std::string error_message = "undefined affectation type: (R^2x2) = (N)"; - CHECK_AST_THROWS_WITH(data, error_message); - } + CHECK_AST_THROWS_WITH(data, error_message); + } - SECTION("R^2 <- R^1") - { - std::string_view data = R"( -let x : R^2; let y : R^1; x = y; + SECTION("(R) -> (R^2x2)") + { + std::string_view data = R"( +let t:(R), t = 1.2; +let b:(R^2x2), b = t; )"; - std::string error_message = "undefined affectation type: R^2 = R^1"; + std::string error_message = "undefined affectation type: (R^2x2) = (R)"; - CHECK_AST_THROWS_WITH(data, error_message); - } + CHECK_AST_THROWS_WITH(data, error_message); + } - SECTION("R^2 <- R^3") - { - std::string_view data = R"( -let x : R^2; let y : R^3; x = y; + SECTION("(R^1) -> (R^2x2)") + { + std::string_view data = R"( +let t:(R^1), t = [1.2]; +let b:(R^2x2), b = t; )"; - std::string error_message = "undefined affectation type: R^2 = R^3"; + std::string error_message = "undefined affectation type: (R^2x2) = (R^1)"; - CHECK_AST_THROWS_WITH(data, error_message); - } + CHECK_AST_THROWS_WITH(data, error_message); + } - SECTION("R^1 <- R^2") - { - std::string_view data = R"( -let x : R^1; let y : R^2; x = y; + SECTION("(R^2) -> (R^2x2)") + { + std::string_view data = R"( +let t:(R^2), t = [1.2, 3]; +let b:(R^2x2), b = t; )"; - std::string error_message = "undefined affectation type: R^1 = R^2"; + std::string error_message = "undefined affectation type: (R^2x2) = (R^2)"; - CHECK_AST_THROWS_WITH(data, error_message); - } + CHECK_AST_THROWS_WITH(data, error_message); + } - SECTION("R^1 <- R^3") - { - std::string_view data = R"( -let x : R^1; let y : R^3; x = y; + SECTION("(R^3) -> (R^2x2)") + { + std::string_view data = R"( +let t:(R^3), t = [1.2, 3, 1]; +let b:(R^2x2), b = t; )"; - std::string error_message = "undefined affectation type: R^1 = R^3"; + std::string error_message = "undefined affectation type: (R^2x2) = (R^3)"; - CHECK_AST_THROWS_WITH(data, error_message); - } - } + CHECK_AST_THROWS_WITH(data, error_message); + } - SECTION("Invalid Z -> R^m affectation [non-zero]") - { - SECTION("R^3 <- Z") - { - std::string_view data = R"( -let x : R^3, x = 3; + SECTION("(R^1x1) -> (R^2x2)") + { + std::string_view data = R"( +let t:(R^1x1), t = [[1.2]]; +let b:(R^2x2), b = t; )"; - std::string error_message = "invalid integral value (0 is the solely valid value)"; + std::string error_message = "undefined affectation type: (R^2x2) = (R^1x1)"; - CHECK_AST_THROWS_WITH(data, error_message); - } + CHECK_AST_THROWS_WITH(data, error_message); + } - SECTION("R^2 <- Z") - { - std::string_view data = R"( -let x : R^2, x = 2; + SECTION("(R^3x3) -> (R^2x2)") + { + std::string_view data = R"( +let t:(R^3x3), t = [[1.2, 3, 1],[1,2,3],[4,2,1]]; +let b:(R^2x2), b = t; )"; - std::string error_message = "invalid integral value (0 is the solely valid value)"; + std::string error_message = "undefined affectation type: (R^2x2) = (R^3x3)"; - CHECK_AST_THROWS_WITH(data, error_message); - } - } + CHECK_AST_THROWS_WITH(data, error_message); + } - SECTION("Invalid R^d -> R^d affectation operator") - { - SECTION("R^3 <- R^3") - { - std::string_view data = R"( -let x : R^3; let y : R^3; x /= y; + SECTION("(string) -> (R^2x2)") + { + std::string_view data = R"( +let t:(string), t = "foo"; +let b:(R^2x2), b = t; )"; - std::string error_message = "undefined affectation type: R^3 /= R^3"; + std::string error_message = "undefined affectation type: (R^2x2) = (string)"; - CHECK_AST_THROWS_WITH(data, error_message); - } + CHECK_AST_THROWS_WITH(data, error_message); + } - SECTION("R^2 <- R^2") - { - std::string_view data = R"( -let x : R^2; let y : R^2; x /= y; + SECTION("(builtin_t) -> (R^2x2)") + { + std::string_view data = R"( +let bt:(builtin_t), bt = a; +let v :(R^2x2), v = bt; )"; - std::string error_message = "undefined affectation type: R^2 /= R^2"; + std::string error_message = "undefined affectation type: (R^2x2) = (builtin_t)"; - CHECK_AST_THROWS_WITH(data, error_message); - } + CHECK_AST_WITH_BUILTIN_THROWS_WITH(data, error_message); + } + } - SECTION("R^1 <- R^1") - { - std::string_view data = R"( -let x : R^1; let y : R^1; x /= y; + SECTION("-> (R^3x3)") + { + SECTION("(N) -> (R^3x3)") + { + std::string_view data = R"( +let n:(N), n = 1; +let b:(R^3x3), b = n; )"; - std::string error_message = "undefined affectation type: R^1 /= R^1"; + std::string error_message = "undefined affectation type: (R^3x3) = (N)"; - CHECK_AST_THROWS_WITH(data, error_message); - } - } + CHECK_AST_THROWS_WITH(data, error_message); + } - SECTION("Invalid R^d -> R^d *= operand") - { - SECTION("R^3 <- R^3") - { - std::string_view data = R"( -let x : R^3; let y : R^3; x *= y; + SECTION("(R) -> (R^3x3)") + { + std::string_view data = R"( +let t:(R), t = 1.2; +let b:(R^3x3), b = t; )"; - std::string error_message = "undefined affectation type: R^3 *= R^3"; + std::string error_message = "undefined affectation type: (R^3x3) = (R)"; - CHECK_AST_THROWS_WITH(data, error_message); - } + CHECK_AST_THROWS_WITH(data, error_message); + } - SECTION("R^2 <- R^2") - { - std::string_view data = R"( -let x : R^2; let y : R^2; x *= y; + SECTION("(R^1) -> (R^3x3)") + { + std::string_view data = R"( +let t:(R^1), t = [1.2]; +let b:(R^3x3), b = t; )"; - std::string error_message = "undefined affectation type: R^2 *= R^2"; + std::string error_message = "undefined affectation type: (R^3x3) = (R^1)"; - CHECK_AST_THROWS_WITH(data, error_message); - } + CHECK_AST_THROWS_WITH(data, error_message); + } - SECTION("R^1 <- R^1") - { - std::string_view data = R"( -let x : R^1; let y : R^1; x *= y; + SECTION("(R^2) -> (R^3x3)") + { + std::string_view data = R"( +let t:(R^2), t = [1.2, 3]; +let b:(R^3x3), b = t; )"; - std::string error_message = "undefined affectation type: R^1 *= R^1"; + std::string error_message = "undefined affectation type: (R^3x3) = (R^2)"; - CHECK_AST_THROWS_WITH(data, error_message); - } - } + CHECK_AST_THROWS_WITH(data, error_message); + } - SECTION("incorrect declarative/definition number of symbols") - { - std::string_view data = R"( -let (x,y,z):R*R*R, (x,y) = (2,3); + SECTION("(R^3) -> (R^3x3)") + { + std::string_view data = R"( +let t:(R^3), t = [1.2, 3, 1]; +let b:(R^3x3), b = t; )"; - TAO_PEGTL_NAMESPACE::string_input input{data, "test.pgs"}; - auto ast = ASTBuilder::build(input); - OperatorRepository::instance().reset(); - ASTModulesImporter{*ast}; + std::string error_message = "undefined affectation type: (R^3x3) = (R^3)"; - ASTSymbolTableBuilder{*ast}; - REQUIRE_THROWS_WITH(ASTSymbolInitializationChecker{*ast}, - std::string{"invalid number of definition identifiers, expecting 3 found 2"}); - } + CHECK_AST_THROWS_WITH(data, error_message); + } - SECTION("incorrect identifier/expression number of symbols") - { - std::string_view data = R"( -let y:R; -let x:R, (x,y) = (2,3); + SECTION("(R^1x1) -> (R^3x3)") + { + std::string_view data = R"( +let t:(R^1x1), t = [[1.2]]; +let b:(R^3x3), b = t; )"; - TAO_PEGTL_NAMESPACE::string_input input{data, "test.pgs"}; - auto ast = ASTBuilder::build(input); - OperatorRepository::instance().reset(); - ASTModulesImporter{*ast}; + std::string error_message = "undefined affectation type: (R^3x3) = (R^1x1)"; - ASTSymbolTableBuilder{*ast}; - REQUIRE_THROWS_WITH(ASTSymbolInitializationChecker{*ast}, - std::string{"unexpected variable list, expecting one identifier"}); - } + CHECK_AST_THROWS_WITH(data, error_message); + } - SECTION("incorrect definition variable identifier") - { - std::string_view data = R"( -let y:R; -let x:R, y = 3; + SECTION("(R^2x2) -> (R^3x3)") + { + std::string_view data = R"( +let t:(R^2x2), t = [[1.2, 3],[3,4]]; +let b:(R^3x3), b = t; )"; - TAO_PEGTL_NAMESPACE::string_input input{data, "test.pgs"}; - auto ast = ASTBuilder::build(input); - OperatorRepository::instance().reset(); - ASTModulesImporter{*ast}; + std::string error_message = "undefined affectation type: (R^3x3) = (R^2x2)"; - ASTSymbolTableBuilder{*ast}; - REQUIRE_THROWS_WITH(ASTSymbolInitializationChecker{*ast}, std::string{"invalid identifier, expecting 'x'"}); - } + CHECK_AST_THROWS_WITH(data, error_message); + } - SECTION("invalid definition variable identifier order") - { - std::string_view data = R"( -let (x,y):R, (y,x) = (3,2); + SECTION("(string) -> (R^3x3)") + { + std::string_view data = R"( +let t:(string), t = "foo"; +let b:(R^3x3), b = t; )"; - TAO_PEGTL_NAMESPACE::string_input input{data, "test.pgs"}; - auto ast = ASTBuilder::build(input); - OperatorRepository::instance().reset(); - ASTModulesImporter{*ast}; + std::string error_message = "undefined affectation type: (R^3x3) = (string)"; - ASTSymbolTableBuilder{*ast}; - REQUIRE_THROWS_WITH(ASTSymbolInitializationChecker{*ast}, std::string{"invalid identifier, expecting 'x'"}); + CHECK_AST_THROWS_WITH(data, error_message); + } + + SECTION("(builtin_t) -> (R^3)") + { + std::string_view data = R"( +let bt:(builtin_t), bt = a; +let v :(R^3x3), v = bt; +)"; + + std::string error_message = "undefined affectation type: (R^3x3) = (builtin_t)"; + + CHECK_AST_WITH_BUILTIN_THROWS_WITH(data, error_message); + } + } + } + } } } } diff --git a/tests/test_AffectationProcessor.cpp b/tests/test_AffectationProcessor.cpp index 4314b3b96165e200a528378a2e1053be27346e87..71670fd5d75b4ae7d20d8ece4b3ef980165cd382 100644 --- a/tests/test_AffectationProcessor.cpp +++ b/tests/test_AffectationProcessor.cpp @@ -10,7 +10,13 @@ #include <language/ast/ASTNodeTypeCleaner.hpp> #include <language/ast/ASTSymbolTableBuilder.hpp> #include <language/utils/ASTPrinter.hpp> +#include <language/utils/DataHandler.hpp> +#include <language/utils/TypeDescriptor.hpp> #include <utils/Demangle.hpp> +#include <utils/Stringify.hpp> + +#include <FixturesForBuiltinT.hpp> +#include <language/utils/BasicAffectationRegistrerFor.hpp> #include <pegtl/string_input.hpp> @@ -46,6 +52,66 @@ REQUIRE(value == expected_value); \ } +#define CHECK_BUILTIN_AFFECTATION_RESULT(data, variable_name, expected_value) \ + { \ + TAO_PEGTL_NAMESPACE::string_input input{data, "test.pgs"}; \ + auto ast = ASTBuilder::build(input); \ + \ + ASTModulesImporter{*ast}; \ + \ + BasicAffectationRegisterFor<EmbeddedData>{ASTNodeDataType::build<ASTNodeDataType::type_id_t>("builtin_t")}; \ + \ + SymbolTable& symbol_table = *ast->m_symbol_table; \ + auto [i_symbol, success] = symbol_table.add(builtin_data_type.nameOfTypeId(), ast->begin()); \ + if (not success) { \ + throw UnexpectedError("cannot add '" + builtin_data_type.nameOfTypeId() + "' type for testing"); \ + } \ + \ + i_symbol->attributes().setDataType(ASTNodeDataType::build<ASTNodeDataType::type_name_id_t>()); \ + i_symbol->attributes().setIsInitialized(); \ + i_symbol->attributes().value() = symbol_table.typeEmbedderTable().size(); \ + symbol_table.typeEmbedderTable().add(std::make_shared<TypeDescriptor>(builtin_data_type.nameOfTypeId())); \ + \ + auto [i_symbol_bt_a, success_bt_a] = symbol_table.add("bt_a", ast->begin()); \ + if (not success_bt_a) { \ + throw UnexpectedError("cannot add 'bt_a' of type builtin_t for testing"); \ + } \ + i_symbol_bt_a->attributes().setDataType(ast_node_data_type_from<std::shared_ptr<const double>>); \ + i_symbol_bt_a->attributes().setIsInitialized(); \ + i_symbol_bt_a->attributes().value() = \ + EmbeddedData(std::make_shared<DataHandler<const double>>(std::make_shared<double>(3.2))); \ + \ + auto [i_symbol_bt_b, success_bt_b] = symbol_table.add("bt_b", ast->begin()); \ + if (not success_bt_b) { \ + throw UnexpectedError("cannot add 'bt_b' of type builtin_t for testing"); \ + } \ + i_symbol_bt_b->attributes().setDataType(ast_node_data_type_from<std::shared_ptr<const double>>); \ + i_symbol_bt_b->attributes().setIsInitialized(); \ + i_symbol_bt_b->attributes().value() = \ + EmbeddedData(std::make_shared<DataHandler<const double>>(std::make_shared<double>(5.3))); \ + \ + ASTSymbolTableBuilder{*ast}; \ + ASTNodeDataTypeBuilder{*ast}; \ + \ + ASTNodeDeclarationToAffectationConverter{*ast}; \ + ASTNodeTypeCleaner<language::var_declaration>{*ast}; \ + \ + ASTNodeExpressionBuilder{*ast}; \ + ExecutionPolicy exec_policy; \ + ast->execute(exec_policy); \ + \ + using namespace TAO_PEGTL_NAMESPACE; \ + position use_position{internal::iterator{"fixture"}, "fixture"}; \ + use_position.byte = 10000; \ + auto [symbol, found] = symbol_table.find(variable_name, use_position); \ + \ + auto attributes = symbol->attributes(); \ + auto embedded_value = std::get<EmbeddedData>(attributes.value()); \ + \ + double value = *dynamic_cast<const DataHandler<const double>&>(embedded_value.get()).data_ptr(); \ + REQUIRE(value == expected); \ + } + #define CHECK_AFFECTATION_THROWS_WITH(data, error_message) \ { \ TAO_PEGTL_NAMESPACE::string_input input{data, "test.pgs"}; \ @@ -93,91 +159,396 @@ TEST_CASE("AffectationProcessor", "[language]") { SECTION("Affectations") { - SECTION("B") + SECTION("from value") { - CHECK_AFFECTATION_RESULT("let b : B; b = true;", "b", true); - } + SECTION("-> B") + { + CHECK_AFFECTATION_RESULT("let b : B; b = true;", "b", true); + } - SECTION("N") - { - CHECK_AFFECTATION_RESULT("let n : N, n = 1;", "n", 1ul); - CHECK_AFFECTATION_RESULT("let m : N, m = 2; let n : N, n = m;", "n", 2ul); - CHECK_AFFECTATION_RESULT("let n : N, n = true;", "n", 1ul); - CHECK_AFFECTATION_RESULT("let n : N, n = false;", "n", 0ul); - } + SECTION("-> N") + { + CHECK_AFFECTATION_RESULT("let n : N, n = 1;", "n", 1ul); + CHECK_AFFECTATION_RESULT("let m : N, m = 2; let n : N, n = m;", "n", 2ul); + CHECK_AFFECTATION_RESULT("let n : N, n = true;", "n", 1ul); + CHECK_AFFECTATION_RESULT("let n : N, n = false;", "n", 0ul); + } - SECTION("Z") - { - CHECK_AFFECTATION_RESULT("let z : Z, z = -1;", "z", -1l); - CHECK_AFFECTATION_RESULT("let z : Z, z = true;", "z", 1l); - CHECK_AFFECTATION_RESULT("let z : Z, z = false;", "z", 0l); - } + SECTION("-> Z") + { + CHECK_AFFECTATION_RESULT("let z : Z, z = -1;", "z", -1l); + CHECK_AFFECTATION_RESULT("let z : Z, z = true;", "z", 1l); + CHECK_AFFECTATION_RESULT("let z : Z, z = false;", "z", 0l); + } - SECTION("R") - { - CHECK_AFFECTATION_RESULT("let r : R, r = -1;", "r", double{-1}); - CHECK_AFFECTATION_RESULT("let r : R, r = true;", "r", double{1}); - CHECK_AFFECTATION_RESULT("let r : R, r = false;", "r", double{0}); - CHECK_AFFECTATION_RESULT("let r : R, r = -2.3;", "r", double{-2.3}); - } + SECTION("-> R") + { + CHECK_AFFECTATION_RESULT("let r : R, r = -1;", "r", double{-1}); + CHECK_AFFECTATION_RESULT("let r : R, r = true;", "r", double{1}); + CHECK_AFFECTATION_RESULT("let r : R, r = false;", "r", double{0}); + CHECK_AFFECTATION_RESULT("let r : R, r = -2.3;", "r", double{-2.3}); + } - SECTION("R^1") - { - 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 = [-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^1") + { + 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 = [-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 = 0;", "x", (TinyVector<2>{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 = 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 = 0;", "x", (TinyVector<3>{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 = 0;", "x", (TinyVector<3>{zero})); + } - SECTION("R^1x1") - { - 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 = [[-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^1x1") + { + 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 = [[-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", - (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;", "x", (TinyMatrix<2>{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", + (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;", "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", + (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", + (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})); + } + + SECTION("-> string") + { + CHECK_AFFECTATION_RESULT("let x : string, x = true;", "x", (stringify(true))); + CHECK_AFFECTATION_RESULT("let n:N, n = 3; let x : string, x = n;", "x", (stringify(3ul))); + CHECK_AFFECTATION_RESULT("let x : string, x = -2;", "x", (stringify(-2l))); + CHECK_AFFECTATION_RESULT("let x : string, x = 1.7;", "x", (stringify(double{1.7}))); + + CHECK_AFFECTATION_RESULT("let x : string, x = [1.7];", "x", (stringify(TinyVector<1>{1.7}))); + CHECK_AFFECTATION_RESULT("let x : string, x = [1.7, 2];", "x", (stringify(TinyVector<2>{1.7, 2}))); + CHECK_AFFECTATION_RESULT("let x : string, x = [1.7, 5, 2];", "x", (stringify(TinyVector<3>{1.7, 5, 2}))); + + CHECK_AFFECTATION_RESULT("let x : string, x = [[1.7]];", "x", (stringify(TinyMatrix<1>{1.7}))); + CHECK_AFFECTATION_RESULT("let x : string, x = [[1.7, 2],[1,3]];", "x", + (stringify(TinyMatrix<2>{1.7, 2, 1, 3}))); + CHECK_AFFECTATION_RESULT("let x : string, x = [[1.7, 5, 2],[1,3,5],[-1,2,6]];", "x", + (stringify(TinyMatrix<3>{1.7, 5, 2, 1, 3, 5, -1, 2, 6}))); + + CHECK_AFFECTATION_RESULT("let x : string, x = \"foobar\";", "x", (std::string{"foobar"})); + } + + SECTION("-> builtin_t") + { + const double expected = double{3.2}; + CHECK_BUILTIN_AFFECTATION_RESULT("let b:builtin_t, b = bt_a;", "b", expected); + } } - SECTION("R^3x3") + SECTION("from tuple") { - 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", - (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})); + SECTION("-> B") + { + CHECK_AFFECTATION_RESULT("let b : B; b = true;", "b", true); + + CHECK_AFFECTATION_RESULT(std::string{R"( +let t:(B), t = true; +let b:B, b = t; +)"}, + "b", true); + } + + SECTION("-> N") + { + CHECK_AFFECTATION_RESULT(std::string{R"( +let t:(B), t = true; +let n:N, n = t; +)"}, + "n", 1ul); + + CHECK_AFFECTATION_RESULT(std::string{R"( +let t:(N), t = 1; +let n:N, n = t; +)"}, + "n", 1ul); + + CHECK_AFFECTATION_RESULT(std::string{R"( +let t:(Z), t = 2; +let n:N, n = t; +)"}, + "n", 2ul); + } + + SECTION("-> Z") + { + CHECK_AFFECTATION_RESULT(std::string{R"( +let t:(B), t = true; +let z:Z, z = t; +)"}, + "z", 1l); + + CHECK_AFFECTATION_RESULT(std::string{R"( +let t:(N), t = 2; +let z:Z, z = t; +)"}, + "z", 2l); + + CHECK_AFFECTATION_RESULT(std::string{R"( +let t:(Z), t = 3; +let z:Z, z = t; +)"}, + "z", 3l); + } + + SECTION("-> R") + { + CHECK_AFFECTATION_RESULT(std::string{R"( +let t:(B), t = true; +let r:R, r = t; +)"}, + "r", double{1}); + + CHECK_AFFECTATION_RESULT(std::string{R"( +let t:(N), t = 2; +let r:R, r = t; +)"}, + "r", double{2}); + + CHECK_AFFECTATION_RESULT(std::string{R"( +let t:(Z), t =-3; +let r:R, r = t; +)"}, + "r", double{-3}); + + CHECK_AFFECTATION_RESULT(std::string{R"( +let t:(R), t =-3.2; +let r:R, r = t; +)"}, + "r", double{-3.2}); + } + + SECTION("-> R^1") + { + using R1x1 = TinyVector<1>; + + CHECK_AFFECTATION_RESULT(std::string{R"( +let t:(B), t = true; +let r:R^1, r = t; +)"}, + "r", R1x1{1}); + + CHECK_AFFECTATION_RESULT(std::string{R"( +let t:(N), t = 2; +let r:R^1, r = t; +)"}, + "r", R1x1{2}); + + CHECK_AFFECTATION_RESULT(std::string{R"( +let t:(Z), t =-3; +let r:R^1, r = t; +)"}, + "r", R1x1{-3}); + + CHECK_AFFECTATION_RESULT(std::string{R"( +let t:(R), t =-3.2; +let r:R^1, r = t; +)"}, + "r", R1x1{-3.2}); + + CHECK_AFFECTATION_RESULT(std::string{R"( +let t:(R^1), t =-1.2; +let r:R^1, r = t; +)"}, + "r", R1x1{-1.2}); + } + + SECTION("-> R^2") + { + using R2 = TinyVector<2>; + + CHECK_AFFECTATION_RESULT(std::string{R"( +let t:(R^2), t =[-1.2, 2]; +let r:R^2, r = t; +)"}, + "r", (R2{-1.2, 2})); + } + + SECTION("-> R^3") + { + using R3 = TinyVector<3>; + + CHECK_AFFECTATION_RESULT(std::string{R"( +let t:(R^3), t =[-1.2, 2, 1]; +let r:R^3, r = t; +)"}, + "r", (R3{-1.2, 2, 1})); + } + + SECTION("-> R^1x1") + { + using R1x1 = TinyMatrix<1>; + + CHECK_AFFECTATION_RESULT(std::string{R"( +let t:(B), t = true; +let r:R^1x1, r = t; +)"}, + "r", R1x1{1}); + + CHECK_AFFECTATION_RESULT(std::string{R"( +let t:(N), t = 2; +let r:R^1x1, r = t; +)"}, + "r", R1x1{2}); + + CHECK_AFFECTATION_RESULT(std::string{R"( +let t:(Z), t =-3; +let r:R^1x1, r = t; +)"}, + "r", R1x1{-3}); + + CHECK_AFFECTATION_RESULT(std::string{R"( +let t:(R), t =-3.2; +let r:R^1x1, r = t; +)"}, + "r", R1x1{-3.2}); + + CHECK_AFFECTATION_RESULT(std::string{R"( +let t:(R^1x1), t =-1.2; +let r:R^1x1, r = t; +)"}, + "r", R1x1{-1.2}); + } + + SECTION("-> R^2x2") + { + using R2x2 = TinyMatrix<2>; + + CHECK_AFFECTATION_RESULT(std::string{R"( +let t:(R^2x2), t =[[-1.2, 2],[1,3]]; +let r:R^2x2, r = t; +)"}, + "r", (R2x2{-1.2, 2, 1, 3})); + } + + SECTION("-> R^3x3") + { + using R3x3 = TinyMatrix<3>; + + CHECK_AFFECTATION_RESULT(std::string{R"( +let t:(R^3x3), t = [[-1.2, 2, 1],[-2.2, 1, 7],[-3, 1, 2]]; +let r:R^3x3, r = t; +)"}, + "r", (R3x3{-1.2, 2, 1, -2.2, 1, 7, -3, 1, 2})); + } + + SECTION("-> string") + { + CHECK_AFFECTATION_RESULT(std::string{R"( +let t:(B), t = true; +let x:string, x = t; +)"}, + "x", (stringify(true))); + + CHECK_AFFECTATION_RESULT(std::string{R"( +let t:(N), t = 3; +let x:string, x = t; +)"}, + "x", (stringify(3ul))); + + CHECK_AFFECTATION_RESULT(std::string{R"( +let t:(Z), t = -2; +let x:string, x = t; +)"}, + "x", (stringify(-2l))); + + CHECK_AFFECTATION_RESULT(std::string{R"( +let t:(R), t = 1.7; +let x:string, x = t; +)"}, + "x", (stringify(double{1.7}))); + + CHECK_AFFECTATION_RESULT(std::string{R"( +let t:(R^1), t = [1.7]; +let x:string, x = t; +)"}, + "x", (stringify(TinyVector<1>{1.7}))); + + CHECK_AFFECTATION_RESULT(std::string{R"( +let t:(R^2), t = [1.7, 2]; +let x:string, x = t; +)"}, + "x", (stringify(TinyVector<2>{1.7, 2}))); + + CHECK_AFFECTATION_RESULT(std::string{R"( +let t:(R^3), t = [1.7, 5, 2]; +let x:string, x = t; +)"}, + "x", (stringify(TinyVector<3>{1.7, 5, 2}))); + + CHECK_AFFECTATION_RESULT(std::string{R"( +let t:(R^1x1), t = [[1.7]]; +let x:string, x = t; +)"}, + "x", (stringify(TinyMatrix<1>{1.7}))); + + CHECK_AFFECTATION_RESULT(std::string{R"( +let t:(R^2x2), t = [[1.7, 2],[1,3]]; +let x:string, x = t; +)"}, + "x", (stringify(TinyMatrix<2>{1.7, 2, 1, 3}))); + + CHECK_AFFECTATION_RESULT(std::string{R"( +let t:(R^3x3), t = [[1.7, 5, 2],[1,3,5],[-1,2,6]]; +let x:string, x = t; +)"}, + "x", (stringify(TinyMatrix<3>{1.7, 5, 2, 1, 3, 5, -1, 2, 6}))); + + CHECK_AFFECTATION_RESULT(std::string{R"( +let t:(string), t = "foobar"; +let x:string, x = t; +)"}, + "x", (std::string{"foobar"})); + } + + SECTION("-> builtin_t") + { + const double expected = double{3.2}; + CHECK_BUILTIN_AFFECTATION_RESULT(std::string{R"( +let t:(builtin_t), t = bt_a; +let x:builtin_t, x = t; +)"}, + "x", expected); + } } } @@ -360,6 +731,33 @@ TEST_CASE("AffectationProcessor", "[language]") { SECTION("invalid affectations") { + SECTION("tuple -> value") + { + CHECK_AFFECTATION_EXEC_THROWS_WITH( + std::string_view{ + R"( +let t : (B), t = (true, 2>1, false); +let b : B; b = t; +)"}, + "cannot affect a (B) of size 3 to a B"); + + CHECK_AFFECTATION_EXEC_THROWS_WITH( + std::string_view{ + R"( +let t :(N), t = (2, 3, 6); +let z : Z; z = t; +)"}, + "cannot affect a (N) of size 3 to a Z"); + + CHECK_AFFECTATION_EXEC_THROWS_WITH( + std::string_view{ + R"( +let t :(R^1), t = (2, 3, 6); +let r : R^1; r = t; +)"}, + "cannot affect a (R^1) of size 3 to a R^1"); + } + SECTION("-> B") { CHECK_AFFECTATION_THROWS_WITH("let n : N, n = 1; let b : B; b = n;", "undefined affectation type: B = N"); diff --git a/tests/test_AffectationToTupleProcessor.cpp b/tests/test_AffectationToTupleProcessor.cpp index 434162ac1bc7a2e9a2e496547b76f3b359475ea0..84d1a1639d52107a802ff66f8cff9dfd3bff0b5f 100644 --- a/tests/test_AffectationToTupleProcessor.cpp +++ b/tests/test_AffectationToTupleProcessor.cpp @@ -500,6 +500,12 @@ let z : (Z), z = (2,-5,6); let n : (N), n = z; )", "trying to affect negative value (-5)"); + + CHECK_AFFECTATION_EXEC_THROWS_WITH(R"( +let z : (Z), z = -3; +let n : N, n = z; +)", + "trying to affect negative value (-3)"); } SECTION("affect negative values to (N) in lists")