Files
oh-my-pi/packages/coding-agent/test/fixtures/computer-schema-construction-preload.ts
T
2026-07-27 00:39:09 +00:00

20 lines
697 B
TypeScript

import { spyOn } from "bun:test";
import * as arktype from "arktype";
declare global {
var __computerCoordinateSchemaConstructionCount: number;
}
const coordinateDefinition = "0 <= number.integer <= 2147483647";
globalThis.__computerCoordinateSchemaConstructionCount = 0;
const originalType = arktype.type;
const countedType = ((...args: unknown[]) => {
if (args[0] === coordinateDefinition) {
globalThis.__computerCoordinateSchemaConstructionCount += 1;
}
return Reflect.apply(originalType, undefined, args);
}) as typeof originalType;
Object.assign(countedType, originalType);
const typeSpy = spyOn(arktype, "type").mockImplementation(countedType);
Object.assign(typeSpy, originalType);