<commit_before>var ordering = require('../ordering.js');

var listEqual = function(l1, l2, test) {
	test.equal(l1.length, l2.length);
	l1.forEach(function(element, index) {
		test.equal(element, l2[index]);
	});
};

exports.test = {
	'reverse': function(test) {
		var list = [2, 3, 0].sort(ordering.reverse());
		listEqual(list, [3, 2, 0], test);
		test.done();
	},
	'double reverse': function(test) {
		var list = [2, 3, 0].sort(ordering.reverse().reverse());
		listEqual(list, [0, 2, 3], test);
		test.done();
	},
	'on result of': function(test) {
		var v1 = {
			value: 1
		}, v3 = {
				value: 3
			}, v5 = {
				value: 5
			},
			list = [v3, v5, v1].sort(ordering.onResultOf(function(item) {
				return item.value;
			}));
		listEqual(list, [v1, v3, v5], test);
		// other syntax
		list = [v3, v5, v1].sort(ordering.onResultOf(function() {
			return this.value;
		}));
		listEqual(list, [v1, v3, v5], test);
		test.done();
	},
	'on path':  function(test) {
		var v1 = {
			value: 1
		}, v3 = {
				value: 3
			}, v5 = {
				value: 5
			},
			list = [v3, v5, v1].sort(ordering.onPath('.value'));
		listEqual(list, [v1, v3, v5], test);<commit_msg>Update test for new syntax<commit_after>var ordering = require('../ordering.js');

var listEqual = function(l1, l2, test) {
	test.equal(l1.length, l2.length);
	l1.forEach(function(element, index) {
		test.equal(element, l2[index]);
	});
};

exports.test = {
	'reverse': function(test) {
		var list = [2, 3, 0].sort(ordering.reverse());
		listEqual(list, [3, 2, 0], test);
		test.done();
	},
	'double reverse': function(test) {
		var list = [2, 3, 0].sort(ordering.reverse().reverse());
		listEqual(list, [0, 2, 3], test);
		test.done();
	},
	'on result of': function(test) {
		var v1 = {
			value: 1
		}, v3 = {
				value: 3
			}, v5 = {
				value: 5
			},
			list = [v3, v5, v1].sort(ordering.onResultOf(function(item) {
				return item.value;
			}));
		listEqual(list, [v1, v3, v5], test);
		// other syntax
		list = [v3, v5, v1].sort(ordering.onResultOf(function() {
			return this.value;
		}));
		listEqual(list, [v1, v3, v5], test);
		test.done();
	},
	'on path':  function(test) {
		var v1 = {
			value: 1
		}, v3 = {
				value: 3
			}, v5 = {
				value: 5
			},
			list = [v3, v5, v1].sort(ordering.onPath('.value'));
		listEqual(list, [v1, v3, v5], test);
		
		// alternative syntax
		list = [v3, v5, v1].sort(ordering.onPath('value'));
		listEqual(list, [v1, v3, v5], test);
		
		// alternative syntax
		list = [v3, v5, v1].sort(ordering.onPath(['value']));
		listEqual(list, [v1, v3, v5], test);

{'fraction_non_alphanumeric': 0.2112676056338028, 'fraction_numerical': 0.04225352112676056, 'mean_word_length': 3.2334437086092715, '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': '4179316', 'n_tokens_mistral': 1199, 'n_tokens_neox': 1038, 'n_words': 231}