import { expect, test } from "bun:test"; import { compile, diagnose } from "../src/index.ts"; test("compiler output remains snapshot-compatible for the canonical component contract", () => { const source = `import Button from "@wrnexus/ui/components/Button.wrn"; component Counter { props { label: string = "Count" } state { count = 0 } outputs { change(value: number) } functions { client function increment(): void { count = count + 1 output.change(count) } } view { } } `; const result = compile(source, "Counter.wrn"); expect({ code: result.code, diagnostics: result.richDiagnostics }).toMatchSnapshot(); }); test("diagnostics tolerate deterministic malformed-source fuzz cases", () => { let state = 0x8f3a21; const alphabet = "{}[]()<>=:/@#$'\"` abcdefghijklmnopqrstuvwxyz0123456789\n\t"; for (let sample = 0; sample < 500; sample++) { let source = ""; const length = 1 + (state % 180); for (let index = 0; index < length; index++) { state = (Math.imul(state, 1664525) + 1013904223) >>> 0; source += alphabet[state % alphabet.length]; } expect(() => diagnose(source, { file: `fuzz-${sample}.wrn` })).not.toThrow(); } });