summaryrefslogtreecommitdiff
path: root/src/config.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/config.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/config.zig')
-rw-r--r--src/config.zig192
1 files changed, 96 insertions, 96 deletions
diff --git a/src/config.zig b/src/config.zig
index b9ddf07a..96a5f557 100644
--- a/src/config.zig
+++ b/src/config.zig
@@ -174,52 +174,6 @@ pub const leader_path = paths: {
break :paths table;
};
-test "Space-k is unbound while Exit, Kill and other k chords remain available" {
- try std.testing.expect(leader_path.get(.Kill) == null);
- try std.testing.expectEqualStrings("q", leader_path.get(.Exit).?);
- try std.testing.expectEqualStrings("w", leader_path.get(.Window).?);
- try std.testing.expectEqualStrings("lk", leader_path.get(.Hover).?);
- try std.testing.expectEqualStrings("d", leader_path.get(.Del).?);
- for (pardes.builtin_rows) |row| if (row.cmd == .Kill) {
- try std.testing.expect(row.path == null);
- try std.testing.expect(std.mem.indexOf(u8, row.line, "SPC") == null);
- try std.testing.expect(std.mem.indexOf(u8, row.line, "Kill") != null);
- };
- const p = try pardes.Pardes.init(std.testing.allocator, .{ .tty_only = true });
- defer p.deinit();
- const pane = try p.setTestFile("first\nsecond\n");
- pane.body.cur_row = 1;
- while (p.nextEffect()) |_| {}
- p.update(.{ .key = .{ .cp = ' ' } });
- try std.testing.expect(p.view().prefix == .leader);
- p.update(.{ .key = .{ .cp = 'k' } });
- try std.testing.expect(p.view().prefix != .leader and !p.quit);
- try std.testing.expectEqual(@as(i32, 1), pane.body.cur_row);
- while (p.nextEffect()) |effect| try std.testing.expect(effect != .quit);
- p.update(.{ .key = .{ .cp = 'k' } });
- try std.testing.expectEqual(@as(i32, 0), pane.body.cur_row);
- // Kill stops commands and never quits; Exit quits.
- try std.testing.expect(p.executeBuiltinLine(p.view().active, "Kill"));
- try std.testing.expect(!p.quit);
- try std.testing.expect(p.executeBuiltinLine(p.view().active, "Exit"));
- try std.testing.expect(p.quit);
-}
-
-test "SPC q runs Exit: refused once over unsaved text, as the tag word is, then it quits" {
- const p = try pardes.Pardes.init(std.testing.allocator, .{ .tty_only = true });
- defer p.deinit();
- const pane = try p.setTestFile("text\n");
- pane.file.?.saved_revision = pane.file.?.revision -% 1; // modified
- pane.file.?.saved_hash = 0; // edited: what it had is not what it has
- while (p.nextEffect()) |_| {}
- p.update(.{ .key = .{ .cp = ' ' } });
- p.update(.{ .key = .{ .cp = 'q' } });
- try std.testing.expect(!p.quit);
- p.update(.{ .key = .{ .cp = ' ' } });
- p.update(.{ .key = .{ .cp = 'q' } });
- try std.testing.expect(p.quit);
-}
-
pub const look_key: []const Chord = &.{.{ .cp = Key.enter }};
pub const exec_key: []const Chord = &.{.{ .cp = Key.tab }};
pub const look_button: Mouse.Button = .right;
@@ -372,20 +326,6 @@ pub fn wheelTick(guard: *u8, vertical: bool) bool {
return false;
}
-test "wheel drift guard" {
- var g: u8 = 0;
- try std.testing.expect(wheelTick(&g, false));
- try std.testing.expect(wheelTick(&g, false));
- if (wheel_guard_ticks == 0) return; // guard disabled: nothing left to check
- for (0..4) |_| try std.testing.expect(wheelTick(&g, true));
- try std.testing.expect(!wheelTick(&g, false));
- try std.testing.expect(wheelTick(&g, true));
- try std.testing.expect(!wheelTick(&g, false));
- for (1..wheel_guard_ticks) |_| try std.testing.expect(!wheelTick(&g, false));
- try std.testing.expect(wheelTick(&g, false));
- try std.testing.expect(wheelTick(&g, false));
-}
-
/// The shell when no `Shell` is set: the user's login shell ($SHELL), as a
/// terminal would start, else /bin/sh. An explicit `Shell` overrides it.
pub fn defaultShell() []const u8 {
@@ -1463,11 +1403,6 @@ pub const User = struct {
}
};
-test {
- _ = Runtime;
- _ = User;
-}
-
/// The docs in docs/typ name words, keys and tags; each must still be here.
const doc_typ = struct {
/// The leading string arguments of every `name("...", "...")` call in a
@@ -1622,37 +1557,6 @@ const doc_typ = struct {
}
};
-test "docs/typ names only words, keys and default tags that exist" {
- var arena: std.heap.ArenaAllocator = .init(std.testing.allocator);
- defer arena.deinit();
- const gpa = arena.allocator();
- const io = std.testing.io;
- var dir = try std.Io.Dir.cwd().openDir(io, @import("doc_typ").dir, .{ .iterate = true });
- defer dir.close(io);
- var found: [3]std.ArrayList([]const u8) = @splat(.empty);
- // The arena's: gone with this test, so no later test reads it.
- defer doc_typ.other_build = "";
- defer doc_typ.addon_sources = "";
- try doc_typ.loadAddons(gpa);
- for ([_][]const u8{ "builtins-tui.json", "builtins-gui.json" }) |f| {
- const text = dir.readFileAlloc(io, f, gpa, .limited(1 << 20)) catch continue;
- doc_typ.other_build = try std.mem.concat(gpa, u8, &.{ doc_typ.other_build, text });
- }
- var it = dir.iterate();
- while (try it.next(io)) |entry| if (entry.kind == .file and std.mem.endsWith(u8, entry.name, ".typ")) {
- const source = try dir.readFileAlloc(io, entry.name, gpa, .limited(1 << 20));
- inline for (.{ "word", "key", "tag" }, &found) |name, *list| try doc_typ.calls(gpa, source, name, list);
- try doc_typ.calls(gpa, source, "keys", &found[1]); // alternatives, each a key
- };
- inline for (.{ "word", "key", "tag" }, found) |name, list| {
- try std.testing.expect(list.items.len >= 5);
- for (list.items) |arg| if (!@field(doc_typ, name)(arg)) {
- std.debug.print("docs/typ: {s}(\"{s}\") is not in pardes\n", .{ name, arg });
- return error.DocDrift;
- };
- }
-}
-
/// The tutor's own spellings, which the docs/typ test cannot read: a
/// builtin in backticks (`Save`, `Kill make`), a tag on a line of its own
/// after "| ", a leader path after SPC (`SPC f s`), a chord as Ctrl-, Alt-
@@ -1729,6 +1633,102 @@ const doc_tutor = struct {
}
};
+test "Space-k is unbound while Exit, Kill and other k chords remain available" {
+ try std.testing.expect(leader_path.get(.Kill) == null);
+ try std.testing.expectEqualStrings("q", leader_path.get(.Exit).?);
+ try std.testing.expectEqualStrings("w", leader_path.get(.Window).?);
+ try std.testing.expectEqualStrings("lk", leader_path.get(.Hover).?);
+ try std.testing.expectEqualStrings("d", leader_path.get(.Del).?);
+ for (pardes.builtin_rows) |row| if (row.cmd == .Kill) {
+ try std.testing.expect(row.path == null);
+ try std.testing.expect(std.mem.indexOf(u8, row.line, "SPC") == null);
+ try std.testing.expect(std.mem.indexOf(u8, row.line, "Kill") != null);
+ };
+ const p = try pardes.Pardes.init(std.testing.allocator, .{ .tty_only = true });
+ defer p.deinit();
+ const pane = try p.setTestFile("first\nsecond\n");
+ pane.body.cur_row = 1;
+ while (p.nextEffect()) |_| {}
+ p.update(.{ .key = .{ .cp = ' ' } });
+ try std.testing.expect(p.view().prefix == .leader);
+ p.update(.{ .key = .{ .cp = 'k' } });
+ try std.testing.expect(p.view().prefix != .leader and !p.quit);
+ try std.testing.expectEqual(@as(i32, 1), pane.body.cur_row);
+ while (p.nextEffect()) |effect| try std.testing.expect(effect != .quit);
+ p.update(.{ .key = .{ .cp = 'k' } });
+ try std.testing.expectEqual(@as(i32, 0), pane.body.cur_row);
+ // Kill stops commands and never quits; Exit quits.
+ try std.testing.expect(p.executeBuiltinLine(p.view().active, "Kill"));
+ try std.testing.expect(!p.quit);
+ try std.testing.expect(p.executeBuiltinLine(p.view().active, "Exit"));
+ try std.testing.expect(p.quit);
+}
+
+test "SPC q runs Exit: refused once over unsaved text, as the tag word is, then it quits" {
+ const p = try pardes.Pardes.init(std.testing.allocator, .{ .tty_only = true });
+ defer p.deinit();
+ const pane = try p.setTestFile("text\n");
+ pane.file.?.saved_revision = pane.file.?.revision -% 1; // modified
+ pane.file.?.saved_hash = 0; // edited: what it had is not what it has
+ while (p.nextEffect()) |_| {}
+ p.update(.{ .key = .{ .cp = ' ' } });
+ p.update(.{ .key = .{ .cp = 'q' } });
+ try std.testing.expect(!p.quit);
+ p.update(.{ .key = .{ .cp = ' ' } });
+ p.update(.{ .key = .{ .cp = 'q' } });
+ try std.testing.expect(p.quit);
+}
+
+test "wheel drift guard" {
+ var g: u8 = 0;
+ try std.testing.expect(wheelTick(&g, false));
+ try std.testing.expect(wheelTick(&g, false));
+ if (wheel_guard_ticks == 0) return; // guard disabled: nothing left to check
+ for (0..4) |_| try std.testing.expect(wheelTick(&g, true));
+ try std.testing.expect(!wheelTick(&g, false));
+ try std.testing.expect(wheelTick(&g, true));
+ try std.testing.expect(!wheelTick(&g, false));
+ for (1..wheel_guard_ticks) |_| try std.testing.expect(!wheelTick(&g, false));
+ try std.testing.expect(wheelTick(&g, false));
+ try std.testing.expect(wheelTick(&g, false));
+}
+
+test {
+ _ = Runtime;
+ _ = User;
+}
+
+test "docs/typ names only words, keys and default tags that exist" {
+ var arena: std.heap.ArenaAllocator = .init(std.testing.allocator);
+ defer arena.deinit();
+ const gpa = arena.allocator();
+ const io = std.testing.io;
+ var dir = try std.Io.Dir.cwd().openDir(io, @import("doc_typ").dir, .{ .iterate = true });
+ defer dir.close(io);
+ var found: [3]std.ArrayList([]const u8) = @splat(.empty);
+ // The arena's: gone with this test, so no later test reads it.
+ defer doc_typ.other_build = "";
+ defer doc_typ.addon_sources = "";
+ try doc_typ.loadAddons(gpa);
+ for ([_][]const u8{ "builtins-tui.json", "builtins-gui.json" }) |f| {
+ const text = dir.readFileAlloc(io, f, gpa, .limited(1 << 20)) catch continue;
+ doc_typ.other_build = try std.mem.concat(gpa, u8, &.{ doc_typ.other_build, text });
+ }
+ var it = dir.iterate();
+ while (try it.next(io)) |entry| if (entry.kind == .file and std.mem.endsWith(u8, entry.name, ".typ")) {
+ const source = try dir.readFileAlloc(io, entry.name, gpa, .limited(1 << 20));
+ inline for (.{ "word", "key", "tag" }, &found) |name, *list| try doc_typ.calls(gpa, source, name, list);
+ try doc_typ.calls(gpa, source, "keys", &found[1]); // alternatives, each a key
+ };
+ inline for (.{ "word", "key", "tag" }, found) |name, list| {
+ try std.testing.expect(list.items.len >= 5);
+ for (list.items) |arg| if (!@field(doc_typ, name)(arg)) {
+ std.debug.print("docs/typ: {s}(\"{s}\") is not in pardes\n", .{ name, arg });
+ return error.DocDrift;
+ };
+ }
+}
+
test "the tutor names only words, keys, paths and default tags that exist" {
var arena: std.heap.ArenaAllocator = .init(std.testing.allocator);
defer arena.deinit();