From ff0b8a382de7a1994a6912dc71ba28a8ecdaf474 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Wed, 4 Nov 2026 10:45:36 -0300 Subject: test: syntax colours and Save's prompt through the 9P tree alone, Session.styles added (each cell's style as /screen draws it, as JSON text): in test/behaviour/settings.zig Colors off drawing a source plain and on again colouring its fn and if, the layout as it was, an edit made while off included, and SyntaxBold keywords coloured and bold in every row a detached session's size grows a pane into; in panes.zig a rename colouring a source in its new name's language, its text unchanged; in keys.zig Save's prompt on a scratch made by New from a file's pane starting from its directory, one slash after it (/dír space/, and / alone); each checked to fail against a break (the Colors toggle not marking syntax dirty, the painted stretch four rows from the scroll, a rename not marking syntax dirty, the prompt's slash always added, the prompt from the session's directory); test/panes.zig's Colors and growing tests and pane.zig's cached-syntax rename test deleted, and the Save prompt test trimmed to an owned directory ending in a slash or empty (a shell's, T2) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge --- test/behaviour/keys.zig | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'test/behaviour/keys.zig') diff --git a/test/behaviour/keys.zig b/test/behaviour/keys.zig index 41a2821a..989489d7 100644 --- a/test/behaviour/keys.zig +++ b/test/behaviour/keys.zig @@ -225,3 +225,18 @@ test "keys: SPC j n and SPC j p walk Themes' rows, whole, never its section head try s.keys("\t"); try std.testing.expectEqualStrings(names.items[brk - 1]["Theme ".len..], try setting(&s, "Theme")); } + +test "keys: Save's prompt on a scratch starts from the scratch's directory, one slash after it" { + for ([_][2][]const u8{ .{ "/dír space/f.txt", " Save /dír space/zq" }, .{ "/f.txt", " Save /zq" } }) |c| { + var s = try Session.initFile(std.testing.allocator, "one\n"); + defer s.deinit(); + const n = try s.focused(); + try s.write(s.at("/pane/{d}/name", .{n}), s.at("{s}\n", .{c[0]})); + // New from the file's pane: a scratch in its directory. + try s.write(s.at("/pane/{d}/exec", .{n}), "New\n"); + try std.testing.expect(try s.focused() != n); + try s.keys(":\tzq"); + _ = try s.where(c[1]); + try s.keys("\x1b"); + } +} -- cgit v1.3 From 9cfebaeca67301a8925eaa44c71859b42b676e59 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Wed, 4 Nov 2026 10:49:58 -0300 Subject: test: a tag's file-name tint and Back and Forward through the 9P tree alone: in test/behaviour/tags.zig a file pane's tag tinting its name (界file.zig) and not its directory, dirty marker or words, the tag at the top or the bottom (Session.styles); in keys.zig Ctrl-o and Ctrl-i (Kctl o, i) jumping between line 60 and line 1 made by 60G1G, dot empty where the jump lands and no B1 sweep drawn after either, a wrapped Unicode and tab sweep included, swept either way; each checked to fail against a break (the tint starting at the last slash, focusPaneLine not moving the caret; clearNavigationSelection returning at once is not caught, the key's own path dropping the sweep too); test/panes.zig's two one-pane jump tests deleted, the tint test trimmed to its search pane (fillResults), the cross-pane jump test kept (it seeds held selections) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge --- test/behaviour/keys.zig | 57 +++++++++++++++++++++++++++++++++++++ test/behaviour/tags.zig | 31 ++++++++++++++++++++ test/panes.zig | 76 ++++--------------------------------------------- 3 files changed, 93 insertions(+), 71 deletions(-) (limited to 'test/behaviour/keys.zig') diff --git a/test/behaviour/keys.zig b/test/behaviour/keys.zig index 989489d7..0c2c0a43 100644 --- a/test/behaviour/keys.zig +++ b/test/behaviour/keys.zig @@ -240,3 +240,60 @@ test "keys: Save's prompt on a scratch starts from the scratch's directory, one try s.keys("\x1b"); } } + +/// A B1 sweep from cell (x0, y0) to (x1, y1). +fn sweep(s: *Session, x0: usize, y0: usize, x1: usize, y1: usize) !void { + try s.write("/mousein", s.at("m {d} {d} 1\nm {d} {d} 1\nm {d} {d} 0\n", .{ x0, y0, x1, y1, x1, y1 })); +} + +/// Whether any cell /screen draws is in `style`. +fn drawsIn(s: *Session, style: []const u8) !bool { + for (try s.styles()) |cell| if (std.mem.eql(u8, cell, style)) return true; + return false; +} + +test "keys: Ctrl-o and Ctrl-i jump back and forth, leaving no sweep drawn, a wrapped Unicode and tab one included" { + const ctl = "\u{F017}"; + for ([_]struct { []const u8, []const u8, bool }{ + .{ "alpha\nbravo\n", "alpha", false }, + .{ "界\tabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\n", "界", true }, + }) |c| for ([_]bool{ false, true }) |reverse| { + const prefix, const first, const wrap = c; + var buf: [4096]u8 = undefined; + @memcpy(buf[0..prefix.len], prefix); + for (0..80) |i| @memcpy(buf[prefix.len + i * 27 ..][0..27], "unrelated destination text\n"); + var s = try Session.initFile(std.testing.allocator, buf[0 .. prefix.len + 80 * 27]); + defer s.deinit(); + const n = try s.focused(); + s.detach(); + try s.write("/ctl", "size 34 10\n"); + try s.write("/ctl", if (wrap) "Wrap on\n" else "Wrap off\n"); + const dot = s.at("/pane/{d}/dot", .{n}); + const addr = s.at("/pane/{d}/addr", .{n}); + // Two places in the jump list: line 60, then line 1. + try s.keys("60G1G"); + const x, const y = try s.where(first); + const plain = (try s.styles())[0]; + if (reverse) try sweep(&s, x + 3, y + 1, x + 1, y) else try sweep(&s, x + 1, y, x + 3, y + 1); + const screen = try s.screen(); + const cols = try std.unicode.utf8CountCodepoints(screen[0..std.mem.indexOfScalar(u8, screen, '\n').?]); + const swept = (try s.styles())[(y + 1) * cols + x]; + try std.testing.expect(!std.mem.eql(u8, swept, plain)); + try s.keys(ctl ++ "o"); + try s.write(addr, "60"); + const line60 = (try s.range(addr))[0]; + try std.testing.expectEqual(.{ line60, line60 }, try s.range(dot)); + try std.testing.expectError(error.NotOnScreen, s.where(first)); + try std.testing.expect(!try drawsIn(&s, swept)); + // A sweep made after Back is gone after Forward. + const x2, const y2 = try s.where("unrelated"); + try sweep(&s, x2 + 1, y2, x2 + 3, y2 + 1); + try std.testing.expect(try drawsIn(&s, swept)); + try s.keys(ctl ++ "i"); + // Back where the sweep left the caret, nothing selected. + const q0, const q1 = try s.range(dot); + try std.testing.expect(q0 == q1 and q1 < line60); + _ = try s.where(first); + try std.testing.expect(!try drawsIn(&s, swept)); + }; +} diff --git a/test/behaviour/tags.zig b/test/behaviour/tags.zig index f4a5a469..39ca3a05 100644 --- a/test/behaviour/tags.zig +++ b/test/behaviour/tags.zig @@ -450,3 +450,34 @@ test "tags: truncating a tag clears its own text, u in the tag undoes it, and > try s.write(path, " Tail\n"); try std.testing.expectEqualStrings("/test.txt Make\nMore\n Tail\n", try tag(&s, n)); } + +test "tags: a pane tag's file name is tinted, its directory, dirty marker and words not, the tag at the top or the bottom" { + for ([_]bool{ false, true }) |bottom| { + var s = try Session.initFile(std.testing.allocator, "body\n"); + defer s.deinit(); + const n = try s.focused(); + try s.write("/ctl", "FocusTint off\n"); + if (bottom) try s.write("/ctl", "Tagbottom\n"); + try s.write(s.at("/pane/{d}/name", .{n}), "/project/界file.zig\n"); + try s.write(s.at("/pane/{d}/dirty", .{n}), "1"); + const x0, const y = try s.where("/project/"); + const screen = try s.screen(); + const styles = try s.styles(); + const cols = try std.unicode.utf8CountCodepoints(screen[0..std.mem.indexOfScalar(u8, screen, '\n').?]); + var rows = std.mem.splitScalar(u8, screen, '\n'); + for (0..y) |_| _ = rows.next(); + var cells = (try std.unicode.Utf8View.init(rows.next().?)).iterator(); + var x: usize = 0; + var tinted: ?[]const u8 = null; + var ink: ?[]const u8 = null; + while (cells.nextCodepointSlice()) |cell| : (x += 1) { + if (x < x0 or std.mem.eql(u8, cell, " ")) continue; + // `界file.zig`: the wide glyph's two cells, then eight. + const in_name = x >= x0 + "/project/".len and x < x0 + "/project/".len + 10; + const want = if (in_name) &tinted else &ink; + if (want.* == null) want.* = styles[y * cols + x]; + try std.testing.expectEqualStrings(want.*.?, styles[y * cols + x]); + } + try std.testing.expect(!std.mem.eql(u8, tinted.?, ink.?)); + } +} diff --git a/test/panes.zig b/test/panes.zig index c996ca00..a7ecf994 100644 --- a/test/panes.zig +++ b/test/panes.zig @@ -788,75 +788,8 @@ const JumpSelectionTests = struct { p.update(.{ .mouse = .{ .button = .left, .kind = .release, .col = col1, .row = row1 } }); } - fn exercise(prefix: []const u8, wrap: bool, reverse: bool, first_col: u16, last_col: u16, expected: ?[]const u8) !void { - const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 34, .rows = 10 }); - defer p.deinit(); - p.settings.wrap = wrap; - const text = try std.fmt.allocPrint(p.gpa, "{s}{s}", .{ prefix, std.mem.asBytes(&@as([80][27]u8, @splat("unrelated destination text\n".*))) }); - defer p.gpa.free(text); - const pane = try p.setTestFile(text); - var frame = std.heap.ArenaAllocator.init(p.gpa); - defer frame.deinit(); - _ = try p.render(frame.allocator()); - if (wrap) try std.testing.expectEqual(pane.wrap_line[0], pane.wrap_line[1]); - const rect = p.rects[0]; - const x = rect.x + config.GUTTER + panes.File.gutterWidth(pane); - const y = p.bodyTop(pane, rect); - if (reverse) - drag(p, x + last_col, y + 1, x + first_col, y) - else - drag(p, x + first_col, y, x + last_col, y + 1); - - const selected = try p.gpa.dupe(u8, pardes.exec.heldSelection(p, 0) orelse return error.MissingMouseSelection); - defer p.gpa.free(selected); - if (expected) |want| try std.testing.expectEqualStrings(want, selected); - try std.testing.expect(std.mem.indexOfScalar(u8, selected, '\n') != null); - if (wrap) try std.testing.expect(std.mem.indexOf(u8, selected, "界") != null); - - // Seed two actual locations after the drag, so both history directions - // must scroll and discard the previous selection. - p.njumps = 2; - p.jcur = 1; - p.jumps[0] = .{ .pane = 0, .serial = pane.serial, .line = 60, .col = 1 }; - p.jumps[1] = .{ .pane = 0, .serial = pane.serial, .line = 1, .col = 1 }; - p.update(.{ .key = .{ .cp = 'o', .ctrl = true } }); - _ = frame.reset(.retain_capacity); - _ = try p.render(frame.allocator()); - try std.testing.expectEqual(@as(usize, 0), p.jcur); - try std.testing.expect(pane.file.?.scroll > 20); - try LookResetTests.cleared(pane); - try std.testing.expect(!pane.body.vsel.active); - try std.testing.expect(pardes.exec.heldSelection(p, 0) == null); - try std.testing.expectEqual(@as(i32, 59), pane.body.cur_row); - try std.testing.expectEqual(@as(i32, 0), pane.body.cur_col); - - // A selection created after Back must also disappear on Forward. - // Back announces itself, so the body sits under a notice band now. - const y2 = p.bodyTop(pane, p.rects[0]); - drag(p, x + 1, y2, x + 3, y2 + 1); - try std.testing.expect(pardes.exec.heldSelection(p, 0) != null); - p.update(.{ .key = .{ .cp = 'i', .ctrl = true } }); - _ = frame.reset(.retain_capacity); - _ = try p.render(frame.allocator()); - try std.testing.expectEqual(@as(usize, 1), p.jcur); - try std.testing.expectEqual(@as(usize, 0), pane.file.?.scroll); - try LookResetTests.cleared(pane); - try std.testing.expect(!pane.body.vsel.active); - try std.testing.expect(pardes.exec.heldSelection(p, 0) == null); - try std.testing.expectEqual(@as(i32, 0), pane.body.cur_row); - try std.testing.expectEqual(@as(i32, 0), pane.body.cur_col); - } - - test "jump selection clears copied sweeps in both history directions" { - for ([_]bool{ false, true }) |reverse| - try exercise("alpha\nbravo\n", false, reverse, 1, 3, "lpha\nbrav"); - } - - test "jump selection clears wrapped Unicode and tab rectangles" { - for ([_]bool{ false, true }) |reverse| - try exercise("界\tabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\n", true, reverse, 0, 8, null); - } - + // One pane's Back and Forward are test/behaviour/keys.zig's; this + // one seeds held selections in two panes, which only internals reach. test "jump selection clears source and destination state across panes" { const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 100, .rows = 30 }); defer p.deinit(); @@ -947,7 +880,9 @@ const TagNameTintTests = struct { return visible_name; } - test "tag filename tint excludes directories dirty marker and output commands" { + // A file pane's is test/behaviour/tags.zig's; a search pane's needs + // results put in through fillResults. + test "tag filename tint of a search pane excludes its directory and command" { for ([_]bool{ false, true }) |bottom| { const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 100, .rows = 24 }); defer p.deinit(); @@ -959,7 +894,6 @@ const TagNameTintTests = struct { configure(p); defer p.custom_theme = null; p.settings.tag_bottom = bottom; - try std.testing.expect((try check(p, 0, pane.file.?.path)) > 0); try panes.Output.fillResults(p, 0, "/project", .search, "tint", try p.gpa.dupe(u8, "no matches\n"), null); const id = pane.search_pane.?; p.update(.tick); -- cgit v1.3 From a5504e6e808c5b147e114d43b5c165bbe714f3c3 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Wed, 4 Nov 2026 11:09:10 -0300 Subject: test: test/output.zig's Mini, setting and command-output LookNext tests through the 9P tree alone: in a new test/behaviour/builtins.zig (docs/typ/builtins.typ) Mini mapping a file of the pane's directory over pardes's own of that name, one pane for it, a snapshot refreshed only by the next Mini, and Save on it writing nothing (the old test trimmed to the watch it never asks for, an effect); in test/behaviour/settings.zig every on/off setting the root ctl reads flipping when its word is written bare, and Theme and Shell taking a value (the old test trimmed to a window's fonts, transitions and passes in DumpConfig's report); in test/behaviour/keys.zig SPC j n in a command output (+Themes) selecting its whole row, Tab running it, and from a pane a Look took the keyboard to walking on in it, and SPC j n and SPC j p walking on and back from the place a Look's +Search listing chose (the old test trimmed to its fillResults answers); each checked to fail against a break (Mini making a new pane each time, a setting's bare word not flipping it, a command output's grain a word, the walk's owner forgotten) Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge --- test/behaviour.zig | 1 + test/behaviour/builtins.zig | 35 +++++++++++++++++++++++ test/behaviour/keys.zig | 49 +++++++++++++++++++++++++++++++ test/behaviour/settings.zig | 23 +++++++++++++++ test/output.zig | 70 ++++++--------------------------------------- 5 files changed, 117 insertions(+), 61 deletions(-) create mode 100644 test/behaviour/builtins.zig (limited to 'test/behaviour/keys.zig') diff --git a/test/behaviour.zig b/test/behaviour.zig index d9b15183..2e2ca864 100644 --- a/test/behaviour.zig +++ b/test/behaviour.zig @@ -4,6 +4,7 @@ //! so a test sees the session as a 9P client does. test { _ = @import("behaviour/addresses.zig"); + _ = @import("behaviour/builtins.zig"); _ = @import("behaviour/columns_and_tags.zig"); _ = @import("behaviour/edit.zig"); _ = @import("behaviour/event.zig"); diff --git a/test/behaviour/builtins.zig b/test/behaviour/builtins.zig new file mode 100644 index 00000000..6f029072 --- /dev/null +++ b/test/behaviour/builtins.zig @@ -0,0 +1,35 @@ +//! docs/typ/builtins.typ, the builtins' glossary. +const std = @import("std"); +const Session = @import("session").Session; + +test "builtins: Mini maps a file of the pane's directory over pardes's own source of that name, in one pane, refreshed only when asked again" { + var tmp = std.testing.tmpDir(.{}); + defer tmp.cleanup(); + try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "build.zig", .data = "x\n" }); + try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "a.txt", .data = "a\n" }); + var dir: [4096]u8 = undefined; + const at = dir[0..try tmp.dir.realPath(std.testing.io, &dir)]; + var s = try Session.initFile(std.testing.allocator, "x\n"); + defer s.deinit(); + try s.write("/look", s.at("{s}/a.txt\n", .{at})); + const a = try s.focused(); + // The directory's one-line build.zig, one braille row, not pardes's. + try s.write(s.at("/pane/{d}/exec", .{a}), "Mini build.zig\n"); + const mini = try s.focused(); + try std.testing.expect(mini != a); + const body = s.at("/pane/{d}/body", .{mini}); + try s.expect(body, "⠁\n"); + const index = try s.read("/index"); + try s.write(s.at("/pane/{d}/exec", .{mini}), "Mini build.zig\n"); + try std.testing.expectEqual(mini, try s.focused()); + try s.expect("/index", index); + // A snapshot: the file grown on disk shows only at the next Mini. + try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "build.zig", .data = "xx\n" }); + try s.expect(body, "⠁\n"); + try s.write(s.at("/pane/{d}/exec", .{mini}), "Mini build.zig\n"); + try s.expect(body, "⠉\n"); + try s.expect("/index", index); + // Save asks for a path; nothing is written for it. + try s.write(s.at("/pane/{d}/exec", .{mini}), "Save\n"); + try std.testing.expectEqual(@as(usize, 0), s.saved); +} diff --git a/test/behaviour/keys.zig b/test/behaviour/keys.zig index 41a2821a..e659b369 100644 --- a/test/behaviour/keys.zig +++ b/test/behaviour/keys.zig @@ -225,3 +225,52 @@ test "keys: SPC j n and SPC j p walk Themes' rows, whole, never its section head try s.keys("\t"); try std.testing.expectEqualStrings(names.items[brk - 1]["Theme ".len..], try setting(&s, "Theme")); } + +test "keys: SPC j n in a command output selects its whole row, Tab runs it, and from where a Look took the keyboard it walks on there" { + var tmp = std.testing.tmpDir(.{}); + defer tmp.cleanup(); + for ([_][]const u8{ "a.txt", "b.txt" }) |name| try tmp.dir.writeFile(std.testing.io, .{ .sub_path = name, .data = "x\n" }); + var dir: [4096]u8 = undefined; + const at = dir[0..try tmp.dir.realPath(std.testing.io, &dir)]; + var s = try Session.initFile(std.testing.allocator, "x\n"); + defer s.deinit(); + try s.write("/look", s.at("{s}/a.txt\n", .{at})); + const a = try s.focused(); + try s.write(s.at("/pane/{d}/exec", .{a}), "Themes\n"); + try s.keys(" jn"); + const themes = try s.focused(); + try std.testing.expect(themes != a); + const sel = s.at("/pane/{d}/sel", .{themes}); + try s.expect(sel, "Theme orchard"); + try s.keys(" jn\t"); + try std.testing.expect(std.mem.indexOf(u8, try s.read("/ctl"), "\nTheme dusk\n") != null); + try s.write(s.at("/pane/{d}/exec", .{a}), "Look b.txt\n"); + try std.testing.expect(try s.focused() != themes); + try s.keys(" jn"); + try std.testing.expectEqual(themes, try s.focused()); + try std.testing.expect(std.mem.startsWith(u8, try s.read(sel), "Theme ")); +} + +test "keys: SPC j n and SPC j p walk on from the place a Look's +Search listing chose, its keyboard left in the file" { + var tmp = std.testing.tmpDir(.{}); + defer tmp.cleanup(); + try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "look-owner.txt", .data = "alpha target\nbeta target\ngamma target\n" }); + var dir: [4096]u8 = undefined; + const at = dir[0..try tmp.dir.realPath(std.testing.io, &dir)]; + var s = try Session.initFile(std.testing.allocator, "x\n"); + defer s.deinit(); + try s.write("/ctl", "LookWord list\n"); // the +Search listing is what is walked + try s.write("/look", s.at("{s}/look-owner.txt\n", .{at})); + const file = try s.focused(); + try s.write(s.at("/pane/{d}/exec", .{file}), "Look target\n"); + try std.testing.expectEqual(file, try s.focused()); + // The Look took the first; the walk goes on from it, and back. + try s.keys(" jn"); + const results = try s.focused(); + try std.testing.expect(results != file); + const sel = s.at("/pane/{d}/sel", .{results}); + try s.expect(sel, "look-owner.txt:2:6-11"); + try s.keys(" jp"); + try std.testing.expectEqual(results, try s.focused()); + try s.expect(sel, "look-owner.txt:1:7-12"); +} diff --git a/test/behaviour/settings.zig b/test/behaviour/settings.zig index ff24704a..027fd1c9 100644 --- a/test/behaviour/settings.zig +++ b/test/behaviour/settings.zig @@ -101,3 +101,26 @@ test "settings: Config without a configuration directory says so and opens nothi try s.expect("/index", index); try expectHas(try s.read("/log"), "Config: no startup file here: no configuration directory"); } + +test "settings: every on/off setting the root ctl reads flips when its word is written bare, and Theme and Shell take a value" { + var s = try Session.initFile(std.testing.allocator, "x\n"); + defer s.deinit(); + var lines = std.mem.tokenizeScalar(u8, try s.read("/ctl"), '\n'); + var flipped: usize = 0; + while (lines.next()) |line| { + const space = std.mem.indexOfScalar(u8, line, ' ') orelse continue; + const word, const was = .{ line[0..space], line[space + 1 ..] }; + const on = std.mem.eql(u8, was, "on"); + if (!on and !std.mem.eql(u8, was, "off")) continue; + try s.write("/ctl", s.at("{s}\n", .{word})); + try std.testing.expectEqualStrings(s.at("{s} {s}", .{ word, if (on) "off" else "on" }), try setting(&s, word)); + flipped += 1; + } + try std.testing.expect(flipped > 20); + for ([_][]const u8{ "Colors off", "Wrap off", "Tagbottom on", "Debug on" }) |want| + try std.testing.expectEqualStrings(want, try setting(&s, want[0..std.mem.indexOfScalar(u8, want, ' ').?])); + try s.write("/ctl", "Theme acme\n"); + try s.write("/ctl", "Shell /bin/sh\n"); + try std.testing.expectEqualStrings("Theme acme", try setting(&s, "Theme")); + try std.testing.expectEqualStrings("Shell /bin/sh", try setting(&s, "Shell")); +} diff --git a/test/output.zig b/test/output.zig index 3cfece45..876cd8fc 100644 --- a/test/output.zig +++ b/test/output.zig @@ -389,7 +389,9 @@ test "result stepping reaches an unterminated last row" { try std.testing.expectEqual(@as(i32, 1), result.body.cur_row); } -test "Mini uses OS source precedence and refreshes one independent snapshot" { +// What it shows and when it refreshes is test/behaviour/builtins.zig's; +// the watch it never asks for is an effect, unseen through 9P. +test "Mini asks for no watch on its pane" { var tmp = std.testing.tmpDir(.{}); defer tmp.cleanup(); try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "build.zig", .data = "x\n" }); @@ -401,27 +403,11 @@ test "Mini uses OS source precedence and refreshes one independent snapshot" { try std.testing.expect(p.executeBuiltinLine(0, "Mini build.zig")); const id = p.active; try std.testing.expect(id != 0); - const mini = p.panes[id].?; - try std.testing.expect(mini.terminal == null); - try std.testing.expectEqualStrings("⠁\n", mini.file.?.content); - try std.testing.expect(std.mem.startsWith(u8, mini.file.?.mini.?.source, dir)); - const next = p.freeSlot(); - const body = mini.file.?.content.ptr; - try std.testing.expect(p.executeBuiltinLine(id, "Mini build.zig")); - try std.testing.expectEqual(id, p.active); - try std.testing.expectEqual(body, mini.file.?.content.ptr); - try std.testing.expectEqual(next, p.freeSlot()); - try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "build.zig", .data = "xx\n" }); - try std.testing.expectEqualStrings("⠁\n", mini.file.?.content); try std.testing.expect(p.executeBuiltinLine(id, "Mini build.zig")); - try std.testing.expectEqual(id, p.active); - try std.testing.expectEqualStrings("⠉\n", mini.file.?.content); while (p.nextEffect()) |effect| switch (effect) { .watch => |watch| try std.testing.expect(watch.pane != id), else => {}, }; - try std.testing.expect(p.executeBuiltinLine(id, "Save")); - try std.testing.expect(mini.prompt == .save); } test "Mini dump preserves its exact virtual snapshot and body writes detach colors" { @@ -617,7 +603,7 @@ test "EffectCode lists readable virtual sources used by this backend" { try std.testing.expectEqualStrings(pardes.filesystem.sourceBytes(backend_source["/virtual/".len..]).?, source.content); } -test "every enabled setting builtin mutates the State Config reports" { +test "a window's setting builtins (TaglineSize, Font, transitions, scene passes) reach the report DumpConfig writes" { const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true }); defer p.deinit(); p.locations_config.layout = .@"inline"; @@ -653,14 +639,8 @@ test "every enabled setting builtin mutates the State Config reports" { try std.testing.expect(p.executeBuiltinLine(p.active, "DumpConfig")); const report = p.panes[p.active].?.file.?.content; - for ([_][]const u8{ - "Colors off\n", - "Wrap off\n", - "Tagbottom on\n", - "Debug on\n", - "Theme acme\n", - "Shell fish\n", - }) |line| try std.testing.expect(std.mem.indexOf(u8, report, line) != null); + // The toggles, Theme and Shell are test/behaviour/settings.zig's, through + // the root ctl; what is left is a window's (fonts, transitions, passes). const transition = if (!builtins.viewCapabilities(p).panel_transitions) "PanelSlide unsupported\n" else if (p.settings.panel_transition == .off) @@ -821,7 +801,7 @@ test "LookNext/LookPrev selects one output location per row and opens nothing" { try std.testing.expectEqual(panes.Output.Grain.word, panes.Output.grain(p.panes[p.active].?.file.?.output)); } -test "LookNext/LookPrev resumes the result output whose Look moved focus away" { +test "LookNext/LookPrev keeps the result output a Look chose through a no-match answer, and a stale serial once it is deleted" { if (platform == .web) return; var tmp = std.testing.tmpDir(.{}); defer tmp.cleanup(); @@ -844,12 +824,8 @@ test "LookNext/LookPrev resumes the result output whose Look moved focus away" { try std.testing.expect(results.look_at != null); try std.testing.expectEqual(results.serial, p.look_walk_owner orelse return error.MissingLookOwner); - lookKey(p, 'n'); - try std.testing.expectEqual(rid, p.active); - try std.testing.expectEqual(first + 1, results.body.cur_row); - lookKey(p, 'N'); - try std.testing.expectEqual(first, results.body.cur_row); - + // The walk on and back from it is test/behaviour/keys.zig's; what is + // left needs answers put in by fillResults. // A later no-match answer has no position to resume and therefore cannot // steal the provenance established by the Look above. const owner = results.serial; @@ -924,34 +900,6 @@ test "LookPrev exactly reverses LookNext across output panes and the ring seam" try std.testing.expect(saw_first and saw_second); } -test "LookNext/LookPrev selects command outputs by whole row" { - if (platform == .web) return; - var cwd_buf: [4096]u8 = undefined; - var path_buf: [4096]u8 = undefined; - const paths = try projectPaths(&cwd_buf, &path_buf); - const p = try Pardes.init(std.testing.allocator, .{ .cols = 100, .rows = 40, .file = paths.boot }); - defer p.deinit(); - p.update(.{ .resize = .{ .cols = 100, .rows = 40 } }); - - try std.testing.expect(p.executeBuiltinLine(p.active, "Themes")); - const tid = p.panes[p.active].?.search_pane orelse return error.MissingThemeList; - const themes = p.panes[tid].?; - try std.testing.expect(panes.Output.fileTraits(themes.file.?.output).commands); - lookKey(p, 'n'); - const row0 = std.mem.trimEnd(u8, modal.lineSlice(themes.file.?.content, 1), " \t\r"); - try std.testing.expectEqualStrings(row0, selectedOutputText(themes) orelse ""); - const theme_before = p.settings.theme; - lookKey(p, 'n'); - p.update(.{ .key = .{ .cp = Key.tab } }); - try std.testing.expect(p.settings.theme != theme_before); - - try std.testing.expect(p.executeBuiltinLine(0, "Look build.zig")); - p.update(.tick); - try std.testing.expect(p.active != 0); - lookKey(p, 'n'); - try std.testing.expectEqual(@as(usize, 0), p.active); -} - test "identical result refresh keeps warm content caches without allocation" { var allocator: std.testing.FailingAllocator = .init(std.testing.allocator, .{}); const p = try Pardes.init(allocator.allocator(), .{ .tty_only = true, .cols = 80, .rows = 24 }); -- cgit v1.3 From 49ed5492dec8275ace22e37003f4de548b2d2fc5 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Wed, 4 Nov 2026 11:19:29 -0300 Subject: test: test/pdf.zig's PDF normal-mode keys through the 9P tree alone, in test/behaviour/keys.zig: in a PDF, : giving its tag the keyboard in normal mode and : again the body back, SPC a leader (its keys shown at the row's end) that a key it has not cancels, and / a search prompt that Esc closes, the PDF keeping the keyboard; each checked to fail against a break (a PDF's : doing nothing, its / doing nothing, its SPC not starting the leader) Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge --- test/behaviour/keys.zig | 32 ++++++++++++++++++++++++++++++++ test/pdf.zig | 28 ---------------------------- 2 files changed, 32 insertions(+), 28 deletions(-) (limited to 'test/behaviour/keys.zig') diff --git a/test/behaviour/keys.zig b/test/behaviour/keys.zig index e659b369..b6fe1e83 100644 --- a/test/behaviour/keys.zig +++ b/test/behaviour/keys.zig @@ -274,3 +274,35 @@ test "keys: SPC j n and SPC j p walk on from the place a Look's +Search listing try std.testing.expectEqual(results, try s.focused()); try s.expect(sel, "look-owner.txt:1:7-12"); } + +/// Screen row `row` as drawn. +fn screenRow(s: *Session, row: usize) ![]const u8 { + var rows = std.mem.splitScalar(u8, try s.screen(), '\n'); + for (0..row) |_| _ = rows.next(); + return rows.next().?; +} + +test "keys: a PDF in normal mode keeps : (its tag and back), SPC (a leader, cancelled by a key it has not) and / (a search prompt, Esc closing it)" { + var s = try Session.initFile(std.testing.allocator, "x\n"); + defer s.deinit(); + const n = try s.lookFile("docs/design.pdf"); + const body = (try s.cursor()).?; + const tag = (try s.where("docs/design.pdf [1/"))[1]; + try s.keys(":"); + const on_tag = (try s.cursor()).?[1]; + try std.testing.expect(on_tag == tag or on_tag == tag + 1); + try std.testing.expect(std.mem.endsWith(u8, try s.read(s.at("/pane/{d}/ctl", .{n})), " mode:normal ")); + try s.keys(":"); + try std.testing.expectEqual(body, (try s.cursor()).?); + // The leader shows its keys at the row's end until one it has not. + try s.keys(" "); + try std.testing.expect(std.mem.endsWith(u8, std.mem.trimEnd(u8, try screenRow(&s, body[1]), " "), " SPC")); + try s.keys("!"); + try std.testing.expect(!std.mem.endsWith(u8, std.mem.trimEnd(u8, try screenRow(&s, body[1]), " "), " SPC")); + try s.keys("/"); + try std.testing.expect(!std.meta.eql(body, (try s.cursor()).?)); + try std.testing.expectEqual(n, try s.focused()); + try s.keys("\x1b"); + try std.testing.expectEqual(body, (try s.cursor()).?); + try std.testing.expectEqual(n, try s.focused()); +} diff --git a/test/pdf.zig b/test/pdf.zig index a068fc40..16522af6 100644 --- a/test/pdf.zig +++ b/test/pdf.zig @@ -1146,34 +1146,6 @@ fn copySourceRect( return out; } -test "PDF normal mode keeps `:`, SPC and `/` on their shared paths" { - if (!pdf_enabled or platform == .web) return; - - const p = try Pardes.init(std.testing.allocator, .{ - .file = "docs/design.pdf", - .cols = 80, - .rows = 24, - }); - defer p.deinit(); - const pane = p.panes[0].?; - p.native_images = false; - - // Cross-pane BODY-NORMAL actions keep their established shared paths. - p.update(.{ .key = .{ .cp = ':' } }); - try std.testing.expect(pane.focus == .tag); - try std.testing.expectEqual(Mode.normal, pane.body.mode); - p.update(.{ .key = .{ .cp = ':' } }); - try std.testing.expect(pane.focus == .body); - p.update(.{ .key = .{ .cp = ' ' } }); - try std.testing.expect(p.leader_on); - p.update(.{ .key = .{ .cp = '!' } }); - try std.testing.expect(!p.leader_on); - p.update(.{ .key = .{ .cp = '/' } }); - try std.testing.expect(pane.prompt == .search and pane.focus == .body); - p.update(.{ .key = .{ .cp = Key.escape } }); - try std.testing.expect(pane.prompt == .none); -} - test "Escape cancels PDF chrome in place, then leaves the pane; Shift-Escape leaves at once" { if (!pdf_enabled or platform == .web) return; -- cgit v1.3 From c9d27f179b096c4334bc01c2054a6bbf90e298de Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Wed, 4 Nov 2026 11:34:37 -0300 Subject: test: review of the core2 migration's tests: the column tag's Home seen to scroll its text back (the whole text drawn from its first cell), not only its caret; window keys' column tag left as it was by w, so normal mode is checked, not inferred; window mode's d seen to ask (ask del k j in /log) between two panes and not with one; Mini's Save seen to ask for a path (ask save path); the SPC j n command-output test trimmed to the walk back from a Look's pane, its whole-row and Tab checks the Themes walk test's already; each checked to fail against a break (header scroll never stepping back, a header entered in insert mode, Del never asking, Save on an output asking nothing), and a further ten breaks of the migrated tests' behaviour each failing its test (a jump landing at column 1, no file-in-another-pane fallback, Esc not leaving window mode, under-text placement a row low, a split inserted above, Mini never refreshing, a look walk selecting one cell, a PDF's / opening a text query, the same-visit merge off across panes, byte-wise backspace) Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge --- test/behaviour/builtins.zig | 1 + test/behaviour/columns_and_tags.zig | 2 ++ test/behaviour/keys.zig | 5 ++--- test/behaviour/modes.zig | 8 +++++++- 4 files changed, 12 insertions(+), 4 deletions(-) (limited to 'test/behaviour/keys.zig') diff --git a/test/behaviour/builtins.zig b/test/behaviour/builtins.zig index 6f029072..3c16a4a2 100644 --- a/test/behaviour/builtins.zig +++ b/test/behaviour/builtins.zig @@ -31,5 +31,6 @@ test "builtins: Mini maps a file of the pane's directory over pardes's own sourc try s.expect("/index", index); // Save asks for a path; nothing is written for it. try s.write(s.at("/pane/{d}/exec", .{mini}), "Save\n"); + try std.testing.expect(std.mem.indexOf(u8, try s.read("/log"), s.at("ask {d} save path\n", .{mini})) != null); try std.testing.expectEqual(@as(usize, 0), s.saved); } diff --git a/test/behaviour/columns_and_tags.zig b/test/behaviour/columns_and_tags.zig index ac8e7034..c1935bf8 100644 --- a/test/behaviour/columns_and_tags.zig +++ b/test/behaviour/columns_and_tags.zig @@ -285,6 +285,8 @@ test "columns-and-tags: a column tag lights the word under the mouse, is clicked try std.testing.expect(std.mem.indexOf(u8, try s.screen(), s.at("{s}b", .{row[1..]})) != null); try s.keys("\u{F00D}"); try std.testing.expectEqual(x, (try s.cursor()).?[0]); + // Scrolled back: the text drawn whole from its first cell again. + try std.testing.expect(std.mem.indexOf(u8, try s.screen(), s.at("{s}b", .{row})) != null); try s.keys("\x1b\x1b"); try s.write("/mousein", "m 0 23 0\n"); } diff --git a/test/behaviour/keys.zig b/test/behaviour/keys.zig index b6fe1e83..aa1128a3 100644 --- a/test/behaviour/keys.zig +++ b/test/behaviour/keys.zig @@ -226,7 +226,8 @@ test "keys: SPC j n and SPC j p walk Themes' rows, whole, never its section head try std.testing.expectEqualStrings(names.items[brk - 1]["Theme ".len..], try setting(&s, "Theme")); } -test "keys: SPC j n in a command output selects its whole row, Tab runs it, and from where a Look took the keyboard it walks on there" { +// Its rows whole and Tab running one are the Themes walk's test above. +test "keys: SPC j n from the pane a Look gave the keyboard walks back into the command output" { var tmp = std.testing.tmpDir(.{}); defer tmp.cleanup(); for ([_][]const u8{ "a.txt", "b.txt" }) |name| try tmp.dir.writeFile(std.testing.io, .{ .sub_path = name, .data = "x\n" }); @@ -242,8 +243,6 @@ test "keys: SPC j n in a command output selects its whole row, Tab runs it, and try std.testing.expect(themes != a); const sel = s.at("/pane/{d}/sel", .{themes}); try s.expect(sel, "Theme orchard"); - try s.keys(" jn\t"); - try std.testing.expect(std.mem.indexOf(u8, try s.read("/ctl"), "\nTheme dusk\n") != null); try s.write(s.at("/pane/{d}/exec", .{a}), "Look b.txt\n"); try std.testing.expect(try s.focused() != themes); try s.keys(" jn"); diff --git a/test/behaviour/modes.zig b/test/behaviour/modes.zig index b1641c6f..6e07e1b4 100644 --- a/test/behaviour/modes.zig +++ b/test/behaviour/modes.zig @@ -204,7 +204,9 @@ test "modes: in window mode d deletes the outlined pane, asking k or j between t try expectEqual(row_low, (try s.where("/low Save"))[1]); // d between two panes asks, as SPC d does; Esc takes it back, the // outline where it was. - try s.keys("d\x1b"); + try s.keys("d"); + try std.testing.expect(std.mem.indexOf(u8, try s.read("/log"), s.at("ask {d} del k j\n", .{mid})) != null); + try s.keys("\x1b"); try std.testing.expect(try listed(&s, mid)); try std.testing.expectEqualStrings("/mid", try outlined(&s, lit, names)); // j: the pane below takes the rows, and the outline goes with them. @@ -217,6 +219,7 @@ test "modes: in window mode d deletes the outlined pane, asking k or j between t // pane that grew. try s.keys("d"); try std.testing.expect(!try listed(&s, low)); + try std.testing.expect(std.mem.indexOf(u8, try s.read("/log"), s.at("ask {d} ", .{low})) == null); try std.testing.expectEqualStrings("/test.txt", try outlined(&s, lit, &.{"/test.txt"})); // Enter leaves the mode on it. try s.keys("\n"); @@ -238,7 +241,10 @@ test "modes: window keys walk from a pane up through its column's tag and the wo const x0, const y0 = (try s.cursor()).?; try expectEqual(@as(usize, 1), y0); try std.testing.expect(x0 < right); + const tag = s.at("/col/{d}/tag", .{try s.column(0)}); + const words = try s.read(tag); try s.keys("w"); + try s.expect(tag, words); const remembered = (try s.cursor()).?; try std.testing.expect(remembered[0] > x0); // Across to the right column's tag, and back to where the caret was. -- cgit v1.3