MCPcopy Create free account
hub / github.com/cortex-js/compute-engine / withStepLimitSentinel

Function withStepLimitSentinel

test/compute-engine/fungrim-loops.test.ts:100–112  ·  view source on GitHub ↗

* Run `fn` with a console.warn spy and assert the MAX_SIMPLIFY_STEPS guard * never trips (i.e. every simplification stayed below the iteration limit).

(fn: () => T)

Source from the content-addressed store, hash-verified

98 * never trips (i.e. every simplification stayed below the iteration limit).
99 */
100function withStepLimitSentinel<T>(fn: () => T): T {
101 const warn = jest.spyOn(console, 'warn').mockImplementation(() => {});
102 try {
103 const result = fn();
104 const tripped = warn.mock.calls.filter((args) =>
105 STEP_LIMIT_WARNING.test(args.map(String).join(' '))
106 );
107 expect(tripped).toEqual([]);
108 return result;
109 } finally {
110 warn.mockRestore();
111 }
112}
113
114/**
115 * simplify(simplify(x)): assert termination within the time budget, a stable

Callers 1

Calls 2

fnFunction · 0.85
mapMethod · 0.65

Tested by

no test coverage detected