diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-04 10:28:11 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-04 10:33:28 -0300 |
| commit | 7bbcd971a761def328fb9eeb881301bf45fb4783 (patch) | |
| tree | 402020187b24c3f550f1a84fda1709e110c731e1 /test/behaviour/flags.zig | |
| parent | f697bb13c3599db3ce30fac059932242597acdf6 (diff) | |
| download | pardes-7bbcd971a761def328fb9eeb881301bf45fb4783.tar.gz pardes-7bbcd971a761def328fb9eeb881301bf45fb4783.zip | |
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<serial>:<address> 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 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'test/behaviour/flags.zig')
| -rw-r--r-- | test/behaviour/flags.zig | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/test/behaviour/flags.zig b/test/behaviour/flags.zig index 656d219f..9eca2e38 100644 --- a/test/behaviour/flags.zig +++ b/test/behaviour/flags.zig @@ -40,3 +40,45 @@ test "flags: dirty, mark and scroll read and write the state acme kept behind ct try t.expect(term_dirty, "0\n"); try std.testing.expectEqual(@as(u16, 22), try t.refused(term_dirty, "1")); } + +fn has(hay: []const u8, needle: []const u8) bool { + return std.mem.indexOf(u8, hay, needle) != null; +} + +test "flags: Undo and Redo on a pane's ctl step its body through its edits, and say when there is none, counted" { + var s = try Session.initFile(std.testing.allocator, "one\n"); + defer s.deinit(); + const n = try s.focused(); + const body = s.at("/pane/{d}/body", .{n}); + const ctl = s.at("/pane/{d}/ctl", .{n}); + try s.write(body, "two\n"); + try s.expect(body, "one\ntwo\n"); + try s.write(ctl, "Undo"); + try s.expect(body, "one\n"); + try s.write(ctl, "Redo"); + try s.expect(body, "one\ntwo\n"); + // Nothing left: said, and the write still succeeds, as acme's is silent. + try s.write(ctl, "Redo"); + try std.testing.expect(has(try s.read("/log"), "Redo: nothing to redo")); + try s.write(ctl, "Undo"); + try s.write(ctl, "Undo"); + try std.testing.expect(has(try s.read("/log"), "Undo: nothing to undo")); + // Said again word for word, it is that line counted, as err's are. + for (0..3) |_| try s.write(ctl, "Undo"); + try std.testing.expect(has(try s.read("/log"), "Undo: nothing to undo (x4)\n")); +} + +test "flags: dirty goes back to 0 when the text is the saved text again" { + var s = try Session.initFile(std.testing.allocator, "one\n"); + defer s.deinit(); + const n = try s.focused(); + const dirty = s.at("/pane/{d}/dirty", .{n}); + const ctl = s.at("/pane/{d}/ctl", .{n}); + try s.expect(dirty, "0\n"); + try s.write(s.at("/pane/{d}/body", .{n}), "two\n"); + try s.expect(dirty, "1\n"); + try s.write(ctl, "Undo"); + try s.expect(dirty, "0\n"); + try s.write(ctl, "Redo"); + try s.expect(dirty, "1\n"); +} |
