Skip to content

Commit

Permalink
upgrade cldr data to v42
Browse files Browse the repository at this point in the history
  • Loading branch information
jrmajor committed Dec 9, 2022
1 parent a61b220 commit 5523938
Show file tree
Hide file tree
Showing 16 changed files with 180 additions and 69 deletions.
2 changes: 1 addition & 1 deletion package.json
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"
}
}
4 changes: 3 additions & 1 deletion rules/ca.php
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),
];
6 changes: 2 additions & 4 deletions rules/he.php
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,
];
2 changes: 1 addition & 1 deletion rules/is.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
use function Major\PluralRules\Operators\mod;

return [
'one' => fn ($n) => t($n) == 0 && mod(i($n), 10) == 1 && mod(i($n), 100) != 11 || t($n) != 0,
'one' => fn ($n) => t($n) == 0 && mod(i($n), 10) == 1 && mod(i($n), 100) != 11 || mod(t($n), 10) == 1 && mod(t($n), 100) != 11,
];
2 changes: 1 addition & 1 deletion rules/mo.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@

return [
'one' => fn ($n) => i($n) == 1 && v($n) == 0,
'few' => fn ($n) => v($n) != 0 || n($n) == 0 || in_range(mod(n($n), 100), 2, 19),
'few' => fn ($n) => v($n) != 0 || n($n) == 0 || n($n) != 1 && in_range(mod(n($n), 100), 1, 19),
];
3 changes: 2 additions & 1 deletion rules/mt.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

return [
'one' => fn ($n) => n($n) == 1,
'few' => fn ($n) => n($n) == 0 || in_range(mod(n($n), 100), 2, 10),
'two' => fn ($n) => n($n) == 2,
'few' => fn ($n) => n($n) == 0 || in_range(mod(n($n), 100), 3, 10),
'many' => fn ($n) => in_range(mod(n($n), 100), 11, 19),
];
2 changes: 1 addition & 1 deletion rules/ro.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@

return [
'one' => fn ($n) => i($n) == 1 && v($n) == 0,
'few' => fn ($n) => v($n) != 0 || n($n) == 0 || in_range(mod(n($n), 100), 2, 19),
'few' => fn ($n) => v($n) != 0 || n($n) == 0 || n($n) != 1 && in_range(mod(n($n), 100), 1, 19),
];
9 changes: 9 additions & 0 deletions rules/vec.php
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),
];
20 changes: 19 additions & 1 deletion tests/Locale/CaTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,25 @@ public function provideOneCases(): array
];
}

/**
* @dataProvider provideManyCases
*/
public function testMany(int|float|string $num): void
{
$category = PluralRules::select('ca', $num);
$this->assertSame('many', $category);
}

/**
* @return list<array{int|float|string}>
*/
public function provideManyCases(): array
{
return [
[1000000],
];
}

/**
* @dataProvider provideOtherCases
*/
Expand All @@ -48,7 +67,6 @@ public function provideOtherCases(): array
[1000],
[10000],
[100000],
[1000000],
[0.0],
[1.5],
[10.0],
Expand Down
46 changes: 11 additions & 35 deletions tests/Locale/HeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ public function provideOneCases(): array
{
return [
[1],
[0.0],
[0.9],
['0.00'],
[0.05],
];
}

Expand All @@ -45,37 +49,6 @@ public function provideTwoCases(): array
];
}

/**
* @dataProvider provideManyCases
*/
public function testMany(int|float|string $num): void
{
$category = PluralRules::select('he', $num);
$this->assertSame('many', $category);
}

/**
* @return list<array{int|float|string}>
*/
public function provideManyCases(): array
{
return [
[20],
[30],
[40],
[50],
[60],
[70],
[80],
[90],
[100],
[1000],
[10000],
[100000],
[1000000],
];
}

/**
* @dataProvider provideOtherCases
*/
Expand All @@ -94,10 +67,13 @@ public function provideOtherCases(): array
[0],
[3],
[17],
[101],
[1001],
[0.0],
[1.5],
[100],
[1000],
[10000],
[100000],
[1000000],
[1.0],
[2.5],
[10.0],
[100.0],
[1000.0],
Expand Down
20 changes: 12 additions & 8 deletions tests/Locale/IsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,14 @@ public function provideOneCases(): array
[101],
[1001],
[0.1],
[1.6],
[1.0],
[1.1],
[2.1],
[3.1],
[4.1],
[5.1],
[6.1],
[7.1],
[10.1],
[100.1],
[1000.1],
Expand Down Expand Up @@ -64,13 +71,10 @@ public function provideOtherCases(): array
[100000],
[1000000],
[0.0],
[2.0],
[3.0],
[4.0],
[5.0],
[6.0],
[7.0],
[8.0],
[0.2],
[0.9],
[1.2],
[1.8],
[10.0],
[100.0],
[1000.0],
Expand Down
4 changes: 2 additions & 2 deletions tests/Locale/MoTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ public function provideFewCases(): array
[0],
[2],
[16],
[102],
[1002],
[101],
[1001],
[0.0],
[1.5],
[10.0],
Expand Down
37 changes: 30 additions & 7 deletions tests/Locale/MtTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,29 @@ public function provideOneCases(): array
];
}

/**
* @dataProvider provideTwoCases
*/
public function testTwo(int|float|string $num): void
{
$category = PluralRules::select('mt', $num);
$this->assertSame('two', $category);
}

/**
* @return list<array{int|float|string}>
*/
public function provideTwoCases(): array
{
return [
[2],
[2.0],
['2.00'],
['2.000'],
['2.0000'],
];
}

/**
* @dataProvider provideFewCases
*/
Expand All @@ -46,22 +69,22 @@ public function provideFewCases(): array
{
return [
[0],
[2],
[3],
[10],
[102],
[107],
[1002],
[103],
[109],
[1003],
[0.0],
[2.0],
[3.0],
[4.0],
[5.0],
[6.0],
[7.0],
[8.0],
[9.0],
[10.0],
[102.0],
[1002.0],
[103.0],
[1003.0],
];
}

Expand Down
4 changes: 2 additions & 2 deletions tests/Locale/RoTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ public function provideFewCases(): array
[0],
[2],
[16],
[102],
[1002],
[101],
[1001],
[0.0],
[1.5],
[10.0],
Expand Down
80 changes: 80 additions & 0 deletions tests/Locale/VecTest.php
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],
];
}
}
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# yarn lockfile v1


cldr-core@^41.0:
version "41.0.0"
resolved "https://registry.yarnpkg.com/cldr-core/-/cldr-core-41.0.0.tgz#a2235b53d4a06e241bdbc4616eb22f68b29a4f3d"
integrity sha512-8UL/NVueD9BeyrYGjZWrAvhowmQt4THriUB04jxRHWST9Lmc9K1pISPjnbh0kIfRueslZ37EvQ53dxOm5w8pjQ==
cldr-core@^42.0:
version "42.0.0"
resolved "https://registry.yarnpkg.com/cldr-core/-/cldr-core-42.0.0.tgz#1ad20aa2cb2a189d7dc207cd576e5e22c7079927"
integrity sha512-9Sqy6zdOkt3c3A56hpSM9lvMyUM8h78iJ4JzX1u+kQvUz/Vbvqnm8ySxgWfe8lpx1Hrl30dg8NWdTlcKCpLIbg==

0 comments on commit 5523938

Please sign in to comment.