コード例 #1
0
ファイル: EitherTest.php プロジェクト: php-fp/php-fp-either
 public function testEither()
 {
     $addOne = function ($x) {
         return $x + 1;
     };
     $takeOne = function ($x) {
         return $x - 1;
     };
     $a = new Right(2);
     $b = new Left(2);
     $this->assertEquals($a->either($addOne, $takeOne), 1, 'Eithers a Right.');
     $this->assertEquals($b->either($addOne, $takeOne), 3, 'Eithers a Left.');
 }