diff options
author | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2018-05-27 10:00:35 +0200 |
---|---|---|
committer | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2018-05-27 10:03:40 +0200 |
commit | 3ba47e3fba811c073fc0623374f15861191d2edf (patch) | |
tree | 47dbf4090c09d7b19c058d384e9a54df879bcde4 /testing/tests/methods.rs | |
parent | 0330699a337f4bd86854eaafccc7128117f10b14 (diff) | |
download | askama-3ba47e3fba811c073fc0623374f15861191d2edf.tar.gz askama-3ba47e3fba811c073fc0623374f15861191d2edf.tar.bz2 askama-3ba47e3fba811c073fc0623374f15861191d2edf.zip |
Reformat and rename method testing tests for better organization
Diffstat (limited to 'testing/tests/methods.rs')
-rw-r--r-- | testing/tests/methods.rs | 27 |
1 files changed, 14 insertions, 13 deletions
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"); } |