diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-05 02:20:42 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-05 09:54:56 -0300 |
| commit | d4485660aa6339dbe546a81f4b543d68dfbfa9ec (patch) | |
| tree | 58318fd507577faa19b7dc48b523d691e546f8cd | |
| parent | 534f7da02ac58e475bb24801d315d7b736bd9c38 (diff) | |
| download | pardes-d4485660aa6339dbe546a81f4b543d68dfbfa9ec.tar.gz pardes-d4485660aa6339dbe546a81f4b543d68dfbfa9ec.zip | |
the four gui unit tests that failed on the base pass: the behaviour tests allow the window's own rows (/status ends in `pointer in|out` on a window; a bare setting word moves a setting, a toggle to its other side and Lift, Crt or ShaderAnimation to their next state, and Shader and Pet, whose off means no file and no pet, take a name, not a flip); the tagline pointer-mapping test puts the workspace tag's text TAG_TEXT_INSET cells in, as it is drawn; the caret test that grew a tag past a row's end goes, as a tag wraps onto rows (up to MAX_TAG_ROWS) and no caret is past one
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
| -rw-r--r-- | src/draw.zig | 50 | ||||
| -rw-r--r-- | src/gui/gui.zig | 6 | ||||
| -rw-r--r-- | test/behaviour/look_and_exec.zig | 6 | ||||
| -rw-r--r-- | test/behaviour/settings.zig | 17 |
4 files changed, 24 insertions, 55 deletions
diff --git a/src/draw.zig b/src/draw.zig index 83f93be0..96a12145 100644 --- a/src/draw.zig +++ b/src/draw.zig @@ -2041,56 +2041,6 @@ test "the focused cursor glides a jump, eases a step, the thin caret too, and is try std.testing.expectApproxEqAbs(@as(f32, 1.0 / 8.0), s.chrome.cursor_quad[2] - s.chrome.cursor_quad[0], 1e-4); } -test "a tag caret past its row's end glides to the tag's right edge, where the layer's is" { - if (!builtins.frontend.lift) return error.SkipZigTest; - const p = try Pardes.init(std.testing.allocator, .{ .cols = 60, .rows = 16 }); - defer p.deinit(); - p.update(.{ .resize = .{ .cols = 60, .rows = 16, .row_metrics = .{ .body_w = 10, .body_h = 20, .tagline_w = 6, .tagline_h = 12 } } }); - const pane = try p.setTestFile("text\n"); - var arena: std.heap.ArenaAllocator = .init(std.testing.allocator); - defer arena.deinit(); - // The tag's text grown a letter at a time, the caret after its last one - // in insert mode, until a row is full and the caret is past its end. - var found = false; - var n: usize = 1; - while (n < 200 and !found) : (n += 1) { - _ = arena.reset(.retain_capacity); - if (pane.tag.own) |own| p.gpa.free(own); - const own = try p.gpa.alloc(u8, n); - @memset(own, 'x'); - own[0] = ' '; - pane.tag.own = own; - tagline.enterTag(p, pane); - const whole = try tagline.tagText(p, arena.allocator(), pane); - pane.tag.mode = .insert; - pane.tag.cur_row = 0; - pane.tag.cur_col = @intCast(modal.lineSlice(whole, 0).len); - p.sync(); - const s = try p.render(arena.allocator()); - const layer = for (s.tagLayers()) |*layer| { - if (layer.rows != 0 and layer.kind == .pane and layer.cursor != null) break layer; - } else continue; - const caret = layer.cursor.?; - const right: f32 = @floatFromInt(layer.viewport.x + layer.viewport.w); - const box = focusedCursorBox(p, s).?; - // Never past the tag's right edge, and the pane's. - try std.testing.expect(box.x + box.w <= right + 1e-4); - try std.testing.expect(box.x + box.w <= @as(f32, @floatFromInt(p.rects[p.active].x + p.rects[p.active].w))); - const at = @as(f32, @floatFromInt(layer.viewport.x)) + @as(f32, @floatFromInt(caret.x)) * 6 / 10; - if (at + box.w <= right) { - // Inside its row: exactly where the layer's caret is. - try std.testing.expectApproxEqAbs(at, box.x, 1e-4); - } else { - // Past it: on the tag's right edge, as the pixel shell's caret - // is (gui.zig cursorBoxes). - try std.testing.expectApproxEqAbs(right, box.x + box.w, 1e-4); - try std.testing.expectApproxEqAbs(@as(f32, 6.0 / 10.0 / 8.0), box.w, 1e-4); - found = true; - } - } - try std.testing.expect(found); -} - test "a terminal's cursor lands with scrolling output, never gliding against it" { if (!builtins.frontend.lift or !pardes.terminal_panes) return error.SkipZigTest; const p = try Pardes.init(std.testing.allocator, .{ .cols = 80, .rows = 12 }); diff --git a/src/gui/gui.zig b/src/gui/gui.zig index a5b7f34a..a850cdca 100644 --- a/src/gui/gui.zig +++ b/src/gui/gui.zig @@ -3221,8 +3221,10 @@ test "tagline pointer mapping retains physical grips and carries logical text co try std.testing.expectEqual(body_y, body.row); try std.testing.expect(body.tag_hit == null); - const topbar = gridCellAtDimensions(core, 3.5 * tag_w, 0.5 * body_h, body_w, body_h, tag_w); - try std.testing.expectEqual(@as(u16, 2), topbar.col); + // The workspace tag's text starts TAG_TEXT_INSET cells in, as a pane's. + const x_top = @as(f32, @floatFromInt(pardes.TAG_TEXT_INSET)) * body_w + 3.5 * tag_w; + const topbar = gridCellAtDimensions(core, x_top, 0.5 * body_h, body_w, body_h, tag_w); + try std.testing.expectEqual(pixelCell(x_top, 10), topbar.col); try std.testing.expectEqual(@as(u16, 3), topbar.tag_hit.?.col); try std.testing.expectEqual(pardes.TagKind.workspace, topbar.tag_hit.?.kind); } diff --git a/test/behaviour/look_and_exec.zig b/test/behaviour/look_and_exec.zig index e88a0053..658d2483 100644 --- a/test/behaviour/look_and_exec.zig +++ b/test/behaviour/look_and_exec.zig @@ -500,7 +500,11 @@ test "look-and-exec: status reads the editor, and look and exec validate whole b try std.testing.expect(std.mem.startsWith(u8, rows.next().?, "pid ")); try std.testing.expect(std.mem.startsWith(u8, rows.next().?, "version ")); try std.testing.expectEqualStrings(s.at("panes {d}", .{lines(try s.read("/index"))}), rows.next().?); - try std.testing.expect(rows.next() == null); + // A window adds whether the pointer is over it (Handover asks every window). + if (rows.next()) |row| { + try std.testing.expect(std.mem.eql(u8, row, "pointer in") or std.mem.eql(u8, row, "pointer out")); + try std.testing.expect(rows.next() == null); + } const st = try s.stat("/status"); try expectEqual(@as(u64, status.len), st.size); try expectEqual(@as(u16, 0o444), st.mode & 0o777); diff --git a/test/behaviour/settings.zig b/test/behaviour/settings.zig index 9a14ff50..c4d93419 100644 --- a/test/behaviour/settings.zig +++ b/test/behaviour/settings.zig @@ -257,8 +257,21 @@ test "settings: every on/off setting the root ctl reads flips when its word is w const word, const was = .{ line[0..space], line[space + 1 ..] }; const on = std.mem.eql(u8, was, "on"); if (!on and !std.mem.eql(u8, was, "off")) continue; - try s.write("/ctl", s.at("{s}\n", .{word})); - try std.testing.expectEqualStrings(s.at("{s} {s}", .{ word, if (on) "off" else "on" }), try setting(&s, word)); + // Shader's and Pet's `off` say they have no file and no pet; each takes + // a name, not a flip. + if (std.mem.eql(u8, word, "Shader") or std.mem.eql(u8, word, "Pet")) continue; + s.write("/ctl", s.at("{s}\n", .{word})) catch |err| { + std.debug.print("a bare {s} (was {s}) was refused\n", .{ word, was }); + return err; + }; + // A bare word moves the setting: a toggle to its other side, one with + // more states (Lift's auto, Crt's level, ShaderAnimation's always) to + // the next, never nowhere. + const after = try setting(&s, word); + try std.testing.expect(std.mem.startsWith(u8, after, word)); + try std.testing.expect(!std.mem.eql(u8, after, line)); + if (on) try std.testing.expect(!std.mem.endsWith(u8, after, " on")); + if (!on) try std.testing.expect(!std.mem.endsWith(u8, after, " off")); flipped += 1; } try std.testing.expect(flipped > 20); |
