mirror of
https://github.com/danog/amp.git
synced 2024-11-30 04:29:08 +01:00
Use Error instead of InvalidArgumentException, remove test file
This commit is contained in:
parent
ee11b70395
commit
c13e8e3a66
@ -200,7 +200,7 @@ abstract class Driver {
|
||||
*/
|
||||
public function delay(int $delay, callable $callback, $data = null): string {
|
||||
if ($delay < 0) {
|
||||
throw new \InvalidArgumentException("Delay must be greater than or equal to zero");
|
||||
throw new \Error("Delay must be greater than or equal to zero");
|
||||
}
|
||||
|
||||
$watcher = new Watcher;
|
||||
@ -234,7 +234,7 @@ abstract class Driver {
|
||||
*/
|
||||
public function repeat(int $interval, callable $callback, $data = null): string {
|
||||
if ($interval < 0) {
|
||||
throw new \InvalidArgumentException("Interval must be greater than or equal to zero");
|
||||
throw new \Error("Interval must be greater than or equal to zero");
|
||||
}
|
||||
|
||||
$watcher = new Watcher;
|
||||
|
20
test.php
20
test.php
@ -1,20 +0,0 @@
|
||||
<?php
|
||||
|
||||
require "vendor/autoload.php";
|
||||
|
||||
use Amp\Loop;
|
||||
|
||||
Loop::set(new Loop\NativeDriver);
|
||||
|
||||
var_dump(stream_get_meta_data(STDIN));
|
||||
|
||||
Loop::run(function () {
|
||||
Loop::onReadable(STDIN, function ($watcherId) {
|
||||
var_dump("READ", fread(STDIN, 8192));
|
||||
var_dump("EOF", feof(STDIN));
|
||||
|
||||
if (feof(STDIN)) {
|
||||
Loop::cancel($watcherId);
|
||||
}
|
||||
});
|
||||
});
|
@ -7,13 +7,13 @@ use PHPUnit\Framework\TestCase;
|
||||
|
||||
class LoopTest extends TestCase {
|
||||
public function testDelayWithNegativeDelay() {
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
$this->expectException(\Error::class);
|
||||
|
||||
Loop::delay(-1, function () {});
|
||||
}
|
||||
|
||||
public function testRepeatWithNegativeInterval() {
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
$this->expectException(\Error::class);
|
||||
|
||||
Loop::repeat(-1, function () {});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user