<commit_before>/*
---
script: simple.js
description: a simple runner
license: MIT-style license
authors:
- <NAME>
provides: [SimpleRunner]
...
*/

(function(){

var sys, printer = function(type){
	switch(type){
		case 'node': return require('sys').print;
		case 'flusspferd':
			sys = require('system');
			return function(str){
				sys.stdout.write(str);
				sys.stdout.flush();
			};
		case 'v8cgi': return system.stdout;
	}
	return function(){};
};

var SimpleRunner = function(type, testigo, colors){
	this.$testigo = testigo;
	this.$print = printer(type);
	this.$colors = (colors !== undefined) ? colors : true;
	this.addCallbacks();
};

var callbacks = {

	before: function(){
		this.$print('Starting Tests..\n');
	},

	after: function(success, results){
		this.$print('\nTests Finished: ');
		if (success){
			this.$setColor('green');
			this.$print('Passed');
		} else {
			this.$setColor('red');
			this.$print('Failed');
		}
		this.$setColor();
		this.$print([
			' (Passed: ', results.tests.passes, ', Failed: ', results.tests.failures, ')\n'
		].join(''));
	},

	beforeSuite: function(suite, count){
		this.$setColor('yellow');
		this.$print('\n' + suite);
		this.$setColor();
		this.$print([' (', count, ' Tests):', '\n'].join(''));
	},

	afterSuite: function(suite, success, results){
		this.$print(['End ', suite, ': '].join(''));
		if (success){
			this.$setColor('green');
			this.$print('Passed');
		} else {
			this.$setColor('red');
			this.$print('Failed');
		}
		this.$setColor();
		this.$print([' (Passes: ', results.tests.passes, ', Failures: ', results.tests.failures,').\n'].join(''));
	},

	beforeTest: function(suite, test, count){
		this.$print(' - ');
		this.$setColor('yellow');
		this.$print(test);
		this.$setColor();
		this.$print('... ');
	},

	afterTest: function(suite, test, results){
		if (results.allPassed) {
			this.$setColor('green');
			this.$print('Passed');
		} else {
			this.$setColor('red');
			this.$print('Failed');
		}
		this.$setColor();
		this.$print([' (', results.tests.passes, '/', results.tests.total, ').\n'].join(''));

		for (var i = 0, y = results.results.length; i < y; i++){
			var result = results.results[i];
			if (result.passed) continue;
			this.$setColor('red');
			this.$print(['     ', i + 1, ': '].join(''));
			this.$setColor();
			this.$print([
				'Expected ', result.matcher, ' ', (result.expected) ? result.expected : '',
				', got ', result.received, '\n'
			].join(''));
		}<commit_msg>Added double-quotes to SimpleRunner formatting.<commit_after>/*
---
script: simple.js
description: a simple runner
license: MIT-style license
authors:
- <NAME>
provides: [SimpleRunner]
...
*/

(function(){

var sys, printer = function(type){
	switch(type){
		case 'node': return require('sys').print;
		case 'flusspferd':
			sys = require('system');
			return function(str){
				sys.stdout.write(str);
				sys.stdout.flush();
			};
		case 'v8cgi': return system.stdout;
	}
	return function(){};
};

var SimpleRunner = function(type, testigo, colors){
	this.$testigo = testigo;
	this.$print = printer(type);
	this.$colors = (colors !== undefined) ? colors : true;
	this.addCallbacks();
};

var callbacks = {

	before: function(){
		this.$print('Starting Tests..\n');
	},

	after: function(success, results){
		this.$print('\nTests Finished: ');
		if (success){
			this.$setColor('green');
			this.$print('Passed');
		} else {
			this.$setColor('red');
			this.$print('Failed');
		}
		this.$setColor();
		this.$print([
			' (Passed: ', results.tests.passes, ', Failed: ', results.tests.failures, ')\n'
		].join(''));
	},

	beforeSuite: function(suite, count){
		this.$setColor('yellow');
		this.$print('\n' + suite);
		this.$setColor();
		this.$print([' (', count, ' Tests):', '\n'].join(''));
	},

	afterSuite: function(suite, success, results){
		this.$print(['End ', suite, ': '].join(''));
		if (success){
			this.$setColor('green');
			this.$print('Passed');
		} else {
			this.$setColor('red');
			this.$print('Failed');
		}
		this.$setColor();
		this.$print([' (Passes: ', results.tests.passes, ', Failures: ', results.tests.failures,').\n'].join(''));
	},

	beforeTest: function(suite, test, count){
		this.$print(' - ');
		this.$setColor('yellow');
		this.$print(test);
		this.$setColor();
		this.$print('... ');
	},

	afterTest: function(suite, test, results){
		if (results.allPassed) {
			this.$setColor('green');
			this.$print('Passed');
		} else {
			this.$setColor('red');
			this.$print('Failed');
		}
		this.$setColor();
		this.$print([' (', results.tests.passes, '/', results.tests.total, ').\n'].join(''));

		for (var i = 0, y = results.results.length; i < y; i++){
			var result = results.results[i];
			if (result.passed) continue;
			this.$setColor('red');
			this.$print(['     ', i + 1, ': '].join(''));
			this.$setColor();
			this.$print([
				'Expected ', result.matcher, ' "', (result.expected) ? result.expected : '"',
				', got "', result.received, '"\n'
			].join(''));
		}
{'fraction_non_alphanumeric': 0.23692679002413516, 'fraction_numerical': 0.0012067578439259854, 'mean_word_length': 3.786333012512031, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, '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': '1039180', 'n_tokens_mistral': 1924, 'n_tokens_neox': 1701, 'n_words': 334}