polserver/testsuite/pol/testpkgs/funcref/send_same_prog.src
turleypol 7ff9d877a8
Funcrefs do not detect pid change (#889)
* test for sending a function to the same program

* store executor pid inside funcrefs and classes

* docs
2026-05-31 11:45:35 +02:00

31 lines
605 B
Text

use os;
var state;
program prog( args )
state := args[2];
var parent := GetProcess( args[1] );
if ( state == "main" )
return spawn();
else
parent.SendEvent( struct{ res := @() { return state; } } );
Wait_For_Event( 1 );
endif
endprogram
function spawn()
var spawned := start_script( ":testfuncref:send_same_prog", { GetPid(), "secondary" } );
if ( !spawned )
return $"failed to spawn: {spawned}";
endif
var ev := Wait_For_Event( 1 );
if ( !ev )
return $"no event: {ev}";
endif
var res := ev.res.call();
spawned.SendEvent( 1 );
return res;
endfunction