<commit_before><?php namespace spec\Belt;

use PhpSpec\ObjectBehavior;

class FunctionsSpec extends ObjectBehavior {

    function it_is_initializable()
    {
        $this->shouldHaveType('Belt\Functions');
    }

    function it_can_cache_the_returned_value()
    {
        $closure = function()
        {
            return \uniqid();
        };

        $this->cache($closure)->shouldBeEqualTo($this->cache($closure));
    }

    function it_can_wrap_a_closure_inside_another_closure()
    {
        $closure = function()
        {
            return 'foo';
        };

        $wrapper = function($closure)
        {
            return $closure().'bar';
        };

        $this->wrap($closure, $wrapper)->shouldReturn('foobar');
    }

    function it_can_make_a_composition_of_an_array_of_closures()
    {
        $closures = [];

        $closures[] = function($var)
        {
            return $var;
        };

        $closures[] = function($var)
        {
            return 'foo' == $var;
        };

        $this->compose($closures, ['foo'])->shouldBe(true);
    }

    function it_can_lock_a_closure_so_it_can_be_called_only_once()
    {
        $closure = function()
        {
            static $switch;

            if ( ! is_null($switch)) throw new \LogicException;

            $switch = true;
        };

        $this->once($closure);
        $this->shouldNotThrow('LogicException')->duringOnce($closure);
    }

    function it_can_make_a_closure_callable_only_after_a_number_of_tries()
    {
        $closure = function()
        {
            return 'foo';
        };

        $this->after(2, $closure)->shouldBe(null);
        $this->after(2, $closure)->shouldBe(null);

        $this->after(2, $closure)->shouldBe('foo');
    }

}

<commit_msg>work on naming in FunctionsSpec<commit_after><?php namespace spec\Belt;

use PhpSpec\ObjectBehavior;

class FunctionsSpec extends ObjectBehavior {

    function it_is_initializable()
    {
        $this->shouldHaveType('Belt\Functions');
    }

    function it_saves_the_returned_value()
    {
        $closure = function()
        {
            return \uniqid();
        };

        $this->cache($closure)->shouldBeEqualTo($this->cache($closure));
    }

    function it_wraps_the_closure_inside_another_closure()
    {
        $closure = function()
        {
            return 'foo';
        };

        $wrapper = function($closure)
        {
            return $closure().'bar';
        };

        $this->wrap($closure, $wrapper)->shouldReturn('foobar');
    }

    function it_makes_a_composition_of_multiple_closures()
    {
        $closures = [];

        $closures[] = function($var)
        {
            return $var;
        };

        $closures[] = function($var)
        {
            return 'foo' == $var;
        };

        $this->compose($closures, ['foo'])->shouldBe(true);
    }

    function it_locks_the_closure_so_it_can_be_only_called_once()
    {
        $closure = function()
        {
            static $switch;

            if ( ! is_null($switch)) throw new \LogicException;

            $switch = true;
        };

        $this->once($closure);
        $this->shouldNotThrow('LogicException')->duringOnce($closure);
    }

    function it_calls_the_closure_only_after_a_number_of_failed_tries()
    {
        $closure = function()
        {
            return 'foo';
        };

        $this->after(2, $closure)->shouldBe(null);
        $this->after(2, $closure)->shouldBe(null);

        $this->after(2, $closure)->shouldBe('foo');
    }

}


{'fraction_non_alphanumeric': 0.140163242330425, 'fraction_numerical': 0.0016887137630171687, 'mean_word_length': 2.0246808510638297, 'pattern_counts': {'":': 0, '<': 5, '<?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': '4411421', 'n_tokens_mistral': 1109, 'n_tokens_neox': 1063, 'n_words': 148}