<commit_before><?php

$contents = "";
const TESTS_DIRECTORY = __DIR__ . "/cases/";

$directory = new RecursiveDirectoryIterator(TESTS_DIRECTORY);
$iterator = new RecursiveIteratorIterator($directory);

/** @var SplFileInfo $file */
foreach ($iterator as $file)
{
    if (!$file->isFile() || "js" !== $file->getExtension())
    {
        continue;
    }

    $module = "";

    if (1 === preg_match('~' . preg_quote(TESTS_DIRECTORY, '~') . '(?<module>.*?)/~', $file->getPathname(), $matches))
    {
        $module = $matches["module"];
    }

    $module = 'QUnit.module("' . addslashes($module) . '");' . "\n\n";

    $contents .= "(function () {\n" . $module . file_get_contents($file->getPathname()) . "\n})();\n\n";
}


header("Content-Type: application/javascript; charset=utf-8");
echo $contents;<commit_msg>Improve handling of modules in tests loader<commit_after><?php

$contents = "";
const TESTS_DIRECTORY = __DIR__ . "/cases/";

$directory = new RecursiveDirectoryIterator(TESTS_DIRECTORY);
$iterator = new RecursiveIteratorIterator($directory);

/** @var SplFileInfo $file */
foreach ($iterator as $file)
{
    if (!$file->isFile() || "js" !== $file->getExtension())
    {
        continue;
    }

    $relativeName = substr($file->getPathname(), strlen(TESTS_DIRECTORY));
    $moduleName = addslashes($relativeName);
    $testContent = file_get_contents($file->getPathname());

    $contents .= <<<TEST
(function () { 
    QUnit.module("{$moduleName}", function () {
        {$testContent}
    });
})();


TEST;
}


header("Content-Type: application/javascript; charset=utf-8");
echo $contents;
{'fraction_non_alphanumeric': 0.2016179215930305, 'fraction_numerical': 0.001866832607342875, 'mean_word_length': 4.009345794392523, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 12, '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': '469026', 'n_tokens_mistral': 531, 'n_tokens_neox': 517, 'n_words': 97}