<commit_before><?php

namespace spec\RulerZ\Parser;

use PhpSpec\ObjectBehavior;
use Prophecy\Argument;

class HoaParserSpec extends ObjectBehavior
{
    function it_is_initializable()
    {
        $this->shouldHaveType('RulerZ\Parser\HoaParser');
    }

    /**
     * @dataProvider validRules
     */
    function it_returns_an_ast_for_a_valid_rule($rule)
    {
        $this->parse($rule)->shouldHaveType('RulerZ\Model\Rule');
    }

    /**
     * @dataProvider invalidRules
     */
    function it_throws_an_exception_for_an_invalid_rule($rule)
    {
        $this->shouldThrow('Hoa\Compiler\Exception')->duringParse($rule);
    }

    public function validRules()
    {
        return [
            [ 'points > 30' ],
            [ 'locked = false' ],
            [ 'admin = true' ],
            [ 'deleted_at = null' ],
            [ 'user.group = "members"' ],
            [ "user.group = 'members'" ],
            [ 'user.group in ["members", "admins"]' ],
            [ 'length(name) = 4' ],
            [ 'distance(lat1, long1, lat2, long2) < 50' ],
            [ 'name = :user_name' ],
            [ 'name = ?' ],<commit_msg>Add a few test cases with UTF-8 operators<commit_after><?php

namespace spec\RulerZ\Parser;

use PhpSpec\ObjectBehavior;
use Prophecy\Argument;

class HoaParserSpec extends ObjectBehavior
{
    function it_is_initializable()
    {
        $this->shouldHaveType('RulerZ\Parser\HoaParser');
    }

    /**
     * @dataProvider validRules
     */
    function it_returns_an_ast_for_a_valid_rule($rule)
    {
        $this->parse($rule)->shouldHaveType('RulerZ\Model\Rule');
    }

    /**
     * @dataProvider invalidRules
     */
    function it_throws_an_exception_for_an_invalid_rule($rule)
    {
        $this->shouldThrow('Hoa\Compiler\Exception')->duringParse($rule);
    }

    public function validRules()
    {
        return [
            [ 'points > 30' ],
            [ 'some_point ∈ some_figure' ],
            [ 'some_point ∈ :some_figure' ],
            [ 'some_point ∈ ["some", "list", "of", "points"]' ],
            [ 'group(user) ∈ :allowed_groups' ],
            [ 'locked = false' ],
            [ 'admin = true' ],
            [ 'deleted_at = null' ],
            [ 'user.group = "members"' ],
            [ "user.group = 'members'" ],
            [ 'user.group in ["members", "admins"]' ],
            [ 'length(name) = 4' ],
            [ 'distance(lat1, long1, lat2, long2) < 50' ],
            [ 'name = :user_name' ],
            [ 'name = ?' ],
{'fraction_non_alphanumeric': 0.15476665337056242, 'fraction_numerical': 0.007578779417630634, 'mean_word_length': 2.096296296296296, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 15, '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': '3943063', 'n_tokens_mistral': 813, 'n_tokens_neox': 793, 'n_words': 130}