Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* develop: replace do/while by while to avoid shrinking unshrinkable values add links to sets update the documentation display the variable name before displaying the associated value remove outdated note mark Set interface as internal add test to fail on purpose to check the output of property list add stateful testing example fix associating the wrong values when rethrowing the previous failure add possibility to do stateful testing allow to filter sequences make sure a sequence is never shrunk with fewer elements than the specified lower bound always return the specified number of elements fix sequence type declarations add sequence set
- Loading branch information
Showing
27 changed files
with
1,231 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
declare(strict_types = 1); | ||
|
||
namespace Fixtures\Innmind\BlackBox; | ||
|
||
final class Counter | ||
{ | ||
private int $value; | ||
private bool $correct = true; | ||
|
||
public function __construct(int $initial = 0) | ||
{ | ||
$this->value = $initial; | ||
} | ||
|
||
public static function failOnPurpose(): self | ||
{ | ||
$self = new self; | ||
$self->correct = false; | ||
|
||
return $self; | ||
} | ||
|
||
public function down(): void | ||
{ | ||
if ($this->correct && $this->value === 0) { | ||
return; | ||
} | ||
|
||
--$this->value; | ||
} | ||
|
||
public function up(): void | ||
{ | ||
if ($this->correct && $this->value === 100) { | ||
return; | ||
} | ||
|
||
++$this->value; | ||
} | ||
|
||
public function current(): int | ||
{ | ||
return $this->value; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
declare(strict_types = 1); | ||
|
||
namespace Fixtures\Innmind\BlackBox; | ||
|
||
use Innmind\BlackBox\Property; | ||
use PHPUnit\Framework\Assert; | ||
|
||
final class DownAndUpIsAnIdentityFunction implements Property | ||
{ | ||
public function name(): string | ||
{ | ||
return 'Down and up return to the initial value'; | ||
} | ||
|
||
public function applicableTo(object $counter): bool | ||
{ | ||
return $counter->current() > 0; | ||
} | ||
|
||
public function ensureHeldBy(object $counter): object | ||
{ | ||
$initial = $counter->current(); | ||
$counter->down(); | ||
$counter->up(); | ||
Assert::assertSame($initial, $counter->current()); | ||
|
||
return $counter; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
declare(strict_types = 1); | ||
|
||
namespace Fixtures\Innmind\BlackBox; | ||
|
||
use Innmind\BlackBox\Property; | ||
use PHPUnit\Framework\Assert; | ||
|
||
final class DownChangeState implements Property | ||
{ | ||
public function name(): string | ||
{ | ||
return 'Down change state'; | ||
} | ||
|
||
public function applicableTo(object $counter): bool | ||
{ | ||
return $counter->current() > 0; | ||
} | ||
|
||
public function ensureHeldBy(object $counter): object | ||
{ | ||
$initial = $counter->current(); | ||
$counter->down(); | ||
Assert::assertLessThan($initial, $counter->current()); | ||
|
||
return $counter; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
declare(strict_types = 1); | ||
|
||
namespace Fixtures\Innmind\BlackBox; | ||
|
||
use Innmind\BlackBox\Property; | ||
use PHPUnit\Framework\Assert; | ||
|
||
final class LowerBoundAtZero implements Property | ||
{ | ||
public function name(): string | ||
{ | ||
return 'Counter can not go lower than 0'; | ||
} | ||
|
||
public function applicableTo(object $counter): bool | ||
{ | ||
return $counter->current() < 2; | ||
} | ||
|
||
public function ensureHeldBy(object $counter): object | ||
{ | ||
$counter->down(); | ||
Assert::assertSame(0, $counter->current()); | ||
|
||
return $counter; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
declare(strict_types = 1); | ||
|
||
namespace Fixtures\Innmind\BlackBox; | ||
|
||
use Innmind\BlackBox\Property; | ||
use PHPUnit\Framework\Assert; | ||
|
||
final class UpAndDownIsAnIdentityFunction implements Property | ||
{ | ||
public function name(): string | ||
{ | ||
return 'Up and down return to the initial value'; | ||
} | ||
|
||
public function applicableTo(object $counter): bool | ||
{ | ||
return $counter->current() < 99; | ||
} | ||
|
||
public function ensureHeldBy(object $counter): object | ||
{ | ||
$initial = $counter->current(); | ||
$counter->up(); | ||
$counter->down(); | ||
Assert::assertSame($initial, $counter->current()); | ||
|
||
return $counter; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
declare(strict_types = 1); | ||
|
||
namespace Fixtures\Innmind\BlackBox; | ||
|
||
use Innmind\BlackBox\Property; | ||
use PHPUnit\Framework\Assert; | ||
|
||
final class UpChangeState implements Property | ||
{ | ||
public function name(): string | ||
{ | ||
return 'Up change state'; | ||
} | ||
|
||
public function applicableTo(object $counter): bool | ||
{ | ||
return $counter->current() < 100; | ||
} | ||
|
||
public function ensureHeldBy(object $counter): object | ||
{ | ||
$initial = $counter->current(); | ||
$counter->up(); | ||
Assert::assertGreaterThan($initial, $counter->current()); | ||
|
||
return $counter; | ||
} | ||
} |
Oops, something went wrong.