<commit_before>import * as L from '../src/List';
import should from 'should';

const id = a => a

describe('List', () => {
  describe('head', () => {
    it('head([1,2,3])', () => {
      L.head([1, 2, 3]).should.be.eql(1);
    });
    it('head([1,2])', () => {
      L.head([1, 2]).should.be.eql(1);
    });
    it('head([1])', () => {
      L.head([1]).should.be.eql(1);
    });
    it('head([])', () => {
      (() => { L.head([]) }).should.throw('haskind.List.head: empty list');
    });
  });
  describe('last', () => {
    it('([1,2,3])', () => {
      L.last([1, 2, 3]).should.be.eql(3);
    });
    it('([1,2])', () => {
      L.last([1, 2]).should.be.eql(2);
    });
    it('([1])', () => {
      L.last([1]).should.be.eql(1);
    });
    it('([])', () => {
      (() => { L.last([]) }).should.throw('haskind.List.last: empty list');
    });
  });
  describe('tail', () => {
    it('([1,2,3])', () => {
      L.tail([1,2,3]).should.be.eql([2,3]);
    });
    it('([1,2])', () => {
      L.tail([1,2]).should.be.eql([2]);
    });
    it('([1])', () => {
      L.tail([1]).should.be.eql([]);
    });
    it('([])', () => {
      L.tail([]).should.be.eql([]);
    });
  });
  describe('init', () => {
    it('([1,2,3])', () => {
      L.init([1, 2, 3]).should.be.eql([1,2]);
    });
    it('([1,2])', () => {
      L.init([1, 2]).should.be.eql([1]);
    });
    it('([1])', () => {
      L.init([1]).should.be.eql([]);
    });
    it('([])', () => {
      (() => { L.init([]) }).should.throw('haskind.List.init: empty list');
    });
  });
  
  describe('length', () => {
    it('works', () => {
      should(L.length([])).be.eql(0);
      should(L.length({})).be.eql(0);

      L.length([1]).should.be.eql(1);
      L.length([1, 2, 3]).should.be.eql(3);
      L.length({ '1': 1 }).should.be.eql(1);
    });
  });
  describe('map', () => {
    it('works', () => {
      const fn = x => x + 1

      L.map(id, [1,2,3]).should.eql([1,2,3]);
      L.map(fn, [1,2,3]).should.eql([2,3,4]);
    });
  });
  describe('filter', () => {
    it('works', () => {
      const fn = x => x % 2 === 0;

      L.filter(id, [1,2,3]).should.eql([1,2,3]);
      L.filter(fn, [1,2,3]).should.eql([2]);
    });
  });
  describe('foldl', () => {
    it('works', () => {
      const fn = (acc, x) => acc + x;

      L.foldl(id, 0, [1,2,3]).should.eql(0);
      L.foldl(fn, 0, [1,2,3]).should.eql(6);
    });
  });
});<commit_msg>change test format throughout<commit_after>import * as L from '../src/List';
import should from 'should';

const id = a => a

describe('List', () => {
  describe('head', () => {
    it('head([1,2,3])', () => {
      L.head([1, 2, 3]).should.be.eql(1);
    });
    it('head([1,2])', () => {
      L.head([1, 2]).should.be.eql(1);
    });
    it('head([1])', () => {
      L.head([1]).should.be.eql(1);
    });
    it('head([])', () => {
      (() => { L.head([]) }).should.throw('haskind.List.head: empty list');
    });
  });
  describe('last', () => {
    it('([1,2,3])', () => {
      L.last([1, 2, 3]).should.be.eql(3);
    });
    it('([1,2])', () => {
      L.last([1, 2]).should.be.eql(2);
    });
    it('([1])', () => {
      L.last([1]).should.be.eql(1);
    });
    it('([])', () => {
      (() => { L.last([]) }).should.throw('haskind.List.last: empty list');
    });
  });
  describe('tail', () => {
    it('([1,2,3])', () => {
      L.tail([1,2,3]).should.be.eql([2,3]);
    });
    it('([1,2])', () => {
      L.tail([1,2]).should.be.eql([2]);
    });
    it('([1])', () => {
      L.tail([1]).should.be.eql([]);
    });
    it('([])', () => {
      L.tail([]).should.be.eql([]);
    });
  });
  describe('init', () => {
    it('([1,2,3])', () => {
      L.init([1, 2, 3]).should.be.eql([1,2]);
    });
    it('([1,2])', () => {
      L.init([1, 2]).should.be.eql([1]);
    });
    it('([1])', () => {
      L.init([1]).should.be.eql([]);
    });
    it('([])', () => {
      (() => { L.init([]) }).should.throw('haskind.List.init: empty list');
    });
  });

  describe('length', () => {
    it('works', () => {
      should(L.length([])).be.eql(0);
      should(L.length({})).be.eql(0);

      L.length([1]).should.be.eql(1);
      L.length([1, 2, 3]).should.be.eql(3);
      L.length({ '1': 1 }).should.be.eql(1);
    });
  });
  describe('map', () => {
    it('(id, [1,2,3])', () => {
      L.map(id, [1,2,3]).should.eql([1,2,3]);
    });
    it('(succ, [1,2,3])', () => {
      const fn = x => x + 1
      L.map(fn, [1,2,3]).should.eql([2,3,4]);
    });
  });
  describe('filter', () => {
    it('(id, [1,2,3])', () => {
      L.filter(id, [1,2,3]).should.eql([1,2,3]);
    });
    it('(isEven, [1,2,3])', () => {
      const fn = x => x % 2 === 0;
      L.filter(fn, [1,2,3]).should.eql([2]);
    });
  });
  describe('foldl', () => {
    it('(id, 0, [1,2,3])', () => {
      L.foldl(id, 0, [1,2,3]).should.eql(0);
    });
    it('(add, 0, [1,2,3])', () => {
      const fn = (acc, x) => acc + x;
      L.foldl(fn, 0, [1,2,3]).should.eql(6);
    });
  });
});
{'fraction_non_alphanumeric': 0.359375, 'fraction_numerical': 0.046474358974358976, 'mean_word_length': 2.2633986928104575, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 78, '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': '6458049', 'n_tokens_mistral': 2222, 'n_tokens_neox': 2180, 'n_words': 248}