For Moldavian $count % 100 < 20 is not 'few' form, but $count % 100 in 1..19 is few...
authorSanthosh Thottingal <santhosh@users.mediawiki.org>
Mon, 30 Jan 2012 11:34:36 +0000 (11:34 +0000)
committerSanthosh Thottingal <santhosh@users.mediawiki.org>
Mon, 30 Jan 2012 11:34:36 +0000 (11:34 +0000)
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
tests/phpunit/languages/LanguageMoTest.php [new file with mode: 0644]

index 5d78a50..cc3b25a 100644 (file)
@@ -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 (file)
index 0000000..6bb8ca6
--- /dev/null
@@ -0,0 +1,42 @@
+<?php
+/**
+ * @author Santhosh Thottingal
+ * @copyright Copyright © 2012, Santhosh Thottingal
+ * @file
+ */
+
+/** Tests for MediaWiki languages/classes/LanguageMo.php */
+class LanguageMoTest extends MediaWikiTestCase {
+       private $lang;
+
+       function setUp() {
+               $this->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 ),
+               );
+       }
+
+
+}