const fs = require("fs"); const path = require("path"); const root = path.resolve(__dirname, ".."); const render = fs.readFileSync(path.join(root, "js", "render.js"), "utf8"); const spatial = fs.readFileSync(path.join(root, "js", "sim_core.js"), "utf8"); const budget = fs.readFileSync(path.join(root, "js", "world_spatial_budget.js"), "utf8"); function ok(cond, msg) { if (!cond) throw new Error(msg); console.log(`[OK] ${msg}`); } ok(render.includes("_renderStaticVisibleCache") && render.includes("renderStaticVersion"), "static visible render stacks are version-cached"); ok(!render.includes("insertionSortNearPrevious") && render.includes("dynamicLayered.sort(compareRenderEntries)"), "dynamic sorting uses native sort without previous-order bookkeeping"); ok(render.includes("mergeSortedRenderEntries") && render.includes("mergeSortedBackItems"), "static and dynamic sorted stacks are merged linearly"); ok(spatial.includes("linkRenderCells") && spatial.includes("addLinkRenderItem") && spatial.includes("rebuildLinkRenderItems"), "links use dedicated AABB render spatial cells"); ok(!render.includes("for (const type of LINK_RENDER_TYPES)"), "per-frame full link type fallback scan is removed"); ok(render.includes("drawCarriedPlushieAtOwner") && !render.includes("syncCarriedPlushieToOwner"), "carried plushie rendering no longer synchronizes simulation coordinates"); ok(render.includes("entity._renderCullRadius = value"), "eligible fixed cull radii are cached"); ok(render.includes("it._renderSortY = renderLayerSortY(it)"), "back-layer sort keys are computed before sorting"); ok(budget.includes("this.renderStaticVersion = (this.renderStaticVersion || 0) + 1"), "static spatial rebuilds invalidate the render cache");