// Runs the MATLAB validation script (../matlab/recorder_validate.m) through // numbl in Node: closed-form identities of the passive acoustics, emergent // register selection and overblowing, exact reproducibility of the seeded // turbulence, and the pinned end-to-end diagnostics. // Run with: npm run selftest import { readFileSync, readdirSync } from 'fs'; import { join, dirname } from 'path'; import { fileURLToPath } from 'url'; import { executeCode } from 'numbl'; const matlabDir = join(dirname(fileURLToPath(import.meta.url)), '..', '..', 'matlab'); const workspaceFiles = readdirSync(matlabDir) .filter((f) => f.endsWith('.m')) .map((f) => ({ name: f, source: readFileSync(join(matlabDir, f), 'utf8') })); const main = workspaceFiles.find((f) => f.name === 'recorder_validate.m')!; const t0 = performance.now(); const result = executeCode(main.source, { displayResults: false }, workspaceFiles, 'recorder_validate.m'); const text = result.output.join(''); process.stdout.write(text); console.log(`total time : ${((performance.now() - t0) / 1000).toFixed(2)} s`); if (text.includes('MISMATCH') || text.includes('FAILED')) { process.exit(1); }