diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-25 09:47:44 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-25 09:47:44 -0300 |
| commit | a6d2b61bd78768cf4bbf177717ffea319825de69 (patch) | |
| tree | a5d2fe57480efecab632d90271e6c282353f51dd /test/replicas.zig | |
| parent | 58d7434f56a9fef3098cfc191fbd1cb32ec09cfb (diff) | |
| download | pardes-a6d2b61bd78768cf4bbf177717ffea319825de69.tar.gz pardes-a6d2b61bd78768cf4bbf177717ffea319825de69.zip | |
test/replicas.zig: the soak's typist guards q from its space to its next Esc, not only right after the space: SPC's level stays open over a key it has no child for (keys.zig leaderKey: struck, the level stays) and Backspace takes it back up, so `SPC 7 o q` and `SPC l Backspace q` reached Exit and ended the session mid-run (G4's M6 soak run 1, seed 2 rtt 207: "the session ended (Exit, the last pane's Del)", the last keys drawn client 1's `7 o q 0`); THE CAUSE: nextEvent cleared Script.space on any typed key that was not a space and on every normal-mode key, and the search's and the sweep's scripts (`script.* = .{...}`) reset it with the whole Script; THE FIX: Script.space is set by a space and cleared only by the typist's Esc (the one key sure to leave the level), and both scripts keep it; a q typed meanwhile is an r, as it was right after a space; TEST FIRST: replicas.zig "the typist types no q while a leader its space opened may be open: from its space to its next Esc (SPC 7 o q was Exit)" (200,000 events of seed 109, the level modelled open from a space to an Esc): fails on the base at replicas.zig:3678, and after the first half of the fix at :3679 (the search's script reset), passes now; the harness's tests are built beside it (build/tests.zig: test/replicas.zig as a unit-test root, run by `replicas` and unit-test, its imports the program's); a user could not hit it: the soak's typist only
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBFhdevVu48bvL9kCE
Diffstat (limited to 'test/replicas.zig')
| -rw-r--r-- | test/replicas.zig | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/test/replicas.zig b/test/replicas.zig index cd0a3459..65e6a0ba 100644 --- a/test/replicas.zig +++ b/test/replicas.zig @@ -334,12 +334,11 @@ fn nextEvent(random: std.Random, buf: *[64]u8, aim: Aim, looks: []const []const 0...15 => { buf[0] = typed[random.uintLessThan(usize, typed.len)]; if (buf[0] == 'q' and script.space) buf[0] = 'r'; - script.space = buf[0] == ' '; + script.space = script.space or buf[0] == ' '; return .{ .key = .{ .cp = buf[0], .text = buf[0..1] } }; }, 16...27 => { buf[0] = normal[random.uintLessThan(usize, normal.len)]; - script.space = false; return .{ .key = .{ .cp = buf[0], .text = buf[0..1] } }; }, 28...31 => { @@ -393,7 +392,7 @@ fn nextEvent(random: std.Random, buf: *[64]u8, aim: Aim, looks: []const []const // A search in the pane with the keyboard (a PDF's `/` is its own): // `/`, a pattern, Enter. 41 => { - script.* = .{ .n = 2, .evs = .{ .{ .paste = ([_][]const u8{ "the", "view", "pardes" })[random.uintLessThan(usize, 3)] }, .{ .key = .{ .cp = Key.enter } }, undefined } }; + script.* = .{ .n = 2, .evs = .{ .{ .paste = ([_][]const u8{ "the", "view", "pardes" })[random.uintLessThan(usize, 3)] }, .{ .key = .{ .cp = Key.enter } }, undefined }, .space = script.space }; return .{ .key = .{ .cp = '/', .text = "/" } }; }, // A sweep of B1 over the PDF: a selection (or a page's pan, or nothing). @@ -403,7 +402,7 @@ fn nextEvent(random: std.Random, buf: *[64]u8, aim: Aim, looks: []const []const const y = at[1] + random.uintLessThan(u16, at[3]); const x1 = at[0] + random.uintLessThan(u16, at[2]); const y1 = @min(at[1] + at[3] - 1, y + random.uintLessThan(u16, 3)); - script.* = .{ .n = 2, .evs = .{ .{ .mouse = .{ .button = .left, .kind = .drag, .col = x1, .row = y1 } }, .{ .mouse = .{ .button = .left, .kind = .release, .col = x1, .row = y1 } }, undefined } }; + script.* = .{ .n = 2, .evs = .{ .{ .mouse = .{ .button = .left, .kind = .drag, .col = x1, .row = y1 } }, .{ .mouse = .{ .button = .left, .kind = .release, .col = x1, .row = y1 } }, undefined }, .space = script.space }; return .{ .mouse = .{ .button = .left, .kind = .press, .col = x, .row = y } }; }, // The wheel over the shell, which scrolls its history into view, @@ -426,8 +425,10 @@ const Script = struct { evs: [3]pardes.Event = undefined, n: u8 = 0, at: u8 = 0, - /// Its last key was a space: Space then q is Exit (config.zig's - /// leader), which ends the session and the run with it. + /// A space typed and no Esc since: SPC's level may be open (it stays + /// over a key it has no child for, keys.zig `leaderKey`, and Backspace + /// takes it back up), and q in it is Exit (config.zig's leader), which + /// ends the session and the run with it. space: bool = false, }; @@ -3664,3 +3665,21 @@ fn corpusCase(dir: []const u8) !bool { std.debug.print("corpus through a client: {d} scenes, the own frontend drew {d} frames and the client {d}; {s}\n", .{ steps.len, own_host.shown.frames, shows.shown.frames, if (ok) "every scene's frame the same" else "FAILED" }); return ok; } + +test "the typist types no q while a leader its space opened may be open: from its space to its next Esc (SPC 7 o q was Exit)" { + var prng: std.Random.DefaultPrng = .init(109); + var script: Script = .{}; + var buf: [64]u8 = undefined; + // SPC's level stays open over a key it has no child for (keys.zig + // `leaderKey`), and Backspace takes it back up: Esc is the typist's + // one key sure to leave it. + var open = false; + for (0..200_000) |_| switch (nextEvent(prng.random(), &buf, .{ .shell = null, .pdf = null }, &.{"Look"}, &script, false, true)) { + .key => |k| { + if (open and k.cp == 'q') return error.TestUnexpectedResult; + if (k.cp == ' ') open = true; + if (k.cp == Key.escape) open = false; + }, + else => {}, + }; +} |
