diff options
Diffstat (limited to 'test')
| -rw-r--r-- | test/lspbench.zig | 13 | ||||
| -rw-r--r-- | test/lspfixture/broken.zig | 25 |
2 files changed, 34 insertions, 4 deletions
diff --git a/test/lspbench.zig b/test/lspbench.zig index 73b82e2b..307bdc49 100644 --- a/test/lspbench.zig +++ b/test/lspbench.zig @@ -72,18 +72,23 @@ const anchors = [_]Anchor{ .{ .file = "src/modal.zig", .needle = "pub fn ", .at = 7, .kind = .document_symbols, .expect = "" }, // references to a symbol used in several places .{ .file = "src/lsp.zig", .needle = "pub const Kind", .at = 11, .kind = .references, .expect = "" }, - // diagnostics on a file that should have none - .{ .file = "src/lsp.zig", .needle = "const std", .at = 6, .kind = .diagnostics, .expect = "" }, + // Diagnostics and format probe a DELIBERATELY BROKEN fixture, never the + // real source. On a clean corpus the correct answer is nothing, which is + // byte-identical to "this backend has no diagnostics" — a blind spot that + // rewards emitting a filler row and punishes honesty. test/lspfixture has + // an unused local (semantic: needs a compiler front end, not a tokenizer) + // and a misformatted fn (needs a formatter), so both probes have real work. + .{ .file = "test/lspfixture/broken.zig", .needle = "unused_local", .at = 0, .kind = .diagnostics, .expect = "broken.zig" }, // the remaining kinds, probed once each so the matrix is complete .{ .file = "src/lsp.zig", .needle = "lineCol(source", .at = 0, .kind = .declaration, .expect = "" }, .{ .file = "src/lsp.zig", .needle = "out: *std.ArrayList(u8)", .at = 10, .kind = .type_definition, .expect = "" }, .{ .file = "src/lsp.zig", .needle = "pub const Kind", .at = 11, .kind = .implementation, .expect = "" }, .{ .file = "src/lsp.zig", .needle = "pub const Kind", .at = 11, .kind = .select_refs, .expect = "" }, - .{ .file = "src/lsp.zig", .needle = "pub fn query", .at = 7, .kind = .format, .expect = "" }, + .{ .file = "test/lspfixture/broken.zig", .needle = "badly_spaced", .at = 0, .kind = .format, .expect = "" }, .{ .file = "src/lsp.zig", .needle = "pub fn query", .at = 7, .kind = .code_action, .expect = "" }, .{ .file = "src/lsp.zig", .needle = "pub fn query", .at = 7, .kind = .rename, .expect = "" }, .{ .file = "src/lsp.zig", .needle = "pub const Kind", .at = 11, .kind = .workspace_symbols, .expect = "" }, - .{ .file = "src/lsp.zig", .needle = "const std", .at = 6, .kind = .workspace_diagnostics, .expect = "" }, + .{ .file = "test/lspfixture/broken.zig", .needle = "unused_local", .at = 0, .kind = .workspace_diagnostics, .expect = "broken.zig" }, }; const Result = struct { diff --git a/test/lspfixture/broken.zig b/test/lspfixture/broken.zig new file mode 100644 index 00000000..22c86c9b --- /dev/null +++ b/test/lspfixture/broken.zig @@ -0,0 +1,25 @@ +//! A deliberately defective file, for the lspbench diagnostics and format +//! probes. It is NOT built and NOT imported by anything — `zig build` never +//! sees it, and the snapshot corpus never opens it. +//! +//! Why it exists: on a clean, already-formatted corpus the CORRECT answer to +//! "what is wrong with this file" is nothing, which the harness cannot tell +//! apart from a backend that has no diagnostics at all. That blind spot +//! rewards a backend for emitting a filler row and punishes one for being +//! honest, so the probes point here instead, where there is something real to +//! find: +//! +//! - `unused_local` is a SEMANTIC error. A tokenizer cannot see it; it takes +//! a compiler front end (AstGen/ZIR, or `zig ast-check`). +//! - the spacing in `badly_spaced` is a FORMATTING difference, which only a +//! formatter reports. +//! +//! Keep both. Removing either silently turns a probe back into a blind one. +pub fn hasUnusedLocal() u32 { + const unused_local = 41; + return 7; +} + +pub fn badly_spaced ( a : u32 , b : u32 ) u32 { + return a+b; +} |
