<commit_before><?php

namespace Ardent;

class CallableMock {
    function __invoke($a, $b) {
        return $a[0] == $b[0];
    }
}

class LinkedListTest extends \PHPUnit_Framework_TestCase {

    /**
     * @covers \Ardent\LinkedList::count
     * @covers \Ardent\LinkedList::key
     * @covers \Ardent\LinkedList::offsetSet
     * @covers \Ardent\LinkedList::offsetGet
     * @covers \Ardent\LinkedList::pushBack
     * @covers \Ardent\LinkedList::__seek
     */
    function testOffsetGetAndSet() {
        $list = new LinkedList();

        $list->offsetSet(NULL, 0);
        $this->assertEquals(0, $list->key());
        $this->assertCount(1, $list);
        $this->assertEquals(0, $list[0]);

        $list->offsetSet(NULL, 1);
        $this->assertEquals(1, $list->key());
        $this->assertCount(2, $list);
        $this->assertEquals(0, $list[0]);
        $this->assertEquals(1, $list[1]);

        $list->offsetSet(0, 2);
        $this->assertEquals(0, $list->key());
        $this->assertCount(2, $list);
        $this->assertEquals(2, $list[0]);
        $this->assertEquals(1, $list[1]);
        $this->assertEquals(1, $list->key());
    }

    /**
     * @covers \Ardent\LinkedList::offsetSet
     * @expectedException \Ardent\IndexException
     */
    function testOffsetSetIndexException() {
        $list = new LinkedList();
        $list->offsetSet(0, 0);
    }

    /**
     * @covers \Ardent\LinkedList::offsetGet
     * @expectedException \Ardent\IndexException
     */
    function testOffsetGetIndexException() {
        $list = new LinkedList();
        $list->offsetGet(0);
    }

    /**
     * @covers \Ardent\LinkedList::offsetUnset
     */
    function testOffsetUnsetNonExistent() {
        $list = new LinkedList();
        $list->offsetUnset(0);
    }

    /**
     * @depends testOffsetGetAndSet
     * @covers \Ardent\LinkedList::offsetUnset
     * @covers \Ardent\LinkedList::removeNode
     */
    function testOffsetUnsetOneItem() {
        $list = new LinkedList();
        $list->pushBack(0);
        $list->offsetUnset(0);

        $this->assertCount(0, $list);
    }

    /**
     * @depends testOffsetGetAndSet
     * @covers \Ardent\LinkedList::offsetUnset
     * @covers \Ardent\LinkedList::removeNode
     * @covers \Ardent\LinkedList::seek
     */
    function testOffsetUnsetHead() {
        $list = new LinkedList();
        $list->pushBack(0);
        $list->pushBack(1);
        $list->offsetUnset(0);
        $this->assertEquals(0, $list->key());

        $this->assertCount(1, $list);
        $this->assertEquals(1, $list->offsetGet(0));
    }

    /**
     * @depends testOffsetGetAndSet
     * @covers \Ardent\LinkedList::offsetUnset
     * @covers \Ardent\LinkedList::removeNode
     * @covers \Ardent\LinkedList::seek
     */
    function testOffsetUnsetTail() {
        $list = new LinkedList();
        $list->pushBack(0);
        $list->pushBack(1);
        $list->offsetUnset(1);

        $this->assertEquals(0, $list->key());

        $this->assertCount(1, $list);
        $this->assertEquals(0, $list->offsetGet(0));
    }

    /**
     * @depends testOffsetGetAndSet
     * @covers \Ardent\LinkedList::offsetUnset
     * @covers \Ardent\LinkedList::removeNode
     * @covers \Ardent\LinkedList::seek
     */
    function testOffsetUnsetMiddle() {
        $list = new LinkedList();
        $list->pushBack(0);
        $list->pushBack(1);
        $list->pushBack(2);
        $list->offsetUnset(1);

        $this->assertEquals(1, $list->key());

        $this->assertCount(2, $list);
        $this->assertEquals(0, $list->offsetGet(0));
        $this->assertEquals(2, $list->offsetGet(1));
    }<commit_msg>Improved tests regarding the internal current pointer.<commit_after><?php

namespace Ardent;

class CallableMock {
    function __invoke($a, $b) {
        return $a[0] == $b[0];
    }
}

class LinkedListTest extends \PHPUnit_Framework_TestCase {

    /**
     * @covers \Ardent\LinkedList::count
     * @covers \Ardent\LinkedList::key
     * @covers \Ardent\LinkedList::offsetSet
     * @covers \Ardent\LinkedList::offsetGet
     * @covers \Ardent\LinkedList::pushBack
     * @covers \Ardent\LinkedList::__seek
     */
    function testOffsetGetAndSet() {
        $list = new LinkedList();

        $list->offsetSet(NULL, 0);
        $this->assertEquals(0, $list->key());
        $this->assertCount(1, $list);
        $this->assertEquals(0, $list[0]);

        $list->offsetSet(NULL, 1);
        $this->assertEquals(1, $list->key());
        $this->assertCount(2, $list);
        $this->assertEquals(0, $list[0]);
        $this->assertEquals(1, $list[1]);

        $list->offsetSet(0, 2);
        $this->assertEquals(0, $list->key());
        $this->assertCount(2, $list);
        $this->assertEquals(2, $list[0]);
        $this->assertEquals(1, $list[1]);
        $this->assertEquals(1, $list->key());
    }

    /**
     * @covers \Ardent\LinkedList::offsetSet
     * @expectedException \Ardent\IndexException
     */
    function testOffsetSetIndexException() {
        $list = new LinkedList();
        $list->offsetSet(0, 0);
    }

    /**
     * @covers \Ardent\LinkedList::offsetGet
     * @expectedException \Ardent\IndexException
     */
    function testOffsetGetIndexException() {
        $list = new LinkedList();
        $list->offsetGet(0);
    }

    /**
     * @covers \Ardent\LinkedList::offsetUnset
     */
    function testOffsetUnsetNonExistent() {
        $list = new LinkedList();
        $list->offsetUnset(0);
    }

    /**
     * @depends testOffsetGetAndSet
     * @covers \Ardent\LinkedList::offsetUnset
     * @covers \Ardent\LinkedList::removeNode
     */
    function testOffsetUnsetOneItem() {
        $list = new LinkedList();
        $list->pushBack(0);
        $list->offsetUnset(0);

        $this->assertCount(0, $list);
    }

    /**
     * @depends testOffsetGetAndSet
     * @covers \Ardent\LinkedList::offsetUnset
     * @covers \Ardent\LinkedList::removeNode
     * @covers \Ardent\LinkedList::seek
     */
    function testOffsetUnsetHead() {
        $list = new LinkedList();
        $list->pushBack(0);
        $list->pushBack(1);

        $list->offsetUnset(0);
        $this->assertEquals(0, $list->key());
        $this->assertEquals(1, $list->current());
        $this->assertCount(1, $list);
        $this->assertEquals(1, $list->offsetGet(0));
    }

    /**
     * @depends testOffsetGetAndSet
     * @covers \Ardent\LinkedList::offsetUnset
     * @covers \Ardent\LinkedList::removeNode
     * @covers \Ardent\LinkedList::seek
     */
    function testOffsetUnsetTail() {
        $list = new LinkedList();
        $list->pushBack(1);
        $list->pushBack(2);

        $list->offsetUnset(1);
        $this->assertEquals(0, $list->key());
        $this->assertEquals(1, $list->current());
        $this->assertCount(1, $list);
        $this->assertEquals(1, $list->offsetGet(0));
    }

    /**
     * @depends testOffsetGetAndSet
     * @covers \Ardent\LinkedList::offsetUnset
     * @covers \Ardent\LinkedList::removeNode
     * @covers \Ardent\LinkedList::seek
     */
    function testOffsetUnsetMiddle() {
        $list = new LinkedList();
        $list->pushBack(0);
        $list->pushBack(2);
        $list->pushBack(4);

        $list->offsetUnset(1);
        $this->assertEquals(1, $list->key());
        $this->assertEquals(4, $list->current());
        $this->assertCount(2, $list);
        $this->assertEquals(0, $list->offsetGet(0));
        $this->assertEquals(4, $list->offsetGet(1));
    }
{'fraction_non_alphanumeric': 0.17058276914907738, 'fraction_numerical': 0.014735165272799682, 'mean_word_length': 2.507448789571695, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 113, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '947102', 'n_tokens_mistral': 2507, 'n_tokens_neox': 2418, 'n_words': 362}