Skip to content
This repository has been archived by the owner on Nov 26, 2023. It is now read-only.

Commit

Permalink
add functional test
Browse files Browse the repository at this point in the history
  • Loading branch information
Baptouuuu committed Feb 11, 2023
1 parent d798a9e commit 1851454
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions tests/HaltTest.php
Expand Up @@ -5,6 +5,8 @@

use Innmind\Async\TimeWarp\Halt;
use Innmind\Mantle\{
Forerunner,
Source\Predetermined,
Suspend,
Suspend\Synchronous,
};
Expand All @@ -29,4 +31,33 @@ public function testSuspend()

$this->assertGreaterThanOrEqual(2, \microtime(true) - $start);
}

public function testFunctional()
{
$queue = new \SplQueue;
$clock = new Clock;
$source = Predetermined::of(
static function(Suspend $suspend) use ($clock, $queue) {
$halt = Halt::of($clock, $suspend);

$halt(new Second(2));

$queue->push('World !');
},
static function(Suspend $suspend) use ($clock, $queue) {
$halt = Halt::of($clock, $suspend);

$halt(new Second(1));

$queue->push('Hello ');
},
);

Forerunner::of($clock)(null, $source);

$this->assertSame(
['Hello ', 'World !'],
\iterator_to_array($queue),
);
}
}

0 comments on commit 1851454

Please sign in to comment.