Files
openidea/evals/lib/golden.test.ts
T
l0ng-ai b2d506a929 test(evals): measure Java code intelligence as the user sees it (#2758)
pnpm eval drives the production workbench in Chromium against a release openidea-server and real jdtls, judging each scenario (navigation, usages, implementations, gutter markers, lenses, diagnostics, completion, docs, rename) on time to feedback, first and complete result, and checking results against evals/java/golden/. Supporting changes: data-* hooks in the usages popup, hints and rows; a shared in-page Tauri shim for smoke tests and evals; a shared perf bundle builder; language-server versions in .github/tool-versions.env shared with Language smoke; the eval agent skill.
2026-11-12 12:17:07 +08:00

41 lines
1.3 KiB
TypeScript

import { describe, expect, test } from "vitest";
import { compare, toolDrift } from "./golden.ts";
describe("compare", () => {
test("a perfect answer", () => {
expect(compare({ usages: ["a:1", "b:2"] }, { usages: ["b:2", "a:1"] })).toEqual({
recall: 1,
precision: 1,
missing: [],
extra: [],
});
});
test("dropped and extra results lower recall and precision", () => {
const c = compare({ usages: ["a:1", "c:3"] }, { usages: ["a:1", "b:2"] });
expect(c.recall).toBe(0.5);
expect(c.precision).toBe(0.5);
expect(c.missing).toEqual(["usages: b:2"]);
expect(c.extra).toEqual(["usages: c:3"]);
});
test("groups are part of the identity", () => {
expect(compare({ read: ["a:1"] }, { write: ["a:1"] }).recall).toBe(0);
});
test("nothing expected", () => {
expect(compare({}, {})).toMatchObject({ recall: 1, precision: 1 });
expect(compare({ usages: ["a:1"] }, {})).toMatchObject({ recall: 1, precision: 0 });
});
test("nothing found", () => {
expect(compare({}, { usages: ["a:1"] })).toMatchObject({ recall: 0, precision: 0 });
});
});
test("toolDrift lists tools that changed since the recording", () => {
expect(toolDrift({ tools: { jdtls: "1.63.0", java: "21" }, groups: {} }, { jdtls: "1.64.0", java: "21" })).toEqual([
"jdtls: 1.63.0 → 1.64.0",
]);
});