1
0
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:
Niklas Keller 2017-03-14 18:44:44 +01:00
parent ee11b70395
commit c13e8e3a66
3 changed files with 4 additions and 24 deletions

View File

@ -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;

View File

@ -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);
}
});
});

View File

@ -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 () {});
}