jinja : refactor token advancement (#20864)

* refactor token advancement

* exercise sub-expressions
This commit is contained in:
Sigbjørn Skjæret
2026-03-22 17:45:10 +01:00
committed by GitHub
parent 81bc4d3ddc
commit 23c9182ce8
2 changed files with 41 additions and 27 deletions
+6
View File
@@ -2264,6 +2264,7 @@ static void test_fuzzing(testing & t) {
t.test("malformed templates (should error, not crash)", [&](testing & t) {
const std::vector<std::string> malformed = {
"",
"{{ x",
"{% if %}",
"{% for %}",
@@ -2284,6 +2285,11 @@ static void test_fuzzing(testing & t) {
for (const auto & tmpl : malformed) {
t.assert_true("malformed: " + tmpl, fuzz_test_template(tmpl, json::object()));
}
std::string tmpl = "{% for message in messages %}{{ message.role | string }} : {{ message.content if ('content' in message and message.content is not none) }}{% endfor %";
while (tmpl.length() > 0) {
t.assert_true("malformed: " + tmpl, fuzz_test_template(tmpl, json::object()));
tmpl.pop_back();
}
});
t.test("type coercion edge cases", [&](testing & t) {