diff options
Diffstat (limited to 'src/z/js/parser/parser.zig')
| -rw-r--r-- | src/z/js/parser/parser.zig | 53 |
1 files changed, 2 insertions, 51 deletions
diff --git a/src/z/js/parser/parser.zig b/src/z/js/parser/parser.zig index f269401..050f8c1 100644 --- a/src/z/js/parser/parser.zig +++ b/src/z/js/parser/parser.zig @@ -1,7 +1,7 @@ const std = @import("std"); -const mod = @import("root.zig"); -const Result = mod.Result; +const root = @import("root.zig"); +const Result = root.Result; pub fn Parser(T: type) type { const R = Result(T); @@ -66,52 +66,3 @@ pub fn Parser(T: type) type { } }; } - -test "variants" { - const Char = union(enum) { - upper: u8, - lower: u8, - space: void, - }; - - const parser: Parser(Char) = .variants(struct { - const upper: Parser(u8) = .any(void, &.{ - .{ mod.builtin.literal("A"), 'A' }, - .{ mod.builtin.literal("B"), 'B' }, - }); - - const lower: Parser(u8) = .any(void, &.{ - .{ mod.builtin.literal("a"), 'a' }, - .{ mod.builtin.literal("b"), 'b' }, - }); - - const space: Parser(void) = mod.builtin.literal(" "); - }); - - { - const result = try parser.parseAll("a"); - try std.testing.expect(result.lower == 'a'); - } - - { - const result = try parser.parseAll("b"); - try std.testing.expect(result.lower == 'b'); - } - - { - const result = try parser.parseAll("A"); - try std.testing.expect(result.upper == 'A'); - } - - { - const result = try parser.parseAll("B"); - try std.testing.expect(result.upper == 'B'); - } - - { - const result = try parser.parseAll(" "); - try std.testing.expect(result == .space); - } - - try std.testing.expect(parser.parseAll("c") == error.Variants); -} |