// SPDX-FileCopyrightText: 2026 Milovann Yanatchkov // SPDX-License-Identifier: MIT // smoke.mjs — Node test of the wasm-bindgen web pkg (engine.test.mjs pattern // from bimr-web). Run via `make smoke` after `make pkg`. import assert from "node:assert/strict"; import { readFileSync } from "node:fs"; function section(name) { console.log(`\n# ${name}`); } async function loadWasm() { const jsUrl = new URL("../pkg/bimr_wasm.js", import.meta.url).href; const bimrWasm = await import(jsUrl); const wasmBytes = readFileSync(new URL("../pkg/bimr_wasm_bg.wasm", import.meta.url)); await bimrWasm.default({ module_or_path: wasmBytes }); return bimrWasm; } const WALL_SRC = `p1 = Point(0,0,0) p2 = Point(500,0,0) l1 = Line(p1,p2) w1 = Wall(l1,20,300)`; async function main() { const wasm = await loadWasm(); section("surface — whole-source only (D8)"); { const exports = Object.keys(wasm).filter((k) => typeof wasm[k] === "function" && !k.startsWith("__")); assert.deepEqual( exports.sort(), ["compile", "default", "initSync"], "no session exports, no side queries", ); } section("compile() — wall to IFCX"); { const out = wasm.compile(WALL_SRC); assert.match(out, /wall-001/); assert.match(out, /ifcx_alpha/); assert.match(out, /faceVertexIndices/); } section("compile() — error handling"); { const out = wasm.compile("w1 = Wall(missing)"); assert.match(out, /error/); } console.log("\nAll smoke tests passed."); } main().catch((e) => { console.error(e); process.exit(1); });