<commit_before>module('event');

(function() {
	var order = [];

	// Create an event handler.
	var _makeHandler = function(testId) {
		// When returned function is executed, push testId onto `order` array
		// to ensure execution order.
		return function(arg) {
			order.push(testId);
		};
	};

	D(_makeHandler('a'));
	D(_makeHandler('b'));

	noEarlyExecution = order.length === 0;

	// This assumes that QUnit tests are run on DOM ready!
	test('Ready', function() {
		expect(10);

		ok(noEarlyExecution, 'Handlers bound to DOM ready should not execute before DOM ready');

		// Ensure execution order.
		deepEqual(order, ['a', 'b'], 'Bound DOM ready handlers should execute in on-order');

		// Ensure handler argument is correct.
		equal(args.a, D, 'Argument passed to fn in D(fn) should be D');
		equal(args.b, D, 'Argument passed to fn in D(fn) should be D');

		order = [];

		// Now that the ready event has fired, again bind to the ready event.
		// These event handlers should execute immediately.
		D(_makeHandler('g'));
		equal(order.pop(), 'g', 'Event handler should execute immediately');
		equal(args.g, D, 'Argument passed to fn in D(fn) should be D');

	});

})();
<commit_msg>Refactor ready tests<commit_after>module('event');

(function() {
	var order = [];

	// Create an event handler.
	var _makeHandler = function(testId) {
		// When returned function is executed, push testId onto `order` array
		// to ensure execution order.
		return function(arg) {
			order.push(testId);
		};
	};

	D(_makeHandler('a'));
	D(_makeHandler('b'));

	test('early execution', function() {
		expect(1);
		ok(order.length === 0, 'Handlers bound to DOM ready should not execute before DOM ready');
	});

	asyncTest('ready', function() {
		expect(5);
		
		// This assumes that QUnit tests are run on DOM ready!
		window.onload = function() {
			console.log('hi');

			// Ensure execution order.
			deepEqual(order, ['a', 'b'], 'Bound DOM ready handlers should execute in on-order');

			// Ensure handler argument is correct.
			equal(args.a, D, 'Argument passed to fn in D(fn) should be D');
			equal(args.b, D, 'Argument passed to fn in D(fn) should be D');

			order = [];

			// Now that the ready event has fired, again bind to the ready event.
			// These event handlers should execute immediately.
			D(_makeHandler('c'));
			equal(order.pop(), 'c', 'Event handler should execute immediately');
			equal(args.c, D, 'Argument passed to fn in D(fn) should be D');

		};
	});

})();

{'fraction_non_alphanumeric': 0.14647887323943662, 'fraction_numerical': 0.002414486921529175, 'mean_word_length': 3.638059701492537, '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': '6133664', 'n_tokens_mistral': 834, 'n_tokens_neox': 750, 'n_words': 283}