summaryrefslogtreecommitdiff
path: root/src/Messages.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/Messages.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/Messages.zig')
-rw-r--r--src/Messages.zig36
1 files changed, 18 insertions, 18 deletions
diff --git a/src/Messages.zig b/src/Messages.zig
index e4328a1e..6913f99f 100644
--- a/src/Messages.zig
+++ b/src/Messages.zig
@@ -440,18 +440,6 @@ pub fn zonWhy(diag: *const std.zon.parse.Diagnostics, buf: []u8) []const u8 {
return w.buffered();
}
-test "errors are said in words, and a ZON failure names its line" {
- var buf: [128]u8 = undefined;
- try std.testing.expectEqualStrings("file not found", errorWords(error.FileNotFound, &buf));
- try std.testing.expectEqualStrings("too large", errorWords(error.FileTooLarge, &buf));
- var arena: std.heap.ArenaAllocator = .init(std.testing.allocator);
- defer arena.deinit();
- var diag: std.zon.parse.Diagnostics = undefined;
- const T = struct { a: u8 };
- try std.testing.expectError(error.ParseZon, std.zon.parse.fromSlice(T, .{ .gpa = std.testing.allocator, .arena = arena.allocator(), .source = ".{\n .a = 1,\n .b = 2 }", .diagnostics = &diag }));
- try std.testing.expect(std.mem.startsWith(u8, zonWhy(&diag, &buf), "line 3: "));
-}
-
/// The longest start of `text` that fits `max` bytes and ends between
/// words (or, with no space to cut at, between characters).
pub fn clip(text: []const u8, max: usize) []const u8 {
@@ -490,12 +478,6 @@ pub fn reportFailure(p: *Pardes, id: usize, text: []const u8) void {
setMessage(p, id, text);
}
-test "an error reads as words and a failure is cut between them" {
- try std.testing.expectEqualStrings("go", clip("go haskell", 4));
- try std.testing.expectEqualStrings("go haskell", clip("go haskell", 10));
- try std.testing.expectEqualStrings("\u{e9}", clip("\u{e9}\u{e9}", 3));
-}
-
/// The one place that decides which transient lines a pane is showing and
/// in what order. Everything downstream reads the answer: the body layer
/// so it does not paint under them, and the paint pass so it can stack
@@ -557,6 +539,24 @@ fn collectBands(p: *Pardes, pane: *Pane, r: Rect, id: usize) void {
n.len -= @intCast(drop);
}
+test "errors are said in words, and a ZON failure names its line" {
+ var buf: [128]u8 = undefined;
+ try std.testing.expectEqualStrings("file not found", errorWords(error.FileNotFound, &buf));
+ try std.testing.expectEqualStrings("too large", errorWords(error.FileTooLarge, &buf));
+ var arena: std.heap.ArenaAllocator = .init(std.testing.allocator);
+ defer arena.deinit();
+ var diag: std.zon.parse.Diagnostics = undefined;
+ const T = struct { a: u8 };
+ try std.testing.expectError(error.ParseZon, std.zon.parse.fromSlice(T, .{ .gpa = std.testing.allocator, .arena = arena.allocator(), .source = ".{\n .a = 1,\n .b = 2 }", .diagnostics = &diag }));
+ try std.testing.expect(std.mem.startsWith(u8, zonWhy(&diag, &buf), "line 3: "));
+}
+
+test "an error reads as words and a failure is cut between them" {
+ try std.testing.expectEqualStrings("go", clip("go haskell", 4));
+ try std.testing.expectEqualStrings("go haskell", clip("go haskell", 10));
+ try std.testing.expectEqualStrings("\u{e9}", clip("\u{e9}\u{e9}", 3));
+}
+
test "the message log keeps what the row forgets, and collapses repeats" {
const gpa = std.testing.allocator;
const p = try Pardes.init(gpa, .{ .tty_only = true, .cols = 100, .rows = 30 });