Skip to content

Commit

Permalink
Add UI tests for macros error message
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeGomez authored and djc committed Nov 20, 2023
1 parent 70b5b14 commit ea7267d
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
27 changes: 27 additions & 0 deletions testing/tests/ui/macro.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
use askama::Template;

#[derive(Template)]
#[template(source = "{%- macro thrice(param) -%}
{{ param }}
{%- endmacro -%}
{%- call thrice(2, 3) -%}", ext = "html")]
struct InvalidNumberOfArgs;

#[derive(Template)]
#[template(source = "{%- macro thrice(param, param2) -%}
{{ param }} {{ param2 }}
{%- endmacro -%}
{%- call thrice() -%}", ext = "html")]
struct InvalidNumberOfArgs2;

#[derive(Template)]
#[template(source = "{%- macro thrice() -%}
{%- endmacro -%}
{%- call thrice(1, 2) -%}", ext = "html")]
struct InvalidNumberOfArgs3;

fn main() {
}
23 changes: 23 additions & 0 deletions testing/tests/ui/macro.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
error: macro "thrice" expected 1 argument, found 2
--> tests/ui/macro.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)

error: macro "thrice" expected 2 arguments, found 0
--> tests/ui/macro.rs:11:10
|
11 | #[derive(Template)]
| ^^^^^^^^
|
= note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info)

error: macro "thrice" expected 0 arguments, found 2
--> tests/ui/macro.rs:19:10
|
19 | #[derive(Template)]
| ^^^^^^^^
|
= note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info)

0 comments on commit ea7267d

Please sign in to comment.