summaryrefslogtreecommitdiff
path: root/test/behaviour
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-03 17:00:11 -0300
committerGabriel Schneider <[email protected]>2026-11-03 17:04:18 -0300
commit37408da299e21b8807ccd10545482a709bac88c7 (patch)
treeff29465e50538df66a712d9aeabf156c9185a1b1 /test/behaviour
parentd1273bbd99daf9b1855d82bf315db8ede20abde5 (diff)
downloadpardes-37408da299e21b8807ccd10545482a709bac88c7.tar.gz
pardes-37408da299e21b8807ccd10545482a709bac88c7.zip
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 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'test/behaviour')
-rw-r--r--test/behaviour/columns_and_tags.zig118
-rw-r--r--test/behaviour/look_and_exec.zig8
2 files changed, 126 insertions, 0 deletions
diff --git a/test/behaviour/columns_and_tags.zig b/test/behaviour/columns_and_tags.zig
index 25ba4c64..80f9c710 100644
--- a/test/behaviour/columns_and_tags.zig
+++ b/test/behaviour/columns_and_tags.zig
@@ -1,6 +1,7 @@
//! docs/typ/reference.typ, Columns and tags <columns-and-tags>.
const std = @import("std");
const Session = @import("session").Session;
+const expectEqualStrings = std.testing.expectEqualStrings;
/// /layout's line for the last column.
fn lastColumn(s: *Session) ![]const u8 {
@@ -31,3 +32,120 @@ test "columns-and-tags: a look after Newcol fills the empty column the keyboard
try std.testing.expect(std.mem.indexOf(u8, col, " full ") != null);
try std.testing.expect(std.mem.endsWith(u8, col, s.at(" {d}", .{try s.focused()})));
}
+
+test "columns-and-tags: Joincol folds a column into its right neighbour, keeping its panes, and with none it is inert" {
+ var s = try Session.initFile(std.testing.allocator, "x\n");
+ defer s.deinit();
+ const left = try s.focused();
+ const left_col = try s.column(0);
+ try s.write("/ctl", "Newcol\n");
+ const right_col = try s.column(1);
+ try s.write(s.at("/col/{d}/ctl", .{right_col}), "New\n");
+ const right = try s.focused();
+ try s.write(s.at("/col/{d}/ctl", .{left_col}), "Joincol\n");
+ try expectEqualStrings(s.at("{d}:{d},{d}", .{ right_col, right, left }), try s.columns());
+ _ = try s.refused(s.at("/col/{d}/ctl", .{right_col}), "Joincol\n");
+ try expectEqualStrings("Joincol: no column to the right", s.said);
+ try expectEqualStrings(s.at("{d}:{d},{d}", .{ right_col, right, left }), try s.columns());
+}
+
+test "columns-and-tags: Newcol makes an empty column with the keyboard on its tag, and the next pane made fills it" {
+ var s = try Session.initFile(std.testing.allocator, "x\n");
+ defer s.deinit();
+ const first = try s.focused();
+ try s.write("/ctl", "Newcol\n");
+ const left, const col = .{ try s.column(0), try s.column(1) };
+ try expectEqualStrings(s.at("{d}:{d} {d}:", .{ left, first, col }), try s.columns());
+ try s.expect("/focus", "");
+ try s.write(s.at("/pane/{d}/exec", .{first}), "Tty\n");
+ const shell = try s.focused();
+ try expectEqualStrings(s.at("{d}:{d} {d}:{d}", .{ left, first, col, shell }), try s.columns());
+ // The next Tty splits as it always has: nothing is empty any more.
+ try s.write(s.at("/pane/{d}/exec", .{shell}), "Tty\n");
+ try expectEqualStrings(s.at("{d}:{d} {d}:{d},{d}", .{ left, first, col, shell, try s.focused() }), try s.columns());
+}
+
+test "columns-and-tags: a column's exec acts on that column, and a pane's Delcol on its own" {
+ var s = try Session.initFile(std.testing.allocator, "x\n");
+ defer s.deinit();
+ const first = try s.focused();
+ try s.write("/ctl", "Newcol\n");
+ try s.write("/ctl", "Newcol\n");
+ const left, const middle = .{ try s.column(0), try s.column(1) };
+ // New from the middle column's tag lands in it, not below the pane
+ // with the keyboard.
+ try s.write(s.at("/col/{d}/exec", .{middle}), "New\n");
+ const made = try s.focused();
+ try expectEqualStrings(s.at("{d}:{d} {d}:{d} {d}:", .{ left, first, middle, made, try s.column(2) }), try s.columns());
+ // Delcol from the empty right column's tag closes that one.
+ try s.write(s.at("/col/{d}/exec", .{try s.column(2)}), "Delcol\n");
+ try expectEqualStrings(s.at("{d}:{d} {d}:{d}", .{ left, first, middle, made }), try s.columns());
+ // A pane's own Delcol closes its column whatever tag has the keyboard.
+ try s.write("/ctl", "Newcol\n");
+ try s.expect("/focus", "");
+ const right = try s.column(2);
+ try s.write(s.at("/pane/{d}/exec", .{made}), "Delcol\n");
+ try expectEqualStrings(s.at("{d}:{d} {d}:", .{ left, first, right }), try s.columns());
+}
+
+test "columns-and-tags: closing a column's last pane leaves it empty, its tag with the keyboard; Delcol takes it away" {
+ var s = try Session.initFile(std.testing.allocator, "x\n");
+ defer s.deinit();
+ const first = try s.focused();
+ try s.write("/ctl", "Newcol\n");
+ const left, const col = .{ try s.column(0), try s.column(1) };
+ try s.write(s.at("/col/{d}/ctl", .{col}), "New\n");
+ try s.write(s.at("/pane/{d}/ctl", .{try s.focused()}), "Del\n");
+ // The column outlives the pane, as acme's does.
+ try expectEqualStrings(s.at("{d}:{d} {d}:", .{ left, first, col }), try s.columns());
+ try s.expect("/focus", "");
+ // Down from it goes nowhere: nothing is below.
+ try s.write(s.at("/pane/{d}/exec", .{first}), "Down\n");
+ try s.expect("/focus", "");
+ try s.write(s.at("/col/{d}/ctl", .{col}), "Delcol\n");
+ try expectEqualStrings(s.at("{d}:{d}", .{ left, first }), try s.columns());
+ try std.testing.expectEqual(first, try s.focused());
+}
+
+test "columns-and-tags: a column's tag follows its column through Newcol and Joincol" {
+ var s = try Session.initFile(std.testing.allocator, "x\n");
+ defer s.deinit();
+ try s.write(s.at("/col/{d}/tag", .{try s.column(0)}), " Left");
+ try s.write(s.at("/pane/{d}/exec", .{try s.focused()}), "Newcol\n");
+ try std.testing.expect(std.mem.endsWith(u8, try s.read(s.at("/col/{d}/tag", .{try s.column(0)})), " Left"));
+ try s.write(s.at("/col/{d}/tag", .{try s.column(1)}), " Right");
+ try s.write(s.at("/col/{d}/ctl", .{try s.column(0)}), "Joincol\n");
+ try std.testing.expect(std.mem.endsWith(u8, try s.read(s.at("/col/{d}/tag", .{try s.column(0)})), " Right"));
+}
+
+test "columns-and-tags: Delcol on the last column leaves the window, drawn and typed into, and Newcol starts it again" {
+ var s = try Session.initFile(std.testing.allocator, "x\n");
+ defer s.deinit();
+ try s.write(s.at("/col/{d}/ctl", .{try s.column(0)}), "Delcol\n");
+ try expectEqualStrings("", try s.columns());
+ try s.expect("/index", "");
+ // Drawn, and keys go to the workspace tag.
+ try s.keys("x\n");
+ try std.testing.expect(std.mem.startsWith(u8, try s.screen(), " Newcol "));
+ try s.write("/ctl", "Newcol\n");
+ try s.write(s.at("/col/{d}/ctl", .{try s.column(0)}), "New\n");
+ try expectEqualStrings(s.at("{d}:{d}", .{ try s.column(0), try s.focused() }), try s.columns());
+}
+
+test "columns-and-tags: New is a column tag's word, in no pane's tag nor the workspace's" {
+ var s = try Session.initFile(std.testing.allocator, "x\n");
+ defer s.deinit();
+ var t = try Session.initTerm(std.testing.allocator);
+ defer t.deinit();
+ const scratch = try s.newPane();
+ for ([_][]const u8{
+ try s.read("/tag"),
+ try s.read(s.at("/pane/{d}/tag", .{scratch})),
+ try s.read(s.at("/pane/{d}/tag", .{try s.focused()})),
+ try t.read(t.at("/pane/{d}/tag", .{try t.focused()})),
+ }) |tag| {
+ var words = std.mem.tokenizeScalar(u8, tag, ' ');
+ while (words.next()) |word| try std.testing.expect(!std.mem.eql(u8, word, "New"));
+ }
+ try expectEqualStrings("New Tty Find Grep Joincol Delcol", try s.read(s.at("/col/{d}/tag", .{try s.column(0)})));
+}
diff --git a/test/behaviour/look_and_exec.zig b/test/behaviour/look_and_exec.zig
index 2ff4345b..5b8d7e1a 100644
--- a/test/behaviour/look_and_exec.zig
+++ b/test/behaviour/look_and_exec.zig
@@ -36,3 +36,11 @@ test "look-and-exec: a bare :N or :N:M look addresses the pane itself, from its
try s.write(s.at("/pane/{d}/event", .{n}), "ML0 0 0 2 :1\n");
try expectEqual(.{ @as(u32, 0), @as(u32, 6) }, try s.range(dot));
}
+
+test "look-and-exec: a look that finds nothing says so" {
+ var s = try Session.initFile(std.testing.allocator, "x\n");
+ defer s.deinit();
+ const n = try s.newPane();
+ try s.write(s.at("/pane/{d}/look", .{n}), "/no/such/zzqq\n");
+ try std.testing.expect(std.mem.indexOf(u8, try s.read("/log"), s.at("err {d} look: no match for \"/no/such/zzqq\"\n", .{n})) != null);
+}