summaryrefslogtreecommitdiff
path: root/test/behaviour
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-06 13:15:15 -0300
committerGabriel Schneider <[email protected]>2026-11-06 14:24:59 -0300
commitc37a700474e8b84cc3c7db8bf550b7c5f18b1871 (patch)
tree5498f5f8cf542f4aef7903c75aec56efd80c1126 /test/behaviour
parent9991a90aae7f4591e63e5ecb0ab2467a348ed54e (diff)
downloadpardes-c37a700474e8b84cc3c7db8bf550b7c5f18b1871.tar.gz
pardes-c37a700474e8b84cc3c7db8bf550b7c5f18b1871.zip
kinds #23, the plumber: Plumb, skqrvwks's rules ported (one a line in plumb(6)'s order, the session's and kept in a dump, tried before the built-in ladder, prefix, suffix, isdir and isfile), its ports url, dir, file or any loaded kind by its name from the registry, a rule naming a kind not loaded refused in words when written and passed over like any rule that cannot make its target when its kind has gone since, so `Plumb suffix .svg to image` in init sends a look to the image addon
Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'test/behaviour')
-rw-r--r--test/behaviour/addons.zig23
1 files changed, 23 insertions, 0 deletions
diff --git a/test/behaviour/addons.zig b/test/behaviour/addons.zig
index 4a624c22..b64a6974 100644
--- a/test/behaviour/addons.zig
+++ b/test/behaviour/addons.zig
@@ -174,6 +174,29 @@ test "addons: the image addon opens the pictures a Look names, fitted, with the
try std.testing.expect(has(try s.read("/screen"), "\"src\":[0,0,4,2]"));
}
+test "addons: a Plumb rule to a loaded kind opens that kind's pane, is refused naming one not loaded, and with its kind gone the look falls through to text" {
+ var s = try Session.initFile(std.testing.allocator, "x\n");
+ defer s.deinit();
+ try load(&s, Session.image_addon);
+ var tmp = std.testing.tmpDir(.{});
+ defer tmp.cleanup();
+ var buf: [4096]u8 = undefined;
+ const dir = buf[0..try tmp.dir.realPath(std.testing.io, &buf)];
+ // A PNG under a name no kind claims.
+ const png = "\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x01\x00\x00\x00\x01\x08\x02\x00\x00\x00\x90wS\xde\x00\x00\x00\x0cIDATx\x9cc\xf8\xcf\xc0\x00\x00\x03\x01\x01\x00\xc9\xfe\x92\xef\x00\x00\x00\x00IEND\xaeB`\x82";
+ try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "red.pic", .data = png });
+ try std.testing.expect(try s.refused("/ctl", "Plumb suffix .pic to nokind\n") != 0);
+ try std.testing.expect(has(s.said, "Plumb: invalid port: url, dir, file or a loaded kind"));
+ try s.write("/ctl", "Plumb suffix .pic to image\n");
+ try s.write("/look", s.at("{s}/red.pic\n", .{dir}));
+ try std.testing.expectEqual(try paneOf(&s, "image"), try s.focused());
+ try s.write(s.at("/pane/{d}/ctl", .{try s.focused()}), "Del\n");
+ try s.write("/ctl", "Addon unload image\n");
+ try s.write("/look", s.at("{s}/red.pic\n", .{dir}));
+ try std.testing.expect(has(try s.read(s.at("/pane/{d}/tag", .{try s.focused()})), "red.pic"));
+ try std.testing.expectError(error.NoSuchPane, paneOf(&s, "image"));
+}
+
test "addons: a dump keeps an addon's pane; restored without its addon it waits as a placeholder, and opens in place when the addon comes" {
var s = try Session.initFile(std.testing.allocator, "x\n");
defer s.deinit();