From 3ba47e3fba811c073fc0623374f15861191d2edf Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Sun, 27 May 2018 10:00:35 +0200 Subject: Reformat and rename method testing tests for better organization --- testing/tests/methods.rs | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) (limited to 'testing/tests') diff --git a/testing/tests/methods.rs b/testing/tests/methods.rs index f33441d..5ed5fd1 100644 --- a/testing/tests/methods.rs +++ b/testing/tests/methods.rs @@ -5,38 +5,39 @@ use askama::Template; #[derive(Template)] #[template(source = "{{ self.get_s() }}", ext = "txt")] -struct MethodTemplate<'a> { +struct SelfMethodTemplate<'a> { s: &'a str, } -impl<'a> MethodTemplate<'a> { +impl<'a> SelfMethodTemplate<'a> { fn get_s(&self) -> &str { self.s } } +#[test] +fn test_self_method() { + let t = SelfMethodTemplate { s: "foo" }; + assert_eq!(t.render().unwrap(), "foo"); +} + + #[derive(Template)] #[template(source = "{{ self.get_s() }} {{ t.get_s() }}", ext = "txt")] -struct NestedMethodTemplate<'a> { - t: MethodTemplate<'a>, +struct NestedSelfMethodTemplate<'a> { + t: SelfMethodTemplate<'a>, } -impl<'a> NestedMethodTemplate<'a> { +impl<'a> NestedSelfMethodTemplate<'a> { fn get_s(&self) -> &str { "bar" } } -#[test] -fn test_method() { - let t = MethodTemplate { s: "foo" }; - assert_eq!(t.render().unwrap(), "foo"); -} - #[test] fn test_nested() { - let t = NestedMethodTemplate { - t: MethodTemplate { s: "foo" }, + let t = NestedSelfMethodTemplate { + t: SelfMethodTemplate { s: "foo" }, }; assert_eq!(t.render().unwrap(), "bar foo"); } -- cgit