diff options
| author | Nathan Reiner <nathan@nathanreiner.xyz> | 2026-07-30 09:36:34 +0200 |
|---|---|---|
| committer | Nathan Reiner <nathan@nathanreiner.xyz> | 2026-07-30 09:36:34 +0200 |
| commit | aca38f5c96709f56db75a476051eb644de644d3d (patch) | |
| tree | 1ce90ccffb80cff8d527be6efbd073031fccd3a1 /src/z/js/parser/root.zig | |
| parent | 006674d7e08146a9bd980e2138ce9444d2e40e6f (diff) | |
restructure project
Diffstat (limited to 'src/z/js/parser/root.zig')
| -rw-r--r-- | src/z/js/parser/root.zig | 89 |
1 files changed, 0 insertions, 89 deletions
diff --git a/src/z/js/parser/root.zig b/src/z/js/parser/root.zig deleted file mode 100644 index af0a67d..0000000 --- a/src/z/js/parser/root.zig +++ /dev/null @@ -1,89 +0,0 @@ -const std = @import("std"); - -pub const lexical_grammar = @import("lexical_grammar.zig"); -pub const ast = @import("ast.zig"); - - -pub const Result = @import("result.zig").Result; -pub const Parser = @import("parser.zig").Parser; - -test "simple literal" { - comptime { - _ = try ast.Program.parse("42;"); - } -} - -test "variable declaration" { - comptime { - _ = try ast.Program.parse("var x = 1;"); - } -} - -test "function declaration" { - comptime { - _ = try ast.Program.parse("function foo() { return 1; }"); - } -} - -test "if statement" { - comptime { - _ = try ast.Program.parse("if (x > 0) { x = 1; } else { x = 2; }"); - } -} - -test "binary expression" { - comptime { - _ = try ast.Program.parse("a + b * c;"); - } -} - -test "arrow function" { - comptime { - _ = try ast.Program.parse("const f = (x) => x + 1;"); - } -} - -test "class declaration" { - comptime { - _ = try ast.Program.parse("class Foo { constructor() { } }"); - } -} - -test "for loop" { - comptime { - _ = try ast.Program.parse("for (var i = 0; i < 10; i++) { break; }"); - } -} - -test "try catch" { - comptime { - _ = try ast.Program.parse("try { x; } catch (e) { y; }"); - } -} - -test "multiple statements" { - comptime { - _ = try ast.Program.parse("var a = 1; var b = 2; var c = a + b;"); - } -} - -test "comprehensive fixture" { - comptime { - _ = try ast.Program.parse(@embedFile("test_fixture.js")); - } -} - -test "format fixture" { - comptime { - var buf: [65536]u8 = undefined; - const ast1 = try ast.Program.parse(@embedFile("test_fixture.js")); - var f = ast.Formatter{ .buf = buf[0..], .pos = 0, .indent_level = 0, .options = .{} }; - ast1.fmt(&f); - const formatted = buf[0..f.pos]; - try std.testing.expect(formatted.len > 0); - } -} - -test { - _ = std.testing.refAllDecls(@This()); -} |