food_chain/experiments/ab/variant_check.mjs

13 lines
811 B
JavaScript
Raw Normal View History

2026-09-29 23:45:12 +09:00
import fs from 'node:fs/promises';
import vm from 'node:vm';
for (const file of process.argv.slice(2)) {
const html=await fs.readFile(file,'utf8');
const scripts=[...html.matchAll(/<script[^>]*>([\s\S]*?)<\/script>/g)].map(m=>m[1]);
if(scripts.length!==2) throw new Error(file+': expected 2 scripts, got '+scripts.length);
for(const s of scripts)new vm.Script(s);
const kc={}; vm.runInNewContext(scripts[0],kc);
const kernels=kc.MANDEL_WEBGPU_KERNELS;
if(!kernels||Object.keys(kernels).length!==20)throw new Error(file+': kernel bundle malformed');
for(const k of ['DIRECT_F32_WGSL','FAST_PERTURB_WGSL','UNKNOWN_STATS_WGSL','COLOR_WGSL'])if(typeof kernels[k]!=='string')throw new Error(file+': missing '+k);
console.log('PASS',file.split('/').at(-1),'JS syntax, 19 WGSL kernels + version');
}