public function testTimeIntervalToRunForCanBeConfiguredAndAVeryLowNumberOfIterationsCanBeIgnored() { $this->minimumEvaluationRatio(0.0)->limitTo(new DateInterval("PT2S"))->forAll(Generator\int())->then(function ($value) { usleep(100 * 1000); $this->assertTrue(true); }); }
public function testSumIsAssociative() { $this->forAll(Generator\int(), Generator\neg(), Generator\pos())->then(function ($first, $second, $third) { $x = $first + ($second + $third); $y = $first + $second + $third; $this->assertEquals($x, $y, "Sum between {$first} and {$second} should be associative"); }); }
public function testEqualToNative() { $this->forAll(Generator\seq(Generator\int()))->__invoke(function ($arr) { $e = array_product($arr); $this->assertEquals($e, lazy_product($arr)->resolve()); $this->assertEquals($e, lazy_product(new \ArrayObject($arr))->resolve()); }); }
public function testRangeIsEqualToNative() { $this->forAll(Generator\int(), Generator\int())->__invoke(function ($start, $end) { if ($end < $start) { list($end, $start) = array($start, $end); } $this->assertEquals(range($start, $end), iterator_to_array(lazy_range($start, $end))); }); }
/** @test */ function beneficiary_balance_should_increase_after_funds_have_been_transferred() { $this->forAll(Generator\int(1, 10000))->then(function ($amount) { $fromMember = A::member()->withBalance(10000)->build(); $toMember = A::member()->withBalance(5000)->build(); $fromMember->transfer(Money::MXN($amount), $toMember); $this->assertBalanceIsGreaterThan(5000, $toMember, "Transferring {$amount} increased balance of receiver member"); }); }
public function testUsingThePurePhpMtRandFunction() { $this->withRand(Random\purePhpMtRand())->forAll(Generator\int())->then($this->isInteger()); }
public function testLogOfFailuresAndShrinking() { $this->forAll(Generator\int())->hook(Listener\log('/tmp/eris-log-file-shrinking.log'))->then(function ($number) { $this->assertLessThanOrEqual(42, $number); }); }
/** * With the default sizes this test would pass, * as numbers greater or equal than 100,000 would never be reached. */ public function testMaxSizeCanBeIncreased() { $this->forAll(Generator\int())->withMaxSize(1000 * 1000)->then(function ($number) { $this->assertLessThan(100 * 1000, $number); }); }
public function testGeneratedDataCollectionOnMoreComplexDataStructures() { $this->forAll(Generator\vector(2, Generator\int()), Generator\char())->hook(Listener\collectFrequencies())->then(function ($vector) { $this->assertEquals(2, count($vector)); }); }
public function testEqualToNative() { $this->forAll(Generator\int(), Generator\int())->__invoke(function ($a, $b) { $this->assertEquals($a > $b ? $a : $b, lazy_if($a > $b, $a, $b)->resolve()); }); }