aboutsummaryrefslogtreecommitdiff
path: root/src/z/parser/js/root.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/z/parser/js/root.zig')
-rw-r--r--src/z/parser/js/root.zig14
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());
}