<commit_before><?php

use WP_CLI\SynopsisParser;

class SynopsisParserTest extends PHPUnit_Framework_TestCase {

	function testPositional() {
		$r = SynopsisParser::parse( '<foo> [<bar>]' );

		$this->assertFoundParameters( 2, 'positional', $r );
		$this->assertFalse( $r['positional'][0]['optional'] );
		$this->assertTrue( $r['positional'][1]['optional'] );
	}

	function testFlag() {
		$r = SynopsisParser::parse( '--foo' );
		$this->assertFoundParameters( 0, 'flag', $r ); // flags can't be mandatory

		$r = SynopsisParser::parse( '[--foo]' );
		$this->assertFoundParameters( 1, 'flag', $r );
	}

	function testGeneric() {
		$r = SynopsisParser::parse( '--<field>=<value> [--<field>=<value>]' );

		$this->assertFoundParameters( 2, 'generic', $r );
		$this->assertFalse( $r['generic'][0]['optional'] );
		$this->assertTrue( $r['generic'][1]['optional'] );
	}

	function testAssoc() {
		$r = SynopsisParser::parse( '--foo=<value> [--bar=<value>]' );

		$this->assertFoundParameters( 2, 'assoc', $r );
		$this->assertFalse( $r['assoc'][0]['optional'] );
		$this->assertTrue( $r['assoc'][1]['optional'] );
	}

	function testCombined() {
		$r = SynopsisParser::parse( '<positional> --assoc=<someval> --<field>=<value> [--flag]' );

		$this->assertEquals( 1, count( $r['positional'] ) );
		$this->assertEquals( 1, count( $r['assoc'] ) );
		$this->assertEquals( 1, count( $r['generic'] ) );
		$this->assertEquals( 1, count( $r['flag'] ) );
	}

	protected function assertFoundParameters( $count, $type, $r ) {
		foreach ( $r as $key => $params ) {
			$expected = ( $key == $type ) ? $count : 0;

			$this->assertEquals( $expected, count( $params ) );
		}
	}
}
<commit_msg>use assertCount() instead of assertEquals()<commit_after><?php

use WP_CLI\SynopsisParser;

class SynopsisParserTest extends PHPUnit_Framework_TestCase {

	function testPositional() {
		$r = SynopsisParser::parse( '<foo> [<bar>]' );

		$this->assertFoundParameters( 2, 'positional', $r );
		$this->assertFalse( $r['positional'][0]['optional'] );
		$this->assertTrue( $r['positional'][1]['optional'] );
	}

	function testFlag() {
		$r = SynopsisParser::parse( '--foo' );
		$this->assertFoundParameters( 0, 'flag', $r ); // flags can't be mandatory

		$r = SynopsisParser::parse( '[--foo]' );
		$this->assertFoundParameters( 1, 'flag', $r );
	}

	function testGeneric() {
		$r = SynopsisParser::parse( '--<field>=<value> [--<field>=<value>]' );

		$this->assertFoundParameters( 2, 'generic', $r );
		$this->assertFalse( $r['generic'][0]['optional'] );
		$this->assertTrue( $r['generic'][1]['optional'] );
	}

	function testAssoc() {
		$r = SynopsisParser::parse( '--foo=<value> [--bar=<value>]' );

		$this->assertFoundParameters( 2, 'assoc', $r );
		$this->assertFalse( $r['assoc'][0]['optional'] );
		$this->assertTrue( $r['assoc'][1]['optional'] );
	}

	function testCombined() {
		$r = SynopsisParser::parse( '<positional> --assoc=<someval> --<field>=<value> [--flag]' );

		$this->assertCount( 1, $r['positional'] );
		$this->assertCount( 1, $r['assoc'] );
		$this->assertCount( 1, $r['generic'] );
		$this->assertCount( 1, $r['flag'] );
	}

	protected function assertFoundParameters( $count, $type, $r ) {
		foreach ( $r as $key => $params ) {
			$expected = ( $key == $type ) ? $count : 0;

			$this->assertCount( $expected, $params );
		}
	}
}

{'fraction_non_alphanumeric': 0.23795180722891565, 'fraction_numerical': 0.00963855421686747, 'mean_word_length': 4.816112084063048, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 61, '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': '7213833', 'n_tokens_mistral': 1276, 'n_tokens_neox': 1181, 'n_words': 225}