Files
reverse-engineering-anything/src/domain/appendAll.test.ts
T
gensokyo-devandgensokyo-dev 3ae23bfeff fix: append target-sized arrays without call spreads
`target.push(...items)` passes every item as a call argument and
overflows the stack once a target-sized array grows past the engine's
argument limit. This class was fixed one site at a time in #10304,
#10343, #10362 and #8632. Add one shared appendAll helper in
src/domain and use it at the remaining sites whose arrays grow with the
input: XML member counting, app-task row suggestions, native call
routes and unresolved calls, call-path caveats, environment-manifest
merges, reference-source import entries, dyld trace edges and JS
symbolic flow values. The web bundle merge from the previous commit now
uses the shared helper too.

Bounded spreads (fixed literals, page-sized reads) are left as they are.

Refs #10445
Refs #10342

Co-Authored-By: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>
2026-11-14 14:59:41 +01:00

18 lines
600 B
TypeScript

import { expect, it } from "vitest";
import { appendAll } from "./appendAll.js";
it("appends an array wider than any call-argument limit", () => {
// Where `push(...wide)` overflows depends on the engine's stack; a loop
// has no such limit.
const wide = Array.from({ length: 2_000_000 }, (_, index) => index);
const target = [-1];
expect(appendAll(target, wide)).toBe(target);
expect(target).toHaveLength(2_000_001);
expect(target.at(-1)).toBe(1_999_999);
});
it("appends any iterable in order", () => {
expect(appendAll(["a"], new Set(["b", "c"]))).toEqual(["a", "b", "c"]);
});