From cf558be7e65c405c85cdcdedc71d1da944cf241f Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sun, 6 Jul 2025 23:53:13 +0200 Subject: [PATCH] Add regression test for generics support in macro default value and call --- testing/tests/macro.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/testing/tests/macro.rs b/testing/tests/macro.rs index aeb01b48..c31a6335 100644 --- a/testing/tests/macro.rs +++ b/testing/tests/macro.rs @@ -472,3 +472,25 @@ fn test_rust_keywords_as_args_with_default_expr() { // primarily checking for compilation assert_eq!(MacroRustKwArgsDefaultExpr.render().unwrap(), "3\n1\n1\n"); } + +// This test ensures that default values can be paths with generics. +#[test] +fn test_macro_default_value_generics() { + #[derive(Template)] + #[template( + source = r#" +{%- macro test(title = Option::::None, b = Option::::Some(0)) -%} + {%- if let Some(title) = title -%} + Title: {{title}} + {%- endif -%} + {%- if let Some(b) = b -%}---> {{b}}{% endif -%} +{%- endmacro -%} + +{% call test(b = Option::::Some(3)) %}{% endcall -%} +"#, + ext = "html" + )] + struct Example; + + assert_eq!(Example.render().unwrap(), "---> 3"); +}