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/diff.zig | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'src/diff.zig') diff --git a/src/diff.zig b/src/diff.zig index 842a6b41..ed54c149 100644 --- a/src/diff.zig +++ b/src/diff.zig @@ -405,14 +405,6 @@ pub fn targetAt(lines: []const []const u8, row: usize, continued_rows: bool) ?Ta const testing = std.testing; -fn splitLines(comptime text: []const u8) [std.mem.count(u8, text, "\n")][]const u8 { - @setEvalBranchQuota(100_000); - var out: [std.mem.count(u8, text, "\n")][]const u8 = undefined; - var it = std.mem.splitScalar(u8, text, '\n'); - for (&out) |*line| line.* = it.next().?; - return out; -} - const git_diff = \\diff --git a/src/a.zig b/src/a.zig \\index 1111111..2222222 100644 @@ -439,6 +431,22 @@ const git_diff = \\ ; +fn splitLines(comptime text: []const u8) [std.mem.count(u8, text, "\n")][]const u8 { + @setEvalBranchQuota(100_000); + var out: [std.mem.count(u8, text, "\n")][]const u8 = undefined; + var it = std.mem.splitScalar(u8, text, '\n'); + for (&out) |*line| line.* = it.next().?; + return out; +} + +fn pathsOf(comptime text: []const u8) ![3][]const u8 { + const lines = splitLines(text); + var w: Walk = .{}; + for (lines) |line| _ = w.step(line); + const t = targetAt(&lines, 3, false) orelse return error.NoTarget; + return .{ w.old_path, w.new_path, t.path }; +} + test "diff every line of a section that deletes its file is about a file this diff deletes" { const lines = splitLines(git_diff); var rows: usize = 0; @@ -623,14 +631,6 @@ test "diff git's side prefixes: dropped when both sides carry different ones, el try testing.expect(gitHeader("diff -u old new") == null); } -fn pathsOf(comptime text: []const u8) ![3][]const u8 { - const lines = splitLines(text); - var w: Walk = .{}; - for (lines) |line| _ = w.step(line); - const t = targetAt(&lines, 3, false) orelse return error.NoTarget; - return .{ w.old_path, w.new_path, t.path }; -} - test "diff a section's paths are the repository's names under every prefix git writes, and as written elsewhere" { const expect = struct { fn paths(got: [3][]const u8, old: []const u8, new: []const u8) !void { -- cgit v1.3