-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
180 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"private": true, | ||
"dependencies": { | ||
"cldr-core": "^41.0" | ||
"cldr-core": "^42.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
<?php | ||
|
||
use function Major\PluralRules\Operands\{i, v}; | ||
use function Major\PluralRules\Operands\{e, i, v}; | ||
use function Major\PluralRules\Operators\{in_range, mod}; | ||
|
||
return [ | ||
'one' => fn ($n) => i($n) == 1 && v($n) == 0, | ||
'many' => fn ($n) => e($n) == 0 && i($n) != 0 && mod(i($n), 1000000) == 0 && v($n) == 0 || ! in_range(e($n), 0, 5), | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,8 @@ | ||
<?php | ||
|
||
use function Major\PluralRules\Operands\{i, n, v}; | ||
use function Major\PluralRules\Operators\{in_range, mod}; | ||
use function Major\PluralRules\Operands\{i, v}; | ||
|
||
return [ | ||
'one' => fn ($n) => i($n) == 1 && v($n) == 0, | ||
'one' => fn ($n) => i($n) == 1 && v($n) == 0 || i($n) == 0 && v($n) != 0, | ||
'two' => fn ($n) => i($n) == 2 && v($n) == 0, | ||
'many' => fn ($n) => v($n) == 0 && ! in_range(n($n), 0, 10) && mod(n($n), 10) == 0, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
|
||
use function Major\PluralRules\Operands\{e, i, v}; | ||
use function Major\PluralRules\Operators\{in_range, mod}; | ||
|
||
return [ | ||
'one' => fn ($n) => i($n) == 1 && v($n) == 0, | ||
'many' => fn ($n) => e($n) == 0 && i($n) != 0 && mod(i($n), 1000000) == 0 && v($n) == 0 || ! in_range(e($n), 0, 5), | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
<?php | ||
|
||
namespace Major\PluralRules\Tests\Locale; | ||
|
||
use Major\PluralRules\PluralRules; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
final class VecTest extends TestCase | ||
{ | ||
/** | ||
* @dataProvider provideOneCases | ||
*/ | ||
public function testOne(int|float|string $num): void | ||
{ | ||
$category = PluralRules::select('vec', $num); | ||
$this->assertSame('one', $category); | ||
} | ||
|
||
/** | ||
* @return list<array{int|float|string}> | ||
*/ | ||
public function provideOneCases(): array | ||
{ | ||
return [ | ||
[1], | ||
]; | ||
} | ||
|
||
/** | ||
* @dataProvider provideManyCases | ||
*/ | ||
public function testMany(int|float|string $num): void | ||
{ | ||
$category = PluralRules::select('vec', $num); | ||
$this->assertSame('many', $category); | ||
} | ||
|
||
/** | ||
* @return list<array{int|float|string}> | ||
*/ | ||
public function provideManyCases(): array | ||
{ | ||
return [ | ||
[1000000], | ||
]; | ||
} | ||
|
||
/** | ||
* @dataProvider provideOtherCases | ||
*/ | ||
public function testOther(int|float|string $num): void | ||
{ | ||
$category = PluralRules::select('vec', $num); | ||
$this->assertSame('other', $category); | ||
} | ||
|
||
/** | ||
* @return list<array{int|float|string}> | ||
*/ | ||
public function provideOtherCases(): array | ||
{ | ||
return [ | ||
[0], | ||
[2], | ||
[16], | ||
[100], | ||
[1000], | ||
[10000], | ||
[100000], | ||
[0.0], | ||
[1.5], | ||
[10.0], | ||
[100.0], | ||
[1000.0], | ||
[10000.0], | ||
[100000.0], | ||
[1000000.0], | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters