<commit_before>var util = require('util');

var check = function(ctor, n, pred) {
	var name = util.format("quickselect (new %s(%d), %s)", ctor.name, n, pred);
	console.log(name);
	test(name, function (assert) {

		// SETUP RANDOM
		var randint = algo.randint;
		var sample = algo.sample_t(randint);
		var shuffle = algo.shuffle_t(sample);
		var iota = algo.iota;

		// SETUP SORT
		var partition = algo.partition_t(pred);
		var quicksort = algo.quicksort_t(partition);
		var quickselect = algo.quickselect_t(partition);

		// SETUP REF ARRAY
		var ref = new ctor(n);
		iota(ref, 0, n, 0);
		shuffle(ref, 0, n);
		quicksort(ref, 0, n);

		// SETUP TEST ARRAY
		var a = ref.slice();

		// TEST PREDICATE
		var i = a.length;
		while (i--) {
			shuffle(a, 0, n);
			quickselect(i, a, 0, n);
			deepEqual(a[i], ref[i], 'select #' + i);
		}
<commit_msg>fix bug with node 0.11 (slice does not exist on typed arrays)<commit_after>var util = require('util');

var check = function(ctor, n, pred) {
	var name = util.format("quickselect (new %s(%d), %s)", ctor.name, n, pred);
	console.log(name);
	test(name, function (assert) {

		// SETUP RANDOM
		var randint = algo.randint;
		var sample = algo.sample_t(randint);
		var shuffle = algo.shuffle_t(sample);
		var iota = algo.iota;
		var copy = algo.copy;

		// SETUP SORT
		var partition = algo.partition_t(pred);
		var quicksort = algo.quicksort_t(partition);
		var quickselect = algo.quickselect_t(partition);

		// SETUP REF ARRAY
		var ref = new ctor(n);
		iota(ref, 0, n, 0);
		shuffle(ref, 0, n);
		quicksort(ref, 0, n);

		// SETUP TEST ARRAY
		var a = new ctor(n);
		copy(ref, 0, n, a, 0);

		// TEST PREDICATE
		var i = a.length;
		while (i--) {
			shuffle(a, 0, n);
			quickselect(i, a, 0, n);
			deepEqual(a[i], ref[i], 'select #' + i);
		}

{'fraction_non_alphanumeric': 0.1652707984366276, 'fraction_numerical': 0.009491903964265773, 'mean_word_length': 3.3389830508474576, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '5878773', 'n_tokens_mistral': 785, 'n_tokens_neox': 703, 'n_words': 194}