jinja : refactor token advancement (#20864)
* refactor token advancement * exercise sub-expressions
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user