/** * @covers PHPixme\__PRIVATE__::curryExactly2 */ public function test_curryExactly2() { $arity2 = internal::curryExactly2(function (...$args) { return $args; }); self::assertInstanceOf(Closure, $arity2, 'it should wrap into a closure'); // Testing thunks self::assertInstanceOf(Closure, $arity2(), 'thunks should return a closure'); self::assertSame($arity2, $arity2(), 'at zero arguments, that closure should be itself'); self::assertSame($arity2, $arity2(_(), _()), 'thunks should have no effect'); self::assertSame($arity2, $arity2(_()), 'thunks should have no effect'); // Test eating self::assertEquals([1, 2], $arity2(1, 2, 3, 4), 'the function should eat all but two arguments'); // v1 defined self::assertEquals($arity2(1)->__invoke(2, 3, 4, 5), $arity2(1, 2, 6, 7, 8)); $intermediate = $arity2(1); self::assertSame($intermediate, $intermediate(), 'An intermediate X1 _2 should be a thunk'); self::assertSame($intermediate, $intermediate(_()), 'An intermediate X1 _2 should be a thunk'); // v2 defined self::assertEquals($arity2(_(), 2)->__invoke(1, 3, 4, 5), $arity2(1, 2, 6, 7, 8)); $intermediate = $arity2(_(), 2); self::assertSame($intermediate, $intermediate(), 'An intermediate X1 _2 should be a thunk'); self::assertSame($intermediate, $intermediate(_()), 'An intermediate X1 _2 should be a thunk'); }