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
|
//! docs/typ/reference.typ, Coming from acme <from-acme>.
const std = @import("std");
const Session = @import("session").Session;
test "from-acme: acme's words run as pardes's (Put is Save, Delete a Del that does not ask) or are refused, never run as commands" {
var s = try Session.initFile(std.testing.allocator, "x\n");
defer s.deinit();
const n = try s.focused();
for ([_][]const u8{ "Snarf\n", "Indent\n", "Local\n", "Abort\n" }) |line| {
for ([_][]const u8{ s.at("/pane/{d}/ctl", .{n}), s.at("/pane/{d}/exec", .{n}) }) |path| {
try std.testing.expectEqual(@as(u16, 22), try s.refused(path, line));
try std.testing.expect(std.mem.indexOf(u8, s.said, "is not a pardes builtin") != null);
}
}
// Load is Restore: whatever it says, never acme's word refused.
_ = try s.refused(s.at("/pane/{d}/exec", .{n}), "Load /tmp/pardes-surely-no-dump.zon\n");
try std.testing.expect(std.mem.indexOf(u8, s.said, "is not a pardes builtin") == null);
// Put saves, as Save does.
try s.write(s.at("/pane/{d}/name", .{n}), "/tmp/pardes-put.txt\n");
try s.write(s.at("/pane/{d}/exec", .{n}), "Put\n");
try std.testing.expectEqual(@as(usize, 1), s.saved);
// Delete closes an edited pane without asking.
const made = try s.newPane();
try s.write(s.at("/pane/{d}/name", .{made}), "/tmp/pardes-delete.txt\n");
try s.write(s.at("/pane/{d}/body", .{made}), "edited\n");
try s.write(s.at("/pane/{d}/ctl", .{made}), "Delete\n");
try std.testing.expect(std.mem.indexOf(u8, try s.read("/index"), "/tmp/pardes-delete.txt") == null);
}
|