diff options
Diffstat (limited to 'src/ninep/ctl.zig')
| -rw-r--r-- | src/ninep/ctl.zig | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/ninep/ctl.zig b/src/ninep/ctl.zig index c2a78fb8..2c6d2010 100644 --- a/src/ninep/ctl.zig +++ b/src/ninep/ctl.zig @@ -2079,6 +2079,42 @@ test "a script whose interpreter is not there: Tty refuses it up front, only an try testing.expect(!p.panes[id].?.shell_failed); } +test "a language server question that finds nothing, cannot be answered, or is asked of no file fails, and a write to an image's body is refused" { + const p = try withFile(testing.allocator, "x\n"); + defer p.deinit(); + const id = p.active; + // Asked of a pane that is no file's: at once. + _ = wr(p, root_exec, "Recent\n"); + const listed = p.paneBySerial(try std.fmt.parseInt(u32, std.mem.trimEnd(u8, rd(p, root_exec, 0, 64).bytes, "\n"), 10)).?; + p.lspRequest(listed, .incoming_calls, ""); + try testing.expect(std.mem.indexOf(u8, p.panes[listed].?.msg[0..p.panes[listed].?.msg_len], "Callers: only a file's pane asks") != null); + // Nothing found: Callers says so, and the waiting write hears it. + p.fs.late_failure_len = 0; + p.lspRequest(id, .incoming_calls, ""); + try testing.expect(p.lsp_wait != null); + p.lspResponse(p.lsp_wait.?.id, ""); + try testing.expectEqualStrings("Callers: no callers, not found", p.fs.late_failure[0..p.fs.late_failure_len]); + // A backend that cannot answer says why. + p.fs.late_failure_len = 0; + p.lspRequest(id, .outgoing_calls, ""); + p.lspResponse(p.lsp_wait.?.id, "@none zls does not answer call hierarchy\n"); + try testing.expectEqualStrings("Callees: zls does not answer call hierarchy", p.fs.late_failure[0..p.fs.late_failure_len]); + // No answer at all. + p.fs.late_failure_len = 0; + p.lspRequest(id, .hover, ""); + p.lspResponse(p.lsp_wait.?.id, null); + try testing.expectEqualStrings("Hover: the language server did not answer", p.fs.late_failure[0..p.fs.late_failure_len]); + // No diagnostics is no failure. + p.fs.late_failure_len = 0; + p.lspRequest(id, .diagnostics, ""); + p.lspResponse(p.lsp_wait.?.id, ""); + try testing.expectEqual(@as(u16, 0), p.fs.late_failure_len); + // An image's body takes no write. + const slot = p.freeSlot().?; + const img = try pardes.panes.Image.create(p, slot, "/tmp/pardes-no-such.png", try p.image_gpa.dupe(u8, "not a png")); + try testing.expectEqual(E.INVAL, wr(p, Node.of(img.serial, .body), "text\n").errno()); +} + test "every EINVAL a write gets says why, in its err record too; DEL is a control character in a line" { const p = try withFile(testing.allocator, "x\n"); defer p.deinit(); |
