diff options
Diffstat (limited to 'test/behaviour')
| -rw-r--r-- | test/behaviour/columns_and_tags.zig | 48 | ||||
| -rw-r--r-- | test/behaviour/keys.zig | 7 | ||||
| -rw-r--r-- | test/behaviour/modes.zig | 6 | ||||
| -rw-r--r-- | test/behaviour/tags.zig | 5 |
4 files changed, 40 insertions, 26 deletions
diff --git a/test/behaviour/columns_and_tags.zig b/test/behaviour/columns_and_tags.zig index e1257897..4ca6f7b3 100644 --- a/test/behaviour/columns_and_tags.zig +++ b/test/behaviour/columns_and_tags.zig @@ -129,9 +129,12 @@ test "columns-and-tags: Delcol on the last column leaves the window, drawn and t try s.write(s.at("/col/{d}/ctl", .{try s.column(0)}), "Delcol\n"); try expectEqualStrings("", try s.columns()); try s.expect("/index", ""); - // Drawn, and keys go to the workspace tag. + // Drawn, its words at the window row's right end (UX K'2), and keys go + // to the workspace tag. try s.keys("x\n"); - try std.testing.expect(std.mem.startsWith(u8, try s.screen(), " Newcol ")); + const screen = try s.screen(); + const first = std.mem.trimEnd(u8, screen[0..std.mem.indexOfScalar(u8, screen, '\n').?], " "); + try std.testing.expect(std.mem.endsWith(u8, first, "Find Grep Newcol Help Exit")); try s.write("/ctl", "Newcol\n"); try s.write(s.at("/col/{d}/ctl", .{try s.column(0)}), "New\n"); try expectEqualStrings(s.at("{d}:{d}", .{ try s.column(0), try s.focused() }), try s.columns()); @@ -162,7 +165,8 @@ test "columns-and-tags: New is a column tag's word, in no pane's tag nor the wor var words = std.mem.tokenizeScalar(u8, tag, ' '); while (words.next()) |word| try std.testing.expect(!std.mem.eql(u8, word, "New")); } - try expectEqualStrings("New Term Find Grep Joincol Delcol", try s.read(s.at("/col/{d}/tag", .{try s.column(0)}))); + // A lone column's words (UX K'2), and no text of the user's. + try expectEqualStrings("New Term ", try s.read(s.at("/col/{d}/tag", .{try s.column(0)}))); } test "columns-and-tags: a click past a column tag's text types after it, a newline typed there a space, and a long tag scrolls to its caret" { @@ -171,18 +175,20 @@ test "columns-and-tags: a click past a column tag's text types after it, a newli // A held pane (Keep): its tag as it was before the walk, no `Keep` word (SPEC §6.5). try s.write(s.at("/pane/{d}/exec", .{try s.focused()}), "Keep\n"); const tag = s.at("/col/{d}/tag", .{try s.column(0)}); - // Its row, then the pane's tag: the column's stays one row. - const rows = " New Term Find Grep Joincol Delcol"; - try std.testing.expect(std.mem.indexOf(u8, try s.screen(), rows ++ " ") != null); - try s.click("Delcol", 20, 1); - // A clicked tag is in normal mode: `i` types where it was clicked. + // A lone column's tag is at the window row's left (UX K'2). + try std.testing.expect(std.mem.startsWith(u8, try s.screen(), " New Term ")); + // Past its text, on its caret's cell. A clicked tag is in normal mode: + // `i` types where it was clicked, after its computed words. + try s.click("Term", 5, 1); try s.keys("i\nSnarf"); - try expectEqualStrings("New Term Find Grep Joincol Delcol Snarf", try s.read(tag)); - try std.testing.expect(std.mem.indexOf(u8, try s.screen(), rows ++ " Snarf ") != null); - // The pane's tag on the row right under it: the column's is one row. + try expectEqualStrings("New Term Snarf", try s.read(tag)); + // The user's text brings the column row, one row under the window's, + // and the pane's tag on the row right under it. + const rows = " New Term Snarf"; + try std.testing.expectEqual(@as(usize, 1), (try s.where(rows ++ " "))[1]); try std.testing.expectEqual((try s.where(rows))[1] + 1, (try s.where("/test.txt Del"))[1]); // Wider than the screen: the tag scrolls to keep its caret drawn. - try s.keys(" 界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界"); + try s.keys(" 界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界"); const col, const row = (try s.cursor()).?; try std.testing.expectEqual(@as(usize, 1), row); try std.testing.expect(col < 80); @@ -204,9 +210,9 @@ test "columns-and-tags: Enter in a tag in normal mode runs the word under its cu try s.expect("/focus", ""); try s.keys("iMine\x1b"); try std.testing.expect(std.mem.indexOf(u8, try s.read(s.at("/col/{d}/tag", .{try s.column(1)})), "Mine") != null); - try s.click("Tutor", 1, 1); + try s.click("Help", 1, 1); try s.keys("\t"); - try std.testing.expect(std.mem.endsWith(u8, try s.read(s.at("/pane/{d}/name", .{try s.focused()})), "/+Tutor\n")); + try std.testing.expect(std.mem.endsWith(u8, try s.read(s.at("/pane/{d}/name", .{try s.focused()})), "/+Help\n")); } test "columns-and-tags: a tag write refuses NUL and the other control characters, the workspace's, a column's and a pane's" { @@ -279,14 +285,18 @@ test "columns-and-tags: a column tag lights the word under the mouse, is clicked try s.write("/mousein", s.at("m {d} 1 1\nm {d} 1 0\n", .{ x + 3, x + 3 })); for (0..4) |k| try expectEqualStrings(lit, try s.bg(x + k, 1)); try std.testing.expect(!std.mem.eql(u8, lit, try s.bg(x + 4, 1))); - // A clicked tag is in normal mode: `i` types at its caret. - try s.keys("\u{F00D}iHelp "); - try std.testing.expect(std.mem.startsWith(u8, try s.read(tag), "Help New Term")); - try std.testing.expectEqual(x + 5, (try s.cursor()).?[0]); + // A clicked tag is in normal mode: `i` types at its caret, after its + // computed words (UX K'1). + const lead = "New Term Joincol Delcol ".len; + try s.keys("\u{F00D}"); + try s.write("/mousein", s.at("m {d} 1 1\nm {d} 1 0\n", .{ x + lead, x + lead })); + try s.keys("iHelp "); + try expectEqualStrings("New Term Joincol Delcol Help ", try s.read(tag)); + try std.testing.expectEqual(x + lead + 5, (try s.cursor()).?[0]); // A tag one short of its room: its caret at the end is drawn on the // last cell, and one more letter scrolls the text, never the caret. const as: [80]u8 = @splat('a'); - const row = as[0 .. width - 1]; + const row = as[0 .. width - 1 - lead]; try s.replace(tag, row); try s.keys("\u{F018}"); try std.testing.expectEqual(x + width - 1, (try s.cursor()).?[0]); diff --git a/test/behaviour/keys.zig b/test/behaviour/keys.zig index 9eb33ac2..2274e73a 100644 --- a/test/behaviour/keys.zig +++ b/test/behaviour/keys.zig @@ -414,11 +414,12 @@ test "keys: zz and zc put the cursor's line in the middle row of an odd view, as for (&lines, 0..) |*l, i| _ = try std.fmt.bufPrint(l, "l{d:0>2}\n", .{i}); var s = try Session.initFile(std.testing.allocator, std.mem.asBytes(&lines)); defer s.deinit(); - s.resize(80, 25); + s.resize(80, 24); for ([_][]const u8{ "15jzz", "ztzc" }) |keys| { try s.keys(keys); - // 80x25 gives the pane 21 rows (the notice row under it): l05 to - // l25, l15 the eleventh + // 80x24 gives the pane 21 rows (the window row and its tag above + // them, the notice row under them; one column, no column row): + // l05 to l25, l15 the eleventh const top = (try s.where("l05"))[1]; try std.testing.expectEqual(top + 10, (try s.where("l15"))[1]); try std.testing.expectEqual(top + 20, (try s.where("l25"))[1]); diff --git a/test/behaviour/modes.zig b/test/behaviour/modes.zig index 47f2ccd2..39bb66c8 100644 --- a/test/behaviour/modes.zig +++ b/test/behaviour/modes.zig @@ -249,10 +249,12 @@ test "modes: window keys walk from a pane up through its column's tag and the wo try std.testing.expect(x0 < right); const tag = s.at("/col/{d}/tag", .{try s.column(0)}); const words = try s.read(tag); - try s.keys("w"); + // On its user's text, after its computed words (UX K'1): `b` moves + // back onto them. + try s.keys("b"); try s.expect(tag, words); const remembered = (try s.cursor()).?; - try std.testing.expect(remembered[0] > x0); + try std.testing.expect(remembered[0] < x0); // Across to the right column's tag, and back to where the caret was. try s.keys("\x17l"); try std.testing.expect((try s.cursor()).?[0] >= right); diff --git a/test/behaviour/tags.zig b/test/behaviour/tags.zig index e7779b86..fcef9fd3 100644 --- a/test/behaviour/tags.zig +++ b/test/behaviour/tags.zig @@ -255,12 +255,13 @@ test "tags: a tag with more lines than rows scrolls to keep its caret in view" { try s.keys("\x1bgg"); try std.testing.expectEqual(.{ x, y }, try s.where("/test.txt")); try std.testing.expectEqual(y, (try s.cursor()).?[1]); - // A column tag is one row, as acme's: its lines are joined. + // A column tag is one row, as acme's: its lines are joined. Its user's + // text brings the column row (UX K'2): the pane one row lower, no more. var layout = std.mem.tokenizeScalar(u8, try s.read("/layout"), ' '); const col_tag = s.at("/col/{s}/tag", .{layout.next().?}); try s.replace(col_tag, "New\nC1\nC2"); try std.testing.expect(std.mem.indexOfScalar(u8, try s.read(col_tag), '\n') == null); - try std.testing.expectEqual(y, (try s.where("/test.txt"))[1]); + try std.testing.expectEqual(y + 1, (try s.where("/test.txt"))[1]); } test "tags: a long pane tag wraps onto rows, and a click on a wrapped row maps to the whole tag's address" { |
