Functional\Tests\DropTest::test PHP Method

test() public method

public test ( )
    public function test()
    {
        $fn = function ($v, $k, $collection) {
            InvalidArgumentException::assertCollection($collection, __FUNCTION__, 3);
            $return = is_int($k) ? $k != 2 : $v[3] != 3;
            return $return;
        };
        $this->assertSame([0 => 'value1', 1 => 'value2'], drop_last($this->list, $fn));
        $this->assertSame([2 => 'value3', 3 => 'value4'], drop_first($this->list, $fn));
        $this->assertSame([2 => 'value3', 3 => 'value4'], drop_first($this->listIterator, $fn));
        $this->assertSame([0 => 'value1', 1 => 'value2'], drop_last($this->listIterator, $fn));
        $this->assertSame(['k3' => 'val3', 'k4' => 'val4'], drop_first($this->hash, $fn));
        $this->assertSame(['k1' => 'val1', 'k2' => 'val2'], drop_last($this->hash, $fn));
        $this->assertSame(['k3' => 'val3', 'k4' => 'val4'], drop_first($this->hashIterator, $fn));
        $this->assertSame(['k1' => 'val1', 'k2' => 'val2'], drop_last($this->hashIterator, $fn));
    }