From 244bd9129e4b875a8b81addcbcf413ec839cc83c Mon Sep 17 00:00:00 2001 From: Wim Looman Date: Tue, 2 Feb 2016 16:17:10 +0100 Subject: [PATCH] Add tests for issue #21 --- maud_macros/tests/tests.rs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/maud_macros/tests/tests.rs b/maud_macros/tests/tests.rs index a7ce1560..f49a617f 100644 --- a/maud_macros/tests/tests.rs +++ b/maud_macros/tests/tests.rs @@ -424,3 +424,30 @@ fn issue_26_3() { let s = to_string!(p { "Hi, " ^{"person called ".to_string() + name} "!" }); assert_eq!(s, "

Hi, person called Lyra!

"); } + +#[test] +fn issue_21() { + macro_rules! greet { + () => ({ + let mut result = String::new(); + let name = "Pinkie Pie"; + html!(result, p { "Hello, " ^name "!" }).map(|()| result) + }) + } + + let s = greet!().unwrap(); + assert_eq!(s, "

Hello, Pinkie Pie!

"); +} + +#[test] +fn issue_21_2() { + macro_rules! greet { + ($name:expr) => ({ + let mut result = String::new(); + html!(result, p { "Hello, " ^$name "!" }).map(|()| result) + }) + } + + let s = greet!("Pinkie Pie").unwrap(); + assert_eq!(s, "

Hello, Pinkie Pie!

"); +}