<commit_before>/// <reference types="jasmine"/>

import * as fs from 'fs';
import * as path from 'path';

import { generateDtsBundle } from '../src/bundle-generator';

import { TestCaseConfig } from './test-cases/test-case-config';

interface TestCase {
	name: string;
	inputFileName: string;
	outputFileContent: string;
	config: TestCaseConfig;
}

const testCasesDir = path.resolve(__dirname, 'test-cases');

function isDirectory(filePath: string): boolean {
	return fs.lstatSync(path.resolve(testCasesDir, filePath)).isDirectory();
}

function getTestCases(): TestCase[] {
	return fs.readdirSync(testCasesDir)
		.filter(isDirectory)
		.map((directoryName: string) => {
			const testCaseDir = path.resolve(testCasesDir, directoryName);
			const outputFileName = path.resolve(testCaseDir, 'output.d.ts');

			const result: TestCase = {
				name: directoryName,
				inputFileName: path.resolve(testCaseDir, 'input.ts'),
				config: require(path.resolve(testCaseDir, 'config.js')) as TestCaseConfig,
				outputFileContent: fs.readFileSync(outputFileName, 'utf-8').trim(),
			};

			return result;
		});
}

for (const testCase of getTestCases()) {
	it(testCase.name, () => {
		const result = generateDtsBundle(testCase.inputFileName, testCase.config.generatorOptions).trim();
		expect(result).toEqual(testCase.outputFileContent, 'Output should be the same as expected');
	});
}<commit_msg>Added handling CLRF in generated file to pass tests<commit_after>/// <reference types="jasmine"/>

import * as fs from 'fs';
import * as path from 'path';

import { generateDtsBundle } from '../src/bundle-generator';

import { TestCaseConfig } from './test-cases/test-case-config';

interface TestCase {
	name: string;
	inputFileName: string;
	outputFileContent: string;
	config: TestCaseConfig;
}

const testCasesDir = path.resolve(__dirname, 'test-cases');

function isDirectory(filePath: string): boolean {
	return fs.lstatSync(path.resolve(testCasesDir, filePath)).isDirectory();
}

function prepareString(str: string): string {
	return str.trim().replace(/\r\n/g, '\n');
}

function getTestCases(): TestCase[] {
	return fs.readdirSync(testCasesDir)
		.filter(isDirectory)
		.map((directoryName: string) => {
			const testCaseDir = path.resolve(testCasesDir, directoryName);
			const outputFileName = path.resolve(testCaseDir, 'output.d.ts');

			const result: TestCase = {
				name: directoryName,
				inputFileName: path.resolve(testCaseDir, 'input.ts'),
				config: require(path.resolve(testCaseDir, 'config.js')) as TestCaseConfig,
				outputFileContent: prepareString(fs.readFileSync(outputFileName, 'utf-8')),
			};

			return result;
		});
}

for (const testCase of getTestCases()) {
	it(testCase.name, () => {
		const result = prepareString(generateDtsBundle(testCase.inputFileName, testCase.config.generatorOptions));
		expect(result).toEqual(testCase.outputFileContent, 'Output should be the same as expected');
	});
}
{'fraction_non_alphanumeric': 0.14016449623029473, 'fraction_numerical': 0.0006854009595613434, 'mean_word_length': 5.250535331905781, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '3360026', 'n_tokens_mistral': 960, 'n_tokens_neox': 901, 'n_words': 203}