From 1ab6291116d7416803fb0ce474b07a0e7376d0bb Mon Sep 17 00:00:00 2001 From: "Lucas F." Date: Sat, 17 Jan 2026 20:32:33 -0300 Subject: [PATCH] update: test for something inside block --- src/parser_test.zig | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/src/parser_test.zig b/src/parser_test.zig index 98dc220..56aefc7 100644 --- a/src/parser_test.zig +++ b/src/parser_test.zig @@ -247,7 +247,6 @@ test "parse comment" { try testing.expectEqualStrings("Bazinga! ", nodes[0].text.?.content); } -// FIX: check parse block something is wrong test "parse comment inside block" { std.debug.print("____________________________________________________\n", .{}); std.debug.print("12 - parse comment\n", .{}); @@ -263,17 +262,15 @@ test "parse comment inside block" { try testing.expectEqual(@as(usize, 1), nodes.len); try testing.expect(nodes[0].type == .tag); - // try testing.expectEqual(@as(usize,2), nodes[0].tag.?.body.block.body.len); - // - // const b = nodes[0].tag.?.body.block.body; - // for (b) |node| { - // if (node.type == .text) std.debug.print("{s}\n", .{node.text.?.content}); - // std.debug.print("{any}\n", .{node}); - // } - // // std.debug.print("{any}",.{nodes[0].tag.?.body.block.body}); - try testing.expect(nodes[0].tag.?.body.block.body[0].type == .text); - try testing.expectEqualStrings("Bazinga!", nodes[0].tag.?.body.block.body[0].text.?.content); + const child_nodes = nodes[0].tag.?.body.block.body; + + try testing.expectEqual(@as(usize, 2), child_nodes.len); + + try testing.expect(child_nodes[0].type == .text); + try testing.expect(child_nodes[1].type == .text); + try testing.expectEqualStrings("Bazinga!", child_nodes[0].text.?.content); + try testing.expectEqualStrings(" haha", child_nodes[1].text.?.content); } test "parse simple cycle" { @@ -1006,13 +1003,7 @@ test "parse spaceless nested" { try testing.expect(nodes[0].type == .tag); try testing.expect(nodes[0].tag.?.kind == .spaceless); const sl = nodes[0].tag.?.body.spaceless; - // for (sl.body) |node| { - // if (node.type == .text) { - // std.debug.print("{s}\n", .{node.text.?.content}); - // } else { - // std.debug.print("{any}\n", .{node}); - // } - // } + try testing.expectEqual(@as(usize, 4), sl.body.len); } test "parse templatetag openblock" { @@ -1183,7 +1174,6 @@ test "parse simple verbatim" { try testing.expect(nodes[1].type == .tag); try testing.expect(nodes[1].tag.?.kind == .verbatim); const vb = nodes[1].tag.?.body.verbatim; - std.debug.print("{s}\n", .{vb.name.?}); try testing.expectEqualStrings("{{ variável }}{% endblock %}", vb.content); try testing.expect(std.mem.eql(u8, vb.name.?, ""));