<commit_before>var deck = require('../');
var test = require('tape');
var every = require('lodash.every');
var reduce = require('lodash.reduce');
var keys = require('lodash.keys');

function shuffler(fn, t) {
  var xs = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
  var xs_ = fn(xs);
  t.deepEqual(xs, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]);
  t.equal(xs.length, 10);
  t.ok(every(xs, function(x) {
    return xs_.indexOf(x) >= 0;
  }));
}

test('shuffle', function(t) {
  t.plan(3);

  shuffler(deck.shuffle, t);
});

test('quick', function(t) {
  t.plan(2);

  var xs = [];
  for (var i = 0; i < 1e5; i++) {
    xs.push(Math.random());
  }

  var t0 = Date.now();
  var xs_ = deck.shuffle(xs);
  var elapsed = Date.now() - t0;
  t.ok(elapsed < 1100);
  t.equal(xs.length, 1e5);
});

test('shuffle object', function(t) {
  t.plan(3);

  shuffler(function(xs) {
    return deck(xs).shuffle();<commit_msg>test: raise shuffle timeout<commit_after>var deck = require('../');
var test = require('tape');
var every = require('lodash.every');
var reduce = require('lodash.reduce');
var keys = require('lodash.keys');

function shuffler(fn, t) {
  var xs = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
  var xs_ = fn(xs);
  t.deepEqual(xs, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]);
  t.equal(xs.length, 10);
  t.ok(every(xs, function(x) {
    return xs_.indexOf(x) >= 0;
  }));
}

test('shuffle', function(t) {
  t.plan(3);

  shuffler(deck.shuffle, t);
});

test('not-so-quick', function(t) {
  t.plan(2);

  var xs = [];
  for (var i = 0; i < 1e5; i++) {
    xs.push(Math.random());
  }

  var t0 = Date.now();
  var xs_ = deck.shuffle(xs);
  var elapsed = Date.now() - t0;
  t.ok(elapsed < 1600);
  t.equal(xs.length, 1e5);
});

test('shuffle object', function(t) {
  t.plan(3);

  shuffler(function(xs) {
    return deck(xs).shuffle();
{'fraction_non_alphanumeric': 0.22724734785036294, 'fraction_numerical': 0.0413176996091569, 'mean_word_length': 3.392156862745098, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, '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': '2682058', 'n_tokens_mistral': 844, 'n_tokens_neox': 760, 'n_words': 182}