<commit_before>const Assertion = require('./Assertion.js'),
	LoggingTester = require('./LoggingTester.js'),
	FakeLogger =  require('./FakeLogger.js');

const t = new LoggingTester(console),
	testThat = t.testThat,
	beforeEach = t.beforeEach,
	describe = t.describe;

const fail = Assertion.fail,
	FailException = Assertion.FailException,
	isTrue = Assertion.isTrue,
	TrueException = Assertion.TrueException,
	assertThat = Assertion.assertThat,
	isFalse = Assertion.isFalse,
	equals = Assertion.equals;

testThat('testThat should pass if nothing fails', function() {
	var testPassed = false,
		tester = new LoggingTester(new FakeLogger());

	tester.testThat('something', function() {
		testPassed = true;
	});

	if(!testPassed) {
		fail();
	}
});

testThat('beforeEach should be run before each test', function() {
	var step = 1,
		steps = '',
		tester = new LoggingTester(new FakeLogger());
	tester.beforeEach(function() {
		steps += step.toString();
		step++;
	});

	['a', 'b', 'c'].forEach(function(letter) {
		tester.testThat('something', function() {
			steps += letter;
		});
	});
	
	if(steps !== '1a2b3c') {
		fail();
	}
});

var tester, logger;

beforeEach(function() {
	logger = new FakeLogger();
	tester = new LoggingTester(logger);
});

testThat('assertThat should pass if assertion is true', function() {
	var testPassed = false;

	tester.testThat('something', function() {
		assertThat(true, isTrue);
		testPassed = true;
	});

	if(!testPassed) {
		fail();
	}
});

testThat('assertThat should fail test if assertion failed', function() {
	var testFailed = false;

	tester.testThat('something', function() {
		assertThat(false, isTrue);
		testFailed = true;
	});

	if(testFailed) {
		fail();
	}
});

testThat('testThat should be true if nothing fails', function() {
	assertThat(
		tester.testThat('something', function() {}),
		isTrue
	);
});

testThat('testThat should be false if something fails', function() {
	assertThat(
		tester.testThat('something', fail),
		isFalse
	);
});

testThat('describe should run the tests it contains', function() {
	var numberOfRunTests = 0;

	tester.describe('a feature', function() {
		tester.testThat('a 1st test', function() {
			numberOfRunTests++;
		});

		tester.testThat('a 2nd test', function() {
			numberOfRunTests++;<commit_msg>used the TesterCore in the Tester spec<commit_after>const Assertion = require('./Assertion.js'),
	TesterCore = require('./TesterCore.js'),
	LoggingTester = require('./LoggingTester.js');

const t = new LoggingTester(console),
	testThat = t.testThat,
	beforeEach = t.beforeEach,
	describe = t.describe;

const fail = Assertion.fail,
	FailException = Assertion.FailException,
	isTrue = Assertion.isTrue,
	TrueException = Assertion.TrueException,
	assertThat = Assertion.assertThat,
	isFalse = Assertion.isFalse,
	equals = Assertion.equals;

testThat('testThat should pass if nothing fails', function() {
	var testPassed = false,
		tester = new TesterCore();

	tester.testThat('something', function() {
		testPassed = true;
	});

	if(!testPassed) {
		fail();
	}
});

testThat('beforeEach should be run before each test', function() {
	var step = 1,
		steps = '',
		tester = new TesterCore();
	tester.beforeEach(function() {
		steps += step.toString();
		step++;
	});

	['a', 'b', 'c'].forEach(function(letter) {
		tester.testThat('something', function() {
			steps += letter;
		});
	});
	
	if(steps !== '1a2b3c') {
		fail();
	}
});

var tester;

beforeEach(function() {
	tester = new TesterCore();
});

testThat('assertThat should pass if assertion is true', function() {
	var testPassed = false;

	tester.testThat('something', function() {
		assertThat(true, isTrue);
		testPassed = true;
	});

	if(!testPassed) {
		fail();
	}
});

testThat('assertThat should fail test if assertion failed', function() {
	var testFailed = false;

	tester.testThat('something', function() {
		assertThat(false, isTrue);
		testFailed = true;
	});

	if(testFailed) {
		fail();
	}
});

testThat('testThat should be true if nothing fails', function() {
	assertThat(
		tester.testThat('something', function() {}).passed,
		isTrue
	);
});

testThat('testThat should be false if something fails', function() {
	assertThat(
		tester.testThat('something', fail).passed,
		isFalse
	);
});

testThat('describe should run the tests it contains', function() {
	var numberOfRunTests = 0;

	tester.describe('a feature', function() {
		tester.testThat('a 1st test', function() {
			numberOfRunTests++;
		});

		tester.testThat('a 2nd test', function() {
			numberOfRunTests++;
{'fraction_non_alphanumeric': 0.15838303512259774, 'fraction_numerical': 0.0030925557764523966, 'mean_word_length': 4.66, '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': '2428574', 'n_tokens_mistral': 1597, 'n_tokens_neox': 1492, 'n_words': 356}