summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/behaviour/look_and_exec.zig11
-rw-r--r--test/behaviour/other_files.zig17
2 files changed, 27 insertions, 1 deletions
diff --git a/test/behaviour/look_and_exec.zig b/test/behaviour/look_and_exec.zig
index 2ce95354..f769d72a 100644
--- a/test/behaviour/look_and_exec.zig
+++ b/test/behaviour/look_and_exec.zig
@@ -458,7 +458,11 @@ test "look-and-exec: a look opens spaced paths and locations without editing the
try expectEqual(@as(u32, 8), (try s.range(s.at("/pane/{d}/dot", .{opened})))[0]); // line 2, column 3
// The source: its text, its undo steps and its cursor as they were.
try s.expect(s.at("/pane/{d}/body", .{source}), "source stays intact\n");
- try std.testing.expectEqualStrings(ctl[0..60], (try s.read(s.at("/pane/{d}/ctl", .{source})))[0..60]);
+ const after = try s.read(s.at("/pane/{d}/ctl", .{source}));
+ try std.testing.expectEqualStrings(ctl[0..60], after[0..60]);
+ var fields = std.mem.tokenizeScalar(u8, after, ' ');
+ for (0..8) |_| _ = fields.next();
+ try std.testing.expectEqualStrings("0", fields.next().?); // still no undo step
try expectEqual(.{ @as(u32, 3), @as(u32, 3) }, try s.range(s.at("/pane/{d}/dot", .{source})));
try s.expect("/look", s.at("{d}\n", .{opened}));
// From the root, with the source focused: the same pane, moved.
@@ -623,6 +627,8 @@ test "look-and-exec: a second LookWord list look in a directory refills its +Sea
try s.write(s.at("/pane/{d}/look", .{n}), "beta\n");
try expectEqual(@as(usize, 1), std.mem.count(u8, try s.read("/index"), "/+Search "));
try expectEqual(first, try paneNamed(&s, "/+Search"));
+ // Refilled with beta's places (columns 7-10), not alpha's.
+ try std.testing.expect(has(try s.read(s.at("/pane/{d}/body", .{first})), "words.txt:1:7-10\n"));
}
test "look-and-exec: `@pN:` looks at pane N as `a.txt:` looks at a.txt, and a line past the end is said one way, `:N` or `file:N`" {
@@ -668,6 +674,9 @@ test "look-and-exec: a builtin that fails through exec, tagexec or a column's ex
// the same record, counted.
try expectEqual(@as(usize, 3), std.mem.count(u8, log, "Unmount: no such mount zzz"));
try std.testing.expect(has(log, "mount zzz (x2)"));
+ // A control character is refused with its reason.
+ try expectEqual(@as(u16, 22), try s.refused("/exec", "Msg a\x01b\n"));
+ try std.testing.expectEqualStrings("invalid command line: it holds a control character (or DEL) other than a tab", s.said);
// A look miss: one err, no msg; the same miss again is that record counted.
try s.write("/look", "zzqqnotthere\n");
try std.testing.expect(has(try s.read("/log"), "look: no match for \"zzqqnotthere\""));
diff --git a/test/behaviour/other_files.zig b/test/behaviour/other_files.zig
index 2d5cb112..701f4f14 100644
--- a/test/behaviour/other_files.zig
+++ b/test/behaviour/other_files.zig
@@ -309,3 +309,20 @@ test "other-files: a remembered place is clamped to the file as it is now, its s
try std.testing.expectEqual(back, try s.focused());
try std.testing.expectEqual(dot, try s.range(s.at("/pane/{d}/dot", .{back})));
}
+
+test "other-files: /index and /recent show a name's own backslash doubled, so `\\n` written in a name reads back unlike a newline" {
+ var tmp = std.testing.tmpDir(.{});
+ defer tmp.cleanup();
+ try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "back\\nslash", .data = "x\n" });
+ var s = try Session.initFile(std.testing.allocator, "x\n");
+ defer s.deinit();
+ const dir = try tmpPath(&s, &tmp);
+ const n = try s.focused();
+ try s.write(s.at("/pane/{d}/name", .{n}), s.at("{s}/back\\nslash\n", .{dir}));
+ const index = try s.read("/index");
+ try std.testing.expect(has(index, s.at("{s}/back\\\\nslash ", .{dir})));
+ try std.testing.expectEqual(@as(usize, 1), std.mem.count(u8, index, "\n"));
+ try s.write(s.at("/pane/{d}/exec", .{n}), "Get\n");
+ try s.write(s.at("/pane/{d}/ctl", .{n}), "Del\n");
+ try std.testing.expect(has(try s.read("/recent"), s.at("closed {s}/back\\\\nslash\n", .{dir})));
+}