Files
reverse-engineering-anything/tests/evaluation/limitClassGuard.test.ts
T
morluto 6eb0e3dac6 refactor(native): report bounded string reads that stop at their allowance as decode limits (#11174)
* refactor(native): report bounded string reads that stop at their allowance as decode limits

* fix(verify): count generic and multi-line plain-Error limit classes
2026-11-15 22:02:20 +08:00

36 lines
1.0 KiB
TypeScript

import { expect, it } from "vitest";
import { localLimitErrorClassCount } from "../../scripts/verify/limit-class-guard.mjs";
it("counts plain-Error limit classes in every layout", () => {
expect(
localLimitErrorClassCount("class ProbeLimitFailure extends Error {}"),
).toBe(1);
expect(
localLimitErrorClassCount(
"export class ProbeBudgetError<T> extends Error {}",
),
).toBe(1);
expect(
localLimitErrorClassCount(
"class ProbeExhausted<T extends Map<string, number>>\n extends Error {}",
),
).toBe(1);
expect(
localLimitErrorClassCount("class ProbeExceeded\n extends Error {}"),
).toBe(1);
});
it("ignores classes on the shared owners and unrelated names", () => {
expect(
localLimitErrorClassCount(
'class ProbeLimit extends ParseFailureError<"limit"> {}',
),
).toBe(0);
expect(localLimitErrorClassCount("class ProbeFailure extends Error {}")).toBe(
0,
);
expect(
localLimitErrorClassCount("class ProbeLimit extends ErrorBase {}"),
).toBe(0);
});