aboutsummaryrefslogtreecommitdiffstats
path: root/testing
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--testing/templates/ranges.txt5
-rw-r--r--testing/tests/operators.rs14
2 files changed, 19 insertions, 0 deletions
diff --git a/testing/templates/ranges.txt b/testing/templates/ranges.txt
new file mode 100644
index 0000000..d87ef6a
--- /dev/null
+++ b/testing/templates/ranges.txt
@@ -0,0 +1,5 @@
+{{ foo[..]|join("") }}
+{{ foo[0 + 1..]|join("") }}
+{% let bar = 1 %}
+{{ foo[..bar]|join("") }}
+{{ foo[..=bar]|join("") }}
diff --git a/testing/tests/operators.rs b/testing/tests/operators.rs
index edeb32a..5e23dff 100644
--- a/testing/tests/operators.rs
+++ b/testing/tests/operators.rs
@@ -40,3 +40,17 @@ fn test_precedence() {
let t = PrecedenceTemplate {};
assert_eq!(t.render().unwrap(), "6".repeat(7));
}
+
+#[derive(Template)]
+#[template(path = "ranges.txt")]
+struct RangesTemplate<'a> {
+ foo: Vec<&'a str>,
+}
+
+#[test]
+fn test_ranges() {
+ let t = RangesTemplate {
+ foo: vec!["a", "b", "c", "d"],
+ };
+ assert_eq!(t.render().unwrap(), "abcd\nbcd\n\na\nab");
+}