diff options
Diffstat (limited to 'src/Messages.zig')
| -rw-r--r-- | src/Messages.zig | 36 |
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 }); |
