From 798ba31bfdbebea9c4d5e3edaa26491fb8dd88e1 Mon Sep 17 00:00:00 2001 From: Frederik Hennig <frederik.hennig@fau.de> Date: Mon, 10 Feb 2025 13:29:57 +0100 Subject: [PATCH] add test for nested namespaces --- tests/generator_scripts/index.yaml | 4 ++++ .../source/NestedNamespaces.harness.cpp | 12 ++++++++++++ .../source/NestedNamespaces.py | 19 +++++++++++++++++++ 3 files changed, 35 insertions(+) create mode 100644 tests/generator_scripts/source/NestedNamespaces.harness.cpp create mode 100644 tests/generator_scripts/source/NestedNamespaces.py diff --git a/tests/generator_scripts/index.yaml b/tests/generator_scripts/index.yaml index eae4c39..b723799 100644 --- a/tests/generator_scripts/index.yaml +++ b/tests/generator_scripts/index.yaml @@ -48,6 +48,10 @@ Conditionals: - regex: if\s*\(\s*noodle\s==\sNoodles::RIGATONI\s\|\|\snoodle\s==\sNoodles::SPAGHETTI\s*\) count: 1 +NestedNamespaces: + sfg-args: + output-mode: header-only + # Kernel Generation ScaleKernel: diff --git a/tests/generator_scripts/source/NestedNamespaces.harness.cpp b/tests/generator_scripts/source/NestedNamespaces.harness.cpp new file mode 100644 index 0000000..ea7c465 --- /dev/null +++ b/tests/generator_scripts/source/NestedNamespaces.harness.cpp @@ -0,0 +1,12 @@ +#include "NestedNamespaces.hpp" + +static_assert( outer::X == 13 ); +static_assert( outer::inner::Y == 52 ); +static_assert( outer::Z == 41 ); +static_assert( outer::second_inner::W == 91 ); +static_assert( outer::inner::innermost::V == 29 ); +static_assert( GLOBAL == 42 ); + +int main() { + return 0; +} diff --git a/tests/generator_scripts/source/NestedNamespaces.py b/tests/generator_scripts/source/NestedNamespaces.py new file mode 100644 index 0000000..4af7bc7 --- /dev/null +++ b/tests/generator_scripts/source/NestedNamespaces.py @@ -0,0 +1,19 @@ +from pystencilssfg import SourceFileGenerator + +with SourceFileGenerator() as sfg: + + with sfg.namespace("outer"): + sfg.code("constexpr int X = 13;") + + with sfg.namespace("inner"): + sfg.code("constexpr int Y = 52;") + + sfg.code("constexpr int Z = 41;") + + with sfg.namespace("outer::second_inner"): + sfg.code("constexpr int W = 91;") + + with sfg.namespace("outer::inner::innermost"): + sfg.code("constexpr int V = 29;") + + sfg.code("constexpr int GLOBAL = 42;") -- GitLab