From 5157579ff7f9ae0cfc3c7629e953da05bce340fc Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Mon, 9 Nov 2026 00:52:52 -0300 Subject: tests: at the end of their files: every top-level test block of the 46 files that had one mid-file (the locality analysis's 45 and test/hxdiff.zig; gui.zig, macos.zig, look, host_io, 9p_io, terminal, tui, mouse, fs, replica, layout among them, 11,429 test lines), with the functions only tests call, moved after the file's code in their order, a mechanical move (.scratch/suites/tests_to_end.py), zig fmt'd; the unit suites pass as before (tui 1486/1487, gui 1536/1537, core 956/956 on both), macos.zig only parse-checked here Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge --- src/exec.zig | 78 ++++++++++++++++++++++++++++++------------------------------ 1 file changed, 39 insertions(+), 39 deletions(-) (limited to 'src/exec.zig') diff --git a/src/exec.zig b/src/exec.zig index ee6370bf..35d081fd 100644 --- a/src/exec.zig +++ b/src/exec.zig @@ -1201,45 +1201,6 @@ fn columnOf(p: *Pardes, id: usize) usize { return if (layout.findPane(p, id)) |f| f.col else p.view().ncol - 1; } -test "the acme chords act once per selection, not once on the primary" { - const gpa = std.testing.allocator; - const p = try Pardes.init(gpa, .{ .tty_only = true, .cols = 100, .rows = 30 }); - defer p.deinit(); - while (p.nextEffect()) |_| {} - // Two selections, each naming a DIFFERENT builtin, so what ran is visible - // in the layout rather than in a shell nobody can read from a test. - const pane = try p.setTestFile("Newcol\nNewcol\n"); - const ranges = [_]modal.Selection{ - .{ .anchor = 0, .head = 6 }, - .{ .anchor = 7, .head = 13 }, - }; - pane.body.setRanges(pane.file.?.content, &ranges, &.{}, 0, true); - try std.testing.expectEqual(@as(u16, 1), pane.body.nsel); - - const before = p.view().ncol; - p.update(.{ .key = .{ .cp = Key.tab } }); // config.exec_key: Exec - // BOTH ran. Before this the chord read the primary range and dropped the - // other cursor, so one keystroke over two cursors made one column. - try std.testing.expectEqual(before + 2, p.view().ncol); - // ...and the chord consumed the selection exactly as it does with one. - try std.testing.expectEqual(@as(u16, 0), p.panes[0].?.body.nsel); -} - -test "a switch clicked with a selection held flips unless the selection says on or off" { - const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 80, .rows = 24 }); - defer p.deinit(); - while (p.nextEffect()) |_| {} - const before = p.settings.verbose; - _ = execute(p, p.view().active, withArg(p, "Verbose", "some selected text")); - try std.testing.expectEqual(!before, p.settings.verbose); - _ = execute(p, p.view().active, withArg(p, "Verbose", "on")); - try std.testing.expect(p.settings.verbose); - _ = execute(p, p.view().active, withArg(p, "Verbose", " off\n")); - try std.testing.expect(!p.settings.verbose); - // A word that takes any argument still gets the selection. - try std.testing.expectEqualStrings("Msg some text", withArg(p, "Msg", "some text")); -} - // ---- the words addons bring (Kind.Registry's) ---- /// A line whose first word is an addon's: run, and true; false for one @@ -1288,3 +1249,42 @@ pub fn runWord(p: *Pardes, id: usize, w: *const pardes.Kind.Word, line: []const next.len = @intCast(out.buffered().len); s.values = next; } + +test "the acme chords act once per selection, not once on the primary" { + const gpa = std.testing.allocator; + const p = try Pardes.init(gpa, .{ .tty_only = true, .cols = 100, .rows = 30 }); + defer p.deinit(); + while (p.nextEffect()) |_| {} + // Two selections, each naming a DIFFERENT builtin, so what ran is visible + // in the layout rather than in a shell nobody can read from a test. + const pane = try p.setTestFile("Newcol\nNewcol\n"); + const ranges = [_]modal.Selection{ + .{ .anchor = 0, .head = 6 }, + .{ .anchor = 7, .head = 13 }, + }; + pane.body.setRanges(pane.file.?.content, &ranges, &.{}, 0, true); + try std.testing.expectEqual(@as(u16, 1), pane.body.nsel); + + const before = p.view().ncol; + p.update(.{ .key = .{ .cp = Key.tab } }); // config.exec_key: Exec + // BOTH ran. Before this the chord read the primary range and dropped the + // other cursor, so one keystroke over two cursors made one column. + try std.testing.expectEqual(before + 2, p.view().ncol); + // ...and the chord consumed the selection exactly as it does with one. + try std.testing.expectEqual(@as(u16, 0), p.panes[0].?.body.nsel); +} + +test "a switch clicked with a selection held flips unless the selection says on or off" { + const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 80, .rows = 24 }); + defer p.deinit(); + while (p.nextEffect()) |_| {} + const before = p.settings.verbose; + _ = execute(p, p.view().active, withArg(p, "Verbose", "some selected text")); + try std.testing.expectEqual(!before, p.settings.verbose); + _ = execute(p, p.view().active, withArg(p, "Verbose", "on")); + try std.testing.expect(p.settings.verbose); + _ = execute(p, p.view().active, withArg(p, "Verbose", " off\n")); + try std.testing.expect(!p.settings.verbose); + // A word that takes any argument still gets the selection. + try std.testing.expectEqualStrings("Msg some text", withArg(p, "Msg", "some text")); +} -- cgit v1.3