summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-03 17:12:17 -0300
committerGabriel Schneider <[email protected]>2026-11-03 17:12:42 -0300
commitd6694f29be417ccc568b2f7c20fe8d61b085fda3 (patch)
tree7ac46ccbf5ae86f1fdeae58387ddc3d3abd0253a
parent6ff5fc7447cc411dc24cb1d841130f15a410e354 (diff)
downloadpardes-d6694f29be417ccc568b2f7c20fe8d61b085fda3.tar.gz
pardes-d6694f29be417ccc568b2f7c20fe8d61b085fda3.zip
test: two of test/output.zig's walk tests through the 9P tree alone (test/behaviour/keys): SPC j n and SPC j p in plain text selecting its places, never a comment's slashes, round the end and opening nothing (sel, dot, /index), and walking Themes' rows whole, never a section heading, both ways, the theme unchanged until Tab sets the one selected (the root ctl's Theme), its body a heading and a row a theme in sections; each checked to fail against a break (resolve taking a run of slashes as the root, the walk taking every row of an output)
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
-rw-r--r--test/behaviour/keys.zig67
-rw-r--r--test/output.zig81
2 files changed, 67 insertions, 81 deletions
diff --git a/test/behaviour/keys.zig b/test/behaviour/keys.zig
index 3d6fdf31..5441c018 100644
--- a/test/behaviour/keys.zig
+++ b/test/behaviour/keys.zig
@@ -25,3 +25,70 @@ test "keys: a PDF shown as text turns pages for the moving keys, counted, and th
try s.keys("j");
try std.testing.expectEqual(@as(u32, 3), (try s.pdfPage(n))[0]);
}
+
+test "keys: SPC j n and SPC j p in plain text select its places, never a comment's slashes, round the end, opening nothing" {
+ var s = try Session.initFile(std.testing.allocator, "// ordinary comment\n/// documentation comment\n(//) [///] punctuation\n/\n// /tmp\n//tmp\n");
+ defer s.deinit();
+ const n = try s.focused();
+ const index = try s.read("/index");
+ for ([_]struct { []const u8, []const u8, u32 }{
+ .{ " jn", "/", 69 }, .{ " jn", "/tmp", 74 }, .{ " jn", "//tmp", 79 }, .{ " jn", "/", 69 },
+ .{ " jp", "//tmp", 79 }, .{ " jp", "/tmp", 74 }, .{ " jp", "/", 69 },
+ }) |step| {
+ try s.keys(step[0]);
+ try std.testing.expectEqual(n, try s.focused());
+ try s.expect(s.at("/pane/{d}/sel", .{n}), step[1]);
+ try std.testing.expectEqual(step[2], (try s.range(s.at("/pane/{d}/dot", .{n})))[0]);
+ try s.expect("/index", index);
+ }
+}
+
+/// The value the root ctl's read gives `word`.
+fn setting(s: *Session, word: []const u8) ![]const u8 {
+ var lines = std.mem.splitScalar(u8, try s.read("/ctl"), '\n');
+ while (lines.next()) |line| if (std.mem.startsWith(u8, line, word) and line.len > word.len and line[word.len] == ' ') return line[word.len + 1 ..];
+ return error.NoSuchSetting;
+}
+
+test "keys: SPC j n and SPC j p walk Themes' rows, whole, never its section headings, and Tab sets the one selected" {
+ var s = try Session.initFile(std.testing.allocator, "x\n");
+ defer s.deinit();
+ const text = try s.focused();
+ // An imported theme's, the list still begins with the natives.
+ try s.write("/ctl", "Theme dark\n");
+ try s.write(s.at("/pane/{d}/exec", .{text}), "Themes\n");
+ // Listed beside the text, which keeps the keyboard.
+ try std.testing.expectEqual(text, try s.focused());
+ const list = text + 1;
+ try std.testing.expect(std.mem.indexOf(u8, try s.read("/index"), s.at("{d} text 0 /+Themes ", .{list})) != null);
+ const body = try s.read(s.at("/pane/{d}/body", .{list}));
+ // A heading, then a row a theme; each section after the first a blank
+ // line and its heading.
+ var lines = std.mem.splitScalar(u8, body, '\n');
+ try std.testing.expectEqualStrings("# Pardes themes", lines.next().?);
+ var names: std.ArrayList([]const u8) = .empty;
+ var first_break: ?usize = null;
+ while (lines.next()) |line| {
+ if (line.len == 0) {
+ const heading = lines.next() orelse break; // the newline ending the last row
+ try std.testing.expect(std.mem.startsWith(u8, heading, "# "));
+ first_break = first_break orelse names.items.len;
+ continue;
+ }
+ try std.testing.expect(std.mem.startsWith(u8, line, "Theme "));
+ try names.append(s.arena.allocator(), line);
+ }
+ const brk = first_break orelse return error.NoSections;
+ try std.testing.expect(std.mem.indexOf(u8, body[0..std.mem.indexOf(u8, body, "\n\n").?], "\nTheme acme\n") != null);
+ // Across the first section's end and back, the theme as it was.
+ for (names.items[0 .. brk + 1]) |row| {
+ try s.keys(" jn");
+ try std.testing.expectEqual(list, try s.focused());
+ try s.expect(s.at("/pane/{d}/sel", .{list}), row);
+ try std.testing.expectEqualStrings("dark", try setting(&s, "Theme"));
+ }
+ try s.keys(" jp");
+ try s.expect(s.at("/pane/{d}/sel", .{list}), names.items[brk - 1]);
+ try s.keys("\t");
+ try std.testing.expectEqualStrings(names.items[brk - 1]["Theme ".len..], try setting(&s, "Theme"));
+}
diff --git a/test/output.zig b/test/output.zig
index 4d5945cd..3cfece45 100644
--- a/test/output.zig
+++ b/test/output.zig
@@ -715,31 +715,6 @@ fn selectedOutputText(pane: *const pardes.Pane) ?[]const u8 {
return line[lo..@min(line.len, hi + 1)];
}
-test "LookNext/LookPrev in ordinary text skips comment slashes and retains real paths" {
- if (platform == .web) return error.SkipZigTest;
- const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 100, .rows = 20 });
- defer p.deinit();
- const pane = try p.setTestFile("// ordinary comment\n/// documentation comment\n(//) [///] punctuation\n/\n// /tmp\n//tmp\n");
- try std.testing.expect(pane.file.?.output == null);
- pardes.look.armLookWalk(p, 0);
- const available = p.freeSlot();
- for ([_]struct { key: u21, row: i32, text: []const u8 }{
- .{ .key = 'n', .row = 3, .text = "/" },
- .{ .key = 'n', .row = 4, .text = "/tmp" },
- .{ .key = 'n', .row = 5, .text = "//tmp" },
- .{ .key = 'n', .row = 3, .text = "/" },
- .{ .key = 'N', .row = 5, .text = "//tmp" },
- .{ .key = 'N', .row = 4, .text = "/tmp" },
- .{ .key = 'N', .row = 3, .text = "/" },
- }) |step| {
- lookKey(p, step.key);
- try std.testing.expectEqual(@as(usize, 0), p.active);
- try std.testing.expectEqual(step.row, pane.body.cur_row);
- try std.testing.expectEqualStrings(step.text, selectedOutputText(pane) orelse "");
- try std.testing.expectEqual(available, p.freeSlot());
- }
-}
-
test "LookNext/LookPrev skips formatted context and selects comment match locations" {
if (!pardes.syntax.enabled) return error.SkipZigTest;
for ([_]panes.Output.Origin{ .search, .{ .query = .references } }) |origin| {
@@ -949,62 +924,6 @@ test "LookPrev exactly reverses LookNext across output panes and the ring seam"
try std.testing.expect(saw_first and saw_second);
}
-test "Themes lists the ring in sections and skips headings in both directions" {
- const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 100, .rows = 40 });
- defer p.deinit();
- const source = try p.setTestFile("notes\n");
- pardes.colors.setThemeIndex(p, pardes.themes.len - 1);
- const original_theme = p.settings.theme;
- try std.testing.expect(p.executeBuiltinLine(0, "Themes"));
- const tid = source.search_pane orelse return error.MissingThemeList;
- const list = p.panes[tid].?;
- const content = list.file.?.content;
- try std.testing.expectEqual(@as(usize, 0), p.active);
- try std.testing.expectEqual(@as(i32, 0), list.body.cur_row);
- try std.testing.expectEqual(@as(usize, 0), list.file.?.scroll);
- try std.testing.expectEqualStrings("# Pardes themes", modal.lineSlice(content, 0));
- // Every theme in ring order, each section's heading after a blank line
- // where colors.groupAt says one starts.
- var row: usize = 1;
- var sections: usize = 1;
- var first_break: ?usize = null;
- for (pardes.themes, 0..) |theme, i| {
- if (i > 0) if (pardes.colors.groupAt(i)) |title| {
- try std.testing.expectEqualStrings("", modal.lineSlice(content, row));
- try std.testing.expect(std.mem.startsWith(u8, modal.lineSlice(content, row + 1), "# "));
- try std.testing.expectEqualStrings(title, modal.lineSlice(content, row + 1)["# ".len..]);
- row += 2;
- sections += 1;
- if (first_break == null) first_break = i;
- };
- const line = modal.lineSlice(content, row);
- try std.testing.expect(std.mem.startsWith(u8, line, "Theme "));
- try std.testing.expectEqualStrings(theme.name, line["Theme ".len..]);
- row += 1;
- }
- try std.testing.expectEqual(pardes.themes.len + 1 + 2 * (sections - 1), std.mem.count(u8, content, "\n"));
- // acme is a current theme: it is listed before any break.
- const acme = for (pardes.themes, 0..) |t, i| {
- if (std.mem.eql(u8, t.name, "acme")) break i;
- } else return error.MissingAcme;
- const brk = first_break orelse return error.NoSections;
- try std.testing.expect(acme < brk);
- // Opening an imported theme's selector must still begin with the natives.
- // Walk across the section break without selecting or executing a heading.
- for (pardes.themes[0 .. brk + 1]) |theme| {
- lookKey(p, 'n');
- try std.testing.expectEqual(tid, p.active);
- const selected = selectedOutputText(list) orelse return error.MissingThemeSection;
- try std.testing.expectEqualStrings(theme.name, selected["Theme ".len..]);
- try std.testing.expectEqual(original_theme, p.settings.theme);
- }
- lookKey(p, 'N');
- const previous = selectedOutputText(list) orelse return error.MissingThemeSection;
- try std.testing.expectEqualStrings(pardes.themes[brk - 1].name, previous["Theme ".len..]);
- p.update(.{ .key = .{ .cp = Key.tab } });
- try std.testing.expectEqual(brk - 1, p.settings.theme);
-}
-
test "LookNext/LookPrev selects command outputs by whole row" {
if (platform == .web) return;
var cwd_buf: [4096]u8 = undefined;