<commit_before><?php
/******************************************************************************
 * An implementation of dicto (scg.unibe.ch/dicto) in and for PHP.
 *
 * Copyright (c) 2016, 2015 <NAME> <<EMAIL>>
 *
 * This software is licensed under The MIT License. You should have received
 * a copy of the licence along with the code.
 */

use Lechimp\Dicto as Dicto;
use Lechimp\Dicto\Analysis\RulesToSqlCompiler;
use Lechimp\Dicto\Analysis\Consts;
use Lechimp\Dicto\Definition as Def;
use Lechimp\Dicto\Definition\Rules as R;
use Lechimp\Dicto\Definition\Variables as V;
use Lechimp\Dicto\App\DB;

use Doctrine\DBAL\Connection;
use Doctrine\DBAL\DriverManager;

class RulesToSqlCompilerTest extends PHPUnit_Framework_TestCase {
    public function setUp() {
        $this->connection = DriverManager::getConnection
            ( array
                ( "driver" => "pdo_sqlite"
                , "dbname" => ":memory:"
                , "host" => ""
                , "port" => ""
                , "user" => ""
                , "password" => ""
                )
            ); 
        $this->db = new DB($this->connection);
        $this->db->create_database();
        $this->compiler = new RulesToSqlCompiler();
    }

    public function all_classes_cannot_contain_text_foo() {
        return new R\ContainText
            ( R\Rule::MODE_CANNOT
            , new V\Classes("allClasses")
            , "foo"
            );
    }<commit_msg>need to initialize REGEXP for sqlite<commit_after><?php
/******************************************************************************
 * An implementation of dicto (scg.unibe.ch/dicto) in and for PHP.
 *
 * Copyright (c) 2016, 2015 <NAME> <<EMAIL>>
 *
 * This software is licensed under The MIT License. You should have received
 * a copy of the licence along with the code.
 */

use Lechimp\Dicto as Dicto;
use Lechimp\Dicto\Analysis\RulesToSqlCompiler;
use Lechimp\Dicto\Analysis\Consts;
use Lechimp\Dicto\Definition as Def;
use Lechimp\Dicto\Definition\Rules as R;
use Lechimp\Dicto\Definition\Variables as V;
use Lechimp\Dicto\App\DB;

use Doctrine\DBAL\Connection;
use Doctrine\DBAL\DriverManager;

class RulesToSqlCompilerTest extends PHPUnit_Framework_TestCase {
    public function setUp() {
        $this->connection = DriverManager::getConnection
            ( array
                ( "driver" => "pdo_sqlite"
                , "dbname" => ":memory:"
                , "host" => ""
                , "port" => ""
                , "user" => ""
                , "password" => ""
                )
            ); 

        // initialize regexp function for sqlite
        $pdo = $this->connection->getWrappedConnection();
        $pdo->sqliteCreateFunction("regexp", function($pattern, $data) {
            return preg_match("%$pattern%", $data) > 0;
        });

        $this->db = new DB($this->connection);
        $this->db->create_database();
        $this->compiler = new RulesToSqlCompiler();
    }

    public function all_classes_cannot_contain_text_foo() {
        return new R\ContainText
            ( R\Rule::MODE_CANNOT
            , new V\Classes("allClasses")
            , "foo"
            );
    }
{'fraction_non_alphanumeric': 0.16556707508639648, 'fraction_numerical': 0.0053408733898837575, 'mean_word_length': 2.423655913978495, 'pattern_counts': {'":': 2, '<': 11, '<?xml version=': 0, '>': 37, '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': '6866363', 'n_tokens_mistral': 965, 'n_tokens_neox': 900, 'n_words': 215}