<commit_before><?php

use QCheck\Generator as Gen;
use QCheck\Quick;

class QuickcheckTest extends PHPUnit_Framework_TestCase {
  const RUN_COUNT = 5000;

  public function testRgbToHsb() {
    $r = Gen::choose(0, 255);
    $g = Gen::choose(0, 255);
    $b = Gen::choose(0, 255);
    $gen = Gen::forAll([$r, $g, $b], function($r, $g, $b) {
      (new \Colourist\RGB($r, $g, $b))->toHsb();
      return true;
    });

    $check = Quick::check(self::RUN_COUNT, $gen);
    if ($check['result']) {
      $this->assertTrue($check['result'], "This should never happen!");
    }
    else {
      $failed = new \Colourist\RGB(...$check['fail']);
      $this->assertTrue($check['result'], "Unable to generate HSB colour for " . $failed->toHex());
    }
  }

  public function testRgbToHsl() {
    $r = Gen::choose(0, 255);
    $g = Gen::choose(0, 255);
    $b = Gen::choose(0, 255);
    $gen = Gen::forAll([$r, $g, $b], function($r, $g, $b) {
      (new \Colourist\RGB($r, $g, $b))->toHsl();
      return true;
    });

    $check = Quick::check(self::RUN_COUNT, $gen);
    if ($check['result']) {
      $this->assertTrue($check['result'], "This should never happen!");
    }
    else {
      $failed = new \Colourist\RGB(...$check['fail']);
      $this->assertTrue($check['result'], "Unable to generate HSL colour for " . $failed->toHex());
    }
  }

  public function testHsbToRgb() {
    $h = Gen::choose(0, 255);
    $s = Gen::choose(0, 100);
    $b = Gen::choose(0, 100);
    $gen = Gen::forAll([$h, $s, $b], function($h, $s, $b) {
      (new \Colourist\HSB($h, $s, $b))->toRgb();
      return true;
    });

    $check = Quick::check(self::RUN_COUNT, $gen);
    if ($check['result']) {
      $this->assertTrue($check['result'], "This should never happen!");
    }
    else {
      $failed = new \Colourist\HSB(...$check['fail']);
      $this->assertTrue($check['result'], "Unable to generate RGB colour for hsb(" . $failed->hue() . ", " . $failed->saturation() . ", " . $failed->brightness() . ")");
    }
  }

  public function testHslToRgb() {
    $h = Gen::choose(0, 255);
    $s = Gen::choose(0, 100);
    $b = Gen::choose(0, 100);
    $gen = Gen::forAll([$h, $s, $b], function($h, $s, $b) {
      (new \Colourist\HSL($h, $s, $b))->toRgb();
      return true;
    });

    $check = Quick::check(self::RUN_COUNT, $gen);
    if ($check['result']) {
      $this->assertTrue($check['result'], "This should never happen!");
    }
    else {
      $failed = new \Colourist\HSL(...$check['fail']);
      $this->assertTrue($check['result'], "Unable to generate RGB colour for hsl(" . $failed->hue() . ", " . $failed->saturation() . ", " . $failed->lightness() . ")");
    }
  }
}<commit_msg>PHP 5.5 compat change<commit_after><?php

use QCheck\Generator as Gen;
use QCheck\Quick;

class QuickcheckTest extends PHPUnit_Framework_TestCase {
  const RUN_COUNT = 5000;

  public function testRgbToHsb() {
    $r = Gen::choose(0, 255);
    $g = Gen::choose(0, 255);
    $b = Gen::choose(0, 255);
    $gen = Gen::forAll([$r, $g, $b], function($r, $g, $b) {
      (new \Colourist\RGB($r, $g, $b))->toHsb();
      return true;
    });

    $check = Quick::check(self::RUN_COUNT, $gen);
    if ($check['result']) {
      $this->assertTrue($check['result'], "This should never happen!");
    }
    else {
      $failed = new \Colourist\RGB($check['fail'][0], $check['fail'][1], $check['fail'][2]);
      $this->assertTrue($check['result'], "Unable to generate HSB colour for " . $failed->toHex());
    }
  }

  public function testRgbToHsl() {
    $r = Gen::choose(0, 255);
    $g = Gen::choose(0, 255);
    $b = Gen::choose(0, 255);
    $gen = Gen::forAll([$r, $g, $b], function($r, $g, $b) {
      (new \Colourist\RGB($r, $g, $b))->toHsl();
      return true;
    });

    $check = Quick::check(self::RUN_COUNT, $gen);
    if ($check['result']) {
      $this->assertTrue($check['result'], "This should never happen!");
    }
    else {
      $failed = new \Colourist\RGB($check['fail'][0], $check['fail'][1], $check['fail'][2]);
      $this->assertTrue($check['result'], "Unable to generate HSL colour for " . $failed->toHex());
    }
  }

  public function testHsbToRgb() {
    $h = Gen::choose(0, 255);
    $s = Gen::choose(0, 100);
    $b = Gen::choose(0, 100);
    $gen = Gen::forAll([$h, $s, $b], function($h, $s, $b) {
      (new \Colourist\HSB($h, $s, $b))->toRgb();
      return true;
    });

    $check = Quick::check(self::RUN_COUNT, $gen);
    if ($check['result']) {
      $this->assertTrue($check['result'], "This should never happen!");
    }
    else {
      $failed = new \Colourist\HSB($check['fail'][0], $check['fail'][1], $check['fail'][2]);
      $this->assertTrue($check['result'], "Unable to generate RGB colour for hsb(" . $failed->hue() . ", " . $failed->saturation() . ", " . $failed->brightness() . ")");
    }
  }

  public function testHslToRgb() {
    $h = Gen::choose(0, 255);
    $s = Gen::choose(0, 100);
    $b = Gen::choose(0, 100);
    $gen = Gen::forAll([$h, $s, $b], function($h, $s, $b) {
      (new \Colourist\HSL($h, $s, $b))->toRgb();
      return true;
    });

    $check = Quick::check(self::RUN_COUNT, $gen);
    if ($check['result']) {
      $this->assertTrue($check['result'], "This should never happen!");
    }
    else {
      $failed = new \Colourist\HSL($check['fail'][0], $check['fail'][1], $check['fail'][2]);
      $this->assertTrue($check['result'], "Unable to generate RGB colour for hsl(" . $failed->hue() . ", " . $failed->saturation() . ", " . $failed->lightness() . ")");
    }
  }
}
{'fraction_non_alphanumeric': 0.23770788141720897, 'fraction_numerical': 0.021330441070137384, 'mean_word_length': 3.163280662151994, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 43, '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': '3795199', 'n_tokens_mistral': 2125, 'n_tokens_neox': 2024, 'n_words': 427}