update: add regroup and resetcycle

This commit is contained in:
Lucas F. 2026-01-03 21:30:59 -03:00
parent 0a0c7c9e8b
commit 35bc0df2cd
3 changed files with 130 additions and 4 deletions

View file

@ -806,3 +806,51 @@ test "parse querystring múltiplos" {
try testing.expectEqualStrings("pagina", qs.modifications[1]);
try testing.expectEqualStrings("None", qs.modifications[2]);
}
test "parse regroup simples" {
const allocator = testing.allocator;
const template = "{% regroup pessoas by cidade as grupos_cidade %}";
const nodes = try parser.parse(allocator, template);
defer {
for (nodes) |node| node.deinit(allocator);
allocator.free(nodes);
}
try testing.expectEqual(@as(usize, 1), nodes.len);
try testing.expect(nodes[0].type == .regroup);
const r = nodes[0].regroup.?;
try testing.expectEqualStrings("pessoas", r.source);
try testing.expectEqualStrings("cidade", r.by);
try testing.expectEqualStrings("grupos_cidade", r.as_var);
}
test "parse resetcycle simples" {
const allocator = testing.allocator;
const template = "{% resetcycle %}";
const nodes = try parser.parse(allocator, template);
defer {
for (nodes) |node| node.deinit(allocator);
allocator.free(nodes);
}
try testing.expectEqual(@as(usize, 1), nodes.len);
try testing.expect(nodes[0].type == .resetcycle);
const rc = nodes[0].resetcycle.?;
try testing.expect(rc.cycle_name == null);
}
test "parse resetcycle com nome" {
const allocator = testing.allocator;
const template = "{% resetcycle rowclass %}";
const nodes = try parser.parse(allocator, template);
defer {
for (nodes) |node| node.deinit(allocator);
allocator.free(nodes);
}
try testing.expectEqual(@as(usize, 1), nodes.len);
try testing.expect(nodes[0].type == .resetcycle);
const rc = nodes[0].resetcycle.?;
try testing.expect(rc.cycle_name != null);
try testing.expectEqualStrings("rowclass", rc.cycle_name.?);
}