Skip to content

Commit

Permalink
Add regression test for config delimiters
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeGomez committed Oct 20, 2024
1 parent d15fc3a commit c77cd37
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 2 deletions.
4 changes: 4 additions & 0 deletions testing/operator-paren-config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[[syntax]]
name = "paren"
expr_start = "<)"
expr_end = "(>"
4 changes: 4 additions & 0 deletions testing/operator-plus-config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[[syntax]]
name = "plus"
expr_start = "<+"
expr_end = "+>"
8 changes: 8 additions & 0 deletions testing/tests/ui/broken-config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,12 @@ struct DelimClash;
#[template(source = "", ext = "txt", config = "delim-too-short.toml")]
struct DelimTooShort;

#[derive(Template)]
#[template(source = "<+a+> and <+b+>", config = "operator-plus-config.toml", syntax = "plus", ext = "txt")]
struct PlusOperator;

#[derive(Template)]
#[template(source = "<)a(> and <)b(>", config = "operator-paren-config.toml", syntax = "paren", ext = "txt")]
struct ParenOperator;

fn main() {}
14 changes: 14 additions & 0 deletions testing/tests/ui/broken-config.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,17 @@ error: delimiters must be at least two characters long. The opening block delimi
|
16 | #[template(source = "", ext = "txt", config = "delim-too-short.toml")]
| ^^^^^^^^^^^^^^^^^^^^^^

error: closing delimiters may not start with operators. The closing expression delimiter ("+>") starts with operator `+`
--> testing/operator-plus-config.toml
--> tests/ui/broken-config.rs:20:49
|
20 | #[template(source = "<+a+> and <+b+>", config = "operator-plus-config.toml", syntax = "plus", ext = "txt")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: closing delimiters may not start with operators. The closing expression delimiter ("(>") starts with operator `(`
--> testing/operator-paren-config.toml
--> tests/ui/broken-config.rs:24:49
|
24 | #[template(source = "<)a(> and <)b(>", config = "operator-paren-config.toml", syntax = "paren", ext = "txt")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4 changes: 2 additions & 2 deletions testing/tests/ui/terminator-operator.stderr
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
error: a closing delimiter must not start with an operator. The expression delimiter (">>") is also an operator
error: closing delimiters may not start with operators. The closing expression delimiter (">>") starts with operator `>`
--> testing/issue-128.toml
--> tests/ui/terminator-operator.rs:4:49
|
4 | #[template(source = "<<a>> and <<b>>", config = "issue-128.toml", syntax = "mwe", ext="")]
| ^^^^^^^^^^^^^^^^

error: a closing delimiter must not start an with operator. The expression delimiter (">>>") starts with the ">>" operator
error: closing delimiters may not start with operators. The closing expression delimiter (">>>") starts with operator `>`
--> testing/issue-128-2.toml
--> tests/ui/terminator-operator.rs:11:49
|
Expand Down

0 comments on commit c77cd37

Please sign in to comment.