summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/panes.zig34
1 files changed, 22 insertions, 12 deletions
diff --git a/test/panes.zig b/test/panes.zig
index 28256495..249ce7eb 100644
--- a/test/panes.zig
+++ b/test/panes.zig
@@ -3902,7 +3902,7 @@ const PdfAddon = struct {
try std.testing.expect(r.diverged == null);
}
- test "a client's input whose session step ticks a PDF's pane waits for that step, never guessed and rolled back" {
+ 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;
const gpa = std.testing.allocator;
@@ -3917,15 +3917,22 @@ const PdfAddon = struct {
l.r.confirm(try l.a.local(ev));
}
};
- _ = try opened(a, Land{ .a = a, .r = r });
+ const id = try opened(a, Land{ .a = a, .r = r });
const guessed = r.stats.mispredicted;
- // Its window resized: the pane's view moves, and the session's
- // step ticks its kind, which only the session runs.
+ const stopped = r.stats.stopped;
+ const told = a.core.panes[id].?.addon.?.views;
+ // Its window resized: the pane's view moves; the client's input
+ // calls no kind, so its guess is the session's step.
r.confirm(try a.take(try r.input(.{ .resize = .{ .cols = 100, .rows = 30 } })));
r.settle();
- try std.testing.expect(r.diverged == null);
try std.testing.expectEqual(guessed, r.stats.mispredicted);
- try std.testing.expect(r.stats.stopped >= 1);
+ try std.testing.expectEqual(stopped, r.stats.stopped);
+ // The session's own next step tells the kind, ticks it, and the
+ // client replays that unit.
+ r.confirm(try a.local(.tick));
+ try std.testing.expect(r.diverged == null);
+ try std.testing.expect(!std.mem.eql(u64, &told, &a.core.panes[id].?.addon.?.views));
+ try std.testing.expectEqualSlices(u64, &a.core.panes[id].?.addon.?.views, &r.core().panes[id].?.addon.?.views);
}
test "a PDF's tag has the core's art words from its first step, in a view without graphics and with them" {
@@ -3942,14 +3949,14 @@ const PdfAddon = struct {
};
const land: Land = .{ .a = a };
const id = try opened(a, land);
- const slot = a.core.panes[id].?.addon.?;
// A view without graphics: the page's text layer, its pictures'
// words glyph art's (PA_PICTURES: the kind's, not the frame's).
- try std.testing.expect(std.mem.indexOf(u8, slot.told.slice(), " petscii:on ") != null);
+ const pane = a.core.panes[id].?;
+ try std.testing.expect(std.mem.indexOf(u8, try pardes.tagline.tagPrefix(a.core, pane), " petscii:on ") != null);
// A window's: the pages as pictures, the same words, its own.
try land.step(.{ .frontend = .{ .windowed = true, .native_images = true } });
try jobs(a.core, land);
- try std.testing.expect(std.mem.indexOf(u8, slot.told.slice(), " petscii:off ") != null);
+ try std.testing.expect(std.mem.indexOf(u8, try pardes.tagline.tagPrefix(a.core, pane), " petscii:off ") != null);
}
test "a PDF's pane in a window's view and a terminal's in turn: each is told its view, its tag its page and art words in both" {
@@ -3980,8 +3987,11 @@ const PdfAddon = struct {
const win = try R.Replica.initDump(gpa, 2, k, bytes, .{ .cols = 80, .rows = 24 });
defer win.deinit();
_ = try a.take(try win.input(.{ .frontend = .{ .windowed = true, .native_images = true } }));
+ // Its view's facts are the session's own step's to tell (17.2).
+ try land.step(.tick);
try jobs(a.core, land);
- try std.testing.expect(std.mem.indexOf(u8, slot.told.slice(), " petscii:on ") != null);
+ const pane = a.core.panes[id].?;
+ try std.testing.expect(std.mem.indexOf(u8, try pardes.tagline.tagPrefix(a.core, pane), " petscii:on ") != null);
// Both views told (by id, the session's 1 and the window's), each
// with its own frontend's facts.
try std.testing.expect(slot.views[0] != 0 and slot.views[k] != 0 and slot.views[0] != slot.views[k]);
@@ -3991,9 +4001,9 @@ const PdfAddon = struct {
// session's first view's art words, a terminal's: glyph art).
_ = try a.take(try tty.input(.{ .key = .{ .cp = 'j', .text = "j" } }));
try jobs(a.core, land);
- try std.testing.expect(std.mem.indexOf(u8, slot.told.slice(), "/16] petscii:on ") != null);
+ try std.testing.expect(std.mem.indexOf(u8, try pardes.tagline.tagPrefix(a.core, pane), "/16] petscii:on ") != null);
_ = try a.take(try win.input(.{ .key = .{ .cp = 'j', .text = "j" } }));
- try std.testing.expect(std.mem.indexOf(u8, slot.told.slice(), "/16] petscii:on ") != null);
+ try std.testing.expect(std.mem.indexOf(u8, try pardes.tagline.tagPrefix(a.core, pane), "/16] petscii:on ") != null);
try jobs(a.core, land);
}
}