diff options
Diffstat (limited to 'test/panes.zig')
| -rw-r--r-- | test/panes.zig | 30 |
1 files changed, 13 insertions, 17 deletions
diff --git a/test/panes.zig b/test/panes.zig index b02cf296..011399f5 100644 --- a/test/panes.zig +++ b/test/panes.zig @@ -1777,14 +1777,13 @@ const OutputTests = struct { } } - test "stacked Callstack aligns source below locations and keeps exact emphasis and navigation" { + test "Callstack aligns source below locations and keeps exact emphasis and navigation" { if (!syntax.enabled) return error.SkipZigTest; const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 80, .rows = 30 }); defer p.deinit(); const source = " pub fn caller(\n value: u32,\n ) void {\n work(value);\n }\n"; const pane = try TreeContextTests.setZigFile(p, source); - try std.testing.expectEqual(config.Runtime.CallstackLayout.stacked, p.settings.callstack_layout); - const input = try std.fmt.allocPrint(p.gpa, "╰──╮ {s}:1:12-17 caller\n@callstack-match ╰─ {s}:4:9-12 work(value);\n", .{ pane.file.?.path, pane.file.?.path }); + const input = try std.fmt.allocPrint(p.gpa, "╰──┬ {s}:1:12-17 caller\n@callstack-match ╰─ {s}:4:9-12 work(value);\n", .{ pane.file.?.path, pane.file.?.path }); try fillResults(p, 0, "/", .{ .query = .callstack }, "", input, null); const result_id = pane.search_pane.?; const result = p.panes[result_id].?; @@ -1806,29 +1805,24 @@ const OutputTests = struct { } p.active = result_id; result.body.cur_row = 4; - result.body.cur_col = " └─ ".len; + result.body.cur_col = " ╰─ ".len; p.update(.{ .key = .{ .cp = Key.enter } }); try std.testing.expectEqual(@as(usize, 0), p.active); try std.testing.expectEqual(@as(i32, 3), pane.body.cur_row); try pardes.dump.dumpState(p); const restored = try pardes.dump.initFromDump(p.gpa, .{ .tty_only = true }, p.dump_out.?); defer restored.deinit(); - try std.testing.expectEqual(config.Runtime.CallstackLayout.stacked, restored.settings.callstack_layout); const after = restored.panes[result_id].?.file.?; try std.testing.expectEqualStrings(file.content, after.content); try std.testing.expectEqual(@as(usize, 8), after.location_rows[5].source_column); const restored_decoration = panes.Output.decorateRow(after.output, text, after.location_rows[5]); try std.testing.expectEqual(decoration, restored_decoration); - try std.testing.expect(p.executeBuiltinLine(0, "CallstackLayout inline")); - try fillResults(p, 0, "/", .{ .query = .callstack }, "", try p.gpa.dupe(u8, "No callers reported\n"), null); - try std.testing.expectEqual(config.Runtime.CallstackLayout.@"inline", p.settings.callstack_layout); } test "Callstack signatures share unsaved tree context and keep guides out of Look selections" { if (!syntax.enabled) return error.SkipZigTest; const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 110, .rows = 30 }); defer p.deinit(); - p.settings.callstack_layout = .@"inline"; const source = "const Box = struct {\n" ++ " pub fn caller(\n" ++ " value: u32,\n" ++ @@ -1837,7 +1831,7 @@ const OutputTests = struct { " }\n};\n"; const pane = try TreeContextTests.setZigFile(p, source); const path = pane.file.?.path; - const input = try std.fmt.allocPrint(p.gpa, "├──┬ {s}:2:12-17 caller\n@callstack-match │ └─ {s}:5:9-12 work(value);\n└─── missing.zig:3:4-8 other ↻ recursion\n", .{ path, path }); + const input = try std.fmt.allocPrint(p.gpa, "├──┬ {s}:2:12-17 caller\n@callstack-match │ ╰─ {s}:5:9-12 work(value);\n╰─── missing.zig:3:4-8 other ↻ recursion\n", .{ path, path }); try fillResults(p, 0, "/", .{ .query = .callstack }, "", input, null); const result_id = pane.search_pane.?; const result = p.panes[result_id].?; @@ -1846,20 +1840,22 @@ const OutputTests = struct { try std.testing.expect(std.mem.indexOf(u8, file.content, "value: u32,") != null); try std.testing.expect(std.mem.indexOf(u8, file.content, "const Box") == null); try std.testing.expect(std.mem.indexOf(u8, file.content, "other ↻ recursion") != null); - try std.testing.expectEqual(@as(usize, 5), file.location_rows.len); - for (file.location_rows[0..3]) |row| { + // Each location on its row, its code below it: the caller's + // three-line signature, the call site's line, the missing file's text. + try std.testing.expectEqual(@as(usize, 8), file.location_rows.len); + for (file.location_rows[1..4]) |row| { try std.testing.expect(!row.declaration); try std.testing.expect(!row.mark_occurrence); try std.testing.expect(row.colors.len > 0); } - for (1..3) |index| try std.testing.expect(std.mem.startsWith(u8, modal.lineSlice(file.content, index), "│ │ ")); + for (1..4) |index| try std.testing.expect(std.mem.startsWith(u8, modal.lineSlice(file.content, index), "│ │ ")); const analysis = try syntax.analyzeSource(p.scratch.allocator(), path, source, true, true); - for (file.location_rows[0..3], 1..) |row, source_row| { - const offset = modal.lineStartOffset(source, source_row); + for (file.location_rows[1..4], 1..) |row, source_row| { + const offset = modal.lineStartOffset(source, source_row) + row.source_column; try std.testing.expectEqualSlices(u8, analysis.colors[offset..][0..row.colors.len], row.colors); } - try std.testing.expect(file.location_rows[3].mark_occurrence); - try std.testing.expect(!file.location_rows[3].declaration); + try std.testing.expect(file.location_rows[5].mark_occurrence); + try std.testing.expect(!file.location_rows[5].declaration); try std.testing.expect(!panes.Output.isWalkRow(file, 1, modal.lineSlice(file.content, 1))); p.active = result_id; result.body.cur_row = 0; |
