From 035dabc8bf049d80ee60c12e5ee80f828f107d60 Mon Sep 17 00:00:00 2001
From: Alexander Schlemmer <alexander@mail-schlemmer.de>
Date: Wed, 12 Oct 2022 10:35:39 +0200
Subject: [PATCH] TST: Failing test for macro replacements in definitions

---
 unittests/test_macros.py | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)

diff --git a/unittests/test_macros.py b/unittests/test_macros.py
index 7ac34cc7..8adc4194 100644
--- a/unittests/test_macros.py
+++ b/unittests/test_macros.py
@@ -328,3 +328,38 @@ extroot: !macro
     assert cfood["extroot"]["once"]["something"]["a"] == "4"
     assert cfood["extroot"]["twice"]["something"]["a"] == "5"
     assert cfood["extroot"]["default_name"]["something"]["a"] == "4"
+
+
+
+def test_def_replacements():
+    """Test that parameters in macro definitions can be used
+    for defining subsequent parameters.
+    """
+
+    cfood = _temp_file_load("""
+---
+metadata:
+  macros:
+    - !defmacro
+      name: test_def_replacements
+      params:
+        macro_name: default_name
+        a: $macro_name
+      definition:
+        $macro_name:
+          macro_name: $macro_name
+          a: $a
+---
+extroot: !macro
+  test_def_replacements:
+  - macro_name: once
+  - macro_name: twice
+    a: 5
+  - {}
+    """)
+    assert cfood["extroot"]["once"]["a"] == "once"
+    assert cfood["extroot"]["once"]["macro_name"] == "once"
+    assert cfood["extroot"]["twice"]["a"] == "5"
+    assert cfood["extroot"]["twice"]["macro_name"] == "twice"
+    assert cfood["extroot"]["default_name"]["a"] == "default_name"
+    assert cfood["extroot"]["default_name"]["macro_name"] == "default_name"
-- 
GitLab