From 44c0623a581413bba0dc59f8de72abc5dded843f Mon Sep 17 00:00:00 2001 From: René Kijewski Date: Thu, 1 Jul 2021 12:58:13 +0200 Subject: Add tuple destructoring tests --- testing/templates/let-destruct-tuple.html | 3 +++ testing/tests/vars.rs | 14 ++++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 testing/templates/let-destruct-tuple.html diff --git a/testing/templates/let-destruct-tuple.html b/testing/templates/let-destruct-tuple.html new file mode 100644 index 0000000..395e872 --- /dev/null +++ b/testing/templates/let-destruct-tuple.html @@ -0,0 +1,3 @@ +{% let (a, ((b, c), (d))) = abcd %}{{a}}{{b}}{{c}}{{d}} +{% let (a, (_, d)) = abcd %}{{a}}{{d}} +{% let (((a))) = abcd.0 %}{{a}} diff --git a/testing/tests/vars.rs b/testing/tests/vars.rs index d70a084..75d10e5 100644 --- a/testing/tests/vars.rs +++ b/testing/tests/vars.rs @@ -91,3 +91,17 @@ fn test_if_let() { let t = IfLet { a: Some("foo") }; assert_eq!(t.render().unwrap(), "foo"); } + +#[derive(Template)] +#[template(path = "let-destruct-tuple.html")] +struct LetDestructTupleTemplate { + abcd: (char, ((char, char), char)), +} + +#[test] +fn test_destruct_tuple() { + let t = LetDestructTupleTemplate { + abcd: ('w', (('x', 'y'), 'z')), + }; + assert_eq!(t.render().unwrap(), "wxyz\nwz\nw"); +} -- cgit