<commit_before><?php
namespace DrdPlus\Cave\TablesBundle\Tables;

use DrdPlus\Cave\TablesBundle\Tests\TestWithMockery;

class AmountTableTest extends TestWithMockery
{

    /**
     * @test
     */
    public function can_convert_bonus_to_amount()
    {
        $amountTable = new AmountTable();
        do {
            $attempt = 1;
            $attempt++;
            $zeroOrOne = $amountTable->toAmount(-20);
            if ($zeroOrOne === 1.0) {
                break;
            }
        } while ($attempt < 1000);
        $this->assertSame(1.0, $zeroOrOne);
        $this->assertSame(1.0, $amountTable->toAmount(0));
        $this->assertSame(90000.0, $amountTable->toAmount(99));
    }

    /**
     * @test
     * @expectedException \OutOfRangeException
     */
    public function too_low_bonus_to_amount_cause_exception()
    {
        $amountTable = new AmountTable();
        $amountTable->toAmount(-21);
    }

    /**
     * @test
     * @expectedException \OutOfRangeException
     */
    public function too_high_bonus_to_amount_cause_exception()
    {
        $amountTable = new AmountTable();
        $amountTable->toAmount(100);
    }

    /**
     * @test
     */
    public function can_convert_amount_to_bonus()
    {
        $amountTable = new AmountTable();
        $this->assertSame(0, $amountTable->toBonus(new AmountMeasurement(1)));

        $this->assertSame(40, $amountTable->amountToBonus(104)); // 40 is the closest bonus
        $this->assertSame(41, $amountTable->amountToBonus(105)); // 40 and 41 are closest bonuses, 41 is taken because higher

        $this->assertSame(99, $amountTable->toBonus(new AmountMeasurement(90000)));
        $this->assertSame(99, $amountTable->amountToBonus(90000));
    }

    /**
     * @test
     * @expectedException \OutOfRangeException
     */
    public function too_low_value_to_bonus_cause_exception()
    {
        $amountTable = new AmountTable();
        $amountTable->toAmount(-1);
    }

    /**
     * @test<commit_msg>Amount table test fix<commit_after><?php
namespace DrdPlus\Cave\TablesBundle\Tables;

use DrdPlus\Cave\TablesBundle\Tests\TestWithMockery;

class AmountTableTest extends TestWithMockery
{

    /**
     * @test
     */
    public function can_convert_bonus_to_amount()
    {
        $amountTable = new AmountTable();
        do {
            $attempt = 1;
            $attempt++;
            $zeroOrOne = $amountTable->toAmount(-20);
            if ($zeroOrOne === 1.0) {
                break;
            }
        } while ($attempt < 1000);
        $this->assertSame(1.0, $zeroOrOne);
        $this->assertSame(1.0, $amountTable->toAmount(0));
        $this->assertSame(90000.0, $amountTable->toAmount(99));
    }

    /**
     * @test
     * @expectedException \OutOfRangeException
     */
    public function too_low_bonus_to_amount_cause_exception()
    {
        $amountTable = new AmountTable();
        $amountTable->toAmount(-21);
    }

    /**
     * @test
     * @expectedException \OutOfRangeException
     */
    public function too_high_bonus_to_amount_cause_exception()
    {
        $amountTable = new AmountTable();
        $amountTable->toAmount(100);
    }

    /**
     * @test
     */
    public function can_convert_amount_to_bonus()
    {
        $amountTable = new AmountTable();
        $this->assertSame(0, $amountTable->toBonus(new AmountMeasurement(1)));

        $this->assertSame(40, $amountTable->amountToBonus(104)); // 40 is the closest bonus
        $this->assertSame(41, $amountTable->amountToBonus(105)); // 40 and 41 are closest bonuses, 41 is taken because higher

        $this->assertSame(99, $amountTable->toBonus(new AmountMeasurement(90000)));
        $this->assertSame(99, $amountTable->amountToBonus(90000));
    }

    /**
     * @test
     * @expectedException \OutOfRangeException
     */
    public function too_low_value_to_bonus_cause_exception()
    {
        $amountTable = new AmountTable();
        $amountTable->amountToBonus(0);
    }

    /**
     * @test
{'fraction_non_alphanumeric': 0.1322211155378486, 'fraction_numerical': 0.030876494023904383, 'mean_word_length': 2.448068669527897, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 41, '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': '3314458', 'n_tokens_mistral': 1340, 'n_tokens_neox': 1237, 'n_words': 204}