aboutsummaryrefslogtreecommitdiffstats
path: root/testing/tests
diff options
context:
space:
mode:
Diffstat (limited to 'testing/tests')
-rw-r--r--testing/tests/rust_macro.rs24
1 files changed, 22 insertions, 2 deletions
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());
}