Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Baptouuuu committed Jul 9, 2023
1 parent 2f95f3a commit 62e1c13
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 102 deletions.
40 changes: 8 additions & 32 deletions tests/File/Content/AtPathTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,7 @@ public function testInterface()
public function testForeach()
{
$this
->forAll(Set\Sequence::of(
$this->strings(),
Set\Integers::between(1, 10),
))
->forAll(Set\Sequence::of($this->strings())->between(1, 10))
->then(function($lines) {
\file_put_contents('/tmp/test_content', \implode("\n", $lines));
$content = AtPath::of(Path::of('/tmp/test_content'));
Expand Down Expand Up @@ -74,10 +71,7 @@ public function testMap()
{
$this
->forAll(
Set\Sequence::of(
$this->strings(),
Set\Integers::between(1, 10),
),
Set\Sequence::of($this->strings())->between(1, 10),
$this->strings(),
)
->then(function($lines, $replacement) {
Expand Down Expand Up @@ -128,10 +122,7 @@ public function testFlatMap()
{
$this
->forAll(
Set\Sequence::of(
$this->strings(),
Set\Integers::between(1, 10),
),
Set\Sequence::of($this->strings())->between(1, 10),
$this->strings(),
)
->then(function($lines, $newLine) {
Expand Down Expand Up @@ -168,10 +159,7 @@ public function testFlatMap()
public function testFilter()
{
$this
->forAll(Set\Sequence::of(
$this->strings(),
Set\Integers::between(1, 10),
))
->forAll(Set\Sequence::of($this->strings())->between(1, 10))
->then(function($lines) {
\file_put_contents('/tmp/test_content', \implode("\n", $lines));
$content = AtPath::of(Path::of('/tmp/test_content'));
Expand All @@ -196,10 +184,7 @@ public function testLines()
{
$this
->forAll(
Set\Sequence::of(
$this->strings(),
Set\Integers::between(1, 10),
),
Set\Sequence::of($this->strings())->between(1, 10),
$this->strings(),
)
->then(function($lines, $replacement) {
Expand Down Expand Up @@ -232,10 +217,7 @@ public function testLines()
public function testReduce()
{
$this
->forAll(Set\Sequence::of(
$this->strings(),
Set\Integers::between(1, 10),
))
->forAll(Set\Sequence::of($this->strings())->between(1, 10))
->then(function($lines) {
\file_put_contents('/tmp/test_content', \implode("\n", $lines));
$content = AtPath::of(Path::of('/tmp/test_content'));
Expand All @@ -253,10 +235,7 @@ public function testReduce()
public function testToString()
{
$this
->forAll(Set\Sequence::of(
$this->strings(),
Set\Integers::between(1, 10),
))
->forAll(Set\Sequence::of($this->strings())->between(1, 10))
->then(function($lines) {
\file_put_contents('/tmp/test_content', \implode("\n", $lines));
$content = AtPath::of(Path::of('/tmp/test_content'));
Expand All @@ -268,10 +247,7 @@ public function testToString()
public function testSize()
{
$this
->forAll(Set\Sequence::of(
$this->strings(),
Set\Integers::between(0, 10),
))
->forAll(Set\Sequence::of($this->strings())->between(0, 10))
->then(function($lines) {
$expectedSize = Str::of(\implode("\n", $lines))->toEncoding('ASCII')->length();
\file_put_contents('/tmp/test_content', \implode("\n", $lines));
Expand Down
6 changes: 2 additions & 4 deletions tests/File/Content/ChunksTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,7 @@ public function testSize()
$this
->forAll(Set\Sequence::of(
Set\Unicode::strings(),
Set\Integers::between(0, 10),
))
)->between(0, 10))
->then(function($chunks) {
$expectedSize = Str::of(\implode('', $chunks), 'ASCII')->length();
$content = Chunks::of(Sequence::of(...$chunks)->map(Str::of(...)));
Expand Down Expand Up @@ -303,8 +302,7 @@ private function chunks(): Set
{
return Set\Sequence::of(
Set\Unicode::strings(),
Set\Integers::between(1, 10),
);
)->between(1, 10);
}

private function strings(): Set
Expand Down
40 changes: 8 additions & 32 deletions tests/File/Content/LinesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,7 @@ public function testInterface()
public function testForeach()
{
$this
->forAll(Set\Sequence::of(
$this->strings(),
Set\Integers::between(1, 10),
))
->forAll(Set\Sequence::of($this->strings())->between(1, 10))
->then(function($lines) {
$content = Lines::of(Sequence::of(...$lines));
$called = 0;
Expand Down Expand Up @@ -69,10 +66,7 @@ public function testMap()
{
$this
->forAll(
Set\Sequence::of(
$this->strings(),
Set\Integers::between(1, 10),
),
Set\Sequence::of($this->strings())->between(1, 10),
$this->strings(),
)
->then(function($lines, $replacement) {
Expand All @@ -96,10 +90,7 @@ public function testFlatMap()
{
$this
->forAll(
Set\Sequence::of(
$this->strings(),
Set\Integers::between(1, 10),
),
Set\Sequence::of($this->strings())->between(1, 10),
$this->strings(),
)
->then(function($lines, $newLine) {
Expand Down Expand Up @@ -134,10 +125,7 @@ public function testFlatMap()
public function testFilter()
{
$this
->forAll(Set\Sequence::of(
$this->strings(),
Set\Integers::between(1, 10),
))
->forAll(Set\Sequence::of($this->strings())->between(1, 10))
->then(function($lines) {
$content = Lines::of(Sequence::of(...$lines));
$shouldBeEmpty = $content->filter(static fn() => false);
Expand All @@ -161,10 +149,7 @@ public function testLines()
{
$this
->forAll(
Set\Sequence::of(
$this->strings(),
Set\Integers::between(1, 10),
),
Set\Sequence::of($this->strings())->between(1, 10),
$this->strings(),
)
->then(function($lines, $replacement) {
Expand All @@ -189,10 +174,7 @@ public function testLines()
public function testReduce()
{
$this
->forAll(Set\Sequence::of(
$this->strings(),
Set\Integers::between(1, 10),
))
->forAll(Set\Sequence::of($this->strings())->between(1, 10))
->then(function($lines) {
$content = Lines::of(Sequence::of(...$lines));

Expand All @@ -209,10 +191,7 @@ public function testReduce()
public function testToString()
{
$this
->forAll(Set\Sequence::of(
$this->strings(),
Set\Integers::between(1, 10),
))
->forAll(Set\Sequence::of($this->strings())->between(1, 10))
->then(function($lines) {
$content = Lines::of(Sequence::of(...$lines));

Expand Down Expand Up @@ -274,10 +253,7 @@ public function testSize()
));

$this
->forAll(Set\Sequence::of(
$this->strings(),
Set\Integers::between(0, 10),
))
->forAll(Set\Sequence::of($this->strings())->between(0, 10))
->then(function($lines) {
$raw = \array_map(
static fn($line) => $line->toString(),
Expand Down
40 changes: 8 additions & 32 deletions tests/File/Content/OfStreamTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,7 @@ public function testInterface()
public function testForeach()
{
$this
->forAll(Set\Sequence::of(
$this->strings(),
Set\Integers::between(1, 10),
))
->forAll(Set\Sequence::of($this->strings())->between(1, 10))
->then(function($lines) {
\file_put_contents('/tmp/test_content', \implode("\n", $lines));
$content = OfStream::of(Stream::open(Path::of('/tmp/test_content')));
Expand Down Expand Up @@ -75,10 +72,7 @@ public function testMap()
{
$this
->forAll(
Set\Sequence::of(
$this->strings(),
Set\Integers::between(1, 10),
),
Set\Sequence::of($this->strings())->between(1, 10),
$this->strings(),
)
->then(function($lines, $replacement) {
Expand All @@ -104,10 +98,7 @@ public function testFlatMap()
{
$this
->forAll(
Set\Sequence::of(
$this->strings(),
Set\Integers::between(1, 10),
),
Set\Sequence::of($this->strings())->between(1, 10),
$this->strings(),
)
->then(function($lines, $newLine) {
Expand Down Expand Up @@ -144,10 +135,7 @@ public function testFlatMap()
public function testFilter()
{
$this
->forAll(Set\Sequence::of(
$this->strings(),
Set\Integers::between(1, 10),
))
->forAll(Set\Sequence::of($this->strings())->between(1, 10))
->then(function($lines) {
\file_put_contents('/tmp/test_content', \implode("\n", $lines));
$content = OfStream::of(Stream::open(Path::of('/tmp/test_content')));
Expand All @@ -172,10 +160,7 @@ public function testLines()
{
$this
->forAll(
Set\Sequence::of(
$this->strings(),
Set\Integers::between(1, 10),
),
Set\Sequence::of($this->strings())->between(1, 10),
$this->strings(),
)
->then(function($lines, $replacement) {
Expand Down Expand Up @@ -208,10 +193,7 @@ public function testLines()
public function testReduce()
{
$this
->forAll(Set\Sequence::of(
$this->strings(),
Set\Integers::between(1, 10),
))
->forAll(Set\Sequence::of($this->strings())->between(1, 10))
->then(function($lines) {
\file_put_contents('/tmp/test_content', \implode("\n", $lines));
$content = OfStream::of(Stream::open(Path::of('/tmp/test_content')));
Expand All @@ -229,10 +211,7 @@ public function testReduce()
public function testToString()
{
$this
->forAll(Set\Sequence::of(
$this->strings(),
Set\Integers::between(1, 10),
))
->forAll(Set\Sequence::of($this->strings())->between(1, 10))
->then(function($lines) {
\file_put_contents('/tmp/test_content', \implode("\n", $lines));
$content = OfStream::of(Stream::open(Path::of('/tmp/test_content')));
Expand All @@ -244,10 +223,7 @@ public function testToString()
public function testSize()
{
$this
->forAll(Set\Sequence::of(
$this->strings(),
Set\Integers::between(0, 10),
))
->forAll(Set\Sequence::of($this->strings())->between(0, 10))
->then(function($lines) {
$expectedSize = Str::of(\implode("\n", $lines))->toEncoding('ASCII')->length();
\file_put_contents('/tmp/test_content', \implode("\n", $lines));
Expand Down
3 changes: 1 addition & 2 deletions tests/NameTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,7 @@ public function testAnySequenceOfNamesConstitutesAValidPath()
$this
->forAll(Set\Sequence::of(
Fixture::any(),
Set\Integers::between(1, 10), // enough to prove the behaviour
))
)->between(1, 10)) // enough to prove the behaviour
->then(function($names) {
$strings = \array_map(
static fn($name) => $name->toString(),
Expand Down

0 comments on commit 62e1c13

Please sign in to comment.