From 7bbcd971a761def328fb9eeb881301bf45fb4783 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Wed, 4 Nov 2026 10:28:11 -0300 Subject: test: twenty-one of src/ninep/ctl.zig's tests through the 9P tree alone: in test/behaviour/look_and_exec.zig a look's miss quoting up to 256 bytes then an ellipsis, @p:
taking any sam address (a miss and an unknown serial errs), file:3:0 refused as addr 3:0 is, ./x, ../x, x and /abs/x misses, a terminal's file:addr miss logged once, and an exec's builtin refused wrong #args bare or with an argument it takes none of; in flags.zig Undo and Redo stepping the body and saying when there is none (counted), dirty back to 0 at the saved text; in edit.zig an Edit rename one undo step and a failed one changing nothing; in panes.zig Mini bare, the name word bare, and ctl's undo and redo fields; in addresses.zig malformed addresses and a terminal's addr, dot and limit refused; in event.zig a bad record's words; in the new repls.zig Repl with no such language; in settings.zig two bad values logged as two; in root_ctl.zig Kill with a name and nothing running; in mounts.zig an unknown network a bad dial address; the old Unmount test dropped, mounts.zig's first test covering it; each checked to fail against a break (miss_path_cap 200, "no pane at", captured's wrong #args words, Redo's and Kill's messages, the name word's refusal, an event's backwards-range words, e_syntax, Repl's "others)", Mount's bad dial words, a splice back to the saved text left dirty, Edit's no substitution words, a setting's refusal quoting "x", zeroColumn missing a column 0, a look's no such file words, a terminal's text miss unquoted, ctl's undo flag needing two edits) Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge --- test/behaviour/panes.zig | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'test/behaviour/panes.zig') 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)); +} -- cgit v1.3