diff options
Diffstat (limited to 'testing')
| -rw-r--r-- | testing/templates/rust-macros-full-path.html | 1 | ||||
| -rw-r--r-- | testing/tests/rust_macro.rs | 24 | 
2 files changed, 23 insertions, 2 deletions
| diff --git a/testing/templates/rust-macros-full-path.html b/testing/templates/rust-macros-full-path.html new file mode 100644 index 0000000..f32dc53 --- /dev/null +++ b/testing/templates/rust-macros-full-path.html @@ -0,0 +1 @@ +Hello, {{ foo::hello2!() }}! diff --git a/testing/tests/rust_macro.rs b/testing/tests/rust_macro.rs index 2efe8be..1ee37e3 100644 --- a/testing/tests/rust_macro.rs +++ b/testing/tests/rust_macro.rs @@ -11,11 +11,31 @@ macro_rules! hello {  struct RustMacrosTemplate {}  #[test] -fn main() { +fn macro_basic() {      let template = RustMacrosTemplate {};      assert_eq!("Hello, world!", template.render().unwrap());  } +mod foo { +    macro_rules! hello2 { +        () => { +            "world" +        }; +    } + +    pub(crate) use hello2; +} + +#[derive(Template)] +#[template(path = "rust-macros-full-path.html")] +struct RustMacrosFullPathTemplate {} + +#[test] +fn macro_full_path() { +    let template = RustMacrosFullPathTemplate {}; +    assert_eq!("Hello, world!", template.render().unwrap()); +} +  macro_rules! call_a_or_b_on_tail {      ((a: $a:expr, b: $b:expr, c: $c:expr), call a: $($tail:expr),*) => {          ($a)($($tail),*) @@ -47,7 +67,7 @@ fn day(_: u16, _: &str, d: u8) -> u8 {  struct RustMacrosArgTemplate {}  #[test] -fn args() { +fn macro_with_args() {      let template = RustMacrosArgTemplate {};      assert_eq!("2021\nJuly\n2", template.render().unwrap());  } | 
