From f922f8b5db1f3b92d954c43860c32cd251d5bc55 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Fri, 6 Nov 2026 11:38:06 -0300 Subject: kinds #20, their tests and docs: T1's sessions are a terminal without graphics, so a PDF's key test is the base's text-layer one again beside the strip's (Session.graphics gives a frontend pictures), /addons says 2.2; pane cases for the hand over a link and a touchpad's fraction; reference.typ and the changelog say what a PDF does with and without graphics and what 2.2 added Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge --- test/behaviour/addons.zig | 8 ++++---- test/behaviour/addons_pdf.zig | 7 +++++-- test/behaviour/keys.zig | 25 +++++++++++++++++++++++++ 3 files changed, 34 insertions(+), 6 deletions(-) (limited to 'test/behaviour') diff --git a/test/behaviour/addons.zig b/test/behaviour/addons.zig index 8d780c98..4a624c22 100644 --- a/test/behaviour/addons.zig +++ b/test/behaviour/addons.zig @@ -37,7 +37,7 @@ test "addons: Addon load takes a library in, /addons lists it with the kinds com defer unload(&s, "fake"); // ` `. const listed = try s.read("/addons"); - try std.testing.expect(std.mem.startsWith(u8, listed, "fake 1 2.1 0 /")); + try std.testing.expect(std.mem.startsWith(u8, listed, "fake 1 2.2 0 /")); var fields = std.mem.tokenizeScalar(u8, listed[0..std.mem.indexOfScalar(u8, listed, '\n').?], ' '); for (0..5) |_| _ = fields.next(); try std.testing.expectEqual(@as(usize, 64), fields.next().?.len); @@ -51,7 +51,7 @@ test "addons: Addon load takes a library in, /addons lists it with the kinds com // A pane of it open, it stays; closed, it goes. try s.write("/ctl", "Fake\n"); const pane = try paneOf(&s, "fake"); - try std.testing.expect(std.mem.startsWith(u8, try s.read("/addons"), "fake 1 2.1 1 /")); + try std.testing.expect(std.mem.startsWith(u8, try s.read("/addons"), "fake 1 2.2 1 /")); try std.testing.expect(try s.refused("/ctl", "Addon unload fake\n") != 0); try std.testing.expect(has(s.said, "1 fake pane is open")); try s.write(s.at("/pane/{d}/ctl", .{pane}), "Del\n"); @@ -68,7 +68,7 @@ test "addons: a library of another ABI, one with no pardes_addon, and one whose try std.testing.expect(std.mem.startsWith(u8, listed, "fakeabi 1 3.0 0 /")); try std.testing.expect(has(listed, " refused: wants abi 3, this pardes speaks 2\n")); try std.testing.expect(has(listed, " refused: it has no pardes_addon\n")); - try std.testing.expect(has(listed, "\nfakeword 1 2.1 0 /")); + try std.testing.expect(has(listed, "\nfakeword 1 2.2 0 /")); try std.testing.expect(has(listed, " refused: word Save is the core's\n")); // A file that is no library at all: listed with what the loader said. var tmp = std.testing.tmpDir(.{}); @@ -120,7 +120,7 @@ test "addons: the image addon opens the pictures a Look names, fitted, with the defer s.deinit(); try load(&s, Session.image_addon); const listed = try s.read("/addons"); - try std.testing.expect(std.mem.startsWith(u8, listed, "image 1 2.1 0 /") and has(listed, " loaded\n")); + try std.testing.expect(std.mem.startsWith(u8, listed, "image 1 2.2 0 /") and has(listed, " loaded\n")); var tmp = std.testing.tmpDir(.{}); defer tmp.cleanup(); var buf: [4096]u8 = undefined; diff --git a/test/behaviour/addons_pdf.zig b/test/behaviour/addons_pdf.zig index f3c2d872..60379457 100644 --- a/test/behaviour/addons_pdf.zig +++ b/test/behaviour/addons_pdf.zig @@ -35,9 +35,10 @@ fn ctlOf(s: *Session, n: u32) ![]const u8 { test "addons: a PDF is the pdf addon's pane, its pages pictures, its page in its tag, its fit and tint in its ctl and stepped by its words, all of it back from a Dump" { var s = try Session.initFile(std.testing.allocator, "x\n"); defer s.deinit(); + s.graphics(); const n = try s.lookFile("docs/design.pdf"); try std.testing.expect(has(try s.read("/index"), " pdf ")); - try std.testing.expect(std.mem.startsWith(u8, try s.read("/addons"), "pdf 1 2.1 1 /")); + try std.testing.expect(std.mem.startsWith(u8, try s.read("/addons"), "pdf 1 2.2 1 /")); const pages = (try s.pdfPage(n))[1]; try std.testing.expectEqual(@as(u32, 16), pages); // Its first page, a picture over its body. @@ -46,7 +47,7 @@ test "addons: a PDF is the pdf addon's pane, its pages pictures, its page in its // Its tag: its page, then the core's art words (it placed a picture), // its path and its kind's words. const tag = try s.read(s.at("/pane/{d}/tag", .{n})); - try std.testing.expect(std.mem.startsWith(u8, tag, "[1/16] petscii:on palette:commodore ascii:on /")); + try std.testing.expect(std.mem.startsWith(u8, tag, "[1/16] petscii:off palette:commodore ascii:on /")); try std.testing.expect(has(tag, "/docs/design.pdf Term PdfSections PdfTint PdfFit Collapse Del")); try std.testing.expect(has(try ctlOf(&s, n), " fit:width tint:filtered mode:normal ")); // The words: bare they step, given a value they take it, any other @@ -134,6 +135,7 @@ test "addons: a PDF's / lists its hits as file.pdf:P:H rows in a +Search, n walk test "addons: a PDF's f is its PdfSections, its outline as places a Look in it goes to (none once the PDF is gone), and a jump back over a far one is Ctrl-o's, Forward's on, two places on a page a window apart two" { var s = try Session.initFile(std.testing.allocator, "x\n"); defer s.deinit(); + s.graphics(); const n = try s.lookFile("test/pdf-fixtures/outline.pdf"); try s.keys("f"); var list: u32 = 0; @@ -190,6 +192,7 @@ test "addons: a PDF's f is its PdfSections, its outline as places a Look in it g test "addons: a closed PDF is in Recent and its jumps, and a jump back to it opens it at its page; a tall page is shown a band of it at a time" { var s = try Session.initFile(std.testing.allocator, "x\n"); defer s.deinit(); + s.graphics(); const n = try s.lookFile("docs/design.pdf"); try s.write(s.at("/pane/{d}/look", .{n}), ":5\n"); const name = std.mem.trimEnd(u8, try s.read(s.at("/pane/{d}/name", .{n})), "\n"); diff --git a/test/behaviour/keys.zig b/test/behaviour/keys.zig index 879ff441..118681cd 100644 --- a/test/behaviour/keys.zig +++ b/test/behaviour/keys.zig @@ -136,9 +136,34 @@ test "keys: a count or a prefix a click or a change of pane cancels leaves nothi } } +test "keys: a PDF shown as text turns pages for the moving keys, counted, and the editing keys do nothing" { + var s = try Session.initFile(std.testing.allocator, "x\n"); + defer s.deinit(); + const n = try s.lookFile("docs/design.pdf"); + const pages = (try s.pdfPage(n))[1]; + try std.testing.expect(pages > 3); + // j k, Ctrl-d Ctrl-u, Ctrl-f Ctrl-b: a page each, counted. + for ([_][]const u8{ "2j", "2k", "2\x04", "2\x15", "2\x06", "2\x02" }, 0..) |keys, i| { + try s.keys(keys); + try std.testing.expectEqual(@as(u32, if (i % 2 == 0) 3 else 1), (try s.pdfPage(n))[0]); + } + for ([_]struct { []const u8, u32 }{ .{ "ge", pages }, .{ "gg", 1 }, .{ "3gg", 3 }, .{ "2G", 2 } }) |step| { + try s.keys(step[0]); + try std.testing.expectEqual(step[1], (try s.pdfPage(n))[0]); + } + // Consumed, with their count: the page stays, no selection begins, and + // the next j is one page. + try s.keys("4dv|"); + try std.testing.expectEqual(@as(u32, 2), (try s.pdfPage(n))[0]); + try std.testing.expect(std.mem.endsWith(u8, try s.read(s.at("/pane/{d}/ctl", .{n})), " mode:normal ")); + try s.keys("j"); + try std.testing.expectEqual(@as(u32, 3), (try s.pdfPage(n))[0]); +} + test "keys: a PDF's moving keys scroll its strip, counted, gg G and ge go to pages, and the editing keys do nothing" { var s = try Session.initFile(std.testing.allocator, "x\n"); defer s.deinit(); + s.graphics(); const n = try s.lookFile("docs/design.pdf"); const pages = (try s.pdfPage(n))[1]; try std.testing.expect(pages > 3); -- cgit v1.3