Skip to content

Commit

Permalink
Add more tests for recursion errors
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeGomez committed Jun 19, 2024
1 parent e1ef640 commit 046521c
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 13 deletions.
1 change: 1 addition & 0 deletions rinja_parser/tests/filter-recursion.txt

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion testing/tests/ui/excessive_nesting.stderr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
error: failed to parse template source at row 14, column 34 near:
error: failed to parse template source at row 14, column 42 near:
"%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1"...
--> tests/ui/excessive_nesting.rs:3:10
|
Expand Down
9 changes: 9 additions & 0 deletions testing/tests/ui/filter-recursion.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
use rinja::Template;

#[derive(Template)]
#[template(source = "{{ s|a|a|a|a|a|a|a|A|a|a|a|a|a|a|a|a|a|a|a|a|a", ext = "txt")]
struct Filtered {
s: &'static str,
}

fn main() {}
9 changes: 9 additions & 0 deletions testing/tests/ui/filter-recursion.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
error: unclosed expression, missing "}}"
failed to parse template source at row 1, column 0 near:
"{{ s|a|a|a|a|a|a|a|A|a|a|a|a|a|a|a|a|a|a"...
--> tests/ui/filter-recursion.rs:3:10
|
3 | #[derive(Template)]
| ^^^^^^^^
|
= note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info)
24 changes: 12 additions & 12 deletions testing/tests/ui/unclosed-nodes.stderr
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
error: unclosed expression, missing "}}"
failed to parse template source at row 1, column 7 near:
""
failed to parse template source at row 1, column 0 near:
"{{ expr"
--> tests/ui/unclosed-nodes.rs:3:10
|
3 | #[derive(Template)]
Expand All @@ -9,8 +9,8 @@ error: unclosed expression, missing "}}"
= note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info)

error: unclosed expression, missing "}}"
failed to parse template source at row 1, column 8 near:
""
failed to parse template source at row 1, column 0 near:
"{{ expr "
--> tests/ui/unclosed-nodes.rs:7:10
|
7 | #[derive(Template)]
Expand All @@ -19,8 +19,8 @@ error: unclosed expression, missing "}}"
= note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info)

error: unclosed expression, missing "}}"
failed to parse template source at row 1, column 9 near:
""
failed to parse template source at row 1, column 0 near:
"{{ expr -"
--> tests/ui/unclosed-nodes.rs:11:10
|
11 | #[derive(Template)]
Expand All @@ -38,8 +38,8 @@ error: failed to parse template source at row 1, column 9 near:
= note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info)

error: unclosed block, missing "%}"
failed to parse template source at row 1, column 8 near:
""
failed to parse template source at row 1, column 0 near:
"{% let x"
--> tests/ui/unclosed-nodes.rs:19:10
|
19 | #[derive(Template)]
Expand All @@ -48,8 +48,8 @@ error: unclosed block, missing "%}"
= note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info)

error: unclosed block, missing "%}"
failed to parse template source at row 1, column 9 near:
""
failed to parse template source at row 1, column 0 near:
"{% let x "
--> tests/ui/unclosed-nodes.rs:23:10
|
23 | #[derive(Template)]
Expand All @@ -58,8 +58,8 @@ error: unclosed block, missing "%}"
= note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info)

error: unclosed block, missing "%}"
failed to parse template source at row 1, column 10 near:
""
failed to parse template source at row 1, column 0 near:
"{% let x -"
--> tests/ui/unclosed-nodes.rs:27:10
|
27 | #[derive(Template)]
Expand Down

0 comments on commit 046521c

Please sign in to comment.