From c46957f44e8b5ba0639b7092a1c5abd9516b1b22 Mon Sep 17 00:00:00 2001 From: Anhgelus Morhtuuzh Date: Sun, 19 Apr 2026 18:55:36 +0200 Subject: fix(ast): small memory leak in subs --- src/parser.zig | 30 +----------------------------- 1 file changed, 1 insertion(+), 29 deletions(-) (limited to 'src/parser.zig') diff --git a/src/parser.zig b/src/parser.zig index 442d823..f109a88 100644 --- a/src/parser.zig +++ b/src/parser.zig @@ -49,20 +49,11 @@ fn doTest(alloc: Allocator, t: []const u8, v: []const u8) !void { }; } -fn doTestError(alloc: Allocator, t: []const u8, err: Error) !void { - _ = parse(alloc, t) catch |e| return std.testing.expect(err == e); - return std.testing.expect(false); -} - -test "parse paragraphs" { +test "parse multilines" { var arena = std.heap.DebugAllocator(.{}).init; defer if (arena.deinit() == .leak) std.debug.print("leaking!\n", .{}); const alloc = arena.allocator(); - try doTest(alloc, "hello world", "

hello world

"); - try doTest(alloc, "*hello* world", "

hello world

"); - try doTest(alloc, "*he_ll_o* world", "

hello world

"); - try doTest(alloc, \\hello \\world @@ -71,29 +62,10 @@ test "parse paragraphs" { \\in new paragraph , "

hello world

foo bar in new paragraph

"); - try doTestError(alloc, "hello *world", Error.ModifierNotClosed); - try doTestError(alloc, "hello *wo_rld*", Error.ModifierNotClosed); - try doTestError(alloc, "*hell*o *wo_rld*", Error.ModifierNotClosed); - try doTestError(alloc, "hello ::: world", Error.IllegalPlacement); -} - -test "parse title" { - var arena = std.heap.DebugAllocator(.{}).init; - defer if (arena.deinit() == .leak) std.debug.print("leaking!\n", .{}); - const alloc = arena.allocator(); - - try doTest(alloc, "# hey", "

hey

"); - try doTest(alloc, "## hey", "

hey

"); - try doTest(alloc, "### hey", "

hey

"); - - try doTest(alloc, "# hello *world*", "

hello world

"); - try doTest(alloc, \\# title \\hello world ;3 \\## subtitle \\hehe , "

title

hello world ;3

subtitle

hehe

"); - - try doTestError(alloc, "# aa :::", Error.InvalidTitleContent); } -- cgit v1.2.3