<commit_before>/**
 * EventEmitter tests
 */

(function() {
	test('Adding and retrieving listeners', function() {
		var ee = new EventEmitter();
		
		equal(ee.listeners('testEvent'), [], 'Checking for any listeners');
		
		ee.addListener('testEvent', function() {
			// Listener
		});
		equal(ee.listeners('testEvent')[0].type, 'testEvent', 'Retrieving the first listener');
		
		ee.addListener('testEvent', function() {
			// Another listener for the same event
		});
		equal(ee.listeners('testEvent')[1].type, 'testEvent', 'Retrieving the second listener');
		
		ee.addListener('anotherTestEvent', function() {
			// Listener for new event
		});
		equal(ee.listeners('anotherTestEvent')[0].type, 'anotherTestEvent', 'Retrieving the first listener for a different event');
		
		ee.addListener('anotherTestEvent', function() {
			// Another listener for new event
		});
		equal(ee.listeners('anotherTestEvent')[1].type, 'anotherTestEvent', 'Retrieving the second listener for a different event');
		
		ee.addListener('onTest', function() {
			// Listener via the alias
		});
		equal(ee.listeners('onTest')[0].type, 'onTest', 'Retrieving the first listener for a different event added via the on alias');
	});
	
	test('Removing listeners', function() {
		var ee = new EventEmitter();
		
		function testListener() {
			// Listener
		}
		
		function testListener2() {
			// Listener 2
		}
		
		ee.addListener('testEvent', testListener);
		equal(ee.listeners('testEvent')[0].type, 'testEvent', 'Retrieving the first listener');
		
		ee.addListener('testEvent', testListener2);
		equal(ee.listeners('testEvent')[1].type, 'testEvent', 'Retrieving the second listener');
		
		ee.removeListener('testEvent', testListener);
		equal(ee.listeners('testEvent')[1], undefined, 'Retrieving the second listener (should be gone)');
		equal(ee.listeners('testEvent')[0].listener, testListener2, 'First should now be the second');
		
		ee.removeListener('testEvent', testListener2);
		equal(ee.listeners('testEvent'), false, 'Retrieving any listeners (should be gone)');
		
		ee.addListener('removeAllTest', function() {
			// Listener<commit_msg>Made the retrival tests expect a function rather than an object. #17<commit_after>/**
 * EventEmitter tests
 */

(function() {
	test('Adding and retrieving listeners', function() {
		var ee = new EventEmitter();
		
		equal(ee.listeners('testEvent'), [], 'Checking for any listeners');
		
		ee.addListener('testEvent', function() {
			// Listener
			return true;
		});
		equal(ee.listeners('testEvent')[0](), true, 'Retrieving the first listener');
		
		ee.addListener('testEvent', function() {
			// Another listener for the same event
			return true;
		});
		equal(ee.listeners('testEvent')[1](), true, 'Retrieving the second listener');
		
		ee.addListener('anotherTestEvent', function() {
			// Listener for new event
			return true;
		});
		equal(ee.listeners('anotherTestEvent')[0](), true, 'Retrieving the first listener for a different event');
		
		ee.addListener('anotherTestEvent', function() {
			// Another listener for new event
			return true;
		});
		equal(ee.listeners('anotherTestEvent')[1](), true, 'Retrieving the second listener for a different event');
		
		ee.addListener('onTest', function() {
			// Listener via the alias
			return true;
		});
		equal(ee.listeners('onTest')[0](), true, 'Retrieving the first listener for a different event added via the on alias');
	});
	
	test('Removing listeners', function() {
		var ee = new EventEmitter();
		
		function testListener() {
			// Listener
		}
		
		function testListener2() {
			// Listener 2
		}
		
		ee.addListener('testEvent', testListener);
		equal(ee.listeners('testEvent')[0].type, 'testEvent', 'Retrieving the first listener');
		
		ee.addListener('testEvent', testListener2);
		equal(ee.listeners('testEvent')[1].type, 'testEvent', 'Retrieving the second listener');
		
		ee.removeListener('testEvent', testListener);
		equal(ee.listeners('testEvent')[1], undefined, 'Retrieving the second listener (should be gone)');
		equal(ee.listeners('testEvent')[0].listener, testListener2, 'First should now be the second');
		
		ee.removeListener('testEvent', testListener2);
		equal(ee.listeners('testEvent'), false, 'Retrieving any listeners (should be gone)');
		
		ee.addListener('removeAllTest', function() {
			// Listener
{'fraction_non_alphanumeric': 0.15327793167128348, 'fraction_numerical': 0.006925207756232687, 'mean_word_length': 4.605433376455369, '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': '6458068', 'n_tokens_mistral': 1474, 'n_tokens_neox': 1272, 'n_words': 334}