summaryrefslogtreecommitdiff
path: root/test/behaviour
diff options
context:
space:
mode:
Diffstat (limited to 'test/behaviour')
-rw-r--r--test/behaviour/columns_and_tags.zig23
-rw-r--r--test/behaviour/look_and_exec.zig36
2 files changed, 59 insertions, 0 deletions
diff --git a/test/behaviour/columns_and_tags.zig b/test/behaviour/columns_and_tags.zig
index 71cff4b2..fa3baf48 100644
--- a/test/behaviour/columns_and_tags.zig
+++ b/test/behaviour/columns_and_tags.zig
@@ -42,3 +42,26 @@ test "columns-and-tags: a tag write refuses NUL and the other control characters
try std.testing.expectEqual(@as(u16, 22), try s.refused(tag, " \x7f"));
}
}
+
+test "columns-and-tags: a refused Delcol changes nothing: no pane, no focus" {
+ var s = try Session.initFile(std.testing.allocator, "x\n");
+ defer s.deinit();
+ try s.write("/ctl", "Newcol\n");
+ const made = try s.newPane();
+ try s.write(s.at("/pane/{d}/name", .{made}), "/tmp/pardes-delcol-refused.txt\n");
+ try s.write(s.at("/pane/{d}/body", .{made}), "edit\n");
+ // Its column, /index's last field.
+ const col = col: {
+ var rows = std.mem.tokenizeScalar(u8, try s.read("/index"), '\n');
+ while (rows.next()) |row| if (std.mem.startsWith(u8, row, s.at("{d} ", .{made}))) break :col row[std.mem.lastIndexOfScalar(u8, row, ' ').? + 1 ..];
+ return error.NotListed;
+ };
+ const index = try s.read("/index");
+ const layout = try s.read("/layout");
+ const focus = try s.read("/focus");
+ try std.testing.expect(try s.refused(s.at("/col/{s}/ctl", .{col}), "Delcol\n") != 0);
+ try s.expect("/index", index);
+ try s.expect("/layout", layout);
+ try s.expect("/focus", focus);
+ try std.testing.expect(std.mem.indexOf(u8, try s.read("/log"), "unsaved ") != null);
+}
diff --git a/test/behaviour/look_and_exec.zig b/test/behaviour/look_and_exec.zig
index f9b49ae0..f3b94a3f 100644
--- a/test/behaviour/look_and_exec.zig
+++ b/test/behaviour/look_and_exec.zig
@@ -125,3 +125,39 @@ test "look-and-exec: exec runs a builtin at the pane, and look and exec read bac
try std.testing.expect(try listed(&s, n) and !try listed(&s, made));
try s.expect("/exec", s.at("{d}\n", .{made}));
}
+
+test "look-and-exec: look and exec read back what the last command touched, a ctl write's too" {
+ var s = try Session.initFile(std.testing.allocator, "x\n");
+ defer s.deinit();
+ const n = try s.focused();
+ try s.write("/exec", "Msg first\n");
+ try s.expect("/exec", s.at("{d}\n", .{n}));
+ // A pane made through ctl is what both read next, not the Msg's pane.
+ try s.write(s.at("/pane/{d}/ctl", .{n}), "Tty\n");
+ const made = try s.focused();
+ try std.testing.expect(made != n);
+ try s.expect("/exec", s.at("{d}\n", .{made}));
+ try s.expect("/look", s.at("{d}\n", .{made}));
+ // A ctl write that makes nothing names the pane it ran at.
+ try s.write("/ctl", "Verbose off\n");
+ try s.expect("/exec", s.at("{d}\n", .{made}));
+ // Closed, it is no pane to go to: a fresh read of look is empty.
+ try s.write(s.at("/pane/{d}/ctl", .{made}), "Del\n");
+ try std.testing.expect(!try listed(&s, made));
+ try s.expect("/look", "");
+}
+
+test "look-and-exec: a line starting with # runs as nothing at an exec or a ctl, silently" {
+ var s = try Session.initFile(std.testing.allocator, "x\n");
+ defer s.deinit();
+ const n = try s.focused();
+ // The setup's own announcements are made by the first write.
+ try s.write("/ctl", "# settle\n");
+ const index = try s.read("/index");
+ const log = try s.read("/log");
+ const col = std.mem.sliceTo(try s.read("/layout"), ' ');
+ for ([_][]const u8{ "/exec", s.at("/pane/{d}/exec", .{n}), "/ctl", s.at("/pane/{d}/ctl", .{n}), s.at("/col/{s}/ctl", .{col}) }) |path|
+ try s.write(path, "# Platform: tty\n # indented too\n");
+ try s.expect("/index", index);
+ try s.expect("/log", log);
+}