summaryrefslogtreecommitdiff
path: root/core/replica.zig
diff options
context:
space:
mode:
Diffstat (limited to 'core/replica.zig')
-rw-r--r--core/replica.zig39
1 files changed, 39 insertions, 0 deletions
diff --git a/core/replica.zig b/core/replica.zig
index 46320fea..4126972a 100644
--- a/core/replica.zig
+++ b/core/replica.zig
@@ -6615,6 +6615,45 @@ test "a kind's place moved in a step of another view's: a replica's key that rea
try agrees(a, r);
}
+/// Placed, plain (PA_PLAIN): a client runs it, and its state is the rows
+/// its last view was told.
+const Viewed = struct {
+ const pa = pardes.Kind.c;
+ const words = [_]pa.pa_word{std.mem.zeroInit(pa.pa_word, .{ .name = "Viewed", .opens = 1, .doc = "the rows its view was told" })};
+ const ops = std.mem.zeroInit(pardes.Kind.Ops, .{
+ .head = std.mem.zeroInit(pa.pa_head, .{ .size = @sizeOf(pa.pa_head), .abi = pardes.Kind.abi, .name = "viewed".* ++ @as([10]u8, @splat(0)), .version = 1, .exts = "", .flags = pa.PA_PLAIN, .words = &words, .nwords = 1 }),
+ .open = Placed.open,
+ .paint = Placed.paint,
+ .view = Placed.view,
+ });
+};
+
+test "a client joins with its session's geometry as the session holds it: the view opened for it, not laid out yet, is not laid out in the client either, and a plain kind is told the same views on both" {
+ // The soak's (test/replicas.zig): a client parted at its first unit
+ // after its join, `addon pdf: its state after view is not the
+ // session's`: it had laid every view out at its load, its own new one
+ // too, which the session lays out at that view's first input.
+ const gpa = std.testing.allocator;
+ const a = try Authority.init(gpa, .{ .cols = 80, .rows = 24, .file = "mise.toml" }, TestHost.host());
+ defer a.deinit();
+ var words: [64]pardes.Kind.LoadedWord = undefined;
+ const viewed = pardes.Kind.loadedOf(&Viewed.ops, "/x/viewed.so", @splat(7), &words);
+ _ = try a.local(.{ .addon = .{ .op = .load, .pane = .at(0), .kind = &viewed } });
+ _ = try a.local(.{ .command = "Viewed" });
+ const kid = a.core.view().active;
+ const joined = (try a.join(1, null)).?;
+ defer gpa.free(joined.dump);
+ const r = try Replica.initDump(gpa, 1, joined.view, joined.dump, .{ .cols = 80, .rows = 24 });
+ defer r.deinit();
+ try std.testing.expect(r.loaded(joined.digest));
+ try runsHere(r, kid, &Viewed.ops);
+ try std.testing.expectEqual(a.core.views[joined.view].?.rects[kid], r.core().views[joined.view].?.rects[kid]);
+ // The session's own step tells the kind each view whose facts changed.
+ r.confirm(try a.local(.tick));
+ r.settle();
+ try agrees(a, r);
+}
+
/// A kind whose every key asks a job, for the job tokens' test.
const Jobber = struct {
const pa = pardes.Kind.c;