diff --git a/tests/PartialApplicationTest.php b/tests/PartialApplicationTest.php index 6bed981..d29c63e 100644 --- a/tests/PartialApplicationTest.php +++ b/tests/PartialApplicationTest.php @@ -84,4 +84,22 @@ class PartialApplicationTest extends \PHPUnit\Framework\TestCase $applied(1); } + + public function testYCombinatorFactorial() + { + $applied = f\fix(function ($f) { + return function ($x) use ($f) { return $x >= 2 ? $f($x-1) * $x : 1; }; + }); + + $this->assertEquals(6, $applied(3)); + $this->assertEquals(24, $applied(4)); + } + + public function testYCombinatorCurried() + { + $applied = f\fix(f\curry(function ($f, $x) { return $x >= 2 ? $f($x-1) * $x : 1; })); + + $this->assertEquals(6, $applied(3)); + $this->assertEquals(24, $applied(4)); + } } \ No newline at end of file