Add garbled closing block test

This commit is contained in:
René Kijewski 2024-11-13 20:03:08 +01:00
parent ae4ab28fd4
commit e7f5de2697
2 changed files with 86 additions and 0 deletions

View File

@ -0,0 +1,39 @@
use rinja::Template;
#[derive(Template)]
#[template(ext = "txt", source = "{% if cond %-}{% endif %}")]
struct BlockSuppress {
cond: bool,
}
#[derive(Template)]
#[template(ext = "txt", source = "{% if cond %+}{% endif %}")]
struct BlockPreserve {
cond: bool,
}
#[derive(Template)]
#[template(ext = "txt", source = "{% if cond %~}{% endif %}")]
struct BlockFold {
cond: bool,
}
#[derive(Template)]
#[template(ext = "txt", source = "{% if cond %}{% endif %-}")]
struct BlockSuppress2 {
cond: bool,
}
#[derive(Template)]
#[template(ext = "txt", source = "{% if cond %}{% endif %+}")]
struct BlockPreserve2 {
cond: bool,
}
#[derive(Template)]
#[template(ext = "txt", source = "{% if cond %}{% endif %~}")]
struct BlockFold2 {
cond: bool,
}
fn main() {}

View File

@ -0,0 +1,47 @@
error: failed to parse template source
--> <source attribute>:1:11
"%-}{% endif %}"
--> tests/ui/garbled-closing-blocks.rs:4:34
|
4 | #[template(ext = "txt", source = "{% if cond %-}{% endif %}")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: failed to parse template source
--> <source attribute>:1:11
"%+}{% endif %}"
--> tests/ui/garbled-closing-blocks.rs:10:34
|
10 | #[template(ext = "txt", source = "{% if cond %+}{% endif %}")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: failed to parse template source
--> <source attribute>:1:11
"%~}{% endif %}"
--> tests/ui/garbled-closing-blocks.rs:16:34
|
16 | #[template(ext = "txt", source = "{% if cond %~}{% endif %}")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: failed to parse template source
--> <source attribute>:1:22
"%-}"
--> tests/ui/garbled-closing-blocks.rs:22:34
|
22 | #[template(ext = "txt", source = "{% if cond %}{% endif %-}")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: failed to parse template source
--> <source attribute>:1:22
"%+}"
--> tests/ui/garbled-closing-blocks.rs:28:34
|
28 | #[template(ext = "txt", source = "{% if cond %}{% endif %+}")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: failed to parse template source
--> <source attribute>:1:22
"%~}"
--> tests/ui/garbled-closing-blocks.rs:34:34
|
34 | #[template(ext = "txt", source = "{% if cond %}{% endif %~}")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^