Files
scriptc/packages/compiler/src/native/task.test.ts
Chris Tate c08ab955ae Enforce linting and consistent source formatting
- Enforce oxlint and oxfmt for owned JavaScript and TypeScript with independent CI checks.
- Preserve compiler import boundaries and protected fixtures while cleaning up lint findings.
- Standardize source formatting and validate import, fixture, and embedded-source protections.
2026-10-05 17:51:24 -05:00

26 lines
814 B
TypeScript

import { expect, test } from "vitest";
import { runCompilerTask } from "./task.js";
test("compiler work starts after the caller can suspend and preserves its result", async () => {
const events: string[] = [];
const result = { ok: true, diagnostics: [] };
const pending = runCompilerTask(() => {
events.push("compile");
return result;
});
events.push("caller");
expect(events).toEqual(["caller"]);
expect(await pending).toBe(result);
expect(events).toEqual(["caller", "compile"]);
});
test("synchronous compiler failures reject the task without escaping its microtask", async () => {
const failure = new Error("compiler failed");
await expect(
runCompilerTask(() => {
throw failure;
}),
).rejects.toBe(failure);
expect(await runCompilerTask(() => 42)).toBe(42);
});