1 QUnit
.module( 'mediawiki.cldr', QUnit
.newMwEnvironment() );
3 var pluralTestcases
= {
7 * [ number, [ "form1", "form2", ... ], "expected", "description" ]
11 [ 0, [ "one", "other" ], "other", "English plural test- 0 is other" ],
12 [ 1, [ "one", "other" ], "one", "English plural test- 1 is one" ]
15 [ 0, [ "one", "other" ], "one", "Hindi plural test- 0 is one" ],
16 [ 1, [ "one", "other" ], "one", "Hindi plural test- 1 is one" ],
17 [ 2, [ "one", "other" ], "other", "Hindi plural test- 2 is other" ]
20 [ 0, [ "one", "other" ], "other", "Hebrew plural test- 0 is other" ],
21 [ 1, [ "one", "other" ], "one", "Hebrew plural test- 1 is one" ],
22 [ 2, [ "one", "other" ], "other", "Hebrew plural test- 2 is other with 2 forms" ],
23 [ 2, [ "one", "dual", "other" ], "dual", "Hebrew plural test- 2 is dual with 3 forms" ]
26 [ 0, [ "zero", "one", "two", "few", "many", "other" ], "zero", "Arabic plural test - 0 is zero" ],
27 [ 1, [ "zero", "one", "two", "few", "many", "other" ], "one", "Arabic plural test - 1 is one" ],
28 [ 2, [ "zero", "one", "two", "few", "many", "other" ], "two", "Arabic plural test - 2 is two" ],
29 [ 3, [ "zero", "one", "two", "few", "many", "other" ], "few", "Arabic plural test - 3 is few" ],
30 [ 9, [ "zero", "one", "two", "few", "many", "other" ], "few", "Arabic plural test - 9 is few" ],
31 [ "9", [ "zero", "one", "two", "few", "many", "other" ], "few", "Arabic plural test - 9 is few" ],
32 [ 110, [ "zero", "one", "two", "few", "many", "other" ], "few", "Arabic plural test - 110 is few" ],
33 [ 11, [ "zero", "one", "two", "few", "many", "other" ], "many", "Arabic plural test - 11 is many" ],
34 [ 15, [ "zero", "one", "two", "few", "many", "other" ], "many", "Arabic plural test - 15 is many" ],
35 [ 99, [ "zero", "one", "two", "few", "many", "other" ], "many", "Arabic plural test - 99 is many" ],
36 [ 9999, [ "zero", "one", "two", "few", "many", "other" ], "many", "Arabic plural test - 9999 is many" ],
37 [ 100, [ "zero", "one", "two", "few", "many", "other" ], "other", "Arabic plural test - 100 is other" ],
38 [ 102, [ "zero", "one", "two", "few", "many", "other" ], "other", "Arabic plural test - 102 is other" ],
39 [ 1000, [ "zero", "one", "two", "few", "many", "other" ], "other", "Arabic plural test - 1000 is other" ]
40 // FIXME plural rules for decimal numbers does not work
41 // [ 1.7, [ "zero", "one", "two", "few", "many", "other" ], "other", "Arabic plural test - 1.7 is other" ],
45 function pluralTest( langCode
, tests
) {
46 QUnit
.test( 'Plural Test for ' + langCode
, tests
.length
, function ( assert
) {
47 for ( var i
= 0; i
< tests
.length
; i
++ ) {
49 mw
.language
.convertPlural( tests
[i
][0], tests
[i
][1] ),
57 $.each( pluralTestcases
, function ( langCode
, tests
) {
58 if ( langCode
=== mw
.config
.get( 'wgUserLanguage' ) ) {
59 pluralTest( langCode
, tests
);