From 25cecd0505c30265592107ec4824c8280156ddf1 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Thu, 19 Sep 2024 15:07:37 +0200 Subject: [PATCH] Add regression test for config delimiters --- testing/operator-paren-config.toml | 4 ++++ testing/operator-plus-config.toml | 4 ++++ testing/tests/ui/broken-config.rs | 8 ++++++++ testing/tests/ui/broken-config.stderr | 14 ++++++++++++++ testing/tests/ui/terminator-operator.stderr | 4 ++-- 5 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 testing/operator-paren-config.toml create mode 100644 testing/operator-plus-config.toml diff --git a/testing/operator-paren-config.toml b/testing/operator-paren-config.toml new file mode 100644 index 000000000..666c7a11e --- /dev/null +++ b/testing/operator-paren-config.toml @@ -0,0 +1,4 @@ +[[syntax]] +name = "paren" +expr_start = "<)" +expr_end = "(>" diff --git a/testing/operator-plus-config.toml b/testing/operator-plus-config.toml new file mode 100644 index 000000000..6646425cf --- /dev/null +++ b/testing/operator-plus-config.toml @@ -0,0 +1,4 @@ +[[syntax]] +name = "plus" +expr_start = "<+" +expr_end = "+>" diff --git a/testing/tests/ui/broken-config.rs b/testing/tests/ui/broken-config.rs index b41f95046..4a1525b3a 100644 --- a/testing/tests/ui/broken-config.rs +++ b/testing/tests/ui/broken-config.rs @@ -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() {} diff --git a/testing/tests/ui/broken-config.stderr b/testing/tests/ui/broken-config.stderr index 588b0c3b7..c4e6647b6 100644 --- a/testing/tests/ui/broken-config.stderr +++ b/testing/tests/ui/broken-config.stderr @@ -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")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/testing/tests/ui/terminator-operator.stderr b/testing/tests/ui/terminator-operator.stderr index 65089f1c5..d4ae4b387 100644 --- a/testing/tests/ui/terminator-operator.stderr +++ b/testing/tests/ui/terminator-operator.stderr @@ -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 = "<> and <>", 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 |