Files
scriptc/tests/library-mode/reinit/lib.ts
Chris Tateandmmamedel 9080986166 Add sparse UTF-16 indexing for large strings (#275)
* fix: index large unicode strings sparsely

Co-authored-by: mmamedel <23098414+mmamedel@users.noreply.github.com>

* fix: retain sparse anchors for long ascii prefixes

Co-authored-by: mmamedel <23098414+mmamedel@users.noreply.github.com>

* fix: skip sparse index for proven ASCII strings

Co-authored-by: mmamedel <23098414+mmamedel@users.noreply.github.com>

* fix: complete sparse UTF-16 string indexing

Co-authored-by: mmamedel <23098414+mmamedel@users.noreply.github.com>

* test: rebase static size contracts for sparse index

Co-authored-by: mmamedel <23098414+mmamedel@users.noreply.github.com>

* test: retain sparse checkpoints through ASCII prefix end

Co-authored-by: mmamedel <23098414+mmamedel@users.noreply.github.com>

* fix: retain sparse anchors across threshold append

Co-authored-by: mmamedel <23098414+mmamedel@users.noreply.github.com>

* fix: retain sparse indexes beyond cursor cache

Co-authored-by: mmamedel <23098414+mmamedel@users.noreply.github.com>

* fix: bound sparse string index residency

Co-authored-by: mmamedel <23098414+mmamedel@users.noreply.github.com>

* fix: isolate sparse string index residency

Co-authored-by: mmamedel <23098414+mmamedel@users.noreply.github.com>

* test: restore parseInt oracle outputs

* test: verify committed string oracle

- Regenerate the string case oracle with the active Node executable.\n- Compare the checked-in fixture byte-for-byte before native runtime checks.\n- Keep the Linux parseInt ULP allowance scoped to native output.

---------

Co-authored-by: mmamedel <23098414+mmamedel@users.noreply.github.com>
2026-08-31 17:12:52 -05:00

33 lines
1.0 KiB
TypeScript

// K4 fixture: init re-run determinism. Module state (a scalar, a
// refcounted array, the run-once module guards) fully resets between
// sessions — two init calls produce identical observable outputs, and
// under the sanitize flavor the reset seam asserts zero live heap between
// sessions (the library RC-audit counters).
let counter = 0;
const seen: string[] = [];
export function bump(): number {
counter = counter + 1;
return counter;
}
export function note(s: string): number {
seen.push(s);
return seen.length;
}
export function recall(): string {
return seen.join(",");
}
// Exercise the runtime's lazy sparse UTF-16 side metadata before every
// library re-init. The heap string itself becomes unreachable at the reset;
// the cache must release its owned checkpoints too.
export function indexedUnicode(): number {
const s = "aé😀é".repeat(12000);
const n = Math.floor(s.length / 2);
return s.length + s.charCodeAt(n) + s.slice(n - 1, n + 2).length;
}
console.log(`session start counter=${counter}`);