1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
//! docs/typ/builtins.typ, the builtins' glossary.
const std = @import("std");
const Session = @import("session").Session;
test "builtins: Mini maps a file of the pane's directory over pardes's own source of that name, in one pane, refreshed only when asked again" {
var tmp = std.testing.tmpDir(.{});
defer tmp.cleanup();
try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "build.zig", .data = "x\n" });
try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "a.txt", .data = "a\n" });
var dir: [4096]u8 = undefined;
const at = dir[0..try tmp.dir.realPath(std.testing.io, &dir)];
var s = try Session.initFile(std.testing.allocator, "x\n");
defer s.deinit();
try s.write("/look", s.at("{s}/a.txt\n", .{at}));
const a = try s.focused();
// The directory's one-line build.zig, one braille row, not pardes's.
try s.write(s.at("/pane/{d}/exec", .{a}), "Mini build.zig\n");
const mini = try s.focused();
try std.testing.expect(mini != a);
const body = s.at("/pane/{d}/body", .{mini});
try s.expect(body, "⠁\n");
const index = try s.read("/index");
try s.write(s.at("/pane/{d}/exec", .{mini}), "Mini build.zig\n");
try std.testing.expectEqual(mini, try s.focused());
try s.expect("/index", index);
// A snapshot: the file grown on disk shows only at the next Mini.
try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "build.zig", .data = "xx\n" });
try s.expect(body, "⠁\n");
try s.write(s.at("/pane/{d}/exec", .{mini}), "Mini build.zig\n");
try s.expect(body, "⠉\n");
try s.expect("/index", index);
// Save asks for a path; nothing is written for it.
try s.write(s.at("/pane/{d}/exec", .{mini}), "Save\n");
try std.testing.expect(std.mem.indexOf(u8, try s.read("/log"), s.at("ask {d} save path\n", .{mini})) != null);
try std.testing.expectEqual(@as(usize, 0), s.saved);
}
|