From 20a5f7af7b1195bc8ffa0612a40a8d95bc30914b Mon Sep 17 00:00:00 2001 From: René Kijewski Date: Thu, 1 Jul 2021 20:46:19 +0200 Subject: Add loop variable shadowing test --- testing/tests/loops.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'testing/tests/loops.rs') diff --git a/testing/tests/loops.rs b/testing/tests/loops.rs index 3bba428..7b008a2 100644 --- a/testing/tests/loops.rs +++ b/testing/tests/loops.rs @@ -214,3 +214,24 @@ fn test_for_vec_attr_range() { }; assert_eq!(t.render().unwrap(), "1 2 3 4 5 6 "); } + +#[derive(Template)] +#[template( + source = "{% for v in v %}{% let v = v %}{% for v in v.iterable %}{% let v = v %}{{ v }} {% endfor %}{% endfor %}", + ext = "txt" +)] +struct ForVecAttrSliceShadowingTemplate { + v: Vec, +} + +#[test] +fn test_for_vec_attr_slice_shadowing() { + let t = ForVecAttrSliceShadowingTemplate { + v: vec![ + ForVecAttrSlice { iterable: &[1, 2] }, + ForVecAttrSlice { iterable: &[3, 4] }, + ForVecAttrSlice { iterable: &[5, 6] }, + ], + }; + assert_eq!(t.render().unwrap(), "1 2 3 4 5 6 "); +} -- cgit