From 4f2eaa8d803d6c710f3f2164d40f77c449f1c744 Mon Sep 17 00:00:00 2001 From: Santhosh Thottingal Date: Mon, 30 Jan 2012 11:34:36 +0000 Subject: [PATCH] For Moldavian $count % 100 < 20 is not 'few' form, but $count % 100 in 1..19 is few form. This was causing 200 considered as 'few' form, while it should be 'other' form as per http://unicode.org/repos/cldr-tmp/trunk/diff/supplemental/language_plural_rules.html#mo Add phpunit test cases for LanguageMo plural rules --- languages/classes/LanguageMo.php | 2 +- tests/phpunit/languages/LanguageMoTest.php | 42 ++++++++++++++++++++++ 2 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 tests/phpunit/languages/LanguageMoTest.php diff --git a/languages/classes/LanguageMo.php b/languages/classes/LanguageMo.php index 5d78a5029d..cc3b25af9e 100644 --- a/languages/classes/LanguageMo.php +++ b/languages/classes/LanguageMo.php @@ -20,7 +20,7 @@ class LanguageMo extends Language { if ( $count == 1 ) { $index = 0; - } elseif ( $count == 0 || $count % 100 < 20 ) { + } elseif ( $count == 0 || ( $count % 100 > 1 && $count % 100 < 20 ) ) { $index = 1; } else { $index = 2; diff --git a/tests/phpunit/languages/LanguageMoTest.php b/tests/phpunit/languages/LanguageMoTest.php new file mode 100644 index 0000000000..6bb8ca66e1 --- /dev/null +++ b/tests/phpunit/languages/LanguageMoTest.php @@ -0,0 +1,42 @@ +lang = Language::factory( 'mo' ); + } + function tearDown() { + unset( $this->lang ); + } + + /** @dataProvider providerPlural */ + function testPlural( $result, $value ) { + $forms = array( 'one', 'few', 'other' ); + $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) ); + } + + + function providerPlural() { + return array ( + array( 'few', 0 ), + array( 'one', 1 ), + array( 'few', 2 ), + array( 'few', 3 ), + array( 'few', 19 ), + array( 'few', 119 ), + array( 'other', 20 ), + array( 'other', 20.123 ), + array( 'other', 31 ), + array( 'other', 200 ), + ); + } + + +} -- 2.20.1