From 23ed26d5a521fc4e5422b6b1531a5c3790c80192 Mon Sep 17 00:00:00 2001
From: Stephane Del Pino <stephane.delpino44@gmail.com>
Date: Thu, 13 Feb 2020 11:11:44 +0100
Subject: [PATCH] Add missing ListAffectationProcessor tests

Mainly test that subscript values can be affected in lists such as
``
R^3 x;
(x[1], x[0], x[2]) = (1, 2, 3);
``
then `x` contains `(2, 1, 3)`
---
 src/language/node_processor/AffectationProcessor.hpp | 6 ++++++
 tests/test_ListAffectationProcessor.cpp              | 7 +++++++
 2 files changed, 13 insertions(+)

diff --git a/src/language/node_processor/AffectationProcessor.hpp b/src/language/node_processor/AffectationProcessor.hpp
index 8eeaa8b34..f52362c32 100644
--- a/src/language/node_processor/AffectationProcessor.hpp
+++ b/src/language/node_processor/AffectationProcessor.hpp
@@ -413,8 +413,10 @@ class ListAffectationProcessor final : public INodeProcessor
       DataVariant& value = i_symbol->attributes().value();
 
       if (array_expression.m_data_type != ASTNodeDataType::vector_t) {
+        // LCOV_EXCL_START
         throw parse_error("unexpected error: invalid lhs (expecting R^d)",
                           std::vector{array_subscript_expression.begin()});
+        // LCOV_EXCL_STOP
       }
 
       auto& index_expression = *array_subscript_expression.children[1];
@@ -450,13 +452,17 @@ class ListAffectationProcessor final : public INodeProcessor
           std::make_unique<AffectationExecutorT>(lhs_node, std::get<ArrayTypeT>(value), index_expression));
         break;
       }
+        // LCOV_EXCL_START
       default: {
         throw parse_error("unexpected error: invalid vector dimension",
                           std::vector{array_subscript_expression.begin()});
       }
+        // LCOV_EXCL_STOP
       }
     } else {
+      // LCOV_EXCL_START
       throw parse_error("unexpected error: invalid left hand side", std::vector{lhs_node.begin()});
+      // LCOV_EXCL_STOP
     }
   }
 
diff --git a/tests/test_ListAffectationProcessor.cpp b/tests/test_ListAffectationProcessor.cpp
index eb86bdb66..a888ade21 100644
--- a/tests/test_ListAffectationProcessor.cpp
+++ b/tests/test_ListAffectationProcessor.cpp
@@ -107,5 +107,12 @@ TEST_CASE("ListAffectationProcessor", "[language]")
         CHECK_AFFECTATION_RESULT(R"(R^3 v = (1,2,3); R*R^2*string (x,u,s) = (1.2, (2,3), v);)", "s", os.str());
       }
     }
+
+    SECTION("compound with subscript values")
+    {
+      CHECK_AFFECTATION_RESULT(R"(R^3 x; (x[0], x[2], x[1]) = (4, 6, 5);)", "x", (TinyVector<3>{4, 5, 6}));
+      CHECK_AFFECTATION_RESULT(R"(R^2 x; (x[1], x[0]) = (3, 6);)", "x", (TinyVector<2>{6, 3}));
+      CHECK_AFFECTATION_RESULT(R"(R^1 x; R y; (y, x[0]) = (4, 2.3);)", "x", (TinyVector<1>{2.3}));
+    }
   }
 }
-- 
GitLab