diff options
Diffstat (limited to 'test')
| -rw-r--r-- | test/replicas.zig | 31 | ||||
| -rw-r--r-- | test/snapshots/fsearch.golden | 10 | ||||
| -rw-r--r-- | test/snapshots/lsp.golden | 4 |
3 files changed, 32 insertions, 13 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 => {}, + }; +} diff --git a/test/snapshots/fsearch.golden b/test/snapshots/fsearch.golden index 596f4fa9..8fbf0221 100644 --- a/test/snapshots/fsearch.golden +++ b/test/snapshots/fsearch.golden @@ -52,7 +52,7 @@ |13: 0-0 d,#608269, 1-89 d,#0d1410, 90-90 d,#608269, 91-179 d,#0d1410, |14: 0-0 d,#608269, 1-89 d,#0d1410, 90-90 d,#608269, 91-179 d,#0d1410, |15: 0-0 d,#608269, 1-89 d,#0d1410, 90-90 d,#608269, 91-179 d,#0d1410, -|16: 0-1 d,#496656, 2-30 #b2c3b8,#1d2824, 31-40 #d3b0d9,#1d2824, 41-89 #b2c3b8,#1d2824, 90-91 #000000,#add38a, 92-98 #becfc4,#2c2c0f, 99-99 #bada9d,#2c2c0f,b 100-100 #bada9d,#2c2c0f, 101-106 #becfc4,#2c2c0f, 107-113 #79836f,#2c2c0f, 114-137 #becfc4,#2c2c0f, 138-179 #79836f,#2c2c0f, +|16: 0-1 d,#496656, 2-30 #b2c3b8,#1d2824, 31-40 #d3b0d9,#1d2824, 41-89 #b2c3b8,#1d2824, 90-91 #000000,#add38a, 92-98 #becfc4,#2c2c0f, 99-99 #bada9d,#2c2c0f,b 100-100 #bada9d,#2c2c0f, 101-106 #becfc4,#2c2c0f, 107-113 #79836f,#2c2c0f, 114-126 #becfc4,#2c2c0f, 127-179 #79836f,#2c2c0f, |17: 0-0 d,#608269, 1-1 d,#0d1410, 2-89 #e5eee5,#0d1410, 90-90 #e5eee5,#608269, 91-94 #e5eee5,#0d1410, 95-96 #59675c,#0d1410, 97-179 #e5eee5,#0d1410, |18: 0-0 d,#608269, 1-1 d,#0d1410, 2-89 #e5eee5,#0d1410, 90-90 #e5eee5,#e5eee5, 91-91 #e5eee5,#0d1410, 92-94 #e5eee5,#0d1410,b 95-95 #616f64,#0d1410,b 96-96 #bada9d,#0d1410,b 97-100 #f5f7ee,#3c614a, 101-101 #f5f7ee,#0d1410, 102-179 #e5eee5,#0d1410, |19: 0-0 d,#608269, 1-89 d,#0d1410, 90-90 d,#608269, 91-94 d,#0d1410, 95-96 #59675c,#0d1410, 97-179 #e5eee5,#0d1410, @@ -70,8 +70,8 @@ == snap list grid=180x31 cursor=110,15 |15: ^ ‹@p1 › ␣ l /MARK/ 1/3 |16: /tmp/pardes-snap/fsearch/cwd Term+bash Save Mode Filter Collapse Del │ │ Walk Look Split Newcol Grep Edit Copy Keep Drop | Find Grep Recent Panes … -|17: ls │ │ ▶ /tmp/pardes-snap/fsearch/cwd/g.txt:2:1: MARK a -|18: g.txt │ │ /tmp/pardes-snap/fsearch/cwd/g.txt:6:1: MARK b +|17: ls │ │ ▶ /tmp/pardes-snap/fsearch/cwd/g.txt:2:1: MARK a +|18: g.txt │ │ /tmp/pardes-snap/fsearch/cwd/g.txt:6:1: MARK b |19: │ │ /tmp/pardes-snap/fsearch/cwd/g.txt:10:1: MARK c |20: │ │ |21: 1 l1 @@ -86,8 +86,8 @@ |30: ⏎ lands here · its text is the preview · S-⏎ a new pane 1 message · SPC h m == snap ctrln grid=180x31 cursor=110,15 |15: ^ ‹@p1 › ␣ l /MARK/ 2/3 -|17: ls │ │ /tmp/pardes-snap/fsearch/cwd/g.txt:2:1: MARK a -|18: g.txt │ │ ▶ /tmp/pardes-snap/fsearch/cwd/g.txt:6:1: MARK b +|17: ls │ │ /tmp/pardes-snap/fsearch/cwd/g.txt:2:1: MARK a +|18: g.txt │ │ ▶ /tmp/pardes-snap/fsearch/cwd/g.txt:6:1: MARK b |21: 3 l3 |22: 4 l4 |23: 5 l5 diff --git a/test/snapshots/lsp.golden b/test/snapshots/lsp.golden index 5d536a0f..c680700d 100644 --- a/test/snapshots/lsp.golden +++ b/test/snapshots/lsp.golden @@ -59,8 +59,8 @@ == snap symbols grid=120x41 cursor=24,2 |2: ^ a.zig:8 › ␣ l Symbols 1/3 |3: │ │ Walk Look Split Newcol Grep Edit Copy Keep Drop | Find Grep Recent Panes Symbols All Jumplist -|4: │ │ ▶ a.zig:1:7-9 std -|5: │ │ a.zig:3:4-9 helper +|4: │ │ ▶ a.zig:1:7-9 std +|5: │ │ a.zig:3:4-9 helper |6: │ │ a.zig:7:8-11 main |7: │ │ |8: 1▸const std = @import("std"); |
