diff options
| author | Taylan Kammer <taylan.kammer@gmail.com> | 2026-01-11 19:08:29 +0100 |
|---|---|---|
| committer | Taylan Kammer <taylan.kammer@gmail.com> | 2026-01-11 19:08:29 +0100 |
| commit | c9a1a310e77802a7fa415170c26b7e56c2100de8 (patch) | |
| tree | 9f29f0351d3ed5e1aac14a56c2f6009a9e1dd51a /src/test/parse.zig | |
| parent | dbc3779c552f616437574e04c8673c6f5d8382a6 (diff) | |
Refactoring for ergonomics.
Diffstat (limited to 'src/test/parse.zig')
| -rw-r--r-- | src/test/parse.zig | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/src/test/parse.zig b/src/test/parse.zig index 272c92a..61f8fc3 100644 --- a/src/test/parse.zig +++ b/src/test/parse.zig @@ -3,16 +3,17 @@ const std = @import("std"); const testing = std.testing; const expect = testing.expect; -const gst_io = std.Io.Threaded.global_single_threaded.io(); +const alloc = std.heap.smp_allocator; +const io = std.Io.Threaded.global_single_threaded.io(); -pub const io = @import("../zisp/io.zig"); -pub const value = @import("../zisp/value.zig"); +pub const zisp = @import("../zisp.zig"); -pub const Value = value.Value; +pub const value = zisp.value; +pub const Value = zisp.Value; fn parse(str: []const u8) Value { var fbs = std.Io.Reader.fixed(str); - return io.parse.fromReader(&fbs); + return zisp.io.parse.fromReaderNoError(alloc, io, &fbs); } test "parse empty" { @@ -119,7 +120,7 @@ test "print" { var buf: [32]u8 = undefined; var w = std.Io.Writer.fixed(&buf); const v = parse("#foo"); - try io.print.toWriter(&w, v); + try zisp.io.print.toWriter(&w, v); try testing.expectEqualStrings("#foo", buf[0..w.end]); } @@ -127,7 +128,7 @@ test "print2" { var buf: [128]u8 = undefined; var w = std.Io.Writer.fixed(&buf); const v = parse("#{foo bar['x]}"); - try io.print.toWriter(&w, v); + try zisp.io.print.toWriter(&w, v); try testing.expectEqualStrings( "(#HASH #BRACE foo (#JOIN bar #SQUARE (#QUOTE & x)))", buf[0..w.end], @@ -136,11 +137,11 @@ test "print2" { fn parseAndPrint(str: []const u8) !void { var buf: [64]u8 = undefined; - var fw = std.Io.File.stderr().writer(gst_io, &buf); + var fw = std.Io.File.stderr().writer(io, &buf); const w = &fw.interface; const v = parse(str); - try io.print.toWriter(w, v); + try zisp.io.print.toWriter(w, v); try w.writeByte('\n'); try w.flush(); } @@ -166,18 +167,17 @@ test "print7" { } fn parseBench(path: []const u8, iters: usize) !void { - const file = try std.Io.Dir.cwd().openFile(gst_io, path, .{}); - defer file.close(gst_io); + const file = try std.Io.Dir.cwd().openFile(io, path, .{}); + defer file.close(io); - var sfa = io.Parser.DefaultSfa.withFallback(std.heap.smp_allocator); - var parser = try io.Parser.initWithSfa(&sfa, gst_io); - defer parser.deinit(); + var parser, const sfa = try zisp.io.Parser.init(alloc, io); + defer parser.deinit(sfa); var timer = try std.time.Timer.start(); for (0..iters) |i| { _ = i; var buf: [4096]u8 = undefined; - var reader = file.reader(gst_io, &buf); + var reader = file.reader(io, &buf); var v: Value = undefined; while (true) { v = parser.run(&reader.interface) catch |e| { |
