<commit_before>// libraries
const nexlEngine = require('../nexl-engine');
const util = require('util');
const j79 = require('j79-utils');
const assert = require('assert');
const expressions = require('./expressions/expressions');

// nexl source file
var nexlSource = {asFile: {fileName: 'nexl-sources/nexl-source1.js'}};

// comparing two javascript variables
function compare(result, expectedResult) {
	// todo: temporary, until the big nexl-engine refactoring
	expectedResult = j79.wrapWithArrayIfNeeded(expectedResult);

	var s1 = JSON.stringify(result);
	var s2 = JSON.stringify(expectedResult);
	return s1 === s2;
}

// prints OK message for expression
function printOkExpression(expression) {
	console.log(util.format("OK for [%s] expression", expression));
}

// tests the expression
function testExpression(expression, exprDef) {
	try {
		var result = nexlEngine.evalNexlExpression(nexlSource, expression, exprDef.args);
	} catch (e) {
		if (exprDef.result) {
			throw util.format("The [%s] expression is failed. Reason : [%s]", expression, e);
			return;
		}

		printOkExpression(expression);
		return;
	}

	// if the exprDef.result is not defined, expression must fail. checking
	if (!exprDef.result) {
		throw util.format("The [%s] expression must fail, but hasn't", expression);
	}<commit_msg>- minor fix;<commit_after>// libraries
const nexlEngine = require('../nexl-engine');
const util = require('util');
const j79 = require('j79-utils');
const assert = require('assert');
const expressions = require('./expressions/expressions');

// nexl source file
var nexlSource = {asFile: {fileName: 'nexl-sources/nexl-source1.js'}};

// comparing two javascript variables
function compare(result, expectedResult) {
	// todo: temporary, until the big nexl-engine refactoring
	expectedResult = j79.wrapWithArrayIfNeeded(expectedResult);

	var s1 = JSON.stringify(result);
	var s2 = JSON.stringify(expectedResult);
	return s1 === s2;
}

// prints OK message for expression
function printOkExpression(expression) {
	console.log(util.format("OK for [%s] expression", expression));
}

// tests the expression
function testExpression(expression, exprDef) {
	try {
		var result = nexlEngine.evalNexlExpression(nexlSource, expression, exprDef.args);
	} catch (e) {
		if (exprDef.result) {
			throw util.format("The [%s] expression is failed. Reason : [%s]", expression, e);
		}

		printOkExpression(expression);
		return;
	}

	// if the exprDef.result is not defined, expression must fail. checking
	if (!exprDef.result) {
		throw util.format("The [%s] expression must fail, but hasn't", expression);
	}
{'fraction_non_alphanumeric': 0.1373076923076923, 'fraction_numerical': 0.008461538461538461, 'mean_word_length': 4.911363636363636, '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': '2257019', 'n_tokens_mistral': 824, 'n_tokens_neox': 784, 'n_words': 225}