Update grammar rules and test for Ukrainian
authorAmir E. Aharoni <amir.aharoni@mail.huji.ac.il>
Sun, 27 Sep 2015 07:34:25 +0000 (10:34 +0300)
committerAmir E. Aharoni <amir.aharoni@mail.huji.ac.il>
Sun, 27 Sep 2015 08:49:07 +0000 (11:49 +0300)
The grammar rules for Ukrainian have several mistakes.
This is the first in a series of commits that fix this.

* Add grammar tests for PHP. There weren't any tests at all,
  and now there are some. Not tests are added for rules that
  are wrong and irrelevant and will be removed in subsequent commits.
* Add tests for JavaScript, and update a grammar rule that was
  incorrectly copied from Russian.

Change-Id: I6de4581e2908eba39b33a13b07d048a34a3bd803

resources/src/mediawiki.language/languages/uk.js
tests/phpunit/languages/classes/LanguageUkTest.php
tests/qunit/suites/resources/mediawiki/mediawiki.language.test.js

index a22874b..2e17808 100644 (file)
@@ -18,8 +18,8 @@ mediaWiki.language.convertGrammar = function ( word, form ) {
                                        word = word.slice( 0, -2 ) + 'ки';
                                } else if ( word.slice( -2 ) === 'ти' ) {
                                        word = word.slice( 0, -2 ) + 'тей';
-                               } else if ( word.slice( -2 ) === 'ды' ) {
-                                       word = word.slice( 0, -2 ) + 'дов';
+                               } else if ( word.slice( -2 ) === 'ди' ) {
+                                       word = word.slice( 0, -2 ) + 'дів';
                                } else if ( word.slice( -3 ) === 'ник' ) {
                                        word = word.slice( 0, -3 ) + 'ника';
                                }
index 9051bcf..bd3e560 100644 (file)
@@ -69,4 +69,32 @@ class LanguageUkTest extends LanguageClassesTestCase {
                        array( 'other', 121 ),
                );
        }
+
+       /**
+        * @dataProvider providerGrammar
+        * @covers Language::convertGrammar
+        */
+       public function testGrammar( $result, $word, $case ) {
+               $this->assertEquals( $result, $this->getLang()->convertGrammar( $word, $case ) );
+       }
+
+       public static function providerGrammar() {
+               return array(
+                       array(
+                               'Вікіпедії',
+                               'Вікіпедія',
+                               'genitive',
+                       ),
+                       array(
+                               'Віківидів',
+                               'Віківиди',
+                               'genitive',
+                       ),
+                       array(
+                               'Вікіпедію',
+                               'Вікіпедія',
+                               'accusative',
+                       ),
+               );
+       }
 }
index c71111f..fcbcada 100644 (file)
                                description: 'Grammar test for genitive case'
                        },
                        {
-                               word: 'доводÑ\8b',
+                               word: 'Ð\92Ñ\96кÑ\96види',
                                grammarForm: 'genitive',
-                               expected: 'доводов',
+                               expected: 'Ð\92Ñ\96кÑ\96видÑ\96в',
                                description: 'Grammar test for genitive case'
                        },
                        {