Select Git revision
-
Stéphane Del Pino authored
This reduces a bit the Kokkos adherence
Stéphane Del Pino authoredThis reduces a bit the Kokkos adherence
test_AffectationProcessor.cpp 24.32 KiB
#include <catch2/catch.hpp>
#include <language/ast/ASTBuilder.hpp>
#include <language/ast/ASTNodeAffectationExpressionBuilder.hpp>
#include <language/ast/ASTNodeDataTypeBuilder.hpp>
#include <language/ast/ASTNodeDeclarationToAffectationConverter.hpp>
#include <language/ast/ASTNodeExpressionBuilder.hpp>
#include <language/ast/ASTNodeTypeCleaner.hpp>
#include <language/ast/ASTSymbolTableBuilder.hpp>
#include <language/utils/ASTPrinter.hpp>
#include <utils/Demangle.hpp>
#include <pegtl/string_input.hpp>
#include <sstream>
#define CHECK_AFFECTATION_RESULT(data, variable_name, expected_value) \
{ \
string_input input{data, "test.pgs"}; \
auto ast = ASTBuilder::build(input); \
\
ASTSymbolTableBuilder{*ast}; \
ASTNodeDataTypeBuilder{*ast}; \
\
ASTNodeDeclarationToAffectationConverter{*ast}; \
ASTNodeTypeCleaner<language::var_declaration>{*ast}; \
\
ASTNodeExpressionBuilder{*ast}; \
ExecutionPolicy exec_policy; \
ast->execute(exec_policy); \
\
auto symbol_table = ast->m_symbol_table; \
\
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 value = std::get<decltype(expected_value)>(attributes.value()); \
\
REQUIRE(value == expected_value); \
}
#define CHECK_AFFECTATION_THROWS_WITH(data, error_message) \
{ \
string_input input{data, "test.pgs"}; \
auto ast = ASTBuilder::build(input); \
\
ASTSymbolTableBuilder{*ast}; \
ASTNodeDataTypeBuilder{*ast}; \
\
ASTNodeDeclarationToAffectationConverter{*ast}; \
ASTNodeTypeCleaner<language::var_declaration>{*ast}; \
\
REQUIRE_THROWS_WITH(ASTNodeExpressionBuilder{*ast}, error_message); \
}
// clazy:excludeall=non-pod-global-static
TEST_CASE("AffectationProcessor", "[language]")
{
SECTION("Affectations")
{
SECTION("B")
{
CHECK_AFFECTATION_RESULT("let b : B; b = true;", "b", true);
}
SECTION("N")