From 0628afaf5efd861dcb4967eae3e9f1b3e5e7735d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Kijewski?= Date: Wed, 7 Aug 2024 20:28:33 +0200 Subject: [PATCH] parser: add wrong node terminator test --- testing/tests/ui/wrong-end.rs | 27 ++++++++++++++++++ testing/tests/ui/wrong-end.stderr | 47 +++++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+) create mode 100644 testing/tests/ui/wrong-end.rs create mode 100644 testing/tests/ui/wrong-end.stderr diff --git a/testing/tests/ui/wrong-end.rs b/testing/tests/ui/wrong-end.rs new file mode 100644 index 00000000..9d267716 --- /dev/null +++ b/testing/tests/ui/wrong-end.rs @@ -0,0 +1,27 @@ +use rinja::Template; + +#[derive(Template)] +#[template(source = "{% for _ in 1..=10 %}{% end %}", ext = "txt")] +struct For; + +#[derive(Template)] +#[template(source = "{% macro test() %}{% end %}", ext = "txt")] +struct Macro; + +#[derive(Template)] +#[template(source = "{% filter upper %}{% end %}", ext = "txt")] +struct Filter; + +#[derive(Template)] +#[template(source = "{% match () %}{% when () %}{% end %}", ext = "txt")] +struct Match; + +#[derive(Template)] +#[template(source = "{% block body %}{% end %}", ext = "txt")] +struct Block; + +#[derive(Template)] +#[template(source = "{% if true %}{% end %}", ext = "txt")] +struct If; + +fn main() {} diff --git a/testing/tests/ui/wrong-end.stderr b/testing/tests/ui/wrong-end.stderr new file mode 100644 index 00000000..cb04736d --- /dev/null +++ b/testing/tests/ui/wrong-end.stderr @@ -0,0 +1,47 @@ +error: failed to parse template source + --> :1:24 + "end %}" + --> tests/ui/wrong-end.rs:4:21 + | +4 | #[template(source = "{% for _ in 1..=10 %}{% end %}", ext = "txt")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: failed to parse template source + --> :1:21 + "end %}" + --> tests/ui/wrong-end.rs:8:21 + | +8 | #[template(source = "{% macro test() %}{% end %}", ext = "txt")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: failed to parse template source + --> :1:21 + "end %}" + --> tests/ui/wrong-end.rs:12:21 + | +12 | #[template(source = "{% filter upper %}{% end %}", ext = "txt")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: failed to parse template source + --> :1:30 + "end %}" + --> tests/ui/wrong-end.rs:16:21 + | +16 | #[template(source = "{% match () %}{% when () %}{% end %}", ext = "txt")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: failed to parse template source + --> :1:19 + "end %}" + --> tests/ui/wrong-end.rs:20:21 + | +20 | #[template(source = "{% block body %}{% end %}", ext = "txt")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: failed to parse template source + --> :1:16 + "end %}" + --> tests/ui/wrong-end.rs:24:21 + | +24 | #[template(source = "{% if true %}{% end %}", ext = "txt")] + | ^^^^^^^^^^^^^^^^^^^^^^^^