diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-05 10:40:00 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-05 10:57:08 -0300 |
| commit | e6a9e2a3bbc5954d2c562019b3ce2983bb98b9cc (patch) | |
| tree | 84b50c6a5103acdba0a55f919f1f466393559d51 /test/behaviour | |
| parent | 9941d55222a913ab353fedb4451092be0d958206 (diff) | |
| download | pardes-e6a9e2a3bbc5954d2c562019b3ce2983bb98b9cc.tar.gz pardes-e6a9e2a3bbc5954d2c562019b3ce2983bb98b9cc.zip | |
test: T1 asks the language words' servers, the suite next-tests.md said was missing: a Session made by initLanguage performs each lsp effect as a host does (host_io.Lsp, on the session's thread and at once; host_io is pub in the core for it), a .rs file's server the scripted one (test/lspmock.zig, built for the session's module as for the snapshot scripts), and test/behaviour/callstack.zig pins the guide's Call hierarchy through it: the tree +Callstack shows, and CallstackDepth bounding the walk
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'test/behaviour')
| -rw-r--r-- | test/behaviour/callstack.zig | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/test/behaviour/callstack.zig b/test/behaviour/callstack.zig new file mode 100644 index 00000000..42448031 --- /dev/null +++ b/test/behaviour/callstack.zig @@ -0,0 +1,61 @@ +//! docs/typ/guide.typ, Call hierarchy <callstack>, asked of the scripted +//! language server (test/lspmock.zig): `add` in lib.rs is called twice by +//! `main` in main.rs, and `main` by itself. +const std = @import("std"); +const Session = @import("session").Session; + +/// main.rs and lib.rs in a directory of their own, main.rs shown with its +/// cursor on the first call of `add`; its pane's serial. +fn openMain(s: *Session, tmp: *std.testing.TmpDir) !u32 { + try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "main.rs", .data = "mod lib;\n\nfn main() {\n let x = add(1, 2);\n let y = add(3, 4);\n let _ = x + y;\n}\n" }); + try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "lib.rs", .data = "// mock fixture\npub fn add(a: i32, b: i32) -> i32 {\n a + b\n}\n" }); + var buf: [4096]u8 = undefined; + const dir = buf[0..try tmp.dir.realPath(std.testing.io, &buf)]; + return s.lookFile(s.at("{s}/main.rs:4:13", .{dir})); +} + +test "callstack: Callstack opens +Callstack, the outermost callers first, each with its signature and its call sites, a recursion marked" { + var tmp = std.testing.tmpDir(.{}); + defer tmp.cleanup(); + var s = try Session.initLanguage(std.testing.allocator); + defer s.deinit(); + const main = try openMain(&s, &tmp); + try s.write(s.at("/pane/{d}/ctl", .{main}), "Callstack\n"); + const tree = try s.focused(); + try std.testing.expect(std.mem.endsWith(u8, try s.read(s.at("/pane/{d}/name", .{tree})), "/+Callstack\n")); + try s.expect(s.at("/pane/{d}/body", .{tree}), + \\╰──┬ main.rs:3:4-7 + \\ │ fn main() { + \\ ├─ main.rs:4:13-15 + \\ │ let x = add(1, 2); + \\ ├─ main.rs:5:13-15 + \\ │ let y = add(3, 4); + \\ ╰──┬ main.rs:3:4-7 + \\ │ fn main() { ↻ recursion + \\ ├─ main.rs:4:13-15 + \\ │ let x = add(1, 2); + \\ ╰─ main.rs:5:13-15 + \\ let y = add(3, 4); + \\ + ); +} + +test "callstack: CallstackDepth bounds the walk, its last row inviting a Callstack from a function above" { + var tmp = std.testing.tmpDir(.{}); + defer tmp.cleanup(); + var s = try Session.initLanguage(std.testing.allocator); + defer s.deinit(); + const main = try openMain(&s, &tmp); + try s.write("/ctl", "CallstackDepth 1\n"); + try s.write(s.at("/pane/{d}/ctl", .{main}), "Callstack\n"); + try s.expect(s.at("/pane/{d}/body", .{try s.focused()}), + \\╰──┬ main.rs:3:4-7 + \\ │ fn main() { + \\ ├─ main.rs:4:13-15 + \\ │ let x = add(1, 2); + \\ ╰─ main.rs:5:13-15 + \\ let y = add(3, 4); + \\… continue from a function above with Callstack + \\ + ); +} |
