From 37408da299e21b8807ccd10545482a709bac88c7 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Tue, 3 Nov 2026 17:00:11 -0300 Subject: test: eight of src/pardes.zig's tests through the 9P tree alone (test/behaviour/columns_and_tags, look_and_exec): Joincol folding a column into its right neighbour and refused with none, Newcol's empty column with its tag focused filled by the next Tty, a column's exec acting on that column and a pane's Delcol on its own, a column's last pane closed leaving it empty and Delcol taking it, a column's tag following it through Newcol and Joincol, Delcol on the last column leaving the window typed into, New in no pane's tag nor the workspace's, a look that finds nothing in the log; Session's columns and column (/layout as column:panes); each checked to fail against a break (joinCol inert, joinCol keeping the left tag, acmeColumn ignoring the active column, a scratch ignoring exec_column, no enterHeader for an emptied column, removeColumn refusing the last, New in a file pane's tail, missed logging nothing) Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge --- src/pardes.zig | 184 --------------------------------------------------------- 1 file changed, 184 deletions(-) (limited to 'src') diff --git a/src/pardes.zig b/src/pardes.zig index ff64cb9f..ea8b52df 100644 --- a/src/pardes.zig +++ b/src/pardes.zig @@ -978,29 +978,6 @@ test "compact tag commands stay beside their own prefix across layout changes" { try std.testing.expectEqualStrings(above_tag, try tagline.tagText(p, p.scratch.allocator(), above)); } -test "Joincol folds the active column into its right neighbor, keeping its panes" { - const gpa = std.testing.allocator; - const p = try Pardes.init(gpa, .{ .tty_only = true, .cols = 100, .rows = 30 }); - defer p.deinit(); - while (p.nextEffect()) |_| {} - - const right = p.freeSlot().?; - _ = try p.newShell(right, ""); - try std.testing.expect(layout.splitColumn(p, 0, right, false)); - while (p.nextEffect()) |_| {} - try std.testing.expectEqual(@as(usize, 2), p.ncol); - - p.active = 0; // the left column is current - layout.joinCol(p, 0); - try std.testing.expectEqual(@as(usize, 1), p.ncol); - const lf = layout.findPane(p, 0) orelse return error.LostLeftPane; - const rf = layout.findPane(p, right) orelse return error.LostRightPane; - try std.testing.expectEqual(lf.col, rf.col); - - layout.joinCol(p, 0); // no right neighbor left: inert - try std.testing.expectEqual(@as(usize, 1), p.ncol); -} - test "Tty spawns a raw shell in the caller's directory" { const gpa = std.testing.allocator; const p = try Pardes.init(gpa, .{ .tty_only = true, .cols = 100, .rows = 30 }); @@ -1485,16 +1462,6 @@ test "dragging a column's only pane to another leaves that column in place, empt try std.testing.expectEqual(@as(usize, 1), p.col_n[0]); } -test "pane defaults keep creation of scratch panes in column tags" { - const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true }); - defer p.deinit(); - for ([_][]const u8{ tagline.pane_tail, tagline.file_pane_tail, tagline.pdf_pane_tail, tagline.terminal_pane_tail, config.topbar_str }) |tag| { - var words = std.mem.tokenizeScalar(u8, tag, ' '); - while (words.next()) |word| try std.testing.expect(!std.mem.eql(u8, word, "New")); - } - try std.testing.expectEqualStrings("New Tty Find Grep Joincol Delcol", tagline.columnTag(p, 0)); -} - test "an unsaved file's tag is its name alone: the grip, not a mark, says it is unsaved" { const gpa = std.testing.allocator; const p = try Pardes.init(gpa, .{ .tty_only = true, .cols = 100, .rows = 30 }); @@ -3345,21 +3312,6 @@ test "editable workspace and column tags are typed into and persist" { try std.testing.expectEqualStrings("", tagline.columnTag(empty, 0)); } -test "column tags follow their column through split and close" { - const p = try Pardes.init(std.testing.allocator, .{ .cols = 120, .rows = 20, .tty_only = true }); - defer p.deinit(); - _ = try p.setTestFile("left\n"); - p.col_tags[0].own = try p.gpa.dupe(u8, "Left Find"); - _ = exec.execute(p, 0, "Newcol"); - try std.testing.expectEqual(@as(usize, 2), p.ncol); - try std.testing.expectEqualStrings("Left Find", tagline.columnTag(p, 0)); - p.col_tags[1].own = try p.gpa.dupe(u8, "Right Grep"); - p.active = p.col_panes[0][0]; - layout.joinCol(p, 0); - try std.testing.expectEqual(@as(usize, 1), p.ncol); - try std.testing.expectEqualStrings("Right Grep", tagline.columnTag(p, 0)); -} - test "column tags render edit hover and scroll from the column edge" { const p = try Pardes.init(std.testing.allocator, .{ .cols = 80, .rows = 20, .tty_only = true }); defer p.deinit(); @@ -8609,62 +8561,6 @@ test "a prompt is typed on its own line in the notice band and leaves the tag ro try std.testing.expect(pane.prompt == .none and pane.input.own == null); } -test "Newcol makes an empty column, and the next pane made from its tag fills it" { - if (platform == .web) return; - const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 160, .rows = 40 }); - defer p.deinit(); - const first = p.active; - const panes_before = p.col_n[0]; - try std.testing.expect(p.executeBuiltinLine(first, "Newcol")); - try std.testing.expectEqual(@as(usize, 2), p.ncol); - try std.testing.expectEqual(@as(usize, 0), p.col_n[1]); - try std.testing.expectEqual(panes_before, p.col_n[0]); - // The keyboard is on the new column's tag; no pane has it. - try std.testing.expect(p.header_focus and p.header_column.? == 1); - try std.testing.expectEqual(first, p.active); - p.sync(); - try std.testing.expect(p.executeBuiltinLine(first, "Tty")); - const shell = p.active; - try std.testing.expect(shell != first); - try std.testing.expectEqual(@as(usize, 1), p.col_n[1]); - try std.testing.expectEqual(shell, p.col_panes[1][0]); - try std.testing.expect(!p.header_focus); - - // The next Tty splits as it always has: nothing is empty any more. - p.sync(); - try std.testing.expect(p.executeBuiltinLine(shell, "Tty")); - try std.testing.expectEqual(@as(usize, 2), p.col_n[1]); -} - -test "a column tag's command acts on that column" { - if (platform == .web) return; - const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 160, .rows = 40 }); - defer p.deinit(); - const first = p.active; - try std.testing.expect(p.executeBuiltinLine(first, "Newcol")); - try std.testing.expect(p.executeBuiltinLine(first, "Newcol")); - try std.testing.expectEqual(@as(usize, 3), p.ncol); - p.sync(); - // New from the middle column's tag lands in it, not below `first`. - p.exec_column = 1; - try std.testing.expect(p.executeBuiltinLine(first, "New")); - p.exec_column = null; - try std.testing.expectEqual(@as(usize, 1), p.col_n[1]); - try std.testing.expectEqual(p.active, p.col_panes[1][0]); - // Delcol from the empty right column's tag closes that one. - p.exec_column = 2; - try std.testing.expect(p.executeBuiltinLine(first, "Delcol")); - p.exec_column = null; - try std.testing.expectEqual(@as(usize, 2), p.ncol); - try std.testing.expectEqual(@as(usize, 1), p.col_n[1]); - // A pane's own Delcol closes its column whatever tag has the keyboard. - try std.testing.expect(p.executeBuiltinLine(first, "Newcol")); - try std.testing.expect(p.header_focus); - try std.testing.expect(p.executeBuiltinLine(p.col_panes[1][0], "Delcol")); - try std.testing.expectEqual(@as(usize, 2), p.ncol); - try std.testing.expectEqual(@as(usize, 0), p.col_n[1]); -} - test "Del from a key asks which neighbour takes the rows; nothing else asks" { if (platform == .web) return; const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 80, .rows = 40 }); @@ -8780,17 +8676,6 @@ test "Del from a key asks which neighbour takes the rows; nothing else asks" { try std.testing.expect(p.panes[low] == null); } -test "a Look that finds nothing says so" { - if (platform == .web) return; - const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 80, .rows = 24 }); - defer p.deinit(); - p.newScratchBelow(p.active); - const id = p.active; - p.sync(); - look.lookAt(p, id, "/no/such/zzqq"); - try std.testing.expectEqualStrings("Look: no match for \"/no/such/zzqq\"", p.panes[id].?.msg[0..p.panes[id].?.msg_len]); -} - test "focus on a closed pane goes to the pane that takes its place, not the one focused before" { if (platform == .web) return; const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 120, .rows = 40 }); @@ -8834,47 +8719,6 @@ test "focus on a closed pane goes to the pane that takes its place, not the one try std.testing.expectEqual(right_low, p.active); } -test "closing the last pane in a column leaves the column empty, its tag focused" { - if (platform == .web) return; - const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 120, .rows = 24 }); - defer p.deinit(); - const shell = p.active; - p.newColumn(shell); - p.newScratchIn(shell, p.activeColumn().?); - const lone = p.active; - try std.testing.expect(lone != shell); - try std.testing.expectEqual(@as(usize, 2), p.ncol); - const at = layout.findPane(p, lone).?; - try std.testing.expectEqual(@as(usize, 1), p.col_n[at.col]); - p.sync(); - - try p.removePane(lone, null); - p.sync(); - - // The column outlives the pane, as acme's does: still two columns, the - // emptied one with no pane and the keyboard on its tag. - try std.testing.expectEqual(@as(usize, 2), p.ncol); - try std.testing.expectEqual(@as(usize, 0), p.col_n[at.col]); - try std.testing.expect(p.panes[lone] == null); - try std.testing.expect(p.header_focus and p.header_column.? == at.col); - try std.testing.expectEqual(shell, p.active); - try std.testing.expect(!p.quit); - - // Down from it goes nowhere: nothing is below. - try std.testing.expect(p.executeBuiltinLine(shell, "Down")); - try std.testing.expect(p.header_focus and p.header_column.? == at.col); - - // ...and Delcol is what actually takes the column away. - try p.removeColumn(at.col); - p.sync(); - try std.testing.expectEqual(@as(usize, 1), p.ncol); - try std.testing.expectEqual(shell, p.active); - - // The session's last pane closing ends it. - try p.removePane(shell, null); - try std.testing.expect(p.quit); -} - test "the bare tty startup opens a text pane under the shell, unfocused" { if (platform == .web) return; const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .boot = .tty }); @@ -10070,31 +9914,3 @@ test "a Save the host could not do logs no save record" { p.perform(.{ .save_file = .{ .pane = 0 } }); try std.testing.expect(th.logHas(p, "\nsave ")); } - -test "Delcol on the last column leaves the window, drawn and typed into, and Newcol starts it again" { - const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 80, .rows = 24 }); - defer p.deinit(); - while (p.nextEffect()) |_| {} - while (p.ncol > 0) { - p.exec_column = 0; - _ = p.executeBuiltinLine(p.active, "Delcol"); - p.exec_column = null; - p.sync(); - } - try std.testing.expect(!p.quit); - try std.testing.expect(p.anyPane() == null); - // Drawn, and keys go to the workspace tag. - _ = try p.render(p.frame_arena.allocator()); - p.update(.{ .key = .{ .cp = 'x', .text = "x" } }); - p.update(.{ .key = .{ .cp = Key.enter } }); - p.sync(); - _ = try p.render(p.frame_arena.allocator()); - try std.testing.expect(!p.quit); - _ = p.executeBuiltinLine(p.active, "Newcol"); - p.sync(); - try std.testing.expectEqual(@as(usize, 1), p.ncol); - _ = p.executeBuiltinLine(p.active, "New"); - p.sync(); - try std.testing.expect(p.anyPane() != null); - _ = try p.render(p.frame_arena.allocator()); -} -- cgit v1.3