Beispiel #1
0
 /**
  * @dataProvider provideData
  */
 public function test_if_io_monad_obeys_the_laws($f, $g, $x)
 {
     MonadLaws::test(function (IO $f, IO $g, $message) {
         $this->assertEquals($f->run(), $g->run(), $message);
     }, function ($x) {
         return IO::of(function () use($x) {
             return $x;
         });
     }, $f, $g, $x);
 }
 /**
  * @dataProvider provideData
  */
 public function test_if_identity_monad_obeys_the_laws($f, $g, $x)
 {
     MonadLaws::test(f\curryN(3, [$this, 'assertEquals']), f\curryN(1, Identity::of), $f, $g, $x);
 }
 /**
  * @dataProvider provideData
  */
 public function test_if_writer_monad_obeys_the_laws($f, $g, $x)
 {
     MonadLaws::test(function (Writer $a, Writer $b, $message) {
         $this->assertEquals($a->runWriter(), $b->runWriter(), $message);
     }, Writer\pure, $f, $g, $x);
 }
Beispiel #4
0
 /**
  * @dataProvider provideData
  */
 public function test_if_maybe_monad_obeys_the_laws($return, $f, $g, $x)
 {
     MonadLaws::test(f\curryN(3, [$this, 'assertEquals']), f\curryN(1, $return), $f, $g, $x);
 }
 /**
  * @dataProvider provideData
  */
 public function test_if_reader_monad_obeys_the_laws($f, $g, $x, $env)
 {
     MonadLaws::test(function (Reader $a, Reader $b, $message) use($env) {
         $this->assertEquals($a->runReader($env), $b->runReader($env), $message);
     }, Reader\value, $f, $g, $x);
 }
Beispiel #6
0
 /**
  * @dataProvider provideData
  */
 public function test_if_state_monad_obeys_the_laws($f, $g, $x, $state)
 {
     MonadLaws::test(function (State $a, State $b, $message) use($state) {
         $this->assertEquals($a->runState($state), $b->runState($state), $message);
     }, State\value, $f, $g, $x);
 }
Beispiel #7
0
 /**
  * @dataProvider provideData
  */
 public function test_if_list_obeys_the_laws($f, $g, $x)
 {
     MonadLaws::test(f\curryN(3, [$this, 'assertEquals']), f\curryN(1, Listt::of), $f, $g, $x);
 }