Esempio n. 1
0
 public function testTimeIntervalToRunForCanBeConfiguredAndAVeryLowNumberOfIterationsCanBeIgnored()
 {
     $this->minimumEvaluationRatio(0.0)->limitTo(new DateInterval("PT2S"))->forAll(Generator\int())->then(function ($value) {
         usleep(100 * 1000);
         $this->assertTrue(true);
     });
 }
Esempio n. 2
0
 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");
     });
 }
Esempio n. 3
0
 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());
     });
 }
Esempio n. 4
0
 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)));
     });
 }
Esempio n. 5
0
 /** @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());
 }
Esempio n. 7
0
 public function testLogOfFailuresAndShrinking()
 {
     $this->forAll(Generator\int())->hook(Listener\log('/tmp/eris-log-file-shrinking.log'))->then(function ($number) {
         $this->assertLessThanOrEqual(42, $number);
     });
 }
Esempio n. 8
0
 /**
  * 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);
     });
 }
Esempio n. 9
0
 public function testGeneratedDataCollectionOnMoreComplexDataStructures()
 {
     $this->forAll(Generator\vector(2, Generator\int()), Generator\char())->hook(Listener\collectFrequencies())->then(function ($vector) {
         $this->assertEquals(2, count($vector));
     });
 }
Esempio n. 10
0
 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());
     });
 }