diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-18 12:16:51 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-18 12:32:20 -0300 |
| commit | f3a38a45c00eb02f0aaaca7185e5601ab7224913 (patch) | |
| tree | 694d59f4151325cd624b7692c9ab31c770430f01 /test/panes.zig | |
| parent | 69bf62d3e245934b922025c62d8703700521cac0 (diff) | |
| download | pardes-f3a38a45c00eb02f0aaaca7185e5601ab7224913.tar.gz pardes-f3a38a45c00eb02f0aaaca7185e5601ab7224913.zip | |
pdf: address P:H checks hit H against page P's count alone when this process has no counts (a client joined after the search: it searched every page on its loop, about 6.8 s of CPU against 0.36 s for a page jump on a 1,008-page file, at load 4-22; 0.47 s after), the job's counts as before where they came; tests through the replicated cores: a terminal's client shows a PDF's page as its text layer, the session's page's first line on its first row, no picture placed; a PDF pane a client closes waits for the session's order (its kind's close is never guessed, so the client's own side is freed when the session's unit closes it), then is gone in both; tui core-test 817/956 (139 skipped), shell-test 991/994, behaviour-test 274/274, --replay 20 seeds 0 failures, pane-test 183/184, replicas pass, addon-test 1/1, process-test 2 of 144 failed (lspcomplete and lspcompletemoved, the base's), test/daemon.py, --far, --games and --window-clients pass; gui unit-test 1588/1592 (its perf check's BaselineBuildMismatch, the base's), the frame corpus 77/77 against mbase2; no client: pdf-scroll-bench 18,064-18,069M instructions:u against 18,066-18,071M for the base with the fixed bench (visual hashes the same), start to the first frame (terminal) 53.7-54.7M against 53.6-54.7M
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'test/panes.zig')
| -rw-r--r-- | test/panes.zig | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/test/panes.zig b/test/panes.zig index a9a22351..de9d3aea 100644 --- a/test/panes.zig +++ b/test/panes.zig @@ -4235,6 +4235,95 @@ const PdfAddon = struct { } try std.testing.expectEqualSlices([4]u32, &at[0], &at[1]); } + + /// A session with design.pdf open and a client on a view of its own + /// (`frontend`'s), which runs the kind as the session does: handed the + /// session's library (a test's replica finds none of its own). + fn clientOf(a: *pardes.replica.Authority, win: *pardes.replica.Replica, frontend: pardes.Event) !struct { id: usize, view: u8 } { + const land = Confirmed{ .a = a, .r = win }; + try land.step(.{ .frontend = .{ .windowed = true, .native_images = true } }); + var words: [64]pardes.Kind.LoadedWord = undefined; + var why: pardes.Kind.Buf(160) = .{}; + const lib = pardes.Addon.readLoaded(pdf_lib, &words, &why); + try land.step(.{ .addon = .{ .op = .load, .pane = 0, .kind = &lib } }); + const kind = a.core.kinds.n - 1; + win.core().kinds.ops[kind] = a.core.kinds.ops[kind]; + const id = try opened(a, land); + const k = try a.openView(2); + win.confirm(k.unit); + win.view = k.view; + win.confirm(try a.take(try win.input(frontend))); + try land.step(.tick); + try jobs(a.core, land); + return .{ .id = id, .view = k.view }; + } + + const Confirmed = struct { + a: *pardes.replica.Authority, + r: *pardes.replica.Replica, + fn step(l: @This(), ev: pardes.Event) !void { + l.r.confirm(try l.a.local(ev)); + } + }; + + test "a terminal's client shows a PDF's page as its text, the session's page's lines from its first" { + if (!addons.has_pdf) return error.SkipZigTest; + const R = pardes.replica; + const gpa = std.testing.allocator; + const a = try R.Authority.init(gpa, .{ .cols = 80, .rows = 24, .file = "mise.toml" }, .{ .vtable = &host_vtable }, false); + defer a.deinit(); + const win = try R.Replica.init(gpa, 2, try a.unit(0, 0), false); + defer win.deinit(); + const c = try clientOf(a, win, .{ .frontend = .{ .windowed = false, .native_images = false } }); + try (Confirmed{ .a = a, .r = win }).step(.tick); + try jobs(a.core, Confirmed{ .a = a, .r = win }); + // The page's text (its body) as the session reads it: its first line + // is the client pane's first row. + const text = try pardes.Kind.body(a.core.panes[c.id].?, gpa); + defer gpa.free(text); + const first = std.mem.trim(u8, text[0 .. std.mem.indexOfScalar(u8, text, '\n') orelse text.len], " "); + try std.testing.expect(first.len > 0); + var arena: std.heap.ArenaAllocator = .init(gpa); + defer arena.deinit(); + win.core().toView(c.view); + const s = try win.core().render(arena.allocator()); + const r = win.core().view().rects[c.id]; + var row: [512]u8 = undefined; + var n: usize = 0; + for (r.x..r.x + r.w) |x| { + const g = s.at(@intCast(x), r.y + win.core().panes[c.id].?.tag_rows).grapheme(); + if (n + g.len > row.len) break; + @memcpy(row[n..][0..g.len], g); + n += g.len; + } + try std.testing.expect(std.mem.indexOf(u8, row[0..n], first[0..@min(first.len, 20)]) != null); + var placed: usize = 0; + for (s.placements.items) |pl| placed += @intFromBool(pl.pane == c.id); + try std.testing.expectEqual(@as(usize, 0), placed); + } + + test "a PDF pane a client closes waits for the session's order (its kind's close is never guessed), then is gone in both" { + if (!addons.has_pdf) return error.SkipZigTest; + const R = pardes.replica; + const gpa = std.testing.allocator; + const a = try R.Authority.init(gpa, .{ .cols = 80, .rows = 24, .file = "mise.toml" }, .{ .vtable = &host_vtable }, false); + defer a.deinit(); + const win = try R.Replica.init(gpa, 2, try a.unit(0, 0), false); + defer win.deinit(); + const c = try clientOf(a, win, .{ .frontend = .{ .windowed = true, .native_images = true } }); + // The client's click in the PDF: its pane the client's own view's. + const r = win.core().view().rects[c.id]; + for ([_]pardes.Mouse.Kind{ .press, .release }) |kind| win.confirm(try a.take(try win.input(.{ .mouse = .{ .button = .left, .kind = kind, .col = r.x + 4, .row = r.y + r.h - 2 } }))); + win.settle(); + const stopped = win.stats.stopped; + const sent = try win.input(.{ .command = "Del" }); + try std.testing.expect(win.core().panes[c.id] != null); + try std.testing.expectEqual(stopped + 1, win.stats.stopped); + win.confirm(try a.take(sent)); + win.settle(); + try std.testing.expect(a.core.panes[c.id] == null and win.core().panes[c.id] == null); + try std.testing.expect(win.diverged == null); + } }; test { |
