<commit_before>/**
	@file test/class-test.js
	@author <NAME>
	@requires augment
	@requires chai
	@requires mocha

	@description
	Test plan for JavaScript objeect libararies {@link module:augment} module (chai)

	@see {@link http://chaijs.com/api/ Chai API Documentation}
	@see {@link http://visionmedia.github.io/mocha/ Mocha Documentation}
*/
/*jshint node: true, indent: 4, smarttabs: true, maxlen: 128, maxstatements: false */
/*global window, beforeEach, describe, it */
'use strict';

var isNode = typeof process === 'object' && process + '' === '[object process]',
	dump = function (n, o) { console.log(n, isNode ? require('util').inspect(o) : o); },
	chai = chai || require('chai'),
	assert = chai.assert,
	expect = chai.expect,
	should = chai.should(), // note function call here
	Classes = !isNode ? window.Classes : {
		'Javascript' : require('../lib/javascript-objs'),
		'Augment': require('../lib/augment-objs'),
		'Klass':   require('../lib/klass-objs')
	},
	XXX = {
		do: function (s) { return s.toUpperCase(); },
		die: function(s) { throw(new Error(s)); }
	},//require('../lib/XXX'),
	MUSTDO = function () { it('MUSTDO test something'); };

chai.config.includeStack = true;   // turn on stack trace on assertion failure
chai.config.showDiff = false;      // turn off reporter diff display
chai.config.truncateThreshold = 0; // disable truncating actual/expected values

dump('Classes', Classes);
//dump('prototypes', Classes.Klass.getPrototypesOf(Classes.Klass.thing));
//dump('ancestors', Classes.Klass.getAncestorsOf(Classes.Klass.thing));


function testPropGen()
{
	describe('Javascript.lib.constant', function()
	{
		it('constant({}, ...) should define visible constant by default', function () {
			var obj = Classes.Javascript.lib.constant({}, 'constant', 42);
			expect(	obj.constant).to.equal(42);
			expect(Object.keys(obj)).to.deep.equal(['constant']);
		});
		it('constant({}, false, ...) should define invisible constant', function () {
			var obj = Classes.Javascript.lib.constant({}, false, 'constant', 48);
			expect(	obj.constant).to.equal(48);
			expect(Object.keys(obj)).to.deep.equal([]);
		});
		it('constant({}, true, ...) should define visible constant explicitly', function () {
			var obj = Classes.Javascript.lib.constant({}, true, 'constant', 148);
			expect(	obj.constant).to.equal(148);
			expect(Object.keys(obj)).to.deep.equal(['constant']);
		});
		it('constant({}, ...) should define multiple visible constants by arguments', function () {
			var obj = Classes.Javascript.lib.constant(
				{},
				'constant', 42,
				'CONST', 88);
			expect(	obj.CONST).to.equal(88);
			expect(Object.keys(obj)).to.deep.equal(['constant', 'CONST']);
		});
		it('constant({}, ...) should handle odd number of arguments', function () {
			var obj = Classes.Javascript.lib.constant(
				{},
				'constant', 42,
				'CONST');
			expect(	obj.CONST).to.equal(void 0);
			expect(Object.keys(obj)).to.deep.equal(['constant', 'CONST']);
		});
		it('constant({}, [ key, value, ...]) should define multiple visible constants by array', function () {
			var obj = Classes.Javascript.lib.constant(
				{},
				[
					'constant', 1242,
					'CONST', 1288
				]);
			expect(	obj.CONST).to.equal(1288);
			expect(Object.keys(obj)).to.deep.equal(['constant', 'CONST']);
		});
		it('constant({}, { key: value, ...}) should define multiple visible constants by object', function () {
			var obj = Classes.Javascript.lib.constant(
				{},
				{
					'constant': 142,
					'CONST': 188
				});
			expect(	obj.CONST).to.equal(188);
			expect(Object.keys(obj)).to.deep.equal(['constant', 'CONST']);
		});
		it('constant({}, false, { key: value, ...}) should define multiple invisible constants by object', function () {
			var obj = Classes.Javascript.lib.constant(
				{},
				false,
				{
					'constant': 1421,
					'CONST': 1881
				});
			expect(	obj.CONST).to.equal(1881);
			expect(Object.keys(obj)).to.deep.equal([]);
		});
	});
}

testPropGen();

function testProperties(libName, nameSpaceName, nameSpace)
{
	var base = nameSpaceName + '.Property',
		obj = nameSpace.Property;

	describe(libName, function()
	{
		describe(base, function()
		{
			var aKeys = [
				'normal',
				'visibleConstant',<commit_msg>classes-test.js - constant() function with unit tests<commit_after>/**
	@file test/class-test.js
	@author <NAME>
	@requires augment
	@requires chai
	@requires mocha

	@description
	Test plan for JavaScript objeect libararies {@link module:augment} module (chai)

	@see {@link http://chaijs.com/api/ Chai API Documentation}
	@see {@link http://visionmedia.github.io/mocha/ Mocha Documentation}
*/
/*jshint node: true, indent: 4, smarttabs: true, maxlen: 128, maxstatements: false */
/*global window, beforeEach, describe, it */
'use strict';

var isNode = typeof process === 'object' && process + '' === '[object process]',
	dump = function (n, o) { console.log(n, isNode ? require('util').inspect(o) : o); },
	chai = chai || require('chai'),
	assert = chai.assert,
	expect = chai.expect,
	should = chai.should(), // note function call here
	Classes = !isNode ? window.Classes : {
		'Javascript' : require('../lib/javascript-objs'),
		'Augment': require('../lib/augment-objs'),
		'Klass':   require('../lib/klass-objs')
	},
	XXX = {
		do: function (s) { return s.toUpperCase(); },
		die: function(s) { throw(new Error(s)); }
	},//require('../lib/XXX'),
	MUSTDO = function () { it('MUSTDO test something'); };

chai.config.includeStack = true;   // turn on stack trace on assertion failure
chai.config.showDiff = false;      // turn off reporter diff display
chai.config.truncateThreshold = 0; // disable truncating actual/expected values

dump('Classes', Classes);
//dump('prototypes', Classes.Klass.getPrototypesOf(Classes.Klass.thing));
//dump('ancestors', Classes.Klass.getAncestorsOf(Classes.Klass.thing));

function testPropGen()
{
	describe('Javascript.lib.constant() - make constants on object', function()
	{
		var make = Classes.Javascript.lib;
		it('constant({}, key, value) should define visible constant by default', function () {
			var obj = make.constant({}, 'constant', 42);
			expect(	obj.constant).to.equal(42);
			expect(Object.keys(obj)).to.deep.equal(['constant']);
			assert.throws(
				function () { obj.constant = 23; },
				/Cannot assign to read only property/);
			expect(obj.constant).to.equal(42);
		});
		it('constant({}, false, key, value) should define invisible constant', function () {
			var obj = make.constant({}, false, 'constant', 48);
			expect(	obj.constant).to.equal(48);
			expect(Object.keys(obj)).to.deep.equal([]);
		});
		it('constant({}, true, key, value) should define visible constant explicitly', function () {
			var obj = make.constant({}, true, 'constant', 148);
			expect(	obj.constant).to.equal(148);
			expect(Object.keys(obj)).to.deep.equal(['constant']);
		});
		it('constant({}, key, value, ...) should define multiple visible constants by arguments', function () {
			var obj = make.constant(
				{},
				'constant', 42,
				'CONST', 88);
			expect(	obj.CONST).to.equal(88);
			expect(Object.keys(obj)).to.deep.equal(['constant', 'CONST']);
		});
		it('constant({}, key, value, ...) should handle odd number of arguments', function () {
			var obj = make.constant(
				{},
				'constant', 42,
				'CONST');
			expect(	obj.CONST).to.equal(void 0);
			expect(Object.keys(obj)).to.deep.equal(['constant', 'CONST']);
		});
		it('constant({}, [ key, value, ...]) should define multiple visible constants by array', function () {
			var obj = make.constant(
				{},
				[
					'constant', 1242,
					'CONST', 1288
				]);
			expect(	obj.CONST).to.equal(1288);
			expect(Object.keys(obj)).to.deep.equal(['constant', 'CONST']);
		});
		it('constant({}, { key: value, ...}) should define multiple visible constants by object', function () {
			var obj = make.constant(
				{},
				{
					'constant': 142,
					'CONST': 188
				});
			expect(	obj.CONST).to.equal(188);
			expect(Object.keys(obj)).to.deep.equal(['constant', 'CONST']);
		});
		it('constant({}, false, { key: value, ...}) should define multiple invisible constants by object', function () {
			var obj = make.constant(
				{},
				false,
				{
					'constant': 1421,
					'CONST': 1881
				});
			expect(	obj.CONST).to.equal(1881);
			expect(Object.keys(obj)).to.deep.equal([]);
		});
		it('constant({}, false, [ key, value, ...]) should define multiple invisible constants by array', function () {
			var obj = make.constant(
				{},
				false,
				[
					'constant', 12042,
					'CONST', 12088
				]);
			expect(	obj.CONST).to.equal(12088);
			expect(Object.keys(obj)).to.deep.equal([]);
		});
	});
}

testPropGen();

function testProperties(libName, nameSpaceName, nameSpace)
{
	var base = nameSpaceName + '.Property',
		obj = nameSpace.Property;

	describe(libName, function()
	{
		describe(base, function()
		{
			var aKeys = [
				'normal',
				'visibleConstant',
{'fraction_non_alphanumeric': 0.1903265626753451, 'fraction_numerical': 0.01582313993940074, 'mean_word_length': 3.783682232957595, 'pattern_counts': {'":': 0, '<': 5, '<?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': '6160636', 'n_tokens_mistral': 3361, 'n_tokens_neox': 2835, 'n_words': 678}