io-core-probe.mjs (1624B)
1 // Executes bare computation trees privately on native evaluators. Production IO 2 // envelopes and terminal providers remain gated; no JS evaluator substitution. 3 export async function run(_control,backend){ 4 const base=new URL('../',document.querySelector('script[type=module][src]').src); 5 const fixtures=await(await fetch('/runtime-fixtures.json')).json(),checks=[]; 6 let execute,dispose; 7 const {CompilerWorker}=await import(new URL('runtime/haskell/client.mjs',base)); 8 const client=new CompilerWorker();dispose=()=>client.dispose();await client.request({type:'init',compiler:false}); 9 execute=async fixture=>{await client.request({type:'load',bytes:new Uint8Array(fixture.bytes).buffer,hash:fixture.hash});return JSON.parse((await client.request({type:'io-core',name:'root',arguments:[]})).text);}; 10 const cases=[['pure','completed'],['bind','completed'],['scope','completed'],['child-0','failed'],['child-1','completed'],['unsupported','completed'],['discard-invalid','completed'],['terminal-2','failed'],['terminal-9','cancelled'],['malformed','failed']]; 11 try{ 12 for(const [name,kind]of cases){ 13 const out=await execute(fixtures['v2-run-'+name]); 14 const expected={kind,value:kind==='completed'?'42':null,cleanup:0,tasks:{scopes:0,tasks:0,hosts:0},resources:{resources:0,admissions:0,leases:0},host:{pending:0,replies:0}}; 15 if(JSON.stringify(out)!==JSON.stringify(expected))throw Error(name+': '+JSON.stringify(out)); 16 checks.push(name); 17 } 18 for(let i=0;i<5;i++)await execute(fixtures['v2-run-scope']); 19 checks.push('repeated run retirement and reuse'); 20 }finally{dispose();} 21 return {backend,checks}; 22 }