Make Primitive\Num tests much more nicer
authorwidmogrod <widmogrod@gmail.com>
Thu, 28 Dec 2017 23:23:56 +0000 (00:23 +0100)
committerwidmogrod <widmogrod@gmail.com>
Thu, 28 Dec 2017 23:23:56 +0000 (00:23 +0100)
test/Primitive/NumTest.php

index 6061938..703b168 100644 (file)
@@ -4,40 +4,28 @@ declare(strict_types=1);
 
 namespace test\Primitive;
 
+use Eris\TestTrait;
+use Eris\Generator;
 use Widmogrod\Helpful\SetoidLaws;
 use Widmogrod\Primitive\Num;
 
 class NumTest extends \PHPUnit\Framework\TestCase
 {
-    /**
-     * @dataProvider provideSetoidLaws
-     */
-    public function test_it_should_obay_setoid_laws(
-        $a,
-        $b,
-        $c
-    ) {
-        SetoidLaws::test(
-            [$this, 'assertEquals'],
-            $a,
-            $b,
-            $c
-        );
-    }
-
-    private function randomize()
-    {
-        return Num::of(random_int(-100000000, 100000000));
-    }
+    use TestTrait;
 
-    public function provideSetoidLaws()
+    public function test_it_should_obay_setoid_laws()
     {
-        return array_map(function () {
-            return [
-                $this->randomize(),
-                $this->randomize(),
-                $this->randomize(),
-            ];
-        }, array_fill(0, 50, null));
+        $this->forAll(
+            Generator\choose(0, 1000),
+            Generator\choose(1000, 4000),
+            Generator\choose(4000, 100000)
+        )->then(function (int $x, int $y, int $z) {
+            SetoidLaws::test(
+                [$this, 'assertEquals'],
+                Num::of($x),
+                Num::of($y),
+                Num::of($z)
+            );
+        });
     }
 }