<commit_before>
(function() {
	var simple = {
		"first": 1,
		"second": 2,
		"third": 3,
		"fourth": 4
	};
	var complex = {
		"first": 1,
		"second": 2,
		"third": 3,
		"fourth": [1,2,3,4,5,6,7,8],
		"fifth": {
			"foo": "bar",
			"baz": 3
		},
		"sixth": ["first","second"]
	};
	
	function eq( input, query, result, title ) {
		if( typeof input == 'string' ) {
			title = result;
			result = query;
			query = input;
			input = [];
		}
		
		deepEqual(jsq(input, query), result, title);
	}
	
	module('Interpreter');
	test('executes unary operations correctly', function() {
		eq('-1, ~1, !1, -2', [-1,-2,false,-2]);
		eq('1--1', [2]);
		eq('0>-1, 1--1', [true,2]);
	});
	
	test('executes binary operations correctly', function() {
		// Arithmetic
		eq('1+2', [3]);
		eq('2-1', [1]);
		eq('2*3', [6]);
		eq('1.5*2', [3]);
		eq('9/3', [3]);
		eq('6/4', [1.5]);
		// Precedence
		eq('1+2*3+2', [9]);
		eq('(1+2)*3+2', [11]);
		eq('1+4/2+1', [4]);
		eq('(2+4)/3+1', [3]);
		eq('((2+4)*2+3)*2', [30]);
		
		// Logical
		eq('1&&2, 2&&1, 1 && 2, 1	&&	2', [2,1,2,2]);
		eq('1&&0, 0&&1', [0,0]);
		eq('1||2, 2||1, 1||0', [1,2,1]);
		eq('1==1, 2!=1, 2>1, 2>=1, 1>=1, 1<2, 1<=2, 1<=1', [true,true,true,true,true,true,true,true]);
		eq('2==1, 1!=1, 1>2, 1>=2, 2<1, 2<=1', [false,false,false,false,false,false]);
		// Precedence
		eq('1||2&&3', [1]);
		eq('(1||2)&&3', [3]);
		eq('0||2&&3', [3]);
		
		// Bitwise
		eq('1\\2', [3]);
		eq('3&7', [3]);
		eq('1^2, 1^3', [3,2]);
		// Precedence
		eq('2\\5&4, (2\\5)&4', [6,4]);
		eq('2&6\\8, 2&(6\\8)', [10,2]);
		eq('7^5&4, (7^5)&4', [3,0]);
		eq('6&4^8, 6&(4^8)', [12,4]);
		eq('7^5\\4, 7^(5\\4)', [6,2]);
		eq('6\\5^4, (6\\5)^4', [7,3]);
	});

	test('executes filters correctly', function() {
		// Simple object
		eq(simple, '.', [simple]);
		eq(simple, '.[]', [1,2,3,4]);
		eq(simple, '.["second"]', [2]);
		eq(simple, '.second', [2]);
		
		// Complex object
		eq(complex, '.[]', [1,2,3,complex['fourth'],complex['fifth'],complex["sixth"]]);
		eq(complex, '.["fifth"]["baz"], .["fifth"].baz, .fifth["baz"], .fifth.baz', [3,3,3,3]);
		eq(complex, '.fifth[]', ['bar',3]);
		eq(complex, '.fourth', [complex["fourth"]]);
		eq(complex, '.fourth[]', complex["fourth"]);
		// Expression as key
		eq(complex, '.fourth[.fourth[0]]', [2]);
		eq(complex, '.[.sixth[]]', [1,2]);
	});

	test('executes pipes correctly', function() {
		eq('2 | .', [2]);
		eq('1,2 | .', [1,2]);
		eq('[1,2] | .', [[1,2]]);
		deepEqual(jsq(complex, '.fifth | .baz'), jsq(complex, '.fifth.baz'));
		deepEqual(jsq(complex, '.[]'), jsq(complex, '. | .[]'));
		deepEqual(jsq(complex, '.fifth[]'), jsq(complex, '.fifth | .[]'));
	});

	test('executes comma separated values correctly', function() {
		eq('1,2,3', [1,2,3]);
		eq('1,2,3 | .', [1,2,3]);
		eq('1,2,3 | .[]', []);
		eq('[1,2,3] | .[]', [1,2,3]);
		eq([1,2,3,4,5,6], '.[1,2,3]', [2,3,4]);
		
		eq('1,1\\2,2+1,4', [1,3,3,4]);
	});
	
	test('executes collections correctly', function() {<commit_msg>Improved filter testing<commit_after>
(function() {
	var simple = {
		"first": 1,
		"second": 2,
		"third": 3,
		"fourth": 4
	};
	var complex = {
		"first": 1,
		"second": 2,
		"third": 3,
		"fourth": [1,2,3,4,5,6,7,8],
		"fifth": {
			"foo": "bar",
			"baz": 3,
			"sub": {
				"one": 1,
				"two": 2
			}
		},
		"sixth": ["first","second"],
		"seventh": ["foo", "bar"]
	};
	
	function eq( input, query, result, title ) {
		if( typeof input == 'string' ) {
			title = result;
			result = query;
			query = input;
			input = [];
		}
		
		deepEqual(jsq(input, query), result, title);
	}
	
	module('Interpreter');
	test('executes unary operations correctly', function() {
		eq('-1, ~1, !1, -2', [-1,-2,false,-2]);
		eq('1--1', [2]);
		eq('0>-1, 1--1', [true,2]);
	});
	
	test('executes binary operations correctly', function() {
		// Arithmetic
		eq('1+2', [3]);
		eq('2-1', [1]);
		eq('2*3', [6]);
		eq('1.5*2', [3]);
		eq('9/3', [3]);
		eq('6/4', [1.5]);
		// Precedence
		eq('1+2*3+2', [9]);
		eq('(1+2)*3+2', [11]);
		eq('1+4/2+1', [4]);
		eq('(2+4)/3+1', [3]);
		eq('((2+4)*2+3)*2', [30]);
		
		// Logical
		eq('1&&2, 2&&1, 1 && 2, 1	&&	2', [2,1,2,2]);
		eq('1&&0, 0&&1', [0,0]);
		eq('1||2, 2||1, 1||0', [1,2,1]);
		eq('1==1, 2!=1, 2>1, 2>=1, 1>=1, 1<2, 1<=2, 1<=1', [true,true,true,true,true,true,true,true]);
		eq('2==1, 1!=1, 1>2, 1>=2, 2<1, 2<=1', [false,false,false,false,false,false]);
		// Precedence
		eq('1||2&&3', [1]);
		eq('(1||2)&&3', [3]);
		eq('0||2&&3', [3]);
		
		// Bitwise
		eq('1\\2', [3]);
		eq('3&7', [3]);
		eq('1^2, 1^3', [3,2]);
		// Precedence
		eq('2\\5&4, (2\\5)&4', [6,4]);
		eq('2&6\\8, 2&(6\\8)', [10,2]);
		eq('7^5&4, (7^5)&4', [3,0]);
		eq('6&4^8, 6&(4^8)', [12,4]);
		eq('7^5\\4, 7^(5\\4)', [6,2]);
		eq('6\\5^4, (6\\5)^4', [7,3]);
	});

	test('executes filters correctly', function() {
		// Simple object
		eq(simple, '.', [simple]);
		eq(simple, '.[]', [1,2,3,4]);
		eq(simple, '.["second"]', [2]);
		eq(simple, '.second', [2]);
		
		// Complex object
		eq(complex, '.[]', [1,2,3,complex['fourth'],complex['fifth'],complex['sixth'],complex['seventh']]);
		eq(complex, '.["fifth"]["baz"], .["fifth"].baz, .fifth["baz"], .fifth.baz', [3,3,3,3]);
		eq(complex, '.fifth[]', ['bar',3,complex['fifth']['sub']]);
		eq(complex, '.fourth', [complex["fourth"]]);
		eq(complex, '.fourth[]', complex["fourth"], 'All children of a sub-key');
		eq([{'first':1}, {'first':2}], '.[].first', [1,2], 'Sub-key of all children');
		// Expression as key
		eq(complex, '.fourth[.fourth[0]]', [2]);
		eq(complex, '.[.sixth[]]', [1,2], 'Sub-expression in a filter');
		eq(complex, '.fifth[.seventh[0]]', ['bar'], 'Sub-expression in a sub-filter');
	});

	test('executes pipes correctly', function() {
		eq('2 | .', [2]);
		eq('1,2 | .', [1,2]);
		eq('[1,2] | .', [[1,2]]);
		deepEqual(jsq(complex, '.fifth | .baz'), jsq(complex, '.fifth.baz'));
		deepEqual(jsq(complex, '.[]'), jsq(complex, '. | .[]'));
		deepEqual(jsq(complex, '.fifth[]'), jsq(complex, '.fifth | .[]'));
	});

	test('executes comma separated values correctly', function() {
		eq('1,2,3', [1,2,3]);
		eq('1,2,3 | .', [1,2,3]);
		eq('1,2,3 | .[]', []);
		eq('[1,2,3] | .[]', [1,2,3]);
		eq([1,2,3,4,5,6], '.[1,2,3]', [2,3,4]);
		
		eq('1,1\\2,2+1,4', [1,3,3,4]);
	});
	
	test('executes collections correctly', function() {
{'fraction_non_alphanumeric': 0.3470137336314277, 'fraction_numerical': 0.09022676461194507, 'mean_word_length': 3.8102918586789554, 'pattern_counts': {'":': 28, '<': 13, '<?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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1845568', 'n_tokens_mistral': 3286, 'n_tokens_neox': 2938, 'n_words': 528}