use Widmogrod\Functional as f;
use Widmogrod\Helpful\MonoidLaws;
use Widmogrod\Helpful\SetoidLaws;
+use Widmogrod\Primitive\Product;
use Widmogrod\Primitive\Sum;
class SumTest extends \PHPUnit\Framework\TestCase
{
/**
- * @dataProvider provideSetoidLaws
+ * @dataProvider provideRandomizedData
*/
public function test_it_should_obay_setoid_laws(
$a,
}
/**
- * @dataProvider provideSetoidLaws
+ * @dataProvider provideRandomizedData
*/
public function test_it_should_obay_monoid_laws(
$a,
);
}
+ /**
+ * @expectedException \Widmogrod\Primitive\TypeMismatchError
+ * @expectedExceptionMessage Expected type is Widmogrod\Primitive\Sum but given Widmogrod\Primitive\Product
+ * @dataProvider provideRandomizedData
+ */
+ public function test_it_should_reject_concat_on_different_type(Sum $a)
+ {
+ $a->concat(Product::of(1));
+ }
+
private function randomize()
{
return Sum::of(random_int(-100000000, 100000000));
}
- public function provideSetoidLaws()
+ public function provideRandomizedData()
{
return array_map(function () {
return [