diff options
Diffstat (limited to 'test/behaviour/edit.zig')
| -rw-r--r-- | test/behaviour/edit.zig | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/test/behaviour/edit.zig b/test/behaviour/edit.zig new file mode 100644 index 00000000..e95471c6 --- /dev/null +++ b/test/behaviour/edit.zig @@ -0,0 +1,21 @@ +//! docs/typ/reference.typ, Edit <edit>. +const std = @import("std"); +const Session = @import("session").Session; + +test "edit: a write of an Edit block carries it whole, to a pane's ctl, the root's ctl and exec" { + var s = try Session.initFile(std.testing.allocator, "foo x\nfoo y\n"); + defer s.deinit(); + const n = try s.focused(); + const body = s.at("/pane/{d}/body", .{n}); + try s.write(s.at("/pane/{d}/ctl", .{n}), "Edit ,x/foo/{\ni/[/\na/]/\n}\n"); + try s.expect(body, "[foo] x\n[foo] y\n"); + try s.write("/ctl", "Edit ,x/\\[/{\nc/</\n}\n"); + try s.expect(body, "<foo] x\n<foo] y\n"); + try s.write(s.at("/pane/{d}/exec", .{n}), "Edit $a\nend\n.\n"); + try s.expect(body, "<foo] x\n<foo] y\nend\n"); + // A group still open when its open closes fails there, an err in the + // log, and nothing after it runs as a line. + try s.write(s.at("/pane/{d}/ctl", .{n}), "Edit ,x/foo/{\nd\n"); + try s.expect(body, "<foo] x\n<foo] y\nend\n"); + try std.testing.expect(std.mem.indexOf(u8, try s.read("/log"), "unmatched") != null); +} |
