var array;

require('./_prepare');

array = mod('array');

test('from', function() {
  array.from([1]).should.be.an.instanceOf(Array);
  return array.from([1])[0].should.equal(1);
});

test('pluck', function() {
  var a, after;
  a = [0, 1, 2, 3];
  after = array.pluck(a, 1);
  after.length.should.equal(3);
  after[0].should.equal(0);
  after[1].should.equal(2);
  after[2].should.equal(3);
  return after.should.equal(a);
});

test('pluckMultiple', function() {
  var a;
  a = [0, 1, 2, 3, 4, 5, 6];
  array.pluckMultiple(a, [0, 4, 2, 6]);
  a.length.should.equal(3);
  a[0].should.equal(1);
  a[1].should.equal(3);
  return a[2].should.equal(5);
});

test('pluckItem', function() {
  var a;
  a = [0, 1, 2, 3, 2, 4, 2];
  array.pluckItem(a, 2);
  a[0].should.equal(0);
  a[1].should.equal(1);
  a[2].should.equal(3);
  a[3].should.equal(4);
  return array.pluckItem([1], 2).length.should.equal(1);
});

test('pluckOneItem', function() {
  var a;
  a = [0, 1, 2, 3, 2, 4, 2];
  array.pluckOneItem(a, 2);
  a[0].should.equal(0);
  a[1].should.equal(1);
  a[2].should.equal(3);
  a[3].should.equal(2);
  a[4].should.equal(4);
  a[5].should.equal(2);
  a = [1, 2];
  array.pluckOneItem(a, 1);
  a.length.should.equal(1);
  a[0].should.equal(2);
  array.pluckOneItem([], 1).length.should.equal(0);
  return array.pluckOneItem([1], 2).length.should.equal(1);
});

test('plcukByCallback', function() {
  var a;
  a = [0, 1, 2, 3];
  array.pluckByCallback(a, function(val, i) {
    if (val === 2) {
      return true;
    }
    return false;
  });
  a[0].should.equal(0);
  a[1].should.equal(1);
  return a[2].should.equal(3);
});

test('injectByCallback', function() {
  var a, shouldInject;
  shouldInject = function(valA, valB, toInject) {
    if (valA == null) {
      if (toInject <= valB) {
        return true;
      }
      return false;
    }
    if (valB == null) {
      if (valA <= toInject) {
        return true;
      }
      return false;
    }
    if ((valA <= toInject && toInject <= valB)) {
      return true;
    }
    return false;
  };
  a = [0.5, 1, 2.5, 2.5, 2.75, 2.75, 3];
  array.injectByCallback(a, 0, shouldInject);
  a[0].should.equal(0);
  a[1].should.equal(0.5);
  a[7].should.equal(3);
  a = [0.5, 1, 2.5, 2.5, 2.75, 2.75, 3];
  array.injectByCallback(a, 2.7, shouldInject);
  a[0].should.equal(0.5);
  a[4].should.equal(2.7);
  a[5].should.equal(2.75);
  a[7].should.equal(3);
  a = [0.5, 1, 2.5, 2.5, 2.75, 2.75, 3];
  array.injectByCallback(a, 3.2, shouldInject);
  a[0].should.equal(0.5);
  a[4].should.equal(2.75);
  a[6].should.equal(3);
  return a[7].should.equal(3.2);
});

//# sourceMappingURL=data:application/json;base64,[encoded data, 27916 characters]