import {test,expect,vi} from 'vitest';
function val(v){return typeof v==='function'?{type:'function',name:v.name,length:v.length,tag:Object.prototype.toString.call(v),mock:vi.isMockFunction(v)}:v!==null&&typeof v==='object'?{type:'object',tag:Object.prototype.toString.call(v),keys:Reflect.ownKeys(v).map(String)}:{type:typeof v,value:v}}
function shape(v){if(v===null||(typeof v!=='object'&&typeof v!=='function'))return val(v);return {type:typeof v,tag:Object.prototype.toString.call(v),nullPrototype:Object.getPrototypeOf(v)===null,objectPrototype:Object.getPrototypeOf(v)===Object.prototype,functionPrototype:Object.getPrototypeOf(v)===Function.prototype,keys:Reflect.ownKeys(v).map(k=>typeof k==='symbol'?'symbol:'+String(k.description):k),descriptors:Reflect.ownKeys(v).map(k=>{const d=Object.getOwnPropertyDescriptor(v,k);return {key:typeof k==='symbol'?'symbol:'+String(k.description):k,value:val(d.value),get:typeof d.get,set:typeof d.set,writable:d.writable??null,enumerable:d.enumerable,configurable:d.configurable}}),prototype:typeof v==='function'&&Object.hasOwn(v,'prototype')?{keys:Reflect.ownKeys(v.prototype).map(String),descriptors:Reflect.ownKeys(v.prototype).map(k=>{const d=Object.getOwnPropertyDescriptor(v.prototype,k);return {key:String(k),value:val(d.value),get:typeof d.get,set:typeof d.set,writable:d.writable??null,enumerable:d.enumerable,configurable:d.configurable}})}:null}}
function member(v,key){const d=Object.getOwnPropertyDescriptor(v,key);return d?{value:val(d.value),get:typeof d.get,set:typeof d.set,writable:d.writable??null,enumerable:d.enumerable,configurable:d.configurable}:null}
import * as ns0 from './ordinary.cjs';
test('strict ordinary original receiver',async()=>{const first=ns0;const second=await vi.importActual('./ordinary.cjs');const raw=first.default;let unbound;try{unbound={value:await (0,raw)()}}catch(error){unbound={error:{name:error.name,message:error.message}}}const row={name:"ordinary",namespace:shape(first),raw:shape(raw),defaultDescriptor:member(first,'default'),same:first===second,rawSame:raw===second.default,unbound,bound:await raw.call({label:'bound'}),methodBound:raw.method.call({label:'member-bound'}),rawLabel:raw.label};console.log('WS2_CALLABLE_MUTATION:'+JSON.stringify(row));expect(row.same).toBe(true)});
import * as ns1 from './async.cjs';
test('strict async original receiver',async()=>{const first=ns1;const second=await vi.importActual('./async.cjs');const raw=first.default;let unbound;try{unbound={value:await (0,raw)()}}catch(error){unbound={error:{name:error.name,message:error.message}}}const row={name:"async",namespace:shape(first),raw:shape(raw),defaultDescriptor:member(first,'default'),same:first===second,rawSame:raw===second.default,unbound,bound:await raw.call({label:'bound'}),methodBound:raw.method.call({label:'member-bound'}),rawLabel:raw.label};console.log('WS2_CALLABLE_MUTATION:'+JSON.stringify(row));expect(row.same).toBe(true)});
