diff options
Diffstat (limited to 'core/replica.zig')
| -rw-r--r-- | core/replica.zig | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/core/replica.zig b/core/replica.zig index 818e375a..5bf306fa 100644 --- a/core/replica.zig +++ b/core/replica.zig @@ -6878,3 +6878,51 @@ test "a client of screen-state terminals takes a 9P pty/run in a shell as the se try agrees(a, r); try agrees(a, late); } + +// Del with a pane above and below asks which way the space goes, its +// question shown once a delay is up (builtins.zig): its time was the +// host's clock read in the step, an answering entry a speculation stops at. +test "a far client's Del with panes above and below is applied at once, and its question's time is the session's" { + const gpa = std.testing.allocator; + const Clocked = struct { + var now_ns: u64 = 7 * std.time.ns_per_s; + fn now(_: ?*anyopaque) u64 { + return now_ns; + } + const vtable: pardes.Host.VTable = .{ .watched = TestHost.watched, .now = now }; + }; + const a = try Authority.init(gpa, .{ .cols = 80, .rows = 30, .file = "mise.toml" }, .{ .vtable = &Clocked.vtable }, false); + defer a.deinit(); + _ = try a.local(.{ .command = "New" }); + const mid = a.core.view().active; + _ = try a.local(.{ .command = "New" }); + { + const was = Stepping.begin(&a.t, null); + defer was.end(); + a.core.view().active = mid; + } + const r = try joinedFresh(a); + defer r.deinit(); + var sent: std.ArrayListUnmanaged([]u8) = .empty; + defer { + for (sent.items) |m| gpa.free(m); + sent.deinit(gpa); + } + Clocked.now_ns += std.time.ns_per_s; + try key(r, ' ', &sent); + try key(r, 'd', &sent); + try std.testing.expectEqual(@as(usize, 2), r.applied); + try std.testing.expect(r.core().panes[mid].?.prompt == .del_side); + for (sent.items) |m| { + r.confirm(try a.take(m)); + r.settle(); + } + try std.testing.expectEqual(@as(u32, 0), r.stats.mispredicted); + try agrees(a, r); + // The question shows a delay after it was asked, on the session's clock. + a.pump(); + r.confirm((try a.pending()).?); + r.settle(); + try agrees(a, r); + try std.testing.expectEqual(Clocked.now_ns + pardes.config.del_question_delay_ns, r.core().panes[mid].?.question_due_ns); +} |
