4
4
5
5
namespace test \Primitive ;
6
6
7
+ use Eris \Generator ;
7
8
use Eris \TestTrait ;
8
- use Widmogrod \Functional as f ;
9
9
use Widmogrod \Helpful \MonoidLaws ;
10
10
use Widmogrod \Helpful \SetoidLaws ;
11
11
use Widmogrod \Primitive \Product ;
@@ -15,63 +15,49 @@ class ProductTest extends \PHPUnit\Framework\TestCase
15
15
{
16
16
use TestTrait;
17
17
18
- /**
19
- * @dataProvider provideSetoidLaws
20
- */
21
- public function test_it_should_obay_setoid_laws (
22
- $ a ,
23
- $ b ,
24
- $ c
25
- ) {
26
- SetoidLaws:: test (
27
- f \curryN ( 3 , [ $ this , ' assertEquals ' ] ),
28
- $ a ,
29
- $ b ,
30
- $ c
31
- );
18
+ public function test_it_should_obay_setoid_laws ()
19
+ {
20
+ $ this -> forAll (
21
+ Generator \choose ( 0 , 1000 ),
22
+ Generator \choose ( 1000 , 4000 ) ,
23
+ Generator \choose ( 4000 , 100000 )
24
+ )-> then ( function ( int $ x , int $ y , int $ z ) {
25
+ SetoidLaws:: test (
26
+ [ $ this , ' assertEquals ' ],
27
+ Product:: of ( $ x ),
28
+ Product:: of ( $ y ) ,
29
+ Product:: of ( $ z )
30
+ );
31
+ } );
32
32
}
33
33
34
- /**
35
- * @dataProvider provideSetoidLaws
36
- */
37
- public function test_it_should_obay_monoid_laws (
38
- $ a ,
39
- $ b ,
40
- $ c
41
- ) {
42
- MonoidLaws:: test (
43
- f \curryN ( 3 , [ $ this , ' assertEquals ' ] ),
44
- $ a ,
45
- $ b ,
46
- $ c
47
- );
34
+ public function test_it_should_obay_monoid_laws ()
35
+ {
36
+ $ this -> forAll (
37
+ Generator \choose ( 0 , 1000 ),
38
+ Generator \choose ( 1000 , 4000 ) ,
39
+ Generator \choose ( 4000 , 100000 )
40
+ )-> then ( function ( int $ x , int $ y , int $ z ) {
41
+ MonoidLaws:: test (
42
+ [ $ this , ' assertEquals ' ],
43
+ Product:: of ( $ x ),
44
+ Product:: of ( $ y ) ,
45
+ Product:: of ( $ z )
46
+ );
47
+ } );
48
48
}
49
49
50
50
/**
51
51
* @expectedException \Widmogrod\Primitive\TypeMismatchError
52
52
* @expectedExceptionMessage Expected type is Widmogrod\Primitive\Product but given Widmogrod\Primitive\Stringg
53
- * @dataProvider provideSetoidLaws
54
53
*/
55
- public function test_it_should_reject_concat_on_different_type (Product $ a )
56
- {
57
- $ a ->concat (Stringg::of ("a " ));
58
- }
59
-
60
- private function randomize ()
61
- {
62
- usleep (100 );
63
-
64
- return Product::of (random_int (-1000 , 1000 ));
65
- }
66
-
67
- public function provideSetoidLaws ()
54
+ public function test_it_should_reject_concat_on_different_type ()
68
55
{
69
- return array_map (function () {
70
- return [
71
- $ this ->randomize (),
72
- $ this ->randomize (),
73
- $ this ->randomize (),
74
- ];
75
- }, array_fill (0 , 50 , null ));
56
+ $ this ->forAll (
57
+ Generator \int (),
58
+ Generator \string ()
59
+ )->then (function (int $ x , string $ y ) {
60
+ Product::of ($ x )->concat (Stringg::of ($ y ));
61
+ });
76
62
}
77
63
}
0 commit comments