Files
pugz/tests/debug_test.zig
Ankit Patial aaf6a1af2d fix: add scoped error logging for lexer/parser errors
- Add std.log.scoped(.pugz) to template.zig and view_engine.zig
- Log detailed error info (code, line, column, message) when parsing fails
- Log template path context in ViewEngine on parse errors
- Remove debug print from lexer, use proper scoped logging instead
- Move benchmarks, docs, examples, playground, tests out of src/ to project root
- Update build.zig and documentation paths accordingly
- Bump version to 0.3.1
2026-01-25 17:10:02 +05:30

47 lines
1.3 KiB
Zig

const std = @import("std");
const lexer_mod = @import("../lexer.zig");
const parser_mod = @import("../parser.zig");
const ast = @import("../ast.zig");
test "debug block expansion" {
const alloc = std.testing.allocator;
const pug =
\\ul
\\ li.list-item: .foo: #bar baz
;
var lexer = lexer_mod.Lexer.init(alloc, pug);
const tokens = try lexer.tokenize();
var parser = parser_mod.Parser.init(alloc, tokens);
const doc = try parser.parse();
// Print structure
std.debug.print("\n", .{});
for (doc.nodes) |node| {
printNode(node, 0);
}
}
fn printNode(node: ast.Node, depth: usize) void {
var i: usize = 0;
while (i < depth * 2) : (i += 1) {
std.debug.print(" ", .{});
}
switch (node) {
.element => |elem| {
std.debug.print("element: {s} is_inline={} children={d}", .{elem.tag, elem.is_inline, elem.children.len});
if (elem.inline_text != null) {
std.debug.print(" (has inline_text)", .{});
}
std.debug.print("\n", .{});
for (elem.children) |child| {
printNode(child, depth + 1);
}
},
.text => |_| std.debug.print("text\n", .{}),
else => std.debug.print("other\n", .{}),
}
}