jinja : fix negative step slice with start/stop values (#24580)

This commit is contained in:
Sigbjørn Skjæret
2026-06-13 18:28:40 +02:00
committed by GitHub
parent e8067a8b36
commit f05cf4676a
3 changed files with 23 additions and 5 deletions
+18
View File
@@ -435,6 +435,24 @@ static void test_expressions(testing & t) {
"('c', 'b', 'a')"
);
test_template(t, "string slice negative step",
"{{ 'abcdef'[::-2] }}",
json::object(),
"fdb"
);
test_template(t, "string slice negative start and step",
"{{ 'abcdef'[-1:1:-1] }}",
json::object(),
"fedc"
);
test_template(t, "string slice negative start, stop and step",
"{{ 'abcdef'[-1:-5:-1] }}",
json::object(),
"fedc"
);
test_template(t, "arithmetic",
"{{ (a + b) * c }}",
{{"a", 2}, {"b", 3}, {"c", 4}},