summaryrefslogtreecommitdiff
path: root/src/diff.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-09 00:52:52 -0300
committerGabriel Schneider <[email protected]>2026-11-09 01:28:28 -0300
commit5157579ff7f9ae0cfc3c7629e953da05bce340fc (patch)
tree02147789efdcea998981efcfe05d4bcb3e9bb7b0 /src/diff.zig
parent4c4b9bf54d77dbc0f9f4e2619746908e501c6001 (diff)
downloadpardes-5157579ff7f9ae0cfc3c7629e953da05bce340fc.tar.gz
pardes-5157579ff7f9ae0cfc3c7629e953da05bce340fc.zip
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 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'src/diff.zig')
-rw-r--r--src/diff.zig32
1 files changed, 16 insertions, 16 deletions
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 {