public function test_compose() { $expected = ["2", "4", "6", "8", "10"]; $x2 = f::op('*', [2]); $x2_str = f::compose($x2, "strval"); $actual = array_map($x2_str, range(1, 5)); $this->assertContainsOnly('string', $actual); $this->assertSame($expected, $actual); }
public function test_functools_wrapper() { $f = function () { }; $this->assertEquals(f::arity('explode'), _::arity('explode')); $this->assertEquals(f::tuple('hoge'), _::tuple('hoge')); $this->assertEquals(f::cons("a", "b"), _::cons("a", "b")); $this->assertEquals(f::curry($f), _::curry($f)); $this->assertEquals(f::fix($f), _::fix($f, $f)); $this->assertEquals(f::compose($f, $f), _::compose($f, $f)); }