<commit_before>let assert = require('chai').assert;

import {lift} from '../../src/index.es6';

describe('lift', () => {
  let add3 = (a,b,c) => a + b + c;

  var addN3 = lift(add3);

  it('returns a function', () => {
    assert.strictEqual(typeof lift(add3, 3), 'function');
  });

  it('limits a variadic function to the specified arity', () => {
    assert.deepEqual(addN3([1, 10], [2], [3]), [6, 15]);
  });

  it('produces a cross-product of array values', () => {
    assert.deepEqual(addN3([1, 2, 3], [1, 2], [1, 2, 3]), [3, 4, 5, 4, 5, 6, 4, 5, 6, 5, 6, 7, 5, 6, 7, 6, 7, 8]);
    assert.deepEqual(addN3([1], [2], [3]), [6]);
    assert.deepEqual(addN3([1, 2], [3, 4], [5, 6]), [9, 10, 10, 11, 10, 11, 11, 12]);
  });
});<commit_msg>test(lift): test functions with different arity<commit_after>let assert = require('chai').assert;

import {lift} from '../../src/index.es6';

describe('lift', () => {
  const add3 = (a,b,c) => a + b + c;
  const add4 = (a,b,c,d) => a + b + c + d;
  const add5 = (a,b,c,d,e) => a + b + c + d + e;

  const liftedAdd3 = lift(add3);
  const liftedAdd4 = lift(add4);
  const liftedAdd5 = lift(add5);

  it('returns a function', () => {
    assert.strictEqual(typeof lift(add3, 3), 'function');
  });

  it('limits a variadic function to the specified arity', () => {
    assert.deepEqual(liftedAdd3([1, 10], [2], [3]), [6, 15]);
  });

  it('produces a cross-product of array values', () => {
    assert.deepEqual(liftedAdd3([1, 2, 3], [1, 2], [1, 2, 3]), [3, 4, 5, 4, 5, 6, 4, 5, 6, 5, 6, 7, 5, 6, 7, 6, 7, 8]);
    assert.deepEqual(liftedAdd3([1], [2], [3]), [6]);
    assert.deepEqual(liftedAdd3([1, 2], [3, 4], [5, 6]), [9, 10, 10, 11, 10, 11, 11, 12]);
  });

  it('can lift functions of any arity', function() {
    assert.deepEqual(liftedAdd3([1, 10], [2], [3]), [6, 15]);
    assert.deepEqual(liftedAdd4([1, 10], [2], [3], [40]), [46, 55]);
    assert.deepEqual(liftedAdd5([1, 10], [2], [3], [40], [500, 1000]), [546, 1046, 555, 1055]);
  });
});
{'fraction_non_alphanumeric': 0.2570281124497992, 'fraction_numerical': 0.09738955823293173, 'mean_word_length': 3.602771362586605, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 7, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2608458', 'n_tokens_mistral': 959, 'n_tokens_neox': 817, 'n_words': 233}