Index: trunk/phase3/tests/phpunit/languages/LanguageRoTest.php |
— | — | @@ -0,0 +1,43 @@ |
| 2 | +<?php |
| 3 | +/** |
| 4 | + * @author Amir E. Aharoni |
| 5 | + * @copyright Copyright © 2012, Amir E. Aharoni |
| 6 | + * @file |
| 7 | + */ |
| 8 | + |
| 9 | +/** Tests for MediaWiki languages/classes/LanguageRo.php */ |
| 10 | +class LanguageRoTest extends MediaWikiTestCase { |
| 11 | + private $lang; |
| 12 | + |
| 13 | + function setUp() { |
| 14 | + $this->lang = Language::factory( 'ro' ); |
| 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 | + function providerPlural() { |
| 27 | + return array ( |
| 28 | + array( 'few', 0 ), |
| 29 | + array( 'one', 1 ), |
| 30 | + array( 'few', 2 ), |
| 31 | + array( 'few', 19 ), |
| 32 | + array( 'other', 20 ), |
| 33 | + array( 'other', 99 ), |
| 34 | + array( 'other', 100 ), |
| 35 | + array( 'few', 101 ), |
| 36 | + array( 'few', 119 ), |
| 37 | + array( 'other', 120 ), |
| 38 | + array( 'other', 200 ), |
| 39 | + array( 'few', 201 ), |
| 40 | + array( 'few', 219 ), |
| 41 | + array( 'other', 220 ), |
| 42 | + ); |
| 43 | + } |
| 44 | +} |
Property changes on: trunk/phase3/tests/phpunit/languages/LanguageRoTest.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 45 | + native |
Index: trunk/phase3/tests/phpunit/languages/LanguageMoTest.php |
— | — | @@ -22,22 +22,22 @@ |
23 | 23 | $this->assertEquals( $result, $this->lang->convertPlural( $value, $forms ) ); |
24 | 24 | } |
25 | 25 | |
26 | | - |
27 | 26 | function providerPlural() { |
28 | 27 | 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 ), |
| 28 | + array( 'few', 0 ), |
| 29 | + array( 'one', 1 ), |
| 30 | + array( 'few', 2 ), |
| 31 | + array( 'few', 19 ), |
35 | 32 | array( 'other', 20 ), |
36 | | - array( 'other', 20.123 ), |
37 | | - array( 'other', 31 ), |
| 33 | + array( 'other', 99 ), |
| 34 | + array( 'other', 100 ), |
| 35 | + array( 'few', 101 ), |
| 36 | + array( 'few', 119 ), |
| 37 | + array( 'other', 120 ), |
38 | 38 | array( 'other', 200 ), |
39 | | - array( 'few', 201 ), |
| 39 | + array( 'few', 201 ), |
| 40 | + array( 'few', 219 ), |
| 41 | + array( 'other', 220 ), |
40 | 42 | ); |
41 | 43 | } |
42 | | - |
43 | | - |
44 | 44 | } |
Index: trunk/phase3/languages/classes/LanguageMo.php |
— | — | @@ -14,13 +14,14 @@ |
15 | 15 | function convertPlural( $count, $forms ) { |
16 | 16 | // Plural rules per |
17 | 17 | // http://unicode.org/repos/cldr-tmp/trunk/diff/supplemental/language_plural_rules.html#mo |
| 18 | + // Identical to Romanian (ro). |
18 | 19 | if ( !count( $forms ) ) { return ''; } |
19 | 20 | |
20 | 21 | $forms = $this->preConvertPlural( $forms, 3 ); |
21 | 22 | |
22 | | - if ( $count == 1 ) { |
| 23 | + if ( $count === 1 ) { |
23 | 24 | $index = 0; |
24 | | - } elseif ( $count == 0 || ( $count % 100 > 0 && $count % 100 < 20 ) ) { |
| 25 | + } elseif ( $count === 0 || ( $count % 100 > 0 && $count % 100 < 20 ) ) { |
25 | 26 | $index = 1; |
26 | 27 | } else { |
27 | 28 | $index = 2; |
Index: trunk/phase3/languages/classes/LanguageRo.php |
— | — | @@ -18,9 +18,9 @@ |
19 | 19 | |
20 | 20 | $forms = $this->preConvertPlural( $forms, 3 ); |
21 | 21 | |
22 | | - if ( $count == 1 ) { |
| 22 | + if ( $count === 1 ) { |
23 | 23 | $index = 0; |
24 | | - } elseif ( $count == 0 || $count % 100 < 20 ) { |
| 24 | + } elseif ( $count === 0 || ( $count % 100 > 0 && $count % 100 < 20 ) ) { |
25 | 25 | $index = 1; |
26 | 26 | } else { |
27 | 27 | $index = 2; |