<commit_before><?php

use Getopti\Option;

class OptionTest extends PHPUnit_Framework_TestCase {
  
  /**
   * @test
   * @covers  Getopti\Option::build
   */
  public function build()
  {
    $this->assertInstanceOf('Getopti\\Option\\Base', Option::build('a'));
  }
  
  // --------------------------------------------------------------------
  
  public function buildProvider()
  {
    return array(
      array(
        'a',    // the option(s)
        TRUE,   // expect short opt to be set
        FALSE   // expect long opt to be set
      ),
      array('long', FALSE, TRUE),
      array(array('a'), TRUE, FALSE),
      array(array('long'), FALSE, TRUE),
      array(array(NULL, 'long'), FALSE, TRUE),
      array(array('a', 'long'), TRUE, TRUE)
    );
  }
  
  /**
   * @test
   * @covers  Getopti\Option::build
   * 
   * @dataProvider  buildProvider
   */
  public function build_passes_options_correctly($opts, $is_short = FALSE, $is_long = FALSE)
  {
    $option = Option::build($opts);
    
    $short = ($is_short) ? 'a' : NULL;
    $this->assertEquals($short, $option->short);
    
    $long = ($is_long) ? 'long' : NULL;
    $this->assertEquals($long, $option->long);
  }
<commit_msg>add option type tests<commit_after><?php

use Getopti\Option;

class OptionTest extends PHPUnit_Framework_TestCase {
  
  /**
   * @test
   * @covers  Getopti\Option::build
   */
  public function build()
  {
    $this->assertInstanceOf('Getopti\\Option\\Base', Option::build('a'));
  }
  
  // --------------------------------------------------------------------
  
  public function buildProvider()
  {
    return array(
      array(
        'a',    // the option(s)
        TRUE,   // expect short opt to be set
        FALSE   // expect long opt to be set
      ),
      array('long', FALSE, TRUE),
      array(array('a'), TRUE, FALSE),
      array(array('long'), FALSE, TRUE),
      array(array(NULL, 'long'), FALSE, TRUE),
      array(array('a', 'long'), TRUE, TRUE)
    );
  }
  
  /**
   * @test
   * @covers  Getopti\Option::build
   * 
   * @dataProvider  buildProvider
   */
  public function build_passes_options_correctly($opts, $is_short = FALSE, $is_long = FALSE)
  {
    $option = Option::build($opts);
    
    $short = ($is_short) ? 'a' : NULL;
    $this->assertEquals($short, $option->short);
    
    $long = ($is_long) ? 'long' : NULL;
    $this->assertEquals($long, $option->long);
  }

  // --------------------------------------------------------------------

  public function optionTypeProvider()
  {
    return array(
      array(Option::TYPE_DEFAULT, 'Getopti\\Option\\Base'),
      array(OPTION::TYPE_BOOL,    'Getopti\\Option\\Bool')
    );
  }

  /**
   * @test
   * @covers  Getopti\Option::build
   *
   * @dataProvider  optionTypeProvider
   */
  public function build_returns_correct_option_type($type, $expected_class)
  {
    $option = Option::build('a', array('PARAM', $type));
    $this->assertInstanceOf($expected_class, $option);
  }

  /**
   * @test
   * @covers  Getopti\Option::build
   */
  public function build_throws_exception_for_invalid_option_type()
  {
    $this->setExpectedException('InvalidArgumentException');
    $option = Option::build('a', array(NULL, 'invalid_type'));
  }

{'fraction_non_alphanumeric': 0.21645021645021645, 'fraction_numerical': 0.0, 'mean_word_length': 2.190335305719921, 'pattern_counts': {'":': 0, '<': 5, '<?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': '4009554', 'n_tokens_mistral': 1018, 'n_tokens_neox': 1013, 'n_words': 200}