diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-06 18:23:20 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-06 20:00:43 -0300 |
| commit | 1b38ca0aa0bfae1177f80a6713ec6d787d2f77d4 (patch) | |
| tree | 9c656ca528561286e07c099a8d770af89417100a /test | |
| parent | eeb59b92295e74b956d32e66c3c318e105a391db (diff) | |
| download | pardes-1b38ca0aa0bfae1177f80a6713ec6d787d2f77d4.tar.gz pardes-1b38ca0aa0bfae1177f80a6713ec6d787d2f77d4.zip | |
kinds #39, paint writes nothing a step reads and the digest is every Slot field a step reads (§17.2 B 2-3): the Slot says what is the kind's own or a frame's (its code and memory, its jobs' inputs, a placeholder's record, the place its kind says, the thumb, the pointer, whether a frame was drawn) and the walker digests the rest, `placed` and the prefix leave the Shadow's frame (the pointer its one byte), the dump carries the cancelled tokens a replica's job answers are dropped by, and a pane test dumps a session with a PDF and a picture, loads it on another core and compares every Slot field the walk does not leave out, so a field added and not dumped fails a test, not a soak
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'test')
| -rw-r--r-- | test/panes.zig | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/test/panes.zig b/test/panes.zig index 249ce7eb..3e147c95 100644 --- a/test/panes.zig +++ b/test/panes.zig @@ -3902,6 +3902,67 @@ const PdfAddon = struct { try std.testing.expect(r.diverged == null); } + test "a pane of each kind, dumped and loaded on another core, has every Slot field a step reads as the session's" { + 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 Land = struct { + a: *R.Authority, + fn step(l: @This(), ev: pardes.Event) !void { + _ = try l.a.local(ev); + } + }; + const land: Land = .{ .a = a }; + const pdf = try opened(a, land); + try land.step(.{ .command = "PdfFit width" }); + a.core.panes[pdf].?.addon.?.cancelled[0] = 7; + // A picture beside it (the image addon's). + var words: [64]pardes.Kind.LoadedWord = undefined; + var why: pardes.Kind.Buf(160) = .{}; + const lib = pardes.Addon.readLoaded(@import("test_addons").image, &words, &why); + try land.step(.{ .addon = .{ .op = .load, .pane = 0, .kind = &lib } }); + var tmp = std.testing.tmpDir(.{}); + defer tmp.cleanup(); + try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "dot.ppm", .data = "P6\n1 1\n255\n\x01\x02\x03" }); + var buf: [4096]u8 = undefined; + var line: [4200]u8 = undefined; + try land.step(.{ .command = try std.fmt.bufPrint(&line, "Look {s}/dot.ppm", .{buf[0..try tmp.dir.realPath(std.testing.io, &buf)]}) }); + try jobs(a.core, land); + const was = pardes.tape.on; + pardes.tape.on = &a.t; + const bytes = try pardes.dump.byteDump(a.core); + pardes.tape.resync(&a.t); + pardes.tape.on = was; + defer a.core.gpa.free(bytes); + const r = try R.Replica.initDump(gpa, 2, 0, bytes, .{ .cols = 80, .rows = 24 }); + defer r.deinit(); + try std.testing.expect(r.loaded(pardes.tape.digestOf(a.core))); + // Every field but those the Slot says are the kind's or a frame's + // (`replica.local`): a field added and not dumped fails here. + var kinds: usize = 0; + for (a.core.panes, r.core().panes) |mine, theirs| if (mine) |pane| if (pane.addon) |s| { + const t = theirs.?.addon.?; + kinds += 1; + inline for (@typeInfo(pardes.Kind.Slot).@"struct".field_names) |name| { + const local = comptime for (pardes.Kind.Slot.replica.local) |n| { + if (std.mem.eql(u8, n, name)) break true; + } else false; + const F = @FieldType(pardes.Kind.Slot, name); + if (comptime local) {} else if (comptime @typeInfo(F) == .@"struct" and @hasDecl(F, "slice")) + try std.testing.expectEqualStrings(@field(s, name).slice(), @field(t, name).slice()) + else + try std.testing.expectEqualDeep(@field(s, name), @field(t, name)); + } + // Its place: what its kind says, and the Shadow's copy of it. + var here: [32]u8 = undefined; + var there: [32]u8 = undefined; + try std.testing.expectEqualStrings(pardes.Kind.where(s, &here), pardes.Kind.where(t, &there)); + }; + try std.testing.expectEqual(2, kinds); + } + test "a client's input that moves a PDF's view is guessed right, never waited for, and the session's tick of it is a unit of its own the client replays" { if (!addons.has_pdf) return error.SkipZigTest; const R = pardes.replica; |
