UtilTest.php 627 B

1234567891011121314151617181920212223242526272829
  1. <?php
  2. namespace React\Partial;
  3. use React\Partial\Util as Partial;
  4. class UtilTest extends \PHPUnit_Framework_TestCase
  5. {
  6. public function testBind()
  7. {
  8. $div = $this->createDivFunction();
  9. $divFun = Partial::bind($div, 10, 5);
  10. $this->assertSame(0.02, $divFun(100));
  11. }
  12. public function testBindRight()
  13. {
  14. $div = $this->createDivFunction();
  15. $divFun = Partial::bindRight($div, 10, 5);
  16. $this->assertSame(2, $divFun(100));
  17. }
  18. private function createDivFunction()
  19. {
  20. return function ($a, $b, $c) {
  21. return $a / $b / $c;
  22. };
  23. }
  24. }