<commit_before><?php
namespace Icecave\Collections;

use Eloquent\Liberator\Liberator;
use PHPUnit_Framework_TestCase;

class LinkedListTest extends PHPUnit_Framework_TestCase
{
    public function setUp()
    {
        $this->_collection = new LinkedList;
    }

    public function tearDown()
    {
        // Verify size ...
        $this->assertSame(count($this->_collection->elements()), $this->_collection->size());

        // Verify tail node ...
        $head = Liberator::liberate($this->_collection)->head;
        $tail = Liberator::liberate($this->_collection)->tail;

        for ($node = $head; $node && null !== $node->next; $node = $node->next) {
            // no-op ...
        }
        $this->assertSame($tail, $node);
    }

    public function testConstructor()
    {
        $this->assertSame(0, $this->_collection->size());
    }

    public function testConstructorWithArray()
    {
        $collection = new LinkedList(array(1, 2, 3));
        $this->assertSame(array(1, 2, 3), $collection->elements());
    }

    public function testClone()
    {
        $this->_collection->pushBack(1);
        $this->_collection->pushBack(2);
        $this->_collection->pushBack(3);

        $collection = clone $this->_collection;

        $collection->popBack();

        $this->assertSame(array(1, 2), $collection->elements());
        $this->assertSame(array(1, 2, 3), $this->_collection->elements());
    }

    ///////////////////////////////////////////
    // Implementation of CollectionInterface //
    ///////////////////////////////////////////

    public function testSize()
    {
        $this->assertSame(0, $this->_collection->size());<commit_msg>Added test path for LinkedList:: cloning.<commit_after><?php
namespace Icecave\Collections;

use Eloquent\Liberator\Liberator;
use PHPUnit_Framework_TestCase;

class LinkedListTest extends PHPUnit_Framework_TestCase
{
    public function setUp()
    {
        $this->_collection = new LinkedList;
    }

    public function tearDown()
    {
        // Verify size ...
        $this->assertSame(count($this->_collection->elements()), $this->_collection->size());

        // Verify tail node ...
        $head = Liberator::liberate($this->_collection)->head;
        $tail = Liberator::liberate($this->_collection)->tail;

        for ($node = $head; $node && null !== $node->next; $node = $node->next) {
            // no-op ...
        }
        $this->assertSame($tail, $node);
    }

    public function testConstructor()
    {
        $this->assertSame(0, $this->_collection->size());
    }

    public function testConstructorWithArray()
    {
        $collection = new LinkedList(array(1, 2, 3));
        $this->assertSame(array(1, 2, 3), $collection->elements());
    }

    public function testClone()
    {
        $this->_collection->pushBack(1);
        $this->_collection->pushBack(2);
        $this->_collection->pushBack(3);

        $this->_collection->rewind();
        $this->_collection->next();

        $collection = clone $this->_collection;

        // Check that currentNode is updated correctly ...
        $this->assertSame(2, $collection->current());
        $this->assertSame(2, $this->_collection->current());

        $collection->popBack();

        $this->assertSame(array(1, 2), $collection->elements());
        $this->assertSame(array(1, 2, 3), $this->_collection->elements());
    }

    ///////////////////////////////////////////
    // Implementation of CollectionInterface //
    ///////////////////////////////////////////

    public function testSize()
    {
        $this->assertSame(0, $this->_collection->size());
{'fraction_non_alphanumeric': 0.2045079714128642, 'fraction_numerical': 0.009345794392523364, 'mean_word_length': 2.2346666666666666, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 80, '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': '6023530', 'n_tokens_mistral': 1013, 'n_tokens_neox': 977, 'n_words': 184}