<commit_before><?php

require_once('src/lightncandy.php');

class MustacheSpecTest extends PHPUnit_Framework_TestCase
{
    /**
     * @dataProvider yamlProvider
     */
    public function testSpecs($spec)
    {
        $php = LightnCandy::compile($spec['template'], Array(
            'flags' => LightnCandy::FLAG_HANDLEBARSJS | LightnCandy::FLAG_ERROR_EXCEPTION,
                'helpers' => array(
                )
            )
        );
        $renderer = LightnCandy::prepare($php);

        $this->assertEquals($spec['expected'], $renderer($spec['data']), "[{$spec['name']}]:{$spec['desc']}");
    }

    public function yamlProvider()
    {
        $ret = Array();

        foreach (glob('spec/specs/*.json') as $file) {
           $json = json_decode(file_get_contents($file), true);
           $ret = array_merge($ret, array_map(function ($d) {return Array($d);}, $json['tests']));
        }

        return $ret;
    }
}


?><commit_msg>keep no and file<commit_after><?php

require_once('src/lightncandy.php');

class MustacheSpecTest extends PHPUnit_Framework_TestCase
{
    /**
     * @dataProvider yamlProvider
     */
    public function testSpecs($spec)
    {
        $php = LightnCandy::compile($spec['template'], Array(
            'flags' => LightnCandy::FLAG_HANDLEBARSJS | LightnCandy::FLAG_ERROR_EXCEPTION,
                'helpers' => array(
                )
            )
        );
        $renderer = LightnCandy::prepare($php);

        $this->assertEquals($spec['expected'], $renderer($spec['data']), "[{$spec['file']}.{$spec['name']}]#{$spec['no']}:{$spec['desc']}");
    }

    public function yamlProvider()
    {
        $ret = Array();

        foreach (glob('spec/specs/*.json') as $file) {
           $i=0;
           $json = json_decode(file_get_contents($file), true);
           $ret = array_merge($ret, array_map(function ($d) use ($file, &$i) {
               $d['file'] = $file;
               $d['no'] = ++$i;
               return Array($d);
           }, $json['tests']));
        }

        return $ret;
    }
}


?>
{'fraction_non_alphanumeric': 0.17957405614714425, 'fraction_numerical': 0.000484027105517909, 'mean_word_length': 2.3885245901639345, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, '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': '5073641', 'n_tokens_mistral': 652, 'n_tokens_neox': 635, 'n_words': 101}