diff options
Diffstat (limited to 'tests/phpunit/languages')
-rw-r--r-- | tests/phpunit/languages/LanguageBe_taraskTest.php | 3 | ||||
-rw-r--r-- | tests/phpunit/languages/LanguageBsTest.php | 16 | ||||
-rw-r--r-- | tests/phpunit/languages/LanguageGvTest.php | 31 | ||||
-rw-r--r-- | tests/phpunit/languages/LanguageHrTest.php | 14 | ||||
-rw-r--r-- | tests/phpunit/languages/LanguageHyTest.php | 5 | ||||
-rw-r--r-- | tests/phpunit/languages/LanguageLvTest.php | 14 | ||||
-rw-r--r-- | tests/phpunit/languages/LanguageMkTest.php | 4 | ||||
-rw-r--r-- | tests/phpunit/languages/LanguageRuTest.php | 23 | ||||
-rw-r--r-- | tests/phpunit/languages/LanguageSgsTest.php | 2 | ||||
-rw-r--r-- | tests/phpunit/languages/LanguageShTest.php | 16 | ||||
-rw-r--r-- | tests/phpunit/languages/LanguageSrTest.php | 15 | ||||
-rw-r--r-- | tests/phpunit/languages/LanguageUkTest.php | 15 | ||||
-rw-r--r-- | tests/phpunit/languages/utils/CLDRPluralRuleEvaluatorTest.php | 50 |
13 files changed, 143 insertions, 65 deletions
diff --git a/tests/phpunit/languages/LanguageBe_taraskTest.php b/tests/phpunit/languages/LanguageBe_taraskTest.php index d5822f4a..dbdb5889 100644 --- a/tests/phpunit/languages/LanguageBe_taraskTest.php +++ b/tests/phpunit/languages/LanguageBe_taraskTest.php @@ -79,12 +79,13 @@ class LanguageBe_taraskTest extends LanguageClassesTestCase { * @covers Language::convertPlural */ public function testPluralTwoForms( $result, $value ) { - $forms = array( 'one', 'other' ); + $forms = array( '1=one', 'other' ); $this->assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); } public static function providePluralTwoForms() { return array( + array( 'other', 0 ), array( 'one', 1 ), array( 'other', 11 ), array( 'other', 91 ), diff --git a/tests/phpunit/languages/LanguageBsTest.php b/tests/phpunit/languages/LanguageBsTest.php index fb965b89..7aca2ab1 100644 --- a/tests/phpunit/languages/LanguageBsTest.php +++ b/tests/phpunit/languages/LanguageBsTest.php @@ -5,14 +5,14 @@ * @file */ -/** Tests for MediaWiki languages/LanguageBs.php */ +/** Tests for Croatian (hrvatski) */ class LanguageBsTest extends LanguageClassesTestCase { /** * @dataProvider providePlural * @covers Language::convertPlural */ public function testPlural( $result, $value ) { - $forms = array( 'one', 'few', 'many', 'other' ); + $forms = array( 'one', 'few', 'other' ); $this->assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); } @@ -26,17 +26,17 @@ class LanguageBsTest extends LanguageClassesTestCase { public static function providePlural() { return array( - array( 'many', 0 ), + array( 'other', 0 ), array( 'one', 1 ), array( 'few', 2 ), array( 'few', 4 ), - array( 'many', 5 ), - array( 'many', 11 ), - array( 'many', 20 ), + array( 'other', 5 ), + array( 'other', 11 ), + array( 'other', 20 ), array( 'one', 21 ), array( 'few', 24 ), - array( 'many', 25 ), - array( 'many', 200 ), + array( 'other', 25 ), + array( 'other', 200 ), ); } } diff --git a/tests/phpunit/languages/LanguageGvTest.php b/tests/phpunit/languages/LanguageGvTest.php index a0def628..fc58022a 100644 --- a/tests/phpunit/languages/LanguageGvTest.php +++ b/tests/phpunit/languages/LanguageGvTest.php @@ -1,20 +1,19 @@ <?php /** + * Test for Manx (Gaelg) language + * * @author Santhosh Thottingal - * @copyright Copyright © 2012, Santhosh Thottingal + * @copyright Copyright © 2013, Santhosh Thottingal * @file */ -/** Tests for MediaWiki languages/classes/LanguageGv.php */ class LanguageGvTest extends LanguageClassesTestCase { /** * @dataProvider providePlural * @covers Language::convertPlural */ public function testPlural( $result, $value ) { - // This is not compatible with CLDR plural rules http://unicode.org/repos/cldr-tmp/trunk/diff/supplemental/language_plural_rules.html#gv - // What does this mean? Is there a hard-coded override for gv somewhere? -Ryan Kaldari 2013-01-28 - $forms = array( 'Form 1', 'Form 2', 'Form 3', 'Form 4' ); + $forms = array( 'one', 'two', 'few', 'other' ); $this->assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); } @@ -23,21 +22,23 @@ class LanguageGvTest extends LanguageClassesTestCase { * @covers Language::getPluralRuleType */ public function testGetPluralRuleType( $result, $value ) { - $this->markTestSkipped( "This test won't work since convertPlural for gv doesn't seem to actually follow our plural rules." ); $this->assertEquals( $result, $this->getLang()->getPluralRuleType( $value ) ); } public static function providePlural() { return array( - array( 'Form 4', 0 ), - array( 'Form 2', 1 ), - array( 'Form 3', 2 ), - array( 'Form 4', 3 ), - array( 'Form 1', 20 ), - array( 'Form 2', 21 ), - array( 'Form 3', 22 ), - array( 'Form 4', 23 ), - array( 'Form 4', 50 ), + array( 'few', 0 ), + array( 'one', 1 ), + array( 'two', 2 ), + array( 'other', 3 ), + array( 'few', 20 ), + array( 'one', 21 ), + array( 'two', 22 ), + array( 'other', 23 ), + array( 'other', 50 ), + array( 'few', 60 ), + array( 'other', 80 ), + array( 'few', 100 ) ); } } diff --git a/tests/phpunit/languages/LanguageHrTest.php b/tests/phpunit/languages/LanguageHrTest.php index 6ce4aff9..644c5255 100644 --- a/tests/phpunit/languages/LanguageHrTest.php +++ b/tests/phpunit/languages/LanguageHrTest.php @@ -12,7 +12,7 @@ class LanguageHrTest extends LanguageClassesTestCase { * @covers Language::convertPlural */ public function testPlural( $result, $value ) { - $forms = array( 'one', 'few', 'many', 'other' ); + $forms = array( 'one', 'few', 'other' ); $this->assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); } @@ -26,17 +26,17 @@ class LanguageHrTest extends LanguageClassesTestCase { public static function providePlural() { return array( - array( 'many', 0 ), + array( 'other', 0 ), array( 'one', 1 ), array( 'few', 2 ), array( 'few', 4 ), - array( 'many', 5 ), - array( 'many', 11 ), - array( 'many', 20 ), + array( 'other', 5 ), + array( 'other', 11 ), + array( 'other', 20 ), array( 'one', 21 ), array( 'few', 24 ), - array( 'many', 25 ), - array( 'many', 200 ), + array( 'other', 25 ), + array( 'other', 200 ), ); } } diff --git a/tests/phpunit/languages/LanguageHyTest.php b/tests/phpunit/languages/LanguageHyTest.php index 896522b0..92e0ef94 100644 --- a/tests/phpunit/languages/LanguageHyTest.php +++ b/tests/phpunit/languages/LanguageHyTest.php @@ -5,7 +5,7 @@ * @file */ -/** Tests for MediaWiki languages/LanguageHy.php */ +/** Tests for Armenian (Հայերեն) */ class LanguageHyTest extends LanguageClassesTestCase { /** * @dataProvider providePlural @@ -21,13 +21,12 @@ class LanguageHyTest extends LanguageClassesTestCase { * @covers Language::getPluralRuleType */ public function testGetPluralRuleType( $result, $value ) { - // This fails for 0, but I'm not sure why. Some voodoo going on here. $this->assertEquals( $result, $this->getLang()->getPluralRuleType( $value ) ); } public static function providePlural() { return array( - array( 'other', 0 ), + array( 'one', 0 ), array( 'one', 1 ), array( 'other', 2 ), array( 'other', 200 ), diff --git a/tests/phpunit/languages/LanguageLvTest.php b/tests/phpunit/languages/LanguageLvTest.php index c4d8a6f0..7120cfe3 100644 --- a/tests/phpunit/languages/LanguageLvTest.php +++ b/tests/phpunit/languages/LanguageLvTest.php @@ -5,7 +5,7 @@ * @file */ -/** Tests for MediaWiki languages/classes/LanguageLv.php */ +/** Tests for Latvian */ class LanguageLvTest extends LanguageClassesTestCase { /** * @dataProvider providePlural @@ -28,13 +28,17 @@ class LanguageLvTest extends LanguageClassesTestCase { return array( array( 'zero', 0 ), array( 'one', 1 ), - array( 'other', 11 ), + array( 'zero', 11 ), array( 'one', 21 ), - array( 'other', 411 ), + array( 'zero', 411 ), + array( 'other', 2 ), + array( 'other', 9 ), + array( 'zero', 12 ), array( 'other', 12.345 ), - array( 'other', 20 ), + array( 'zero', 20 ), + array( 'other', 22 ), array( 'one', 31 ), - array( 'other', 200 ), + array( 'zero', 200 ), ); } } diff --git a/tests/phpunit/languages/LanguageMkTest.php b/tests/phpunit/languages/LanguageMkTest.php index 7d47b375..ed155263 100644 --- a/tests/phpunit/languages/LanguageMkTest.php +++ b/tests/phpunit/languages/LanguageMkTest.php @@ -5,7 +5,7 @@ * @file */ -/** Tests for MediaWiki languages/classes/LanguageMk.php */ +/** Tests for македонски/Macedonian */ class LanguageMkTest extends LanguageClassesTestCase { /** * @dataProvider providePlural @@ -28,7 +28,7 @@ class LanguageMkTest extends LanguageClassesTestCase { return array( array( 'other', 0 ), array( 'one', 1 ), - array( 'other', 11 ), + array( 'one', 11 ), array( 'one', 21 ), array( 'one', 411 ), array( 'other', 12.345 ), diff --git a/tests/phpunit/languages/LanguageRuTest.php b/tests/phpunit/languages/LanguageRuTest.php index e938be79..e17c7085 100644 --- a/tests/phpunit/languages/LanguageRuTest.php +++ b/tests/phpunit/languages/LanguageRuTest.php @@ -13,11 +13,22 @@ class LanguageRuTest extends LanguageClassesTestCase { * @covers Language::convertPlural */ public function testPlural( $result, $value ) { - $forms = array( 'one', 'few', 'many', 'other' ); + $forms = array( 'one', 'many', 'other' ); $this->assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); } /** + * Test explicit plural forms - n=FormN forms + * @covers Language::convertPlural + */ + public function testExplicitPlural() { + $forms = array( 'one','many', 'other', '12=dozen' ); + $this->assertEquals( 'dozen', $this->getLang()->convertPlural( 12, $forms ) ); + $forms = array( 'one', 'many', '100=hundred', 'other', '12=dozen' ); + $this->assertEquals( 'hundred', $this->getLang()->convertPlural( 100, $forms ) ); + } + + /** * @dataProvider providePlural * @covers Language::getPluralRuleType */ @@ -31,10 +42,10 @@ class LanguageRuTest extends LanguageClassesTestCase { array( 'many', 11 ), array( 'one', 91 ), array( 'one', 121 ), - array( 'few', 2 ), - array( 'few', 3 ), - array( 'few', 4 ), - array( 'few', 334 ), + array( 'other', 2 ), + array( 'other', 3 ), + array( 'other', 4 ), + array( 'other', 334 ), array( 'many', 5 ), array( 'many', 15 ), array( 'many', 120 ), @@ -46,7 +57,7 @@ class LanguageRuTest extends LanguageClassesTestCase { * @covers Language::convertPlural */ public function testPluralTwoForms( $result, $value ) { - $forms = array( 'one', 'other' ); + $forms = array( '1=one', 'other' ); $this->assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); } diff --git a/tests/phpunit/languages/LanguageSgsTest.php b/tests/phpunit/languages/LanguageSgsTest.php index bf6a14b1..fa49a4dd 100644 --- a/tests/phpunit/languages/LanguageSgsTest.php +++ b/tests/phpunit/languages/LanguageSgsTest.php @@ -5,7 +5,7 @@ * @file */ -/** Tests for MediaWiki languages/classes/LanguageSgs.php */ +/** Tests for Samogitian */ class LanguageSgsTest extends LanguageClassesTestCase { /** * @dataProvider providePluralAllForms diff --git a/tests/phpunit/languages/LanguageShTest.php b/tests/phpunit/languages/LanguageShTest.php index 6d2e25a6..1b390872 100644 --- a/tests/phpunit/languages/LanguageShTest.php +++ b/tests/phpunit/languages/LanguageShTest.php @@ -5,14 +5,14 @@ * @file */ -/** Tests for MediaWiki languages/classes/LanguageSh.php */ +/** Tests for srpskohrvatski / српскохрватски / Serbocroatian */ class LanguageShTest extends LanguageClassesTestCase { /** * @dataProvider providePlural * @covers Language::convertPlural */ public function testPlural( $result, $value ) { - $forms = array( 'one', 'few', 'many', 'other' ); + $forms = array( 'one', 'few', 'other' ); $this->assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); } @@ -26,17 +26,17 @@ class LanguageShTest extends LanguageClassesTestCase { public static function providePlural() { return array( - array( 'many', 0 ), + array( 'other', 0 ), array( 'one', 1 ), array( 'few', 2 ), array( 'few', 4 ), - array( 'many', 5 ), - array( 'many', 10 ), - array( 'many', 11 ), - array( 'many', 12 ), + array( 'other', 5 ), + array( 'other', 10 ), + array( 'other', 11 ), + array( 'other', 12 ), array( 'one', 101 ), array( 'few', 102 ), - array( 'many', 111 ), + array( 'other', 111 ), ); } } diff --git a/tests/phpunit/languages/LanguageSrTest.php b/tests/phpunit/languages/LanguageSrTest.php index ab4d4aba..d6fedb57 100644 --- a/tests/phpunit/languages/LanguageSrTest.php +++ b/tests/phpunit/languages/LanguageSrTest.php @@ -130,7 +130,7 @@ class LanguageSrTest extends LanguageClassesTestCase { * @covers Language::convertPlural */ public function testPlural( $result, $value ) { - $forms = array( 'one', 'few', 'many', 'other' ); + $forms = array( 'one', 'few', 'other' ); $this->assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); } @@ -145,16 +145,16 @@ class LanguageSrTest extends LanguageClassesTestCase { public static function providePlural() { return array( array( 'one', 1 ), - array( 'many', 11 ), + array( 'other', 11 ), array( 'one', 91 ), array( 'one', 121 ), array( 'few', 2 ), array( 'few', 3 ), array( 'few', 4 ), array( 'few', 334 ), - array( 'many', 5 ), - array( 'many', 15 ), - array( 'many', 120 ), + array( 'other', 5 ), + array( 'other', 15 ), + array( 'other', 120 ), ); } @@ -171,8 +171,9 @@ class LanguageSrTest extends LanguageClassesTestCase { return array( array( 'one', 1 ), array( 'other', 11 ), - array( 'other', 91 ), - array( 'other', 121 ), + array( 'other', 4 ), + array( 'one', 91 ), + array( 'one', 121 ), ); } diff --git a/tests/phpunit/languages/LanguageUkTest.php b/tests/phpunit/languages/LanguageUkTest.php index 0783fcf6..9051bcff 100644 --- a/tests/phpunit/languages/LanguageUkTest.php +++ b/tests/phpunit/languages/LanguageUkTest.php @@ -6,7 +6,7 @@ * @file */ -/** Tests for MediaWiki languages/classes/LanguageUk.php */ +/** Tests for Ukrainian */ class LanguageUkTest extends LanguageClassesTestCase { /** * @dataProvider providePlural @@ -18,6 +18,17 @@ class LanguageUkTest extends LanguageClassesTestCase { } /** + * Test explicit plural forms - n=FormN forms + * @covers Language::convertPlural + */ + public function testExplicitPlural() { + $forms = array( 'one', 'few', 'many', 'other', '12=dozen' ); + $this->assertEquals( 'dozen', $this->getLang()->convertPlural( 12, $forms ) ); + $forms = array( 'one', 'few', 'many', '100=hundred', 'other', '12=dozen' ); + $this->assertEquals( 'hundred', $this->getLang()->convertPlural( 100, $forms ) ); + } + + /** * @dataProvider providePlural * @covers Language::getPluralRuleType */ @@ -46,7 +57,7 @@ class LanguageUkTest extends LanguageClassesTestCase { * @covers Language::convertPlural */ public function testPluralTwoForms( $result, $value ) { - $forms = array( 'one', 'other' ); + $forms = array( '1=one', 'other' ); $this->assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); } diff --git a/tests/phpunit/languages/utils/CLDRPluralRuleEvaluatorTest.php b/tests/phpunit/languages/utils/CLDRPluralRuleEvaluatorTest.php index 3bf74146..bd3809d7 100644 --- a/tests/phpunit/languages/utils/CLDRPluralRuleEvaluatorTest.php +++ b/tests/phpunit/languages/utils/CLDRPluralRuleEvaluatorTest.php @@ -78,6 +78,56 @@ class CLDRPluralRuleEvaluatorTest extends MediaWikiTestCase { array( 0, 'n in 3..10,13..19', 13, 'scottish rule - ranges with comma' ), array( 0, '5 mod 3 is n', 2, 'n as result of mod - no need to pass' ), + + # Revision 33 new operand examples + # expected, rule, number, comment + array( 0, 'i is 1', '1.00', 'new operand i' ), + array( 0, 'v is 2', '1.00', 'new operand v' ), + array( 0, 'w is 0', '1.00', 'new operand w' ), + array( 0, 'f is 0', '1.00', 'new operand f' ), + array( 0, 't is 0', '1.00', 'new operand t' ), + + array( 0, 'i is 1', '1.30', 'new operand i' ), + array( 0, 'v is 2', '1.30', 'new operand v' ), + array( 0, 'w is 1', '1.30', 'new operand w' ), + array( 0, 'f is 30', '1.30', 'new operand f' ), + array( 0, 't is 3', '1.30', 'new operand t' ), + + array( 0, 'i is 1', '1.03', 'new operand i' ), + array( 0, 'v is 2', '1.03', 'new operand v' ), + array( 0, 'w is 2', '1.03', 'new operand w' ), + array( 0, 'f is 3', '1.03', 'new operand f' ), + array( 0, 't is 3', '1.03', 'new operand t' ), + + # Revision 33 new operator aliases + # expected, rule, number, comment + array( 0, 'n % 3 is 1', 7, 'new % operator' ), + array( 0, 'n = 1,3,5', 3, 'new = operator' ), + array( 1, 'n != 1,3,5', 5, 'new != operator' ), + + # Revision 33 samples + # expected, rule, number, comment + array( 0, 'n in 1,3,5@integer 3~10, 103~110, 1003, … @decimal 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 103.0, 1003.0, …', 3, 'samples' ), + + # Revision 33 some test cases from CLDR + array( 0, 'i = 1 and v = 0 or i = 0 and t = 1', '0.1', 'pt one' ), + array( 0, 'i = 1 and v = 0 or i = 0 and t = 1', '0.01', 'pt one' ), + array( 0, 'i = 1 and v = 0 or i = 0 and t = 1', '0.10', 'pt one' ), + array( 0, 'i = 1 and v = 0 or i = 0 and t = 1', '0.010', 'pt one' ), + array( 0, 'i = 1 and v = 0 or i = 0 and t = 1', '0.100', 'pt one' ), + array( 1, 'i = 1 and v = 0 or i = 0 and t = 1', '0.0', 'pt other' ), + array( 1, 'i = 1 and v = 0 or i = 0 and t = 1', '0.2', 'pt other' ), + array( 1, 'i = 1 and v = 0 or i = 0 and t = 1', '10.0', 'pt other' ), + array( 1, 'i = 1 and v = 0 or i = 0 and t = 1', '100.0', 'pt other' ), + array( 0, 'v = 0 and i % 10 = 2..4 and i % 100 != 12..14 or f % 10 = 2..4 and f % 100 != 12..14', '2', 'bs few' ), + array( 0, 'v = 0 and i % 10 = 2..4 and i % 100 != 12..14 or f % 10 = 2..4 and f % 100 != 12..14', '4', 'bs few' ), + array( 0, 'v = 0 and i % 10 = 2..4 and i % 100 != 12..14 or f % 10 = 2..4 and f % 100 != 12..14', '22', 'bs few' ), + array( 0, 'v = 0 and i % 10 = 2..4 and i % 100 != 12..14 or f % 10 = 2..4 and f % 100 != 12..14', '102', 'bs few' ), + array( 0, 'v = 0 and i % 10 = 2..4 and i % 100 != 12..14 or f % 10 = 2..4 and f % 100 != 12..14', '0.2', 'bs few' ), + array( 0, 'v = 0 and i % 10 = 2..4 and i % 100 != 12..14 or f % 10 = 2..4 and f % 100 != 12..14', '0.4', 'bs few' ), + array( 0, 'v = 0 and i % 10 = 2..4 and i % 100 != 12..14 or f % 10 = 2..4 and f % 100 != 12..14', '10.2', 'bs few' ), + array( 1, 'v = 0 and i % 10 = 2..4 and i % 100 != 12..14 or f % 10 = 2..4 and f % 100 != 12..14', '10.0', 'bs other' ), + ); return $tests; |