Add regression test for generics support in macro default value and call

This commit is contained in:
Guillaume Gomez 2025-07-06 23:53:13 +02:00 committed by René Kijewski
parent fc2b0349ac
commit cf558be7e6

View File

@ -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::<String>::None, b = Option::<u32>::Some(0)) -%}
{%- if let Some(title) = title -%}
Title: {{title}}
{%- endif -%}
{%- if let Some(b) = b -%}---> {{b}}{% endif -%}
{%- endmacro -%}
{% call test(b = Option::<u32>::Some(3)) %}{% endcall -%}
"#,
ext = "html"
)]
struct Example;
assert_eq!(Example.render().unwrap(), "---> 3");
}