diff options
| author | 2026-10-14 10:38:17 +0000 | |
|---|---|---|
| committer | 2026-10-14 10:38:17 +0000 | |
| commit | 93340f97dce404a008f489729df144ace53528ab (patch) | |
| tree | cbada309f3a4683d083d84484f11952418c8dd2b /tests/drivers/lsp_test.js | |
| parent | todo: handoff section with state, conventions, in-flight work and architectur... (diff) | |
fix std hover, full capture terminator, bare static calls, void main in run-only images
- hover: a symbol from an embedded library source (tinyvm:std.zc, tinyvm:icon.zc) was
looked up only in the document; look it up by its qualified name in the library source
(hover_embedded_sym), and render a method found that way by its line (bs_hover).
- std.capture: allocate one word more than the 256 it holds, so end() terminates inside the buffer.
- a bare call to a static function of the enclosing struct resolves like a bare struct constant
(mstruct is set for every non-generic struct's methods); the struct's own wins over a global.
- run.zc declares main untyped (fn main();), so a run-only image accepts int, void or untyped main
with both compilers.
Diffstat (limited to 'tests/drivers/lsp_test.js')
| -rw-r--r-- | tests/drivers/lsp_test.js | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/drivers/lsp_test.js b/tests/drivers/lsp_test.js index 0f4abe1..2ad9181 100644 --- a/tests/drivers/lsp_test.js +++ b/tests/drivers/lsp_test.js @@ -199,6 +199,18 @@ const tmsrc = 'struct point {\n\tlet x;\n\t// the sum of the parts\n\tint sum(in hv = hover(tmsrc, 7, at(tmsrc, 7, 'sum')); check(hv && hv.includes('int sum(int k)') && hv.includes('the sum of the parts'), 'a typed method shows its return type and parameters', hv); +// members of the embedded standard library hover like the document's own: the group's static +// function, the group, and a top-level function, each with the comment from std.zc +const stdsrc = 'include rt, std;\nfn main() { char[24] b; rt.put_s(std.Text.itoa(5, b)); return std.array_contains; }\n'; +hv = hover(stdsrc, 1, at(stdsrc, 1, 'itoa')); +check(hv && hv.includes('static int itoa(int n, char* dst)') && hv.includes('writes n in decimal into dst'), 'hover on a std group function shows its signature and doc from std.zc', hv); +hv = hover(stdsrc, 1, at(stdsrc, 1, 'Text')); +check(hv && hv.includes('struct Text') && hv.includes('helpers for char* strings'), 'hover on a std group shows the comment of the group', hv); +hv = hover(stdsrc, 1, at(stdsrc, 1, 'array_contains')); +check(hv && hv.includes('array_contains<T>') && hv.includes('true when an element equals value'), 'hover on a top-level std function shows its doc', hv); +hv = hover(stdsrc, 1, at(stdsrc, 1, 'put_s')); +check(hv && hv.includes('int put_s(char* s)'), 'hover on a runtime function still works beside the std ones', hv); + // externs are declarations, so they draw no "never reassigned" hint const ext = 'extern double sqrt(double);\nextern double pow(double x, double y);\nfn main() {\n\treturn 0;\n}\n'; r = run([init(1), open(A, ext)]); |
