aboutsummaryrefslogtreecommitdiffstats
path: root/testing/tests
diff options
context:
space:
mode:
Diffstat (limited to 'testing/tests')
-rw-r--r--testing/tests/loops.rs18
1 files changed, 18 insertions, 0 deletions
diff --git a/testing/tests/loops.rs b/testing/tests/loops.rs
index f014068..4a02153 100644
--- a/testing/tests/loops.rs
+++ b/testing/tests/loops.rs
@@ -417,3 +417,21 @@ fn test_for_cycle_empty() {
};
assert!(t.render().is_err())
}
+
+#[derive(Template)]
+#[template(
+ source = "{% for i in 0..limit if i % 2 == 1 %}{{i}}.{% else %}:({% endfor %}",
+ ext = "txt"
+)]
+struct ForInIf {
+ limit: usize,
+}
+
+#[test]
+fn test_for_in_if() {
+ let t = ForInIf { limit: 10 };
+ assert_eq!(t.render().unwrap(), "1.3.5.7.9.");
+
+ let t = ForInIf { limit: 1 };
+ assert_eq!(t.render().unwrap(), ":(");
+}