<commit_before><?php

namespace Liquid\Tests\Unit;

use \Liquid\Liquid;


class RegexpTest extends \Liquid\Tests\TestCase {

    public function test_empty() {
        $this->assertEquals(0, preg_match_all(Liquid::$QuotedFragment, '', $matches));
        $this->assertEquals(array(), $matches[0]);
    }

    public function test_quote() {
        $this->assertEquals(1, preg_match_all(Liquid::$QuotedFragment, '"arg 1"', $matches));
        $this->assertEquals(array('"arg 1"'), $matches[0]);
    }

    public function test_words() {
        $this->assertEquals(2, preg_match_all(Liquid::$QuotedFragment, 'arg1 arg2', $matches));
        $this->assertEquals(array('arg1', 'arg2'), $matches[0]);
    }

    public function test_tags() {
        $this->assertEquals(2, preg_match_all(Liquid::$QuotedFragment, '<tr> </tr>', $matches));
        $this->assertEquals(array('<tr>', '</tr>'), $matches[0]);

        $this->assertEquals(1, preg_match_all(Liquid::$QuotedFragment, '<tr></tr>', $matches));
        $this->assertEquals(array('<tr></tr>'), $matches[0]);

        $this->assertEquals(3, preg_match_all(Liquid::$QuotedFragment, '<style class="hello">\' </style>', $matches));
        $this->assertEquals(array('<style', 'class="hello">', '</style>'), $matches[0]);
    }
}<commit_msg>Regexp tests.<commit_after><?php

namespace Liquid\Tests\Unit;

use \Liquid\Liquid;


class RegexpTest extends \Liquid\Tests\TestCase {

    public function test_empty() {
        $this->assertEquals(0, preg_match_all(Liquid::$QuotedFragment, '', $matches));
        $this->assertEquals(array(), $matches[0]);
    }

    public function test_quote() {
        $this->assertEquals(1, preg_match_all(Liquid::$QuotedFragment, '"arg 1"', $matches));
        $this->assertEquals(array('"arg 1"'), $matches[0]);
    }

    public function test_words() {
        $this->assertEquals(2, preg_match_all(Liquid::$QuotedFragment, 'arg1 arg2', $matches));
        $this->assertEquals(array('arg1', 'arg2'), $matches[0]);
    }

    public function test_tags() {
        $this->assertEquals(2, preg_match_all(Liquid::$QuotedFragment, '<tr> </tr>', $matches));
        $this->assertEquals(array('<tr>', '</tr>'), $matches[0]);

        $this->assertEquals(1, preg_match_all(Liquid::$QuotedFragment, '<tr></tr>', $matches));
        $this->assertEquals(array('<tr></tr>'), $matches[0]);

        $this->assertEquals(3, preg_match_all(Liquid::$QuotedFragment, '<style class="hello">\' </style>', $matches));
        $this->assertEquals(array('<style', 'class="hello">', '</style>'), $matches[0]);
    }

    public function test_double_quoted_words() {
        $this->assertEquals(3, preg_match_all(Liquid::$QuotedFragment, 'arg1 arg2 "arg 3"', $matches));
        $this->assertEquals(array('arg1', 'arg2', '"arg 3"'), $matches[0]);
    }

    public function test_single_quoted_words() {
        $this->assertEquals(3, preg_match_all(Liquid::$QuotedFragment, "arg1 arg2 'arg 3'", $matches));
        $this->assertEquals(array('arg1', 'arg2', "'arg 3'"), $matches[0]);
    }

    public function test_quoted_words_in_the_middle() {
        $this->assertEquals(4, preg_match_all(Liquid::$QuotedFragment, 'arg1 arg2 "arg 3" arg4   ', $matches));
        $this->assertEquals(['arg1', 'arg2', '"arg 3"', 'arg4'], $matches[0]);
    }

    public function test_variable_parser() {
        $this->assertEquals(1, preg_match_all(Liquid::$VariableParser, 'var', $matches));
        $this->assertEquals(array('var'), $matches[0]);

        $this->assertEquals(2, preg_match_all(Liquid::$VariableParser, 'var.method', $matches));
        $this->assertEquals(array('var', 'method'), $matches[0]);

        $this->assertEquals(2, preg_match_all(Liquid::$VariableParser, 'var[method]', $matches));
        $this->assertEquals(array('var', '[method]'), $matches[0]);

        $this->assertEquals(3, preg_match_all(Liquid::$VariableParser, 'var[method][0]', $matches));
        $this->assertEquals(array('var', '[method]', '[0]'), $matches[0]);

        $this->assertEquals(4, preg_match_all(Liquid::$VariableParser, 'var[method][0].method', $matches));
        $this->assertEquals(array('var', '[method]', '[0]', 'method'), $matches[0]);
    }
}
{'fraction_non_alphanumeric': 0.2096620656830081, 'fraction_numerical': 0.018086625416468348, 'mean_word_length': 4.479791395045632, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 67, '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': '2980296', 'n_tokens_mistral': 1370, 'n_tokens_neox': 1363, 'n_words': 220}