1 module( 'mediawiki.cldr' );
3 test( '-- Initial check', function() {
5 ok( mw
.cldr
, 'mw.cldr defined' );
8 var pluralTestcases
= {
12 * [ number, [ "form1", "form2", ... ], "expected", "description" ],
16 [ 0, [ "one", "other" ], "other", "English plural test- 0 is other" ],
17 [ 1, [ "one", "other" ], "one", "English plural test- 1 is one" ]
20 [ 0, [ "one", "other" ], "one", "Hindi plural test- 0 is one" ],
21 [ 1, [ "one", "other" ], "one", "Hindi plural test- 1 is one" ],
22 [ 2, [ "one", "other" ], "other", "Hindi plural test- 2 is other" ]
25 [ 0, [ "one", "other" ], "other", "Hebrew plural test- 0 is other" ],
26 [ 1, [ "one", "other" ], "one", "Hebrew plural test- 1 is one" ],
27 [ 2, [ "one", "other" ], "other", "Hebrew plural test- 2 is other with 2 forms" ],
28 [ 2, [ "one", "dual", "other" ], "dual", "Hebrew plural test- 2 is dual with 3 forms" ]
31 [ 0, [ "zero", "one", "two", "few", "many", "other" ], "zero", "Arabic plural test - 0 is zero" ],
32 [ 1, [ "zero", "one", "two", "few", "many", "other" ], "one", "Arabic plural test - 1 is one" ],
33 [ 2, [ "zero", "one", "two", "few", "many", "other" ], "two", "Arabic plural test - 2 is two" ],
34 [ 3, [ "zero", "one", "two", "few", "many", "other" ], "few", "Arabic plural test - 3 is few" ],
35 [ 9, [ "zero", "one", "two", "few", "many", "other" ], "few", "Arabic plural test - 9 is few" ],
36 [ "9", [ "zero", "one", "two", "few", "many", "other" ], "few", "Arabic plural test - 9 is few" ],
37 [ 110, [ "zero", "one", "two", "few", "many", "other" ], "few", "Arabic plural test - 110 is few" ],
38 [ 11, [ "zero", "one", "two", "few", "many", "other" ], "many", "Arabic plural test - 11 is many" ],
39 [ 15, [ "zero", "one", "two", "few", "many", "other" ], "many", "Arabic plural test - 15 is many" ],
40 [ 99, [ "zero", "one", "two", "few", "many", "other" ], "many", "Arabic plural test - 99 is many" ],
41 [ 9999, [ "zero", "one", "two", "few", "many", "other" ], "many", "Arabic plural test - 9999 is many" ],
42 [ 100, [ "zero", "one", "two", "few", "many", "other" ], "other", "Arabic plural test - 100 is other" ],
43 [ 102, [ "zero", "one", "two", "few", "many", "other" ], "other", "Arabic plural test - 102 is other" ],
44 [ 1000, [ "zero", "one", "two", "few", "many", "other" ], "other", "Arabic plural test - 1000 is other" ]
45 // FIXME plural rules for decimal numbers does not work
46 // [ 1.7, [ "zero", "one", "two", "few", "many", "other" ], "other", "Arabic plural test - 1.7 is other" ],
50 function pluralTest( langCode
, tests
) {
51 QUnit
.test('-- Plural Test for ' + langCode
, function( assert
) {
52 QUnit
.expect( tests
.length
);
53 for ( var i
= 0; i
< tests
.length
; i
++ ) {
55 mw
.language
.convertPlural( tests
[i
][0], tests
[i
][1] ),
56 tests
[i
][2], // Expected plural form
57 tests
[i
][3] // Description
63 $.each( pluralTestcases
, function( langCode
, tests
) {
64 if ( langCode
=== mw
.config
.get( 'wgUserLanguage' ) ) {
65 pluralTest( langCode
, tests
);