File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1313use Innmind \Server \Status \Server \Memory \Bytes ;
1414use Innmind \TimeContinuum \Period ;
1515use Innmind \TimeWarp \Halt ;
16- use Innmind \Signals \Handler ;
16+ use Innmind \Signals \{
17+ Handler ,
18+ Signal ,
19+ Async \Interceptor ,
20+ };
1721use Innmind \Immutable \SideEffect ;
1822use Psr \Log \NullLogger ;
1923use Innmind \BlackBox \{
@@ -70,6 +74,30 @@ public function testSignals()
7074 $ this ->assertSame ($ process ->signals (), $ process ->signals ());
7175 }
7276
77+ public function testAsyncSignals (): BlackBox \Proof
78+ {
79+ return $ this
80+ ->forAll (Set::of (...Signal::cases ()))
81+ ->prove (function ($ signal ) {
82+ $ config = Config::new ();
83+ $ interceptor = Interceptor::new ();
84+ $ config = $ config ->handleSignalsVia (
85+ $ config ->signalsHandler ()->async ($ interceptor ),
86+ );
87+ $ async = OperatingSystem::new ($ config );
88+ $ called = 0 ;
89+ $ async
90+ ->process ()
91+ ->signals ()
92+ ->listen ($ signal , static function () use (&$ called ) {
93+ ++$ called ;
94+ });
95+ $ interceptor ->dispatch ($ signal );
96+
97+ $ this ->assertSame (1 , $ called );
98+ });
99+ }
100+
73101 public function testMemory ()
74102 {
75103 $ process = CurrentProcess::of (
You can’t perform that action at this time.
0 commit comments