diff options
| author | Nathan Reiner <nathan@nathanreiner.xyz> | 2026-07-30 10:24:19 +0200 |
|---|---|---|
| committer | Nathan Reiner <nathan@nathanreiner.xyz> | 2026-07-30 10:24:19 +0200 |
| commit | 00920ddd36a8ebb851b52c3c048c0017753176bd (patch) | |
| tree | 8498e65ca6c055333aa95b6c3a0d28c8370cb0ef /src/z/parser/js/root.zig | |
| parent | e8259360516078517a2fbeddbf781f701f35d0d0 (diff) | |
complete js parser + minifierjs-parser
Diffstat (limited to 'src/z/parser/js/root.zig')
| -rw-r--r-- | src/z/parser/js/root.zig | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/z/parser/js/root.zig b/src/z/parser/js/root.zig index 565d572..6b2d5c7 100644 --- a/src/z/parser/js/root.zig +++ b/src/z/parser/js/root.zig @@ -1,7 +1,7 @@ const std = @import("std"); pub const lexical_grammar = @import("lexical_grammar.zig"); -pub const ast = @import("ast.zig"); +pub const ast = @import("ast/core.zig"); test "simple literal" { comptime { @@ -80,6 +80,18 @@ test "format fixture" { } } +test "minify" { + comptime { + var buf: [65536]u8 = undefined; + const ast1 = try ast.Program.parse("function foo() { var x = 1; return x; }"); + var f = ast.Formatter{ .buf = buf[0..], .pos = 0, .indent_level = 0, .options = .{ .minify = true } }; + ast1.fmt(&f); + const minified = buf[0..f.pos]; + try std.testing.expect(std.mem.indexOf(u8, minified, "\n") == null); + try std.testing.expect(minified.len < 50); + } +} + test { _ = std.testing.refAllDecls(@This()); } |