From 831df66cdbbac92f52bd97947442872f72d4c645 Mon Sep 17 00:00:00 2001 From: Wim Looman <wim@nemo157.com> Date: Tue, 2 Feb 2016 16:00:14 +0100 Subject: [PATCH] Add tests for issue #26 --- maud_macros/tests/tests.rs | 45 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/maud_macros/tests/tests.rs b/maud_macros/tests/tests.rs index be02f40..027e8fa 100644 --- a/maud_macros/tests/tests.rs +++ b/maud_macros/tests/tests.rs @@ -379,3 +379,48 @@ fn render_once_by_move_with_copy() { html!(s, ^once).unwrap(); assert_eq!(s, "pinkie pinkie "); } + +#[test] +fn issue_26() { + macro_rules! to_string { + ($($x:tt)*) => {{ + let mut s = String::new(); + html!(s, $($x)*).unwrap(); + s + }} + } + + let name = "Lyra"; + let s = to_string!(p { "Hi, " ^(name) "!" }); + assert_eq!(s, "<p>Hi, Lyra!</p>"); +} + +#[test] +fn issue_26_2() { + macro_rules! to_string { + ($($x:tt)*) => {{ + let mut s = String::new(); + html!(s, $($x)*).unwrap(); + s + }} + } + + let name = "Lyra"; + let s = to_string!(p { "Hi, " ^("person called ".to_string() + name) "!" }); + assert_eq!(s, "<p>Hi, person called Lyra!</p>"); +} + +#[test] +fn issue_26_3() { + macro_rules! to_string { + ($($x:tt)*) => {{ + let mut s = String::new(); + html!(s, $($x)*).unwrap(); + s + }} + } + + let name = "Lyra"; + let s = to_string!(p { "Hi, " ^{"person called ".to_string() + name} "!" }); + assert_eq!(s, "<p>Hi, person called Lyra!</p>"); +}