Add regression test for moving variables in let statement

This commit is contained in:
Guillaume Gomez 2024-07-02 22:40:09 +02:00
parent fa467172dd
commit e7f2979b73
2 changed files with 21 additions and 1 deletions

View File

@ -39,7 +39,7 @@ fn test_ref_deref() {
#[derive(Template)]
#[template(
source = r#"
{%- let x = *title -%}
{%- let x = **title -%}
{%- if x == "another" -%}
another2
{%- else -%}

View File

@ -131,3 +131,23 @@ fn test_decl_assign_range() {
let t = DeclAssignRange;
assert_eq!(t.render().unwrap(), "1");
}
#[derive(Template)]
#[template(
source = "
{%- set t = title -%}
{{t}}/{{title -}}
",
ext = "txt"
)]
struct DoNotMoveFields {
title: String,
}
#[test]
fn test_not_moving_fields_in_var() {
let x = DoNotMoveFields {
title: "a".to_string(),
};
assert_eq!(x.render().unwrap(), "a/a");
}