From 3bde721b4013136df8076cbb1f5612445cd9808e Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Wed, 1 Jul 2026 22:44:59 -0300 Subject: tests: add 41 lines of test cases --- tests.zig | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'tests.zig') diff --git a/tests.zig b/tests.zig index 1ada869d..5abd31eb 100644 --- a/tests.zig +++ b/tests.zig @@ -381,6 +381,47 @@ pub fn main(init: std.process.Init) !void { return error.SaveDidNotWriteDisk; } + // 10d. Focused save regression: saving a shorter edited buffer must replace the + // file exactly, not merely leave a marker somewhere on disk. This catches + // missed Save dispatch and non-truncating writes. + { + var hs_save = try Harness.init(gpa, exe.ptr, 24, 80); + hs_save.trace = config.trace; + defer hs_save.deinit(); + try h.writeFile("/tmp/pardesE2Esave.txt", "ZZORIG_SAVE_SHOULD_DISAPPEAR_AND_TAIL\n"); + try hs_save.expectWaitFor("build.zig", 8000, "save regression app never auto-ls'd"); + try hs_save.resize(30, 100); + try hs_save.pump(700); + try hs_save.send("\x1b[<0;60;20M\x1b[<0;60;20m"); // pin a blank row, right column -> normal + try hs_save.pump(400); + try hs_save.send("i"); + try hs_save.pump(300); + try hs_save.send("/tmp/pardesE2Esave.txt"); + try hs_save.pump(500); + try hs_save.send("\x1b"); // -> normal + try hs_save.pump(400); + try hs_save.send("\x1b[<2;70;20M\x1b[<2;70;20m"); // right-click the path -> open file + try hs_save.expectWaitFor("ZZORIG_SAVE_SHOULD_DISAPPEAR", 12000, "save regression file did not open"); + try hs_save.send("x"); // select the original line + try hs_save.pump(300); + try hs_save.send("c"); // clear it and enter insert + try hs_save.pump(300); + try hs_save.send("ZZSAVED_EXACT"); + try hs_save.pump(500); + try hs_save.send("\x1b"); // -> normal + try hs_save.pump(500); + try hs_save.expectContains("ZZSAVED_EXACT", "save regression edit is not visible before saving"); + try hs_save.send("\x1b[<1;31;2M\x1b[<1;31;2m"); // middle-click "Save" in the file tag + try hs_save.pump(1000); + const exact = try std.Io.Dir.cwd().readFileAlloc(io, "/tmp/pardesE2Esave.txt", gpa, .limited(1 << 20)); + defer gpa.free(exact); + if (!std.mem.eql(u8, exact, "ZZSAVED_EXACT\n")) { + hs_save.dump("Save command did not replace the file with the exact edited bytes"); + std.debug.print("saved file bytes: {any}\n", .{exact}); + return error.SaveDidNotWriteExactDisk; + } + } + // 11. The Tutor builtin now lives in the GLOBAL tagbar (top row, full width): // "Kill Newcol Tutor Debug". Clicking "Tutor" there spawns the tutor as a // file pane. The tutor is embedded in the binary (@embedFile), so its -- cgit v1.3