<commit_before>'use strict';

function log(success, message, specification) {
	let text = success ? 'Success' : 'Fail';
	if(message) {
		text += ' : ';
		text += message;
		if(specification) {
			text += ' - ';
			text += specification;
		}
	}
	if(this.debug) {
		console.log(text);
	}
}

function check_has_begun() {
	if(!this.began) {
		throw new Error('Assert must be started before beginning testing');
	}
}

export class Assert {
	constructor(onsuccess, onfail, onbegin, onend, debug) {
		this.onsuccess = onsuccess;
		this.onfail = onfail;
		this.onbegin = onbegin;
		this.onend = onend;
		this.debug = debug || false;
		this.results = [];
		this.began = false;
		this.times = {};
		this.counters = {
			successes: 0,
			fails: 0
		};
	}
	begin() {
		this.times.start = new Date();
		this.began = true;
		//callback
		if(this.onbegin) {
			this.onbegin.call(this);
		}
	}
	end() {
		this.times.stop = new Date();
		//callback
		if(this.onend) {
			this.onend.call(this);
		}
	}
	getDuration() {
		return this.times.stop.getTime() - this.times.start.getTime();
	}
	getSuccessesNumber() {
		return this.counters.successes;
	}
	getFailsNumber() {
		return this.counters.fails;
	}
	getTotal() {
		return this.results.length;
	}
	globalize(object) {
		const hook = object || window;
		const methods = ['begin', 'end', 'success', 'fail', 'equal', 'notEqual', 'similar', 'notSimilar', 'defined', 'undefined', 'null', 'notNull', 'ok', 'notOk', 'doesThrow', 'doesNotThrow'];
		methods.forEach(method => hook[method] = this[method].bind(this));
	}
	success(message, specification) {
		check_has_begun.call(this);
		this.results.push({success: true, message: message, specification: specification});<commit_msg>Remove code used to globalize the assert object<commit_after>function log(success, message, specification) {
	let text = success ? 'Success' : 'Fail';
	if(message) {
		text += ' : ';
		text += message;
		if(specification) {
			text += ' - ';
			text += specification;
		}
	}
	if(this.debug) {
		console.log(text);
	}
}

function check_has_begun() {
	if(!this.began) {
		throw new Error('Assert must be started before beginning testing');
	}
}

export class Assert {
	constructor(onsuccess, onfail, onbegin, onend, debug) {
		this.onsuccess = onsuccess;
		this.onfail = onfail;
		this.onbegin = onbegin;
		this.onend = onend;
		this.debug = debug || false;
		this.results = [];
		this.began = false;
		this.times = {};
		this.counters = {
			successes: 0,
			fails: 0
		};
	}
	begin() {
		this.times.start = new Date();
		this.began = true;
		//callback
		if(this.onbegin) {
			this.onbegin.call(this);
		}
	}
	end() {
		this.times.stop = new Date();
		//callback
		if(this.onend) {
			this.onend.call(this);
		}
	}
	getDuration() {
		return this.times.stop.getTime() - this.times.start.getTime();
	}
	getSuccessesNumber() {
		return this.counters.successes;
	}
	getFailsNumber() {
		return this.counters.fails;
	}
	getTotal() {
		return this.results.length;
	}
	success(message, specification) {
		check_has_begun.call(this);
		this.results.push({success: true, message: message, specification: specification});
{'fraction_non_alphanumeric': 0.164260506897658, 'fraction_numerical': 0.0012832852101379532, 'mean_word_length': 3.6676646706586826, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, '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': '2159258', 'n_tokens_mistral': 1246, 'n_tokens_neox': 1130, 'n_words': 228}