-
-
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
4 changed files
with
101 additions
and
5 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": "^43.0" | ||
"cldr-core": "^44.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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
|
||
use function Major\PluralRules\Operands\n; | ||
|
||
return [ | ||
'zero' => fn ($n) => n($n) == 0, | ||
'one' => fn ($n) => n($n) == 1, | ||
]; |
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,88 @@ | ||
<?php | ||
|
||
namespace Major\PluralRules\Tests\Locale; | ||
|
||
use Major\PluralRules\PluralRules; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
final class BloTest extends TestCase | ||
{ | ||
/** | ||
* @dataProvider provideZeroCases | ||
*/ | ||
public function testZero(int|float|string $num): void | ||
{ | ||
$category = PluralRules::select('blo', $num); | ||
$this->assertSame('zero', $category); | ||
} | ||
|
||
/** | ||
* @return list<array{int|float|string}> | ||
*/ | ||
public static function provideZeroCases(): array | ||
{ | ||
return [ | ||
[0], | ||
[0.0], | ||
['0.00'], | ||
['0.000'], | ||
['0.0000'], | ||
]; | ||
} | ||
|
||
/** | ||
* @dataProvider provideOneCases | ||
*/ | ||
public function testOne(int|float|string $num): void | ||
{ | ||
$category = PluralRules::select('blo', $num); | ||
$this->assertSame('one', $category); | ||
} | ||
|
||
/** | ||
* @return list<array{int|float|string}> | ||
*/ | ||
public static function provideOneCases(): array | ||
{ | ||
return [ | ||
[1], | ||
[1.0], | ||
['1.00'], | ||
['1.000'], | ||
['1.0000'], | ||
]; | ||
} | ||
|
||
/** | ||
* @dataProvider provideOtherCases | ||
*/ | ||
public function testOther(int|float|string $num): void | ||
{ | ||
$category = PluralRules::select('blo', $num); | ||
$this->assertSame('other', $category); | ||
} | ||
|
||
/** | ||
* @return list<array{int|float|string}> | ||
*/ | ||
public static function provideOtherCases(): array | ||
{ | ||
return [ | ||
[2], | ||
[16], | ||
[100], | ||
[1000], | ||
[10000], | ||
[100000], | ||
[1000000], | ||
[2.0], | ||
[2.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