diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-05 22:27:44 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-05 23:58:31 -0300 |
| commit | f930d53c58187381b2f0df6892546ac1c217c9db (patch) | |
| tree | 5ca1eea4698b3c14178d2b1ae5d0251c0b884543 /test/behaviour | |
| parent | 71e5a0f4a8685b385fac762995d45575b638179f (diff) | |
| download | pardes-f930d53c58187381b2f0df6892546ac1c217c9db.tar.gz pardes-f930d53c58187381b2f0df6892546ac1c217c9db.zip | |
settings #1, Tagbottom goes, a pane's tag at its head the one value anyone used: layout.bodyTop and tagTop, mouse's seam and clampBorderRow, applyRowSplit, body_layer's copy and the tests' row arithmetic lose their other arm (reads deleted in Core.zig, layout.zig, mouse.zig, draw.zig, gui.zig, macos.zig, whose ABI slot 11 says 0 now, and ninep/events.zig, ninep/tree.zig, look.zig, Messages.zig), with the registry row, SPC t b, Help, /commands, the builtins JSON and the reference row; deleted: the snapshot scripts tagbottom, tagbottomshort and tagbottomimage with their goldens, the behaviour test "placement: under Tagbottom a look from a pane's text goes under its text too", the window scene 10-tagbottom with its gui-goldens line and the macOS parity check tags-bottom; tests that ran both ends of the tag run the head; a dump that kept the field loads without it; perf.zig's harness id moves in the two debug baselines (its reads of the field went); the window scenes after 10-tagbottom (12 to 15, 17) take new gui-goldens lines, the two Tagbottom writes gone from the scene and with them their words on the message row (the base window build running the same scenes gives the same frames); gates on tui: core-test 966/966, behaviour-test 243/243, unit-test 1484/1485, pane-test 171/172, snap all 105 scripts ok, process-test 0 of 37 failed; gui unit-test 1529/1530, gui-golden 0 of 1 failed
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'test/behaviour')
| -rw-r--r-- | test/behaviour/mouse.zig | 45 | ||||
| -rw-r--r-- | test/behaviour/placement.zig | 23 | ||||
| -rw-r--r-- | test/behaviour/settings.zig | 2 | ||||
| -rw-r--r-- | test/behaviour/tags.zig | 172 |
4 files changed, 102 insertions, 140 deletions
diff --git a/test/behaviour/mouse.zig b/test/behaviour/mouse.zig index a0ac7a23..e64e3ef9 100644 --- a/test/behaviour/mouse.zig +++ b/test/behaviour/mouse.zig @@ -53,30 +53,27 @@ test "mouse: everything a B1 chord does while B1 is down is one undo step" { test "mouse: a click past a line's or the file's end puts the caret where insertion types" { for ([_]bool{ false, true }) |already_insert| { - for ([_]bool{ false, true }) |bottom_tag| { - for ([_]struct { text: []const u8, click_row: usize, dot: u32, col: usize, row: usize, result: []const u8 }{ - .{ .text = "abc\nxy", .click_row = 0, .dot = 3, .col = 3, .row = 0, .result = "abcZ\nxy" }, - .{ .text = "abc\nxy", .click_row = 5, .dot = 6, .col = 2, .row = 1, .result = "abc\nxyZ" }, - .{ .text = "abc\n", .click_row = 5, .dot = 4, .col = 0, .row = 1, .result = "abc\nZ" }, - .{ .text = "", .click_row = 5, .dot = 0, .col = 0, .row = 0, .result = "Z" }, - }) |case| { - var s = try Session.initFile(std.testing.allocator, case.text); - defer s.deinit(); - const n = try s.focused(); - if (bottom_tag) try s.write("/ctl", "Tagbottom on\n"); - if (already_insert) try s.keys("i"); - // The first line's number, then a blank, then its text. - const x, const y = try s.where("1 "); - try mouse(&s, "m {d} {d} 1\nm {d} {d} 0\n", .{ x + 2 + 15, y + case.click_row, x + 2 + 15, y + case.click_row }); - try std.testing.expectEqual(.{ case.dot, case.dot }, try s.range(s.at("/pane/{d}/dot", .{n}))); - // The caret is drawn where it is, and insertion draws it there too. - try std.testing.expectEqual(.{ x + 2 + case.col, y + case.row }, (try s.cursor()).?); - if (!already_insert) try s.keys("i"); - try std.testing.expect(std.mem.endsWith(u8, try s.read(s.at("/pane/{d}/ctl", .{n})), " mode:insert ")); - try std.testing.expectEqual(.{ x + 2 + case.col, y + case.row }, (try s.cursor()).?); - try s.keys("Z"); - try s.expect(s.at("/pane/{d}/body", .{n}), case.result); - } + for ([_]struct { text: []const u8, click_row: usize, dot: u32, col: usize, row: usize, result: []const u8 }{ + .{ .text = "abc\nxy", .click_row = 0, .dot = 3, .col = 3, .row = 0, .result = "abcZ\nxy" }, + .{ .text = "abc\nxy", .click_row = 5, .dot = 6, .col = 2, .row = 1, .result = "abc\nxyZ" }, + .{ .text = "abc\n", .click_row = 5, .dot = 4, .col = 0, .row = 1, .result = "abc\nZ" }, + .{ .text = "", .click_row = 5, .dot = 0, .col = 0, .row = 0, .result = "Z" }, + }) |case| { + var s = try Session.initFile(std.testing.allocator, case.text); + defer s.deinit(); + const n = try s.focused(); + if (already_insert) try s.keys("i"); + // The first line's number, then a blank, then its text. + const x, const y = try s.where("1 "); + try mouse(&s, "m {d} {d} 1\nm {d} {d} 0\n", .{ x + 2 + 15, y + case.click_row, x + 2 + 15, y + case.click_row }); + try std.testing.expectEqual(.{ case.dot, case.dot }, try s.range(s.at("/pane/{d}/dot", .{n}))); + // The caret is drawn where it is, and insertion draws it there too. + try std.testing.expectEqual(.{ x + 2 + case.col, y + case.row }, (try s.cursor()).?); + if (!already_insert) try s.keys("i"); + try std.testing.expect(std.mem.endsWith(u8, try s.read(s.at("/pane/{d}/ctl", .{n})), " mode:insert ")); + try std.testing.expectEqual(.{ x + 2 + case.col, y + case.row }, (try s.cursor()).?); + try s.keys("Z"); + try s.expect(s.at("/pane/{d}/body", .{n}), case.result); } } } diff --git a/test/behaviour/placement.zig b/test/behaviour/placement.zig index f6823feb..73d69883 100644 --- a/test/behaviour/placement.zig +++ b/test/behaviour/placement.zig @@ -108,29 +108,6 @@ test "placement: a look from a pane's text goes under its text when it has many try std.testing.expectEqual(was[big][0] + was[big][1], now[big + 1][0] + now[big + 1][1]); } -test "placement: under Tagbottom a look from a pane's text goes under its text too, every line of it still in sight above its tag" { - var tmp = std.testing.tmpDir(.{}); - defer tmp.cleanup(); - try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "second.txt", .data = "second\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, "alpha\nbeta\ngamma\n"); - defer s.deinit(); - s.detach(); - try s.write("/ctl", "size 200 60\n"); - try s.write("/ctl", "Tagbottom on\n"); - const top = try s.focused(); - try s.write(s.at("/pane/{d}/look", .{top}), s.at("{s}/second.txt\n", .{at})); - // The first pane keeps its three lines with its tag under them, at its - // foot: the split leaves it its tag and its text whichever end the tag - // is on (makenewwindow, util.c:482-486). The new pane starts below. - const alpha = (try s.where("alpha"))[1]; - try std.testing.expectEqual(alpha + 1, (try s.where("beta"))[1]); - try std.testing.expectEqual(alpha + 2, (try s.where("gamma"))[1]); - try std.testing.expectEqual(alpha + 3, try tagRow(&s, "/test.txt")); - try std.testing.expectEqual(alpha + 4, (try s.where("second"))[1]); -} - test "placement: a look from the middle of a column splits only the pane it came from, short ones round it kept short, through a Newcol too" { var tmp = std.testing.tmpDir(.{}); defer tmp.cleanup(); diff --git a/test/behaviour/settings.zig b/test/behaviour/settings.zig index d87e8191..80573e2f 100644 --- a/test/behaviour/settings.zig +++ b/test/behaviour/settings.zig @@ -274,7 +274,7 @@ test "settings: every on/off setting the root ctl reads flips when its word is w // A floor, so a ctl that lists none fails: a bare session's on/off // words, Colors to PagerColor, are ten. try std.testing.expect(flipped >= 10); - for ([_][]const u8{ "Colors off", "Wrap off", "Tagbottom on", "Debug on" }) |want| + for ([_][]const u8{ "Colors off", "Wrap off", "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"); diff --git a/test/behaviour/tags.zig b/test/behaviour/tags.zig index 71faed3a..4477e73e 100644 --- a/test/behaviour/tags.zig +++ b/test/behaviour/tags.zig @@ -149,76 +149,67 @@ test "tags: a renamed path moves the tag's cursor with the text after it and a s } test "tags: window keys move between panes from a tag and each tag keeps its cursor" { - for ([_]bool{ false, true }) |bottom| { - var s = try Session.initFile(std.testing.allocator, "body\n"); - defer s.deinit(); - if (bottom) try s.write("/ctl", "Tagbottom on\n"); - const first = try s.focused(); - const second = try s.newPane(); - try s.write(s.at("/pane/{d}/name", .{second}), "/second.txt"); - try s.write("/focus", s.at("{d}", .{first})); - try s.keys(":" ++ home ++ "ll" ++ window ++ "j\n"); - try std.testing.expectEqual(second, try s.focused()); - try s.keys(":" ++ home ++ "llll" ++ window ++ "k\n"); - try std.testing.expectEqual(first, try s.focused()); - try s.keys(":"); - try std.testing.expectEqual(@as(usize, 2), try tagCol(&s, "/test.txt")); - try s.keys(window ++ "j\n:"); - try std.testing.expectEqual(@as(usize, 4), try tagCol(&s, "/second.txt")); - } + var s = try Session.initFile(std.testing.allocator, "body\n"); + defer s.deinit(); + const first = try s.focused(); + const second = try s.newPane(); + try s.write(s.at("/pane/{d}/name", .{second}), "/second.txt"); + try s.write("/focus", s.at("{d}", .{first})); + try s.keys(":" ++ home ++ "ll" ++ window ++ "j\n"); + try std.testing.expectEqual(second, try s.focused()); + try s.keys(":" ++ home ++ "llll" ++ window ++ "k\n"); + try std.testing.expectEqual(first, try s.focused()); + try s.keys(":"); + try std.testing.expectEqual(@as(usize, 2), try tagCol(&s, "/test.txt")); + try s.keys(window ++ "j\n:"); + try std.testing.expectEqual(@as(usize, 4), try tagCol(&s, "/second.txt")); } test "tags: a tag's normal mode is the body's: motions stay in the tag and insert types into it" { - for ([_]bool{ false, true }) |bottom| { - var s = try Session.initFile(std.testing.allocator, "body\n"); - defer s.deinit(); - if (bottom) try s.write("/ctl", "Tagbottom on\n"); - const first = try s.focused(); - try s.write("/ctl", "Newcol\n"); - const right_pane = try s.newPane(); - try s.write("/focus", s.at("{d}", .{first})); - try s.keys(":" ++ home ++ "l"); - try std.testing.expectEqual(@as(usize, 1), try tagCol(&s, "/test.txt")); - try s.keys("hkj"); - try std.testing.expectEqual(@as(usize, 0), try tagCol(&s, "/test.txt")); - try std.testing.expectEqual(first, try s.focused()); - try s.keys(window ++ "l\n"); - try std.testing.expectEqual(right_pane, try s.focused()); - try s.keys(window ++ "h\n"); - try std.testing.expectEqual(first, try s.focused()); - try s.keys(":i\u{F018}hjklHJKL:"); - try std.testing.expectEqualStrings("/test.txt Save Term Collapse DelhjklHJKL:", try tag(&s, first)); - try std.testing.expect(std.mem.endsWith(u8, try s.read(s.at("/pane/{d}/ctl", .{first})), " mode:normal ")); - try s.expect(s.at("/pane/{d}/body", .{first}), "body\n"); - try std.testing.expectEqual(first, try s.focused()); - } + var s = try Session.initFile(std.testing.allocator, "body\n"); + defer s.deinit(); + const first = try s.focused(); + try s.write("/ctl", "Newcol\n"); + const right_pane = try s.newPane(); + try s.write("/focus", s.at("{d}", .{first})); + try s.keys(":" ++ home ++ "l"); + try std.testing.expectEqual(@as(usize, 1), try tagCol(&s, "/test.txt")); + try s.keys("hkj"); + try std.testing.expectEqual(@as(usize, 0), try tagCol(&s, "/test.txt")); + try std.testing.expectEqual(first, try s.focused()); + try s.keys(window ++ "l\n"); + try std.testing.expectEqual(right_pane, try s.focused()); + try s.keys(window ++ "h\n"); + try std.testing.expectEqual(first, try s.focused()); + try s.keys(":i\u{F018}hjklHJKL:"); + try std.testing.expectEqualStrings("/test.txt Save Term Collapse DelhjklHJKL:", try tag(&s, first)); + try std.testing.expect(std.mem.endsWith(u8, try s.read(s.at("/pane/{d}/ctl", .{first})), " mode:normal ")); + try s.expect(s.at("/pane/{d}/body", .{first}), "body\n"); + try std.testing.expectEqual(first, try s.focused()); } test "tags: a tag with a newline in it is as tall as its lines, and each line is typed into and pointed at" { - for ([_]bool{ false, true }) |bottom| { - var s = try Session.initFile(std.testing.allocator, "body\n"); - defer s.deinit(); - const n = try s.focused(); - if (bottom) try s.write("/ctl", "Tagbottom on\n"); - // Insert mode in a tag is a body's: Enter is a new line. - try s.keys(":A\nSecond"); - try std.testing.expectEqualStrings("/test.txt Save Term Collapse Del\nSecond", try tag(&s, n)); - const x, const y = try s.where("/test.txt"); - try std.testing.expectEqual(.{ x, y + 1 }, try s.where("Second")); - // The caret is on the second line, after what was typed. - try std.testing.expectEqual(.{ x + 6, y + 1 }, (try s.cursor()).?); - // The body starts under (or over) the whole tag. - const by = (try s.where("1 body"))[1]; - try std.testing.expect(if (bottom) by < y else by == y + 2); - // A click on the second line puts the tag's cursor on it. - try s.keys("\x1b:"); - try s.write("/mousein", s.at("m {d} {d} 1\nm {d} {d} 0\n", .{ x + 2, y + 1, x + 2, y + 1 })); - try std.testing.expectEqual(.{ x + 2, y + 1 }, (try s.cursor()).?); - // A clicked tag is in normal mode: `i` types where it was clicked. - try s.keys("iX"); - try std.testing.expectEqualStrings("/test.txt Save Term Collapse Del\nSeXcond", try tag(&s, n)); - try s.expect(s.at("/pane/{d}/body", .{n}), "body\n"); - } + var s = try Session.initFile(std.testing.allocator, "body\n"); + defer s.deinit(); + const n = try s.focused(); + // Insert mode in a tag is a body's: Enter is a new line. + try s.keys(":A\nSecond"); + try std.testing.expectEqualStrings("/test.txt Save Term Collapse Del\nSecond", try tag(&s, n)); + const x, const y = try s.where("/test.txt"); + try std.testing.expectEqual(.{ x, y + 1 }, try s.where("Second")); + // The caret is on the second line, after what was typed. + try std.testing.expectEqual(.{ x + 6, y + 1 }, (try s.cursor()).?); + // The body starts under the whole tag. + const by = (try s.where("1 body"))[1]; + try std.testing.expect(by == y + 2); + // A click on the second line puts the tag's cursor on it. + try s.keys("\x1b:"); + try s.write("/mousein", s.at("m {d} {d} 1\nm {d} {d} 0\n", .{ x + 2, y + 1, x + 2, y + 1 })); + try std.testing.expectEqual(.{ x + 2, y + 1 }, (try s.cursor()).?); + // A clicked tag is in normal mode: `i` types where it was clicked. + try s.keys("iX"); + try std.testing.expectEqualStrings("/test.txt Save Term Collapse Del\nSeXcond", try tag(&s, n)); + try s.expect(s.at("/pane/{d}/body", .{n}), "body\n"); } test "tags: a tag with more lines than rows scrolls to keep its caret in view" { @@ -469,33 +460,30 @@ test "tags: truncating a tag clears its own text, u in the tag undoes it, and > 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.?)); +test "tags: a pane tag's file name is tinted, its directory, dirty marker and words not" { + 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"); + 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.?)); } |
