diff options
Diffstat (limited to 'test/output.zig')
| -rw-r--r-- | test/output.zig | 141 |
1 files changed, 2 insertions, 139 deletions
diff --git a/test/output.zig b/test/output.zig index 2b8bf1f5..3cfece45 100644 --- a/test/output.zig +++ b/test/output.zig @@ -495,60 +495,12 @@ test "Mini syntax colors survive toggles themes and rendering without source acc } } -test "Mini failures leave its existing snapshot and focus unchanged" { - const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true }); - defer p.deinit(); - const source = try p.setTestFile("abc\n"); - var path_buf: [128]u8 = undefined; - const path = try std.fmt.bufPrint(&path_buf, "/virtual/pane/{d}/body", .{source.serial}); - try panes.mini.open(p, 0, path); - const id = p.active; - const mini = p.panes[id].?; - const body = mini.file.?.content.ptr; - const next = p.freeSlot(); - try std.testing.expectError(error.FileNotFound, panes.mini.open(p, 0, "/virtual/does-not-exist")); - try std.testing.expectEqual(id, p.active); - try std.testing.expectEqual(body, mini.file.?.content.ptr); - try std.testing.expectEqual(next, p.freeSlot()); -} - -test "DumpConfig prints the startup path and refreshes its one output" { +test "DumpConfig prints the startup path" { const path = "/home/pardes-test/.config/pardes/init"; const p = try Pardes.init(std.testing.allocator, .{ .startup_config_path = path }); defer p.deinit(); - - try std.testing.expect(p.executeBuiltinLine(0, "DumpConfig")); - const opened = p.active; - const out = p.panes[opened].?.file.?; - for ([_][]const u8{ - "Startup config: " ++ path ++ "\n", - "Theme orchard\n", - "Last shell spawned: (none)\n", - "Shell change pending: on\n", - "LocationsConfig ", - }) |line| try std.testing.expect(std.mem.indexOf(u8, out.content, line) != null); - var default_line: [256]u8 = undefined; - try std.testing.expect(std.mem.indexOf(u8, out.content, try std.fmt.bufPrint(&default_line, "Shell {s}\n", .{config.defaultShell()})) != null); - try std.testing.expectEqualStrings(config.dump_config_buffer, std.fs.path.basename(out.path)); - try std.testing.expectEqual(panes.Output.Origin{ .cmd = .DumpConfig }, out.output.?.from); - - try std.testing.expect(p.executeBuiltinLine(0, "DumpConfig")); - try std.testing.expectEqual(opened, p.active); - var buffers: usize = 0; - for (p.panes) |slot| { - const f = (slot orelse continue).file orelse continue; - const origin = (f.output orelse continue).from; - buffers += @intFromBool(std.meta.eql(origin, panes.Output.Origin{ .cmd = .DumpConfig })); - } - try std.testing.expectEqual(@as(usize, 1), buffers); -} - -test "DumpConfig reports the absence of a per-user config path" { - const p = try Pardes.init(std.testing.allocator, .{}); - defer p.deinit(); try std.testing.expect(p.executeBuiltinLine(0, "DumpConfig")); - const report = p.panes[p.active].?.file.?.content; - try std.testing.expect(std.mem.indexOf(u8, report, "no per-user config path") != null); + try std.testing.expect(std.mem.indexOf(u8, p.panes[p.active].?.file.?.content, "Startup config: " ++ path ++ "\n") != null); } /// The file Config names, in a fresh temporary directory: `pardes/init` @@ -621,14 +573,6 @@ test "Config with no startup file opens a pane of its name, and Save makes its d try std.testing.expectEqual(std.Io.File.Kind.directory, made.kind); } -test "Config without a configuration directory says so and opens nothing" { - const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true }); - defer p.deinit(); - const before = p.freeSlot(); - try std.testing.expect(p.executeBuiltinLine(p.active, "Config")); - try std.testing.expectEqual(before, p.freeSlot()); -} - test "EffectCode lists readable virtual sources used by this backend" { if (comptime !builtins.EffectCode.enabled) return; const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true }); @@ -771,31 +715,6 @@ fn selectedOutputText(pane: *const pardes.Pane) ?[]const u8 { return line[lo..@min(line.len, hi + 1)]; } -test "LookNext/LookPrev in ordinary text skips comment slashes and retains real paths" { - if (platform == .web) return error.SkipZigTest; - const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 100, .rows = 20 }); - defer p.deinit(); - const pane = try p.setTestFile("// ordinary comment\n/// documentation comment\n(//) [///] punctuation\n/\n// /tmp\n//tmp\n"); - try std.testing.expect(pane.file.?.output == null); - pardes.look.armLookWalk(p, 0); - const available = p.freeSlot(); - for ([_]struct { key: u21, row: i32, text: []const u8 }{ - .{ .key = 'n', .row = 3, .text = "/" }, - .{ .key = 'n', .row = 4, .text = "/tmp" }, - .{ .key = 'n', .row = 5, .text = "//tmp" }, - .{ .key = 'n', .row = 3, .text = "/" }, - .{ .key = 'N', .row = 5, .text = "//tmp" }, - .{ .key = 'N', .row = 4, .text = "/tmp" }, - .{ .key = 'N', .row = 3, .text = "/" }, - }) |step| { - lookKey(p, step.key); - try std.testing.expectEqual(@as(usize, 0), p.active); - try std.testing.expectEqual(step.row, pane.body.cur_row); - try std.testing.expectEqualStrings(step.text, selectedOutputText(pane) orelse ""); - try std.testing.expectEqual(available, p.freeSlot()); - } -} - test "LookNext/LookPrev skips formatted context and selects comment match locations" { if (!pardes.syntax.enabled) return error.SkipZigTest; for ([_]panes.Output.Origin{ .search, .{ .query = .references } }) |origin| { @@ -1005,62 +924,6 @@ test "LookPrev exactly reverses LookNext across output panes and the ring seam" try std.testing.expect(saw_first and saw_second); } -test "Themes lists the ring in sections and skips headings in both directions" { - const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 100, .rows = 40 }); - defer p.deinit(); - const source = try p.setTestFile("notes\n"); - pardes.colors.setThemeIndex(p, pardes.themes.len - 1); - const original_theme = p.settings.theme; - try std.testing.expect(p.executeBuiltinLine(0, "Themes")); - const tid = source.search_pane orelse return error.MissingThemeList; - const list = p.panes[tid].?; - const content = list.file.?.content; - try std.testing.expectEqual(@as(usize, 0), p.active); - try std.testing.expectEqual(@as(i32, 0), list.body.cur_row); - try std.testing.expectEqual(@as(usize, 0), list.file.?.scroll); - try std.testing.expectEqualStrings("# Pardes themes", modal.lineSlice(content, 0)); - // Every theme in ring order, each section's heading after a blank line - // where colors.groupAt says one starts. - var row: usize = 1; - var sections: usize = 1; - var first_break: ?usize = null; - for (pardes.themes, 0..) |theme, i| { - if (i > 0) if (pardes.colors.groupAt(i)) |title| { - try std.testing.expectEqualStrings("", modal.lineSlice(content, row)); - try std.testing.expect(std.mem.startsWith(u8, modal.lineSlice(content, row + 1), "# ")); - try std.testing.expectEqualStrings(title, modal.lineSlice(content, row + 1)["# ".len..]); - row += 2; - sections += 1; - if (first_break == null) first_break = i; - }; - const line = modal.lineSlice(content, row); - try std.testing.expect(std.mem.startsWith(u8, line, "Theme ")); - try std.testing.expectEqualStrings(theme.name, line["Theme ".len..]); - row += 1; - } - try std.testing.expectEqual(pardes.themes.len + 1 + 2 * (sections - 1), std.mem.count(u8, content, "\n")); - // acme is a current theme: it is listed before any break. - const acme = for (pardes.themes, 0..) |t, i| { - if (std.mem.eql(u8, t.name, "acme")) break i; - } else return error.MissingAcme; - const brk = first_break orelse return error.NoSections; - try std.testing.expect(acme < brk); - // Opening an imported theme's selector must still begin with the natives. - // Walk across the section break without selecting or executing a heading. - for (pardes.themes[0 .. brk + 1]) |theme| { - lookKey(p, 'n'); - try std.testing.expectEqual(tid, p.active); - const selected = selectedOutputText(list) orelse return error.MissingThemeSection; - try std.testing.expectEqualStrings(theme.name, selected["Theme ".len..]); - try std.testing.expectEqual(original_theme, p.settings.theme); - } - lookKey(p, 'N'); - const previous = selectedOutputText(list) orelse return error.MissingThemeSection; - try std.testing.expectEqualStrings(pardes.themes[brk - 1].name, previous["Theme ".len..]); - p.update(.{ .key = .{ .cp = Key.tab } }); - try std.testing.expectEqual(brk - 1, p.settings.theme); -} - test "LookNext/LookPrev selects command outputs by whole row" { if (platform == .web) return; var cwd_buf: [4096]u8 = undefined; |
