diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-04 11:01:39 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-04 11:02:14 -0300 |
| commit | 3c5cddb963c67df5df0ed0ec023d68e43ba26bd5 (patch) | |
| tree | 2e0bc9d5a65497d341220c3c3be1a5d9425bf859 /test/behaviour/settings.zig | |
| parent | 350e7cc22b85130cbe95a114c668945b1dc12fd7 (diff) | |
| download | pardes-3c5cddb963c67df5df0ed0ec023d68e43ba26bd5.tar.gz pardes-3c5cddb963c67df5df0ed0ec023d68e43ba26bd5.zip | |
test: the Recent, Jumplist and Back/Forward group of src/ninep/ctl.zig, nine tests, through the 9P tree alone: in test/behaviour/other_files.zig Jumplist refilling its one +Jumps, a Jumplist entry (closed) only while no pane has its file, Recent's row of an open file at its dot now, a closed file found again (/recent and Recent list it closed, a look at its row reopens it at its dot, a Back under JumpScope all too), Back and Forward over a closed file's two entries reopening it once, Recent keeping only files on disk, Back over a closed file deleted since skipping it and saying so, and a remembered place clamped to the file as it is now; in settings.zig Back and Forward written to exec keeping to the focused file, and JumpScope all taking every place in order; each checked to fail against a break (refillOrOpen never refilling, a look's reopen not relinking a closed entry, Recent's open row at its closing place, Recent's (closed) word, a jump's reopen relinking no other entry, JumpScope's file test inverted, recentKeeps keeping any local name, Back's deleted words, the clamp's words)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'test/behaviour/settings.zig')
| -rw-r--r-- | test/behaviour/settings.zig | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/test/behaviour/settings.zig b/test/behaviour/settings.zig index f3ed57de..df70dbe6 100644 --- a/test/behaviour/settings.zig +++ b/test/behaviour/settings.zig @@ -132,3 +132,45 @@ test "settings: a setting this frontend cannot show says GUI-only, never run as try std.testing.expectEqualStrings("unknown control message \"Liftt\"", s.said); try std.testing.expect(has(try s.read("/ctl"), "\nDumpDir /")); } + +test "settings: Back and Forward written to exec keep to the focused file, and JumpScope all, written to ctl, takes every place in order" { + var tmp = std.testing.tmpDir(.{}); + defer tmp.cleanup(); + try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "a.txt", .data = std.mem.asBytes(&@as([100][4]u8, @splat("row\n".*))) }); + try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "b.txt", .data = std.mem.asBytes(&@as([100][4]u8, @splat("row\n".*))) }); + var buf: [4096]u8 = undefined; + const dir = buf[0..try tmp.dir.realPath(std.testing.io, &buf)]; + var s = try Session.initFile(std.testing.allocator, "x\n"); + defer s.deinit(); + // Each a look, as a user's jumps are: b1 a1 b40 a40 b80 a80. + for ([_][]const u8{ "b.txt:1", "a.txt:1", "b.txt:40", "a.txt:40", "b.txt:80", "a.txt:80" }) |place| try s.write("/look", s.at("{s}/{s}\n", .{ dir, place })); + const Step = struct { []const u8, []const u8, u32 }; + const walk = struct { + fn run(q: *Session, steps: []const Step) !void { + for (steps) |st| { + try q.write("/exec", q.at("{s}\n", .{st[0]})); + const n = try q.focused(); + try std.testing.expect(std.mem.endsWith(u8, try q.read(q.at("/pane/{d}/name", .{n})), q.at("{s}\n", .{st[1]}))); + // Each line is `row\n`: the line the dot is on. + try std.testing.expectEqual(st[2] - 1, (try q.range(q.at("/pane/{d}/dot", .{n})))[0] / 4); + } + } + }.run; + // a's places first, b only once a has none older; Forward mirrors it + // from b and ends at a80, where it began. + try walk(&s, &.{ + .{ "Back", "/a.txt", 40 }, + .{ "Back", "/a.txt", 1 }, + .{ "Back", "/b.txt", 1 }, + .{ "Forward", "/b.txt", 40 }, + .{ "Forward", "/b.txt", 80 }, + .{ "Forward", "/a.txt", 80 }, + }); + try s.write("/ctl", "JumpScope all\n"); + try std.testing.expect(has(try s.read("/ctl"), "JumpScope all\n")); + try walk(&s, &.{ + .{ "Back", "/b.txt", 80 }, + .{ "Back", "/a.txt", 40 }, + .{ "Forward", "/b.txt", 80 }, + }); +} |
