Skip to content

Commit ee57d4f

Browse files
[IoPoll] Take the wait() parameter validation test from php-src
php/php-src#23099 reports the negative timeout as argument #1 instead of #2, which is what the polyfill already does, and covers both errors with a phpt. It passes as is.
1 parent 655b740 commit ee57d4f

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
--TEST--
2+
Io\Poll\Context::wait(): Parameter validation
3+
--FILE--
4+
<?php
5+
require_once __DIR__ . '/poll.inc';
6+
7+
$poll_ctx = new Io\Poll\Context();
8+
9+
try {
10+
$poll_ctx->wait(timeout: Time\Duration::fromSeconds(1)->negate());
11+
} catch (Throwable $e) {
12+
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
13+
}
14+
15+
try {
16+
$poll_ctx->wait(maxEvents: -1);
17+
} catch (Throwable $e) {
18+
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
19+
}
20+
21+
?>
22+
--EXPECT--
23+
ValueError: Io\Poll\Context::wait(): Argument #1 ($timeout) must not be negative
24+
ValueError: Io\Poll\Context::wait(): Argument #2 ($maxEvents) must be greater than 0

0 commit comments

Comments
 (0)