summaryrefslogtreecommitdiff
path: root/src/pardes.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/pardes.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/pardes.zig')
-rw-r--r--src/pardes.zig213
1 files changed, 106 insertions, 107 deletions
diff --git a/src/pardes.zig b/src/pardes.zig
index 2fa1d390..e9d38ad2 100644
--- a/src/pardes.zig
+++ b/src/pardes.zig
@@ -202,113 +202,6 @@ fn colFromSpan(x: f32, span: f32) u16 {
return @intFromFloat(@min(@floor(@max(x, 0) / span), 10_000));
}
-test "a compact tagline anchors at its own pane, and both shells step from the same origin" {
- const p = try Pardes.init(std.testing.allocator, .{ .cols = 120, .rows = 24 });
- defer p.deinit();
- _ = try p.newShell(1, "");
- try std.testing.expect(layout.splitColumn(p, 0, 1, false));
- p.sync();
-
- // Two panes side by side put two tags on ONE row, which is the case a
- // per-row origin gets wrong and the reason this is asked per cell.
- const left = p.view().rects[0];
- const right = p.view().rects[1];
- try std.testing.expect(right.x > left.x);
- try std.testing.expectEqual(@as(f32, @floatFromInt(left.x)), taglineOriginCol(p, left.x + 3, left.y));
- try std.testing.expectEqual(@as(f32, @floatFromInt(right.x)), taglineOriginCol(p, right.x + 3, right.y));
-
- // The topbar's origin is column zero always — it is not a pane rect, which
- // is why row zero is right even in a window with no core to ask.
- try std.testing.expectEqual(@as(f32, 0), taglineOriginCol(p, 40, 0));
-
- const body_row = left.y + 2;
- try std.testing.expectEqual(@as(f32, 7), taglineOriginCol(p, 7, body_row));
-
- const body_w: f32 = 10;
- const tag_w: f32 = 8;
- for (p.view().col_x[0..p.view().ncol], p.view().col_w[0..p.view().ncol]) |origin, width| {
- if (width == 0) continue;
- const col = origin;
- try std.testing.expectEqual(@as(f32, @floatFromInt(origin)), taglineOriginCol(p, col, TOPBAR_H));
- const glyph_x = @as(f32, @floatFromInt(origin)) * body_w;
- try std.testing.expectEqual(col, gridColAt(p, glyph_x + tag_w / 2, TOPBAR_H, body_w, tag_w));
- }
- for ([_]u16{ 0, 1, 5, 40, 119 }) |col| {
- const origin = taglineOriginCol(p, col, left.y);
- const sdl = origin * (body_w - tag_w) + @as(f32, @floatFromInt(col)) * tag_w;
- const appkit = origin * body_w + (@as(f32, @floatFromInt(col)) - origin) * tag_w;
- try std.testing.expectEqual(sdl, appkit);
- }
-
- for ([_]u16{ 0, 1, 4, 9 }) |offset| {
- const col = left.x + offset;
- if (offset >= left.w) break;
- const origin = taglineOriginCol(p, col, left.y);
- const glyph_x = origin * body_w + (@as(f32, @floatFromInt(col)) - origin) * tag_w;
- try std.testing.expectEqual(col, gridColAt(p, glyph_x + tag_w / 2, left.y, body_w, tag_w));
- }
-
- // The topbar's pointer grid is compact from column zero, with no pane to
- // anchor to — the one tag row that is right with or without a core.
- try std.testing.expectEqual(@as(u16, 3), gridColAt(p, 3.5 * tag_w, 0, body_w, tag_w));
- try std.testing.expectEqual(@as(u16, 3), gridColAt(null, 3.5 * tag_w, 0, body_w, tag_w));
-
- // A body row is untouched: still the body grid, still divided by the body
- // cell. Only tag rows compact.
- try std.testing.expectEqual(@as(u16, 3), gridColAt(p, 3.5 * body_w, body_row, body_w, tag_w));
-}
-
-test {
- _ = @import("Addon.zig");
- _ = @import("rollback.zig");
- _ = @import("Core.zig");
- _ = @import("lsp/Ask.zig");
- _ = @import("Jump.zig");
- _ = @import("keys.zig");
- _ = @import("Effect.zig");
- _ = @import("tape.zig");
- _ = @import("replica.zig");
- _ = @import("echo.zig");
- _ = @import("modal.zig");
- _ = @import("tagline.zig");
- _ = @import("hunks.zig");
- _ = @import("builtins_json.zig");
- _ = @import("exec.zig");
- _ = @import("look.zig");
- _ = @import("sam_edit.zig");
- _ = @import("edit_cmd.zig");
- _ = @import("mouse.zig");
- _ = @import("normal.zig");
- _ = @import("regexp.zig");
- _ = @import("edit.zig");
- _ = @import("Messages.zig");
- _ = @import("Registers.zig");
- _ = @import("Macro.zig");
- _ = @import("selection_pipe.zig");
- _ = @import("Pipe.zig");
- _ = @import("colors.zig");
- _ = @import("surface.zig");
- _ = @import("glide.zig");
- _ = @import("body_layer.zig");
- _ = @import("draw.zig");
- _ = @import("dump.zig"); // its tests ran nowhere before
- _ = @import("upgrade.zig");
- _ = @import("recent.zig");
- _ = @import("Store.zig");
- _ = @import("Db.zig");
- _ = @import("pager.zig");
- _ = @import("Places.zig");
- _ = @import("FrameStats.zig");
- _ = @import("Query.zig");
- _ = @import("Names.zig");
- _ = @import("Stream.zig");
- _ = @import("Tables.zig");
- _ = @import("Handover.zig");
- _ = @import("walk.zig");
- _ = screen_state;
- _ = @import("views.zig");
-}
-
pub const Builtin = builtins.registry.Builtin();
pub const test_api = if (@import("builtin").is_test) struct {
@@ -443,3 +336,109 @@ pub const Options = Pardes.Options;
pub const Boot = Pardes.Boot;
pub const Haptic = Pardes.Haptic;
+test "a compact tagline anchors at its own pane, and both shells step from the same origin" {
+ const p = try Pardes.init(std.testing.allocator, .{ .cols = 120, .rows = 24 });
+ defer p.deinit();
+ _ = try p.newShell(1, "");
+ try std.testing.expect(layout.splitColumn(p, 0, 1, false));
+ p.sync();
+
+ // Two panes side by side put two tags on ONE row, which is the case a
+ // per-row origin gets wrong and the reason this is asked per cell.
+ const left = p.view().rects[0];
+ const right = p.view().rects[1];
+ try std.testing.expect(right.x > left.x);
+ try std.testing.expectEqual(@as(f32, @floatFromInt(left.x)), taglineOriginCol(p, left.x + 3, left.y));
+ try std.testing.expectEqual(@as(f32, @floatFromInt(right.x)), taglineOriginCol(p, right.x + 3, right.y));
+
+ // The topbar's origin is column zero always — it is not a pane rect, which
+ // is why row zero is right even in a window with no core to ask.
+ try std.testing.expectEqual(@as(f32, 0), taglineOriginCol(p, 40, 0));
+
+ const body_row = left.y + 2;
+ try std.testing.expectEqual(@as(f32, 7), taglineOriginCol(p, 7, body_row));
+
+ const body_w: f32 = 10;
+ const tag_w: f32 = 8;
+ for (p.view().col_x[0..p.view().ncol], p.view().col_w[0..p.view().ncol]) |origin, width| {
+ if (width == 0) continue;
+ const col = origin;
+ try std.testing.expectEqual(@as(f32, @floatFromInt(origin)), taglineOriginCol(p, col, TOPBAR_H));
+ const glyph_x = @as(f32, @floatFromInt(origin)) * body_w;
+ try std.testing.expectEqual(col, gridColAt(p, glyph_x + tag_w / 2, TOPBAR_H, body_w, tag_w));
+ }
+ for ([_]u16{ 0, 1, 5, 40, 119 }) |col| {
+ const origin = taglineOriginCol(p, col, left.y);
+ const sdl = origin * (body_w - tag_w) + @as(f32, @floatFromInt(col)) * tag_w;
+ const appkit = origin * body_w + (@as(f32, @floatFromInt(col)) - origin) * tag_w;
+ try std.testing.expectEqual(sdl, appkit);
+ }
+
+ for ([_]u16{ 0, 1, 4, 9 }) |offset| {
+ const col = left.x + offset;
+ if (offset >= left.w) break;
+ const origin = taglineOriginCol(p, col, left.y);
+ const glyph_x = origin * body_w + (@as(f32, @floatFromInt(col)) - origin) * tag_w;
+ try std.testing.expectEqual(col, gridColAt(p, glyph_x + tag_w / 2, left.y, body_w, tag_w));
+ }
+
+ // The topbar's pointer grid is compact from column zero, with no pane to
+ // anchor to — the one tag row that is right with or without a core.
+ try std.testing.expectEqual(@as(u16, 3), gridColAt(p, 3.5 * tag_w, 0, body_w, tag_w));
+ try std.testing.expectEqual(@as(u16, 3), gridColAt(null, 3.5 * tag_w, 0, body_w, tag_w));
+
+ // A body row is untouched: still the body grid, still divided by the body
+ // cell. Only tag rows compact.
+ try std.testing.expectEqual(@as(u16, 3), gridColAt(p, 3.5 * body_w, body_row, body_w, tag_w));
+}
+
+test {
+ _ = @import("Addon.zig");
+ _ = @import("rollback.zig");
+ _ = @import("Core.zig");
+ _ = @import("lsp/Ask.zig");
+ _ = @import("Jump.zig");
+ _ = @import("keys.zig");
+ _ = @import("Effect.zig");
+ _ = @import("tape.zig");
+ _ = @import("replica.zig");
+ _ = @import("echo.zig");
+ _ = @import("modal.zig");
+ _ = @import("tagline.zig");
+ _ = @import("hunks.zig");
+ _ = @import("builtins_json.zig");
+ _ = @import("exec.zig");
+ _ = @import("look.zig");
+ _ = @import("sam_edit.zig");
+ _ = @import("edit_cmd.zig");
+ _ = @import("mouse.zig");
+ _ = @import("normal.zig");
+ _ = @import("regexp.zig");
+ _ = @import("edit.zig");
+ _ = @import("Messages.zig");
+ _ = @import("Registers.zig");
+ _ = @import("Macro.zig");
+ _ = @import("selection_pipe.zig");
+ _ = @import("Pipe.zig");
+ _ = @import("colors.zig");
+ _ = @import("surface.zig");
+ _ = @import("glide.zig");
+ _ = @import("body_layer.zig");
+ _ = @import("draw.zig");
+ _ = @import("dump.zig"); // its tests ran nowhere before
+ _ = @import("upgrade.zig");
+ _ = @import("recent.zig");
+ _ = @import("Store.zig");
+ _ = @import("Db.zig");
+ _ = @import("pager.zig");
+ _ = @import("Places.zig");
+ _ = @import("FrameStats.zig");
+ _ = @import("Query.zig");
+ _ = @import("Names.zig");
+ _ = @import("Stream.zig");
+ _ = @import("Tables.zig");
+ _ = @import("Handover.zig");
+ _ = @import("walk.zig");
+ _ = screen_state;
+ _ = @import("views.zig");
+}