diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-03 17:00:43 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-03 17:01:13 -0300 |
| commit | 53c2a95eff9c67871d6004baa3e7d3c3b2a195fd (patch) | |
| tree | b2bc1fec3ab6b33eab1a29613c7d3cb5be6da1a2 /test/session.zig | |
| parent | d1273bbd99daf9b1855d82bf315db8ede20abde5 (diff) | |
| download | pardes-53c2a95eff9c67871d6004baa3e7d3c3b2a195fd.tar.gz pardes-53c2a95eff9c67871d6004baa3e7d3c3b2a195fd.zip | |
test: three of test/pdf.zig's look tests through the 9P tree alone (test/behaviour/look_and_exec): `:N` on a PDF from its look, the root's and `@pN:N` (the page read from its tag's [P/N]), its misses in the log (no page 0, no search hit, no text to address, one past the last); a page past the last a miss, open or not, opening nothing (/index); a +PdfSections row's page checked against the outline; Session's lookFile and pdfPage; each checked to fail against a break (a PDF look turning to page 1 always, an open PDF's past-last page check dropped, Pdf.openPane taking .last for .refuse, the sections row's page check dropped)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'test/session.zig')
| -rw-r--r-- | test/session.zig | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/test/session.zig b/test/session.zig index 8b3c5c41..f11a4c7f 100644 --- a/test/session.zig +++ b/test/session.zig @@ -182,6 +182,26 @@ pub const Session = struct { fn pardesOf(s: *Session) *Pardes { return @ptrCast(@alignCast(s.core)); } + + // pdf: + + /// A Look of `path` at the root (one relative to the working directory + /// made absolute first); the serial of the pane with the keyboard after. + pub fn lookFile(s: *Session, path: []const u8) !u32 { + var buf: [4096]u8 = undefined; + const abs = if (std.fs.path.isAbsolute(path)) path else s.at("{s}/{s}", .{ buf[0..try std.Io.Dir.cwd().realPath(std.testing.io, &buf)], path }); + try s.write("/look", s.at("{s}\n", .{abs})); + return s.focused(); + } + + /// The page a PDF pane shows and its pages, from its tag's `[page/pages]`. + pub fn pdfPage(s: *Session, n: u32) !struct { u32, u32 } { + const tag = try s.read(s.at("/pane/{d}/tag", .{n})); + const lo = std.mem.indexOf(u8, tag, " [") orelse return error.NoPage; + const close = std.mem.indexOfScalarPos(u8, tag, lo, ']') orelse return error.NoPage; + var it = std.mem.splitScalar(u8, tag[lo + 2 .. close], '/'); + return .{ try std.fmt.parseInt(u32, it.next().?, 10), try std.fmt.parseInt(u32, it.next() orelse return error.NoPage, 10) }; + } }; fn refusal(path: []const u8, r: Reply) error{Refused} { |
