<commit_before>/* eslint-env mocha */
const LinkedList = require('../../src').DataStructures.LinkedList;
const assert = require('assert');

describe('LinkedList', () => {
  it('should be empty when initialized', () => {
    const inst = new LinkedList();
    assert(inst.isEmpty());
    assert.equal(inst.length, 0);
  });

  it('should have 1 node when pushed', () => {
    const inst = new LinkedList();
    assert(inst.isEmpty());

    inst.push(1);
    assert(!inst.isEmpty());
    assert.equal(inst.length, 1);
  });

  it('should have 1 node when pushed twice and popped once', () => {
    const inst = new LinkedList();

    inst.push(1);
    inst.push(2);
    inst.pop();
    assert(!inst.isEmpty());
    assert.equal(inst.length, 1);
  });

  it('should throw error on popping from empty list', () => {
    const inst = new LinkedList();
    assert(inst.isEmpty());
    assert.throws(() => inst.pop(), Error);
  });
});
<commit_msg>Add: More tests added for LinkedList<commit_after>/* eslint-env mocha */
const LinkedList = require('../../src').DataStructures.LinkedList;
const assert = require('assert');

describe('LinkedList', () => {
  it('should be empty when initialized', () => {
    const inst = new LinkedList();
    assert(inst.isEmpty());
    assert.equal(inst.length, 0);
  });

  it('should have 1 node when pushed', () => {
    const inst = new LinkedList();
    assert(inst.isEmpty());

    inst.push(1);
    assert(!inst.isEmpty());
    assert.equal(inst.length, 1);
  });

  it('should have 1 node when pushed twice and popped once', () => {
    const inst = new LinkedList();

    inst.push(1);
    inst.push(2);
    inst.pop();
    assert(!inst.isEmpty());
    assert.equal(inst.length, 1);
  });

  it('should throw error on popping from empty list', () => {
    const inst = new LinkedList();
    assert(inst.isEmpty());
    assert.throws(() => inst.pop(), Error);
  });

  it('should pop using index', () => {
    const inst = new LinkedList();

    inst.push(1);
    inst.push(2);
    inst.popNodeByIndex(1);
    assert(!inst.isEmpty());
    assert.equal(inst.length, 1);
    const ref = inst.getNodeByIndex(0);
    assert.equal(ref.value, 2);
  });

  it('should return list in string format', () => {
    const inst = new LinkedList();

    inst.push(1);
    inst.push(2);
    const listString = inst.toString();
    assert.equal(listString, '2 -> 1 -> null');
  });  
});

{'fraction_non_alphanumeric': 0.18986289987536353, 'fraction_numerical': 0.01080182800166182, 'mean_word_length': 3.1733102253032928, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 19, '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': '2478184', 'n_tokens_mistral': 768, 'n_tokens_neox': 737, 'n_words': 189}