summaryrefslogtreecommitdiff
path: root/test/behaviour/settings.zig
diff options
context:
space:
mode:
Diffstat (limited to 'test/behaviour/settings.zig')
-rw-r--r--test/behaviour/settings.zig42
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 },
+ });
+}