r110279 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r110278‎ | r110279 | r110280 >
Date:11:34, 30 January 2012
Author:santhosh
Status:resolved
Tags:
Comment:
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
Modified paths:
  • /trunk/phase3/languages/classes/LanguageMo.php (modified) (history)
  • /trunk/phase3/tests/phpunit/languages/LanguageMoTest.php (added) (history)

Diff [purge]

Index: trunk/phase3/tests/phpunit/languages/LanguageMoTest.php
@@ -0,0 +1,42 @@
 2+<?php
 3+/**
 4+ * @author Santhosh Thottingal
 5+ * @copyright Copyright © 2012, Santhosh Thottingal
 6+ * @file
 7+ */
 8+
 9+/** Tests for MediaWiki languages/classes/LanguageMo.php */
 10+class LanguageMoTest extends MediaWikiTestCase {
 11+ private $lang;
 12+
 13+ function setUp() {
 14+ $this->lang = Language::factory( 'mo' );
 15+ }
 16+ function tearDown() {
 17+ unset( $this->lang );
 18+ }
 19+
 20+ /** @dataProvider providerPlural */
 21+ function testPlural( $result, $value ) {
 22+ $forms = array( 'one', 'few', 'other' );
 23+ $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) );
 24+ }
 25+
 26+
 27+ function providerPlural() {
 28+ return array (
 29+ array( 'few', 0 ),
 30+ array( 'one', 1 ),
 31+ array( 'few', 2 ),
 32+ array( 'few', 3 ),
 33+ array( 'few', 19 ),
 34+ array( 'few', 119 ),
 35+ array( 'other', 20 ),
 36+ array( 'other', 20.123 ),
 37+ array( 'other', 31 ),
 38+ array( 'other', 200 ),
 39+ );
 40+ }
 41+
 42+
 43+}
Property changes on: trunk/phase3/tests/phpunit/languages/LanguageMoTest.php
___________________________________________________________________
Added: svn:eol-style
144 + native
Index: trunk/phase3/languages/classes/LanguageMo.php
@@ -20,7 +20,7 @@
2121
2222 if ( $count == 1 ) {
2323 $index = 0;
24 - } elseif ( $count == 0 || $count % 100 < 20 ) {
 24+ } elseif ( $count == 0 || ( $count % 100 > 1 && $count % 100 < 20 ) ) {
2525 $index = 1;
2626 } else {
2727 $index = 2;

Follow-up revisions

RevisionCommit summaryAuthorDate
r110288Followup r110279. $count % 100 in 1..19 is few form....santhosh13:51, 30 January 2012

Status & tagging log