<commit_before>/**
 * libjass
 *
 * https://github.com/Arnavion/libjass
 *
 * Copyright 2013 <NAME>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

Array.prototype.sum = function () {
	return this.reduce(function (previous, current) {
		return previous + current;
	}, 0);
};

var rootSuites = [];
var suite = null;
var setup = null;
var test = null;

var require = function (name) {
	if (name === "../libjass.js") {
		return libjass;
	}
	else if (name === "assert") {
		return assert;
	}
	else if (name === "./parser-test.js") {
		return parserTest;
	}
	else {
		throw new Error("Cannot require unmocked module: " + name);
	}
};

(function () {
	var Suite = function (name, parent) {
		this.name = name;

		this.children = [];

		this.parent = parent;

		if (this.parent !== null) {
			this.parent.children.push(this);
			this.number = this.parent.number + "." + this.parent.children.length;
		}

		else {
			rootSuites.push(this);
			this.number = String(rootSuites.length);
		}
	};

	Object.defineProperties(Suite.prototype, {
		total: { get: function () {
			return this.children.reduce(function (previous, current) {
				if (current instanceof Suite) {
					return previous + current.total;
				}
				else {
					return previous + 1;
				}
			}, 0);
		}, enumerable: true },

		passed: { get: function () {
			return this.children.reduce(function (previous, current) {
				if (current instanceof Suite) {
					return previous + current.passed;
				}
				else {
					return previous + ((current.passed === true) ? 1 : 0);
				}
			}, 0);
		}, enumerable: true },

		failed: { get: function () {
			return this.children.reduce(function (previous, current) {
				if (current instanceof Suite) {
					return previous + current.failed;
				}
				else {
					return previous + ((current.passed === false) ? 1 : 0);
				}
			}, 0);
		}, enumerable: true },
	});

	Suite.prototype.run = function (logger) {
		logger.beginSuite(this);

		this.children.forEach(function (child) { child.run(logger); });

		logger.endSuite(this);
	};

	var Test = function (description, body, parent) {
		this.description = description;
		this.body = body;

		parent.children.push(this);

		this.number = parent.number + "." + parent.children.length;

		this.passed = null;
		this.exception = null;
	};

	Test.prototype.run = function (logger) {
		if (this.body) {
			this.passed = false;

			try {
				this.body();

				this.passed = true;
			}
			catch (testException) {
				this.exception = testException;
			}
		}

		logger.writeTest(this);
	};

	var currentSuite = null;

	suite = function (name, body) {
		var newSuite = new Suite(name, currentSuite);

		currentSuite = newSuite;
		body();
		currentSuite = newSuite.parent;

		return newSuite;
	};

	test = function (description, body) {
		return new Test(description, body, currentSuite);
	};
})();

var assert = new function () {
	this.deepEqual = function (actual, expected) {
		if (expected === undefined) {
			throw new Error("Expected should not be undefined");
		}

		if (actual === undefined) {
			throw new Error("Actual should not be undefined");
		}

		if (expected === null && actual === null) {
			return;
		}

		if (expected === null) {
			throw new Error("Expected null but got [" + actual + "]");
		}

		if (actual === null) {
			throw new Error("Expected [" + expected + "] but got null")
		}

		if (expected.constructor !== actual.constructor) {
			throw new Error("Expected value of type [" + expected.constructor.name + "] but got value of type [" + actual.constructor.name + "].");
		}

		switch(typeof expected) {
			case "boolean":
			case "number":
			case "string":
				if (expected !== actual) {
					throw new Error("Expected [" + expected + "] but got [" + actual + "]");
				}
				break;

			case "object":
				if (Array.isArray(expected)) {
					if (!Array.isArray(actual)) {
						throw new Error("Expected an array but got [" + actual + "]");
					}

					if (expected.length !== actual.length) {
						throw new Error("Expected an array of length " + expected.length + " but got array of length " + actual.length);
					}<commit_msg>Support undefined values and objects with undefined constructors in assert.deepEqual<commit_after>/**
 * libjass
 *
 * https://github.com/Arnavion/libjass
 *
 * Copyright 2013 <NAME>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

Array.prototype.sum = function () {
	return this.reduce(function (previous, current) {
		return previous + current;
	}, 0);
};

var rootSuites = [];
var suite = null;
var setup = null;
var test = null;

var require = function (name) {
	if (name === "../libjass.js") {
		return libjass;
	}
	else if (name === "assert") {
		return assert;
	}
	else if (name === "./parser-test.js") {
		return parserTest;
	}
	else {
		throw new Error("Cannot require unmocked module: " + name);
	}
};

(function () {
	var Suite = function (name, parent) {
		this.name = name;

		this.children = [];

		this.parent = parent;

		if (this.parent !== null) {
			this.parent.children.push(this);
			this.number = this.parent.number + "." + this.parent.children.length;
		}

		else {
			rootSuites.push(this);
			this.number = String(rootSuites.length);
		}
	};

	Object.defineProperties(Suite.prototype, {
		total: { get: function () {
			return this.children.reduce(function (previous, current) {
				if (current instanceof Suite) {
					return previous + current.total;
				}
				else {
					return previous + 1;
				}
			}, 0);
		}, enumerable: true },

		passed: { get: function () {
			return this.children.reduce(function (previous, current) {
				if (current instanceof Suite) {
					return previous + current.passed;
				}
				else {
					return previous + ((current.passed === true) ? 1 : 0);
				}
			}, 0);
		}, enumerable: true },

		failed: { get: function () {
			return this.children.reduce(function (previous, current) {
				if (current instanceof Suite) {
					return previous + current.failed;
				}
				else {
					return previous + ((current.passed === false) ? 1 : 0);
				}
			}, 0);
		}, enumerable: true },
	});

	Suite.prototype.run = function (logger) {
		logger.beginSuite(this);

		this.children.forEach(function (child) { child.run(logger); });

		logger.endSuite(this);
	};

	var Test = function (description, body, parent) {
		this.description = description;
		this.body = body;

		parent.children.push(this);

		this.number = parent.number + "." + parent.children.length;

		this.passed = null;
		this.exception = null;
	};

	Test.prototype.run = function (logger) {
		if (this.body) {
			this.passed = false;

			try {
				this.body();

				this.passed = true;
			}
			catch (testException) {
				this.exception = testException;
			}
		}

		logger.writeTest(this);
	};

	var currentSuite = null;

	suite = function (name, body) {
		var newSuite = new Suite(name, currentSuite);

		currentSuite = newSuite;
		body();
		currentSuite = newSuite.parent;

		return newSuite;
	};

	test = function (description, body) {
		return new Test(description, body, currentSuite);
	};
})();

var assert = new function () {
	this.deepEqual = function (actual, expected) {
		if (expected === undefined && actual === undefined) {
			return;
		}

		if (expected === undefined) {
			throw new Error("Expected undefined but got [" + actual + "]");
		}

		if (actual === undefined) {
			throw new Error("Expected [" + expected + "] but got undefined")
		}

		if (expected === null && actual === null) {
			return;
		}

		if (expected === null) {
			throw new Error("Expected null but got [" + actual + "]");
		}

		if (actual === null) {
			throw new Error("Expected [" + expected + "] but got null")
		}

		if (expected.constructor !== actual.constructor && actual.constructor !== undefined) {
			throw new Error("Expected value of type [" + expected.constructor.name + "] but got value of type [" + actual.constructor.name + "].");
		}

		switch(typeof expected) {
			case "boolean":
			case "number":
			case "string":
				if (expected !== actual) {
					throw new Error("Expected [" + expected + "] but got [" + actual + "]");
				}
				break;

			case "object":
				if (Array.isArray(expected)) {
					if (!Array.isArray(actual)) {
						throw new Error("Expected an array but got [" + actual + "]");
					}

					if (expected.length !== actual.length) {
						throw new Error("Expected an array of length " + expected.length + " but got array of length " + actual.length);
					}
{'fraction_non_alphanumeric': 0.14499363597793805, 'fraction_numerical': 0.0036062791684344504, 'mean_word_length': 3.0765239948119327, 'pattern_counts': {'":': 8, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, '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': '4352049', 'n_tokens_mistral': 3364, 'n_tokens_neox': 2841, 'n_words': 849}