summaryrefslogtreecommitdiff
path: root/test/panes.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-09 03:29:30 -0300
committerGabriel Schneider <[email protected]>2026-11-09 03:30:49 -0300
commit84c8209d02f6830db861c3a8dde0c710c88075f0 (patch)
tree10f77e3ab1becb5a0af4de152bb8d8e0e9ee0f03 /test/panes.zig
parent446292e15d56c9c248dae5d6fde1be3a83ade82e (diff)
downloadpardes-84c8209d02f6830db861c3a8dde0c710c88075f0.tar.gz
pardes-84c8209d02f6830db861c3a8dde0c710c88075f0.zip
idioms: the edit surface fails by name: the undo history (Journal.mark, Text.remember and step, File's, terminal's and edit's pushUndo and undoStep) returns error{OutOfMemory} instead of dropping an undo point, setEditText, enterInsert and insertTab return edit.Error with try where they reported each failure, Registers.put and setYank return error{OutOfMemory} instead of losing a yank, and their other-file callers decide (try under edit.Error, said on the pane by Undo, Redo, Pipe, Edit, Query, keys, look, completion, Incl and Plumb, ENOMEM or null where a 9P write answers, Ask's false); ctl.get and getFile return GetError (fs.ReadError, now named at fs.zig's surface, and InvalidName) for the *anyerror out-parameter and errno, the 9P get, Get and Edit's e mapping it as before; the OOM undo test pins the error; perf.zig's try relabels its harness hash, the three baselines re-keyed to it (their numbers the base's)
Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'test/panes.zig')
-rw-r--r--test/panes.zig22
1 files changed, 11 insertions, 11 deletions
diff --git a/test/panes.zig b/test/panes.zig
index f221499b..740f4897 100644
--- a/test/panes.zig
+++ b/test/panes.zig
@@ -615,7 +615,7 @@ const TtySelectionTests = struct {
try std.testing.expectEqual(panes.Text.Mode.tty, pane.body.mode);
if (bracketed) p.update(.{ .output = .{ .pane = 0, .bytes = "\x1b[?2004h" } });
try std.testing.expectEqual(bracketed, panes.terminal.bracketedPaste(pane));
- p.registers.put(p.gpa, '"', "one\ntwo", 0, 1, true); // what a `y` anywhere left behind
+ try p.registers.put(p.gpa, '"', "one\ntwo", 0, 1, true); // what a `y` anywhere left behind
var buf: [256]u8 = undefined;
_ = childInput(p, &buf);
@@ -1111,7 +1111,7 @@ test "terminal edits and undo survive partial history clearing and whole-screen
pane.body.cur_col = 4;
pane.body.cur_pinned = true;
pane.body.vsel = .{ .active = true, .row = row, .col = 1 };
- panes.terminal.pushUndo(p, pane);
+ try panes.terminal.pushUndo(p, pane);
const overlay = pane.ovl.?;
pane.body.ed_redo[0] = .{
.ovl = .{ .row = overlay.row, .rows = overlay.rows, .text = try gpa.dupe(u8, overlay.text) },
@@ -1153,7 +1153,7 @@ test "terminal edits and undo survive partial history clearing and whole-screen
try std.testing.expectEqualStrings("edit one\nedit two", snapshot.ovl.?.text);
}
try std.testing.expectEqual(@as(usize, 2), pane.terminal.?.vt.screens.active.pages.countTrackedPins());
- panes.terminal.undoStep(p, pane, true);
+ try panes.terminal.undoStep(p, pane, true);
try std.testing.expectEqualStrings("edit one\nedit two", pane.ovl.?.text);
try std.testing.expectEqual(expected, pane.ovl.?.row);
}
@@ -1170,7 +1170,7 @@ test "terminal lower scroll regions do not move edits above them" {
pane.ovl = .{ .row = 1, .rows = 1, .text = try gpa.dupe(u8, "unsent") };
pane.body.cur_row = 1;
pane.body.cur_pinned = true;
- panes.terminal.pushUndo(p, pane);
+ try panes.terminal.pushUndo(p, pane);
const total = panes.terminal.scrollbar(pane).total;
var setup: [64]u8 = undefined;
const bytes = try std.fmt.bufPrint(&setup, "\x1b[4;{d}r\x1b[{d};1H", .{ pane.rows, pane.rows });
@@ -1210,7 +1210,7 @@ test "terminal eviction and lower-region scrolling in one read preserve a surviv
pane.ovl = .{ .row = old_row, .rows = 1, .text = try gpa.dupe(u8, "kept edit") };
pane.body.cur_row = old_row;
pane.body.cur_pinned = true;
- panes.terminal.pushUndo(p, pane);
+ try panes.terminal.pushUndo(p, pane);
const old_total = pages.total_rows;
var buf: [128]u8 = undefined;
const bytes = try std.fmt.bufPrint(&buf, "new\r\n\x1b[4;{d}r\x1b[{d};1Hregion\r\n", .{ pane.rows, pane.rows });
@@ -1356,7 +1356,7 @@ test "file history keeps its last undo_max steps, and an undo or redo with no me
const history = file.history;
for (0..pardes.memory.limits.undo_max + 2) |index| {
const next = try std.fmt.allocPrint(p.gpa, "{d}", .{index});
- panes.File.pushUndo(p, pane);
+ try panes.File.pushUndo(p, pane);
panes.File.setContent(p, file, next);
try std.testing.expectEqual(history, file.history);
}
@@ -1366,23 +1366,23 @@ test "file history keeps its last undo_max steps, and an undo or redo with no me
try std.testing.expectEqualStrings("1", j.entries.items[j.steps.items[0].first].removed);
// No memory for the bytes an undo keeps: nothing changes.
failing.fail_index = failing.alloc_index;
- panes.File.undoStep(p, pane, true);
+ try std.testing.expectError(error.OutOfMemory, panes.File.undoStep(p, pane, true));
try std.testing.expectEqualStrings("257", file.content);
try std.testing.expectEqual(pardes.memory.limits.undo_max, j.done);
failing.fail_index = std.math.maxInt(usize);
- panes.File.undoStep(p, pane, true);
+ try panes.File.undoStep(p, pane, true);
try std.testing.expectEqualStrings("256", file.content);
try std.testing.expectEqual(@as(usize, 1), j.steps.items.len - j.done);
failing.fail_index = failing.alloc_index;
- panes.File.undoStep(p, pane, false);
+ try std.testing.expectError(error.OutOfMemory, panes.File.undoStep(p, pane, false));
try std.testing.expectEqualStrings("256", file.content);
try std.testing.expectEqual(@as(usize, 1), j.steps.items.len - j.done);
failing.fail_index = std.math.maxInt(usize);
- panes.File.undoStep(p, pane, false);
+ try panes.File.undoStep(p, pane, false);
try std.testing.expectEqualStrings("257", file.content);
try std.testing.expectEqual(pardes.memory.limits.undo_max, j.done);
// Back through every step kept, and no further.
- for (0..pardes.memory.limits.undo_max + 1) |_| panes.File.undoStep(p, pane, true);
+ for (0..pardes.memory.limits.undo_max + 1) |_| try panes.File.undoStep(p, pane, true);
try std.testing.expectEqualStrings("1", file.content);
try std.testing.expectEqual(@as(usize, 0), j.done);
}