summaryrefslogtreecommitdiff
path: root/test/behaviour/panes.zig
diff options
context:
space:
mode:
Diffstat (limited to 'test/behaviour/panes.zig')
-rw-r--r--test/behaviour/panes.zig36
1 files changed, 36 insertions, 0 deletions
diff --git a/test/behaviour/panes.zig b/test/behaviour/panes.zig
index a46f8432..7febd667 100644
--- a/test/behaviour/panes.zig
+++ b/test/behaviour/panes.zig
@@ -363,3 +363,39 @@ test "panes: a Mini that cannot read its file leaves the panes, the last Mini's
try s.expect("/index", index);
try s.expect(s.at("/pane/{d}/body", .{mini}), body);
}
+
+test "panes: Mini with no argument is wrong #args, EINVAL, as every word that needs one" {
+ var s = try Session.initFile(std.testing.allocator, "x\n");
+ defer s.deinit();
+ try std.testing.expectEqual(@as(u16, 22), try s.refused(s.at("/pane/{d}/ctl", .{try s.focused()}), "Mini\n"));
+ try std.testing.expectEqualStrings("wrong #args in control message \"Mini\"", s.said);
+}
+
+test "panes: the ctl word name with nothing after it says it names nothing" {
+ var s = try Session.initFile(std.testing.allocator, "x\n");
+ defer s.deinit();
+ try std.testing.expectEqual(@as(u16, 22), try s.refused(s.at("/pane/{d}/ctl", .{try s.focused()}), "name \n"));
+ try std.testing.expectEqualStrings("invalid file name: name takes the name, and there is none", s.said);
+}
+
+test "panes: ctl reads acme's fields in acme's order, undo and redo flags included, then pardes's own" {
+ var s = try Session.initFile(std.testing.allocator, "one\n");
+ defer s.deinit();
+ const n = try s.focused();
+ const ctl = s.at("/pane/{d}/ctl", .{n});
+ const field = struct {
+ fn at(text: []const u8, i: usize) []const u8 {
+ var it = std.mem.tokenizeScalar(u8, text, ' ');
+ for (0..i) |_| _ = it.next();
+ return it.next().?;
+ }
+ }.at;
+ try std.testing.expectEqualStrings("0", field(try s.read(ctl), 8)); // nothing to undo
+ try std.testing.expectEqualStrings("0", field(try s.read(ctl), 9)); // nothing to redo
+ const current = field(try s.read(ctl), 10);
+ try std.testing.expect(std.mem.eql(u8, current, "current") or std.mem.eql(u8, current, "notcurrent"));
+ try s.write(s.at("/pane/{d}/body", .{n}), "two\n");
+ try std.testing.expectEqualStrings("1", field(try s.read(ctl), 8));
+ try s.write(ctl, "Undo\n");
+ try std.testing.expectEqualStrings("1", field(try s.read(ctl), 9));
+}