Files
scriptc/packages/runtime/test/closure.test.ts
Malte Ubl 70dfdbd61e Route strings, arrays and emitted records through the small-object allocator
Move the allocator into scr_alloc.c with inline fast paths in scr_runtime.h;
strings, array headers/slot buffers, and emitted acyclic records/classes
(scr_rt_calloc/scr_rt_free) now use it. Adds scr_alloc.test.{c,ts}.
2026-10-08 15:01:26 -05:00

50 lines
1.5 KiB
TypeScript

import { execFile } from "node:child_process";
import { mkdir } from "node:fs/promises";
import { join } from "node:path";
import { promisify } from "node:util";
import { expect, test } from "vitest";
const execFileAsync = promisify(execFile);
const testDir = import.meta.dirname;
const srcDir = join(testDir, "../src");
test("closure/box runtime: RC cascades clean under ASan + audit", async () => {
const buildDir = join(testDir, "build");
await mkdir(buildDir, { recursive: true });
const bin = join(buildDir, "test_closure");
await execFileAsync("clang", [
"-std=c11",
"-O1",
"-Wall",
"-Wextra",
"-fsanitize=address",
"-DSCR_RC_AUDIT",
"-o",
bin,
join(testDir, "test_closure.c"),
join(srcDir, "scr_closure.c"),
join(srcDir, "scr_string.c"),
join(srcDir, "scr_array.c"),
join(srcDir, "scr_json.c"),
join(srcDir, "scr_bigint.c"),
join(srcDir, "scr_map.c"),
join(srcDir, "scr_union.c"),
join(srcDir, "scr_number.c"),
join(srcDir, "scr_cycle.c"),
join(srcDir, "scr_alloc.c"),
join(srcDir, "scr_bytes.c"),
join(srcDir, "scr_shared.c"),
join(srcDir, "scr_lib.c"),
join(srcDir, "scr_console.c"),
join(srcDir, "scr_path.c"),
join(srcDir, "scr_url.c"),
join(srcDir, "scr_url_params.c"),
join(srcDir, "scr_error.c"),
join(srcDir, "scr_exception.c"),
join(srcDir, "scr_object.c"),
...(process.platform === "linux" ? ["-D_GNU_SOURCE", "-lm"] : []),
]);
const { stderr } = await execFileAsync(bin);
expect(stderr.trim()).toBe("all closure tests passed");
});