diff options
Diffstat (limited to 'test/behaviour')
| -rw-r--r-- | test/behaviour/settings.zig | 38 | ||||
| -rw-r--r-- | test/behaviour/tags.zig | 27 |
2 files changed, 19 insertions, 46 deletions
diff --git a/test/behaviour/settings.zig b/test/behaviour/settings.zig index 80573e2f..fdb37fa3 100644 --- a/test/behaviour/settings.zig +++ b/test/behaviour/settings.zig @@ -207,41 +207,15 @@ fn keywordsIn(s: *Session, want: []const u8) !usize { return seen; } -test "settings: Colors off draws a source plain, and on again colours its keywords, the layout as it was, an edit made while off included" { - if (!syntax) return error.SkipZigTest; - for ([_]bool{ false, true }) |edit_while_off| { - var s = try Session.initFile(std.testing.allocator, "pub fn first() void { if (true) {} }\n"); - defer s.deinit(); - const n = try s.focused(); - try s.write(s.at("/pane/{d}/name", .{n}), "/colors.zig\n"); - var ident: []const u8 = "first"; - if (edit_while_off) { - try std.testing.expect(!std.mem.eql(u8, try styleOf(&s, " fn ", 1), try styleOf(&s, "first", 0))); - try s.write("/ctl", "Colors off\n"); - try s.replace(s.at("/pane/{d}/body", .{n}), "pub fn edited() void { if (false) {} }\n"); - ident = "edited"; - } else try s.write("/ctl", "Colors off\n"); - try std.testing.expectEqual(@as(usize, 2), try keywordsIn(&s, try styleOf(&s, ident, 0))); - const layout = try s.read("/layout"); - try s.write("/ctl", "Colors on\n"); - try s.expect("/layout", layout); - const kw = try styleOf(&s, " fn ", 1); - try std.testing.expect(!std.mem.eql(u8, kw, try styleOf(&s, ident, 0))); - try std.testing.expect(!has(kw, "\"bold\":true")); - try std.testing.expectEqual(@as(usize, 2), try keywordsIn(&s, kw)); - } -} - -test "settings: SyntaxBold keywords stay coloured and bold in every row a pane grows into" { +test "settings: keywords stay coloured in every row a pane grows into" { if (!syntax) return error.SkipZigTest; var s = try Session.initFile(std.testing.allocator, std.mem.asBytes(&@as([100][33]u8, @splat("pub fn f() void { if (true) {} }\n".*)))); defer s.deinit(); try s.write(s.at("/pane/{d}/name", .{try s.focused()}), "/resize.zig\n"); - try s.write("/ctl", "SyntaxBold on\n"); s.detach(); try s.write("/ctl", "size 80 8\n"); const kw = try styleOf(&s, " fn ", 1); - try std.testing.expect(has(kw, "\"bold\":true")); + try std.testing.expect(!std.mem.eql(u8, kw, try styleOf(&s, "f()", 0))); for ([_]usize{ 50, 12, 70 }) |rows| { try s.write("/ctl", s.at("size 80 {d}\n", .{rows})); try std.testing.expect(try keywordsIn(&s, kw) >= 2 * (rows - 4)); @@ -272,9 +246,9 @@ test "settings: every on/off setting the root ctl reads flips when its word is w flipped += 1; } // A floor, so a ctl that lists none fails: a bare session's on/off - // words, Colors to PagerColor, are ten. - try std.testing.expect(flipped >= 10); - for ([_][]const u8{ "Colors off", "Wrap off", "Debug on" }) |want| + // words, Wrap, Debug, Verbose and JumpTrail at least, are four. + try std.testing.expect(flipped >= 4); + for ([_][]const u8{ "Wrap off", "Debug on" }) |want| try std.testing.expectEqualStrings(want, try setting(&s, want[0..std.mem.indexOfScalar(u8, want, ' ').?])); try s.write("/ctl", "Theme acme\n"); try s.write("/ctl", "Shell /bin/sh\n"); @@ -289,7 +263,7 @@ fn look(s: *Session, style: []const u8) !struct { bool, []const u8 } { return .{ json.object.get("bold").?.bool, try std.json.Stringify.valueAlloc(a, json.object.get("fg").?, .{}) }; } -test "settings: a keyword is coloured apart from the text beside it, and not bold (SyntaxBold is off by default), at a long file's end" { +test "settings: a keyword is coloured apart from the text beside it, and not bold, at a long file's end" { var s = try Session.initFile(std.testing.allocator, "initial\n"); defer s.deinit(); const n = try s.focused(); diff --git a/test/behaviour/tags.zig b/test/behaviour/tags.zig index 4477e73e..8d04f8ad 100644 --- a/test/behaviour/tags.zig +++ b/test/behaviour/tags.zig @@ -250,15 +250,15 @@ test "tags: a long pane tag wraps onto rows, and a click on a wrapped row maps t try s.write("/ctl", "size 50 12\n"); const n = try s.focused(); try s.write(s.at("/pane/{d}/name", .{n}), "/an/especially/deep/project/path/with/a/long/component/filename.zig"); - try s.write(s.at("/pane/{d}/tag", .{n}), " SyntaxBold"); + try s.write(s.at("/pane/{d}/tag", .{n}), " JumpTrail"); const before = try tag(&s, n); try s.keys(":A"); try std.testing.expect((try s.cursor()).?[0] < 50); - // SyntaxBold is on a row of its own, below the path's. - try std.testing.expect((try s.where("SyntaxBold"))[1] > (try s.where("/an/"))[1]); + // JumpTrail is on a row of its own, below the path's. + try std.testing.expect((try s.where("JumpTrail"))[1] > (try s.where("/an/"))[1]); // Its last character, which a wrapped row's offset not mapped back misses. - try s.click("SyntaxBold", "SyntaxBol".len, 2); - try std.testing.expect(std.mem.indexOf(u8, try s.read("/ctl"), "SyntaxBold on\n") != null); + try s.click("JumpTrail", "JumpTrai".len, 2); + try std.testing.expect(std.mem.indexOf(u8, try s.read("/ctl"), "JumpTrail on\n") != null); try std.testing.expectEqualStrings(before, try tag(&s, n)); } @@ -268,20 +268,20 @@ test "tags: a word the tag's wrapping breaks across rows is still one word to a s.detach(); try s.write("/ctl", "size 50 12\n"); const n = try s.focused(); - // Lengthen the path until the wrap splits the word after "Synt" (a + // Lengthen the path until the wrap splits the word after "Jump" (a // rename resets the tag's text, so it is written again each time). var pad: usize = 1; while (pad < 80) : (pad += 1) { try s.write(s.at("/pane/{d}/name", .{n}), s.at("/{s}/f.zig", .{(&@as([80]u8, @splat('a')))[0..pad]})); - try s.write(s.at("/pane/{d}/tag", .{n}), " SyntaxBold"); + try s.write(s.at("/pane/{d}/tag", .{n}), " JumpTrail"); var rows = std.mem.splitScalar(u8, try s.screen(), '\n'); const split = while (rows.next()) |row| { - if (std.mem.endsWith(u8, std.mem.trimEnd(u8, row, " "), "Synt")) break true; + if (std.mem.endsWith(u8, std.mem.trimEnd(u8, row, " "), "Jump")) break true; } else false; if (split) break; } else return error.NoSplit; - try s.click("Synt", 1, 2); - try std.testing.expect(std.mem.indexOf(u8, try s.read("/ctl"), "SyntaxBold on\n") != null); + try s.click("Jump", 1, 2); + try std.testing.expect(std.mem.indexOf(u8, try s.read("/ctl"), "JumpTrail on\n") != null); } /// A click on the tag's path, at its last character: a name drafted @@ -296,18 +296,18 @@ test "tags: a name drafted in the tag commits with Enter, cancels with two Escs, defer s.deinit(); const n = try s.focused(); const name = s.at("/pane/{d}/name", .{n}); - try s.write(s.at("/pane/{d}/tag", .{n}), " SyntaxBold"); + try s.write(s.at("/pane/{d}/tag", .{n}), " JumpTrail"); for ([_]bool{ false, true }) |commit| { const path = std.mem.trimEnd(u8, try s.read(name), "\n"); try clickPathEnd(&s, path); try s.keys("\x15/new name.zig"); try s.expect(name, s.at("{s}\n", .{path})); - _ = try s.where("/new name.zig Save Term Collapse Del SyntaxBold"); + _ = try s.where("/new name.zig Save Term Collapse Del JumpTrail"); try s.expect(s.at("/pane/{d}/body", .{n}), "original body\n"); // Esc keeps the draft pending; a second drops it. try s.keys(if (commit) "\n" else "\x1b\x1b"); try s.expect(name, if (commit) "/new name.zig\n" else "/test.txt\n"); - try std.testing.expectEqualStrings(s.at("{s} Save Term Collapse Del SyntaxBold", .{if (commit) "/new name.zig" else "/test.txt"}), try tag(&s, n)); + try std.testing.expectEqualStrings(s.at("{s} Save Term Collapse Del JumpTrail", .{if (commit) "/new name.zig" else "/test.txt"}), try tag(&s, n)); // The keyboard is the body's again. try std.testing.expect((try s.cursor()).?[1] != (try s.where("Save Term"))[1]); } @@ -464,7 +464,6 @@ test "tags: a pane tag's file name is tinted, its directory, dirty marker and wo var s = try Session.initFile(std.testing.allocator, "body\n"); defer s.deinit(); const n = try s.focused(); - try s.write("/ctl", "FocusTint off\n"); try s.write(s.at("/pane/{d}/name", .{n}), "/project/界file.zig\n"); try s.write(s.at("/pane/{d}/dirty", .{n}), "1"); const x0, const y = try s.where("/project/"); |
