3
3
namespace Interop \Async \Loop ;
4
4
5
5
if (!defined ("SIGUSR1 " )) {
6
- define ("SIGUSR1 " , 10 );
6
+ define ("SIGUSR1 " , 30 );
7
+ }
8
+ if (!defined ("SIGUSR2 " )) {
9
+ define ("SIGUSR2 " , 31 );
7
10
}
8
11
9
12
abstract class Test extends \PHPUnit_Framework_TestCase {
@@ -464,7 +467,7 @@ function testNoMemoryLeak($type, $args)
464
467
465
468
function testExecutionOrderGuarantees ()
466
469
{
467
- $ this ->expectOutputString ("01 02 03 04 " .str_repeat ("05 " , 8 )."10 11 12 " .str_repeat ("13 " , 4 )."20 21 22 23 24 25 30 31 " );
470
+ $ this ->expectOutputString ("01 02 03 04 " .str_repeat ("05 " , 8 )."10 11 12 " .str_repeat ("13 " , 4 )."20 21 21 21 21 22 30 31 " );
468
471
$ this ->start (function (Driver $ loop ) use (&$ ticks ) {
469
472
$ f = function () use ($ loop ) {
470
473
$ args = func_get_args ();
@@ -517,13 +520,13 @@ function testExecutionOrderGuarantees()
517
520
$ loop ->onWritable (STDIN , $ f (1 , 3 ));
518
521
});
519
522
520
- $ loop ->delay ($ msDelay = 15 , $ f (3 , 1 ));
521
- $ loop ->delay ($ msDelay = 6 , $ f (2 , 5 ));
523
+ $ loop ->delay ($ msDelay = 25 , $ f (3 , 1 ));
524
+ $ loop ->delay ($ msDelay = 6 , $ f (2 , 2 ));
522
525
$ loop ->delay ($ msDelay = 5 , $ f (2 , 1 ));
523
- $ loop ->repeat ($ msDelay = 5 , $ f (2 , 2 ));
524
- $ rep1 = $ loop ->repeat ($ msDelay = 5 , $ f (2 , 4 ));
526
+ $ loop ->repeat ($ msDelay = 5 , $ f (2 , 1 ));
527
+ $ rep1 = $ loop ->repeat ($ msDelay = 5 , $ f (2 , 1 ));
525
528
$ loop ->disable ($ rep1 );
526
- $ loop ->delay ($ msDelay = 5 , $ f (2 , 3 ));
529
+ $ loop ->delay ($ msDelay = 5 , $ f (2 , 1 ));
527
530
$ loop ->enable ($ rep1 );
528
531
529
532
$ loop ->defer ($ f (0 , 1 ));
@@ -934,7 +937,7 @@ function testInitiallyDisabledOnSignalWatcher()
934
937
$ loop ->delay ($ msDelay = 1 , function () use ($ loop , $ watcherId ) {
935
938
$ loop ->enable ($ watcherId );
936
939
$ loop ->delay ($ msDelay = 1 , function () {
937
- \posix_kill (\getmypid (), \ SIGUSR1 );
940
+ \posix_kill (\getmypid (), SIGUSR1 );
938
941
});
939
942
});
940
943
});
@@ -947,7 +950,7 @@ function testNestedLoopSignalDispatch()
947
950
$ this ->markTestSkipped ("ext/posix required to test signal handlers " );
948
951
}
949
952
950
- $ this ->expectOutputString ("inner SIGUSR1 \nouter SIGUSR1 \n" );
953
+ $ this ->expectOutputString ("inner SIGUSR2 \nouter SIGUSR1 \n" );
951
954
$ this ->start (function (Driver $ loop ) {
952
955
$ loop ->delay ($ msDelay = 30 , function () use ($ loop ) {
953
956
$ loop ->stop ();
@@ -963,13 +966,13 @@ function testNestedLoopSignalDispatch()
963
966
echo "ERROR: manual stop " ;
964
967
$ loop ->stop ();
965
968
});
966
- $ loop ->onSignal (SIGUSR1 , function ($ watcherId ) use ($ loop , $ stop ) {
967
- echo "inner SIGUSR1 \n" ;
969
+ $ loop ->onSignal (SIGUSR2 , function ($ watcherId ) use ($ loop , $ stop ) {
970
+ echo "inner SIGUSR2 \n" ;
968
971
$ loop ->cancel ($ stop );
969
972
$ loop ->cancel ($ watcherId );
970
973
});
971
974
$ loop ->delay ($ msDelay = 1 , function () {
972
- \posix_kill (\getmypid (), \ SIGUSR1 );
975
+ \posix_kill (\getmypid (), SIGUSR2 );
973
976
});
974
977
$ loop ->run ();
975
978
});
@@ -1115,25 +1118,25 @@ function testOptionalCallbackDataPassedOnInvocation()
1115
1118
$ this ->assertTrue ($ callbackData ->onWritable );
1116
1119
}
1117
1120
1118
- // implementations SHOULD use Interop\Async\Loop\Registry trait , but are not forced to, hence test it here again
1121
+ // getState and setState are final , but test it here again to be sure
1119
1122
function testRegistry () {
1120
- $ this ->assertNull ($ this ->loop ->fetchState ("foo " ));
1121
- $ this ->loop ->storeState ("foo " , NAN );
1122
- $ this ->assertTrue (is_nan ($ this ->loop ->fetchState ("foo " )));
1123
- $ this ->loop ->storeState ("foo " , "1 " );
1124
- $ this ->assertNull ($ this ->loop ->fetchState ("bar " ));
1125
- $ this ->loop ->storeState ("baz " , -INF );
1123
+ $ this ->assertNull ($ this ->loop ->getState ("foo " ));
1124
+ $ this ->loop ->setState ("foo " , NAN );
1125
+ $ this ->assertTrue (is_nan ($ this ->loop ->getState ("foo " )));
1126
+ $ this ->loop ->setState ("foo " , "1 " );
1127
+ $ this ->assertNull ($ this ->loop ->getState ("bar " ));
1128
+ $ this ->loop ->setState ("baz " , -INF );
1126
1129
// running must not affect state
1127
1130
$ this ->loop ->defer ([$ this ->loop , "stop " ]);
1128
1131
$ this ->loop ->run ();
1129
- $ this ->assertSame (-INF , $ this ->loop ->fetchState ("baz " ));
1130
- $ this ->assertSame ("1 " , $ this ->loop ->fetchState ("foo " ));
1132
+ $ this ->assertSame (-INF , $ this ->loop ->getState ("baz " ));
1133
+ $ this ->assertSame ("1 " , $ this ->loop ->getState ("foo " ));
1131
1134
}
1132
1135
1133
1136
/** @dataProvider provideRegistryValues */
1134
1137
function testRegistryValues ($ val ) {
1135
- $ this ->loop ->storeState ("foo " , $ val );
1136
- $ this ->assertSame ($ val , $ this ->loop ->fetchState ("foo " ));
1138
+ $ this ->loop ->setState ("foo " , $ val );
1139
+ $ this ->assertSame ($ val , $ this ->loop ->getState ("foo " ));
1137
1140
}
1138
1141
1139
1142
function provideRegistryValues () {
0 commit comments